Mercurial > hg > icedtea8-forest > langtools
changeset 2917:69b782e543d5 icedtea-3.0.0pre06
Merge jdk8u60-b24
author | andrew |
---|---|
date | Wed, 30 Sep 2015 16:42:58 +0100 |
parents | 30d080beb15b (current diff) 2af11e10da7d (diff) |
children | 3c76eafe1b70 |
files | .hgtags src/share/classes/com/sun/tools/javac/jvm/ClassReader.java src/share/classes/com/sun/tools/javac/jvm/LVTRanges.java test/tools/javac/7153958/pkg/ClassToBeStaticallyImported.java test/tools/javac/varargs/T8049075/VarargsAndWildcardParameterizedTypeTest.java |
diffstat | 99 files changed, 2506 insertions(+), 1367 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Fri Sep 18 04:09:09 2015 +0100 +++ b/.hgtags Wed Sep 30 16:42:58 2015 +0100 @@ -317,6 +317,8 @@ 9239118487dfb47ee850d2cc9b10a0a2e510da3c jdk8u20-b24 9239118487dfb47ee850d2cc9b10a0a2e510da3c jdk8u20-b25 5e6d409a72327a31b8a8f9aa0b32ef213c8b629c jdk8u20-b26 +7302299fa9c4fa48af02b6477ff3ccbb01f2d4ea jdk8u20-b31 +2f9120236904ce5bd8ebfde755c1b2edcc4dfdd6 jdk8u20-b32 f491f1581f196950c2cb858508dd06601968c417 jdk8u25-b00 5bc865e0a2e3c59c1c8bc41e731509e1737ddea1 jdk8u25-b01 4dec0c684a9ead80ea2bca6b042682367c1abf90 jdk8u25-b02 @@ -336,6 +338,26 @@ 7fa6fa7cc204de988e224c6f8f75e62128fa84cd jdk8u25-b16 53ca196be1ae098466976c017b166d4ce180c36f jdk8u25-b17 a4f0c6dd8f97d4dd89baf09463c748abea9b3ed7 jdk8u25-b18 +c4de614efd7affc001715aa5a7040620924ac44a jdk8u25-b31 +a2a922ccc00f29af625cbecde8e77643c60f147c jdk8u25-b32 +b72a49d88cc3f5394b69b861455552476341558d jdk8u25-b33 +c4bd223559aad3d152968a09d56241175d82c561 jdk8u31-b00 +6b5e2c190f3023162a33b798e57a0d78e027c843 jdk8u31-b01 +8b4ea00b438d7f99ecd6a8345cb018d8a0379620 jdk8u31-b02 +6ce4f2acf83e17d084b9b9bce2ef98438e984064 jdk8u31-b03 +c271515197807db2f0496945241f0b09885af99b jdk8u31-b04 +2deb2110e81fc38f5b45842fd478aae168d2d27a jdk8u31-b05 +fe1980c653be1fa9fb50353c5a5305855dcd7bd4 jdk8u31-b06 +03b8ef4cf0c00aa040db27c7d8e68fa8b6133afd jdk8u31-b07 +05824e9d8171e3d50fd5d1a495169cb38b64cf08 jdk8u31-b08 +26c46688ce4a0909f65dc341df4315bf34a92202 jdk8u31-b09 +99c3209f228e1f9aa874b6bd0908fd5d9ebf7078 jdk8u31-b10 +e72be544fa9e247fba3c6bb61e291d80e127a461 jdk8u31-b11 +c956b12b30ee21a4fc5df1871fa3b01e84310ebe jdk8u31-b12 +7a34ec7bb1c831e82ac88da578a028572b676260 jdk8u31-b13 +b813a76f10911ac8db2c775e52b29f36ab0005f4 jdk8u31-b31 +8dc0c7e42d90c9f323582b742a7f228bad57b124 jdk8u31-b32 +f75e26a5c3acc1ca9f5035dbfc4a40710d354dff jdk8u31-b33 d231957fe3103e790465fcf058fb8cb33bbc4c4e jdk8u40-b00 bf89a471779d13a9407f7d1c86f7716258bc4aa6 jdk8u40-b01 0b6cc4ea670f5d17b56c088f202869bdbb80a5ce jdk8u40-b02 @@ -360,3 +382,71 @@ 0d5d2b8411d9c36f180c6d0d3029629fa2070018 icedtea-3.0.0pre03 66f265db6f474faba47a35888ca9131562fd59a1 icedtea-3.0.0pre04 811deb5a72d392f846f0ab4e38d4ee392e9553cf icedtea-3.0.0pre05 +9113c7c8d902ec94b28ca0ef4a6466bdba65fcfc jdk8u40-b21 +79177246b3dbe5296fb53755d8695acdaef59fc8 jdk8u40-b22 +fb294b49373bda0b3afc7f011d64ecefed73b42e jdk8u40-b23 +c5d4ffa220f3824c2ea5d39dc99d41a9df9e5ae5 jdk8u40-b24 +991141080b2078e67179ff307a5051e59431762c jdk8u40-b25 +2904142783dd0a9e12195a84c7dcdb3d8278b1b1 jdk8u40-b26 +83eca922346e27ec42645e9630c04fbaec5eaf0f jdk8u40-b27 +d727ca30ce3c1b97ed9acd7380f8e4cf41813ffa jdk8u40-b31 +cc9fc1abb5aeffe2b6123c392a5c602a0ba75368 jdk8u40-b32 +dbae37f50c43453f7d6f22d96adc8b5b6cd1e90d jdk8u45-b00 +244e6dc772877dfae6286530f58e11a210a48a3c jdk8u45-b01 +401ec76887623a29d3f868f9f9b18b42838d2e92 jdk8u45-b02 +79d31ae9990e28b99dd64beda6dd247993138431 jdk8u45-b03 +47292f3c0da7dd197a28765004b588bc3141d189 jdk8u45-b04 +77d7dd7f35d63f9fe60ed0b7ef32e4e9a8b46c0b jdk8u45-b05 +22cc48973eae62c63e68c4c4e3f22ff2d89012a8 jdk8u45-b06 +460238ab73ce27112b3d0d7236366960f9898259 jdk8u45-b07 +6dd7fd9f027bf037517feae2a571848aa8fbc20f jdk8u45-b08 +db16aa5c73c99d0050246660ebebb6166002ff57 jdk8u45-b09 +572895f19937b7aadc8c27c5e83887bf40f5bcff jdk8u45-b10 +0547ef2be3b303923b30ce78e1ab832725483f4e jdk8u45-b11 +4f89bbda7b4532b9f6eeee8c41b7a3b38570ae93 jdk8u45-b12 +5ce022bca792453a7efedaed419a9d763d7a9fc3 jdk8u45-b13 +847af465a5425e2caa1f1d7a09efec3b3f31b323 jdk8u45-b14 +ebe1e9d17713e45d157b48b9a31c5c2d077c7970 jdk8u45-b15 +10fae8059bb210df1624b827a3895ccc455e3c64 jdk8u45-b31 +e0b8d79bef0c01d77453579b1d36e926892c774b jdk8u45-b32 +ac1c3ae884633c2ec3881816977023fc44919c66 jdk8u51-b00 +565167bf31eab083c306dfe11c947e59f4f4ee72 jdk8u51-b01 +2078bad2444c509a63a539f3bbe1db0f36513c9e jdk8u51-b02 +30124dd95dc07edf3340c98d5af2a5a254b233b5 jdk8u51-b03 +9cb46d0c0d5932f1e52f1f06f015a9a5c1190bc2 jdk8u51-b04 +412ac274e12075e1a774f9b971ce019bcc2e1435 jdk8u51-b05 +7c65f509ca37c7b45c9762841cc280f572686c70 jdk8u51-b06 +b40a953cbc4dbcd87e56b9f9e006ab048d0deaa1 jdk8u51-b07 +858a7fc598d0baa0949a525fadfe912efd15b459 jdk8u51-b08 +90def0a14f4ad8c99fcda34f2745b6158823e21c jdk8u51-b09 +417f734de62d74c69e3a8465340bfb3aca60151a jdk8u51-b10 +8ac1243890d4f427a32320b81ae1be38f81f0c62 jdk8u51-b11 +f65c2fc549b5e9184da67e3a4f81260c27a88010 jdk8u51-b12 +3836d67a94a92befedd97064358270c6f0760e5c jdk8u51-b13 +f3a44c7deac2b23a53f0fd35b22a5d9181291616 jdk8u51-b14 +f77e8d012e8d6ee3432515ad68dd4f630dd08d56 jdk8u51-b15 +e27a094cb423a3bf32906969e9e454e061ce94d4 jdk8u51-b16 +0c514d1fd006fc79d35b670de10c370c8d559db7 jdk8u60-b00 +0ba07c272e33c93377a5d7ed98b9de873cc91980 jdk8u60-b01 +387cf62ce7895dd5e067aaa51faa93d5c078583e jdk8u60-b02 +e59ced856c92d542b6ea11a3a76e2f0a1ffae17a jdk8u60-b03 +27bb4c63fd70483bb63a6d830c595e691bf28a34 jdk8u60-b04 +fc98314cff57ce33bfe3093441804ee0a3446622 jdk8u60-b05 +44d168f9ad16609062e359ee70c6699ec4525b45 jdk8u60-b06 +39b47ffeb7780407561c0b189c3b3ab497868518 jdk8u60-b07 +e5b93c508212e0db2301cc25f5ada882367d1d9b jdk8u60-b08 +76adee5ad278e33675fdd236179fa83f20de5cc3 jdk8u60-b09 +ba758e1ffa6960266e5c619b7771ca779ee5d148 jdk8u60-b10 +ac218cf56d8ba365ba341132933629c10dbfcc06 jdk8u60-b11 +84eb517777335f079ba16c1fa49e7c36f0c444aa jdk8u60-b12 +9df2a728410bb8603d0cc39bdebed8fa93430cb2 jdk8u60-b13 +a136ed2f3041e48f340d891208cc8ac0171a7816 jdk8u60-b14 +248db113703a917fd38b637d384848a5e458ebcc jdk8u60-b15 +ecb7e46b820f293bb644f92bc1af3ede53bceced jdk8u60-b16 +87dcdc1fd75bf827c8a4596b183de7ea73cb75e1 jdk8u60-b17 +e7e42c79861ea1ab7495de5f238c01f98035a8a8 jdk8u60-b18 +0366d7f1faa12ed35694571c151524e0847f05ff jdk8u60-b19 +976523f1d5626bdb6dd47883e2734614b64a5e61 jdk8u60-b20 +97328f3e2aa2c713931edf471270a1208980b963 jdk8u60-b21 +d1febf79ce5ea41fb4b818ffd3589cf923e6de5f jdk8u60-b22 +7f88b5dc78cebc2c5ebb716938fd9a7632b052b2 jdk8u60-b23
--- a/THIRD_PARTY_README Fri Sep 18 04:09:09 2015 +0100 +++ b/THIRD_PARTY_README Wed Sep 30 16:42:58 2015 +0100 @@ -1140,37 +1140,6 @@ -------------------------------------------------------------------------------- -%% This notice is provided with respect to JSON, which may be included -with JRE 8 & JDK 8. - ---- begin of LICENSE --- - -Copyright (c) 2002 JSON.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -The Software shall be used for Good, not Evil. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - ---- end of LICENSE --- - -------------------------------------------------------------------------------- - %% This notice is provided with respect to Kerberos functionality, which which may be included with JRE 8, JDK 8, and OpenJDK 8. @@ -1250,7 +1219,7 @@ ------------------------------------------------------------------------------- -%% This notice is provided with respect to libpng 1.5.4, which may be +%% This notice is provided with respect to libpng 1.6.16, which may be included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- @@ -1266,8 +1235,8 @@ This code is released under the libpng license. -libpng versions 1.2.6, August 15, 2004, through 1.5.4, July 7, 2011, are -Copyright (c) 2004, 2006-2011 Glenn Randers-Pehrson, and are +libpng versions 1.2.6, August 15, 2004, through 1.6.16, December 22, 2014, are +Copyright (c) 2004, 2006-2014 Glenn Randers-Pehrson, and are distributed according to the same disclaimer and license as libpng-1.2.5 with the following individual added to the list of Contributing Authors @@ -1364,13 +1333,13 @@ Glenn Randers-Pehrson glennrp at users.sourceforge.net -July 7, 2011 +December 22, 2014 --- end of LICENSE --- ------------------------------------------------------------------------------- -%% This notice is provided with respect to libungif 4.1.3, which may be +%% This notice is provided with respect to GIFLIB 5.1.1 & libungif 4.1.3, which may be included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- @@ -1399,13 +1368,13 @@ ------------------------------------------------------------------------------- -%% This notice is provided with respect to Little CMS 2.5, which may be +%% This notice is provided with respect to Little CMS 2.7, which may be included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- Little CMS -Copyright (c) 1998-2011 Marti Maria Saguer +Copyright (c) 1998-2015 Marti Maria Saguer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
--- a/src/share/classes/com/sun/source/doctree/package-info.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/source/doctree/package-info.java Wed Sep 30 16:42:58 2015 +0100 @@ -29,7 +29,7 @@ * * @author Jonathan Gibbons * @since 1.8 - * @see <a href="http://download.oracle.com/javase/6/docs/technotes/tools/solaris/javadoc.html#javadoctags">http://download.oracle.com/javase/6/docs/technotes/tools/solaris/javadoc.html#javadoctags</a> + * @see <a href="https://docs.oracle.com/javase/6/docs/technotes/tools/solaris/javadoc.html#javadoctags">https://docs.oracle.com/javase/6/docs/technotes/tools/solaris/javadoc.html#javadoctags</a> */ @jdk.Exported package com.sun.source.doctree;
--- a/src/share/classes/com/sun/tools/classfile/BootstrapMethods_attribute.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/classfile/BootstrapMethods_attribute.java Wed Sep 30 16:42:58 2015 +0100 @@ -29,7 +29,7 @@ /** * See JVMS 4.7.21 - * http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.21 + * https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.21 * * <p><b>This is NOT part of any supported API. * If you write code that depends on this, you do so at your own risk.
--- a/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java Wed Sep 30 16:42:58 2015 +0100 @@ -113,7 +113,7 @@ Content captionSpan; Content span; if (type.isDefaultTab()) { - captionSpan = HtmlTree.SPAN(new StringContent(type.text())); + captionSpan = HtmlTree.SPAN(configuration.getResource(type.resourceKey())); span = HtmlTree.SPAN(type.tabId(), HtmlStyle.activeTableTab, captionSpan); } else { @@ -136,7 +136,7 @@ */ public Content getMethodTypeLinks(MethodTypes methodType) { String jsShow = "javascript:show(" + methodType.value() +");"; - HtmlTree link = HtmlTree.A(jsShow, new StringContent(methodType.text())); + HtmlTree link = HtmlTree.A(jsShow, configuration.getResource(methodType.resourceKey())); return link; }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java Wed Sep 30 16:42:58 2015 +0100 @@ -471,10 +471,10 @@ for (Map.Entry<String,Integer> entry : typeMap.entrySet()) { vars.append(sep); sep = ","; - vars.append("\""); - vars.append(entry.getKey()); - vars.append("\":"); - vars.append(entry.getValue()); + vars.append("\"") + .append(entry.getKey()) + .append("\":") + .append(entry.getValue()); } vars.append("};").append(DocletConstants.NL); sep = ""; @@ -482,11 +482,19 @@ for (MethodTypes entry : methodTypes) { vars.append(sep); sep = ","; - vars.append(entry.value()).append(":"); - vars.append("[").append("\"").append(entry.tabId()); - vars.append("\"").append(sep).append("\"").append(entry.text()).append("\"]"); + vars.append(entry.value()) + .append(":") + .append("[") + .append("\"") + .append(entry.tabId()) + .append("\"") + .append(sep) + .append("\"") + .append(configuration.getText(entry.resourceKey())) + .append("\"]"); } - vars.append("};").append(DocletConstants.NL); + vars.append("};") + .append(DocletConstants.NL); addStyles(HtmlStyle.altColor, vars); addStyles(HtmlStyle.rowColor, vars); addStyles(HtmlStyle.tableTab, vars);
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties Wed Sep 30 16:42:58 2015 +0100 @@ -150,6 +150,13 @@ doclet.Constructors=Constructors doclet.methods=methods doclet.Methods=Methods +doclet.All_Methods=All Methods +doclet.Static_Methods=Static Methods +doclet.Instance_Methods=Instance Methods +doclet.Abstract_Methods=Abstract Methods +doclet.Concrete_Methods=Concrete Methods +doclet.Default_Methods=Default Methods +doclet.Deprecated_Methods=Deprecated Methods doclet.annotation_type_optional_members=optional elements doclet.Annotation_Type_Optional_Members=Optional Elements doclet.annotation_type_required_members=required elements
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css Wed Sep 30 16:42:58 2015 +0100 @@ -463,7 +463,6 @@ .useSummary td, .constantsSummary td, .deprecatedSummary td { text-align:left; padding:0px 0px 12px 10px; - width:100%; } th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th, td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{ @@ -488,6 +487,7 @@ font-size:13px; } .overviewSummary td.colFirst, .overviewSummary th.colFirst, +.useSummary td.colFirst, .useSummary th.colFirst, .overviewSummary td.colOne, .overviewSummary th.colOne, .memberSummary td.colFirst, .memberSummary th.colFirst, .memberSummary td.colOne, .memberSummary th.colOne,
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java Wed Sep 30 16:42:58 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,22 +31,22 @@ * @author Bhavesh Patel */ public enum MethodTypes { - ALL(0xffff, "All Methods", "t0", true), - STATIC(0x1, "Static Methods", "t1", false), - INSTANCE(0x2, "Instance Methods", "t2", false), - ABSTRACT(0x4, "Abstract Methods", "t3", false), - CONCRETE(0x8, "Concrete Methods", "t4", false), - DEFAULT(0x10, "Default Methods", "t5", false), - DEPRECATED(0x20, "Deprecated Methods", "t6", false); + ALL(0xffff, "doclet.All_Methods", "t0", true), + STATIC(0x1, "doclet.Static_Methods", "t1", false), + INSTANCE(0x2, "doclet.Instance_Methods", "t2", false), + ABSTRACT(0x4, "doclet.Abstract_Methods", "t3", false), + CONCRETE(0x8, "doclet.Concrete_Methods", "t4", false), + DEFAULT(0x10, "doclet.Default_Methods", "t5", false), + DEPRECATED(0x20, "doclet.Deprecated_Methods", "t6", false); private final int value; - private final String text; + private final String resourceKey; private final String tabId; private final boolean isDefaultTab; - MethodTypes(int v, String t, String id, boolean dt) { + MethodTypes(int v, String k, String id, boolean dt) { this.value = v; - this.text = t; + this.resourceKey = k; this.tabId = id; this.isDefaultTab = dt; } @@ -55,8 +55,8 @@ return value; } - public String text() { - return text; + public String resourceKey() { + return resourceKey; } public String tabId() {
--- a/src/share/classes/com/sun/tools/javac/code/Scope.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Scope.java Wed Sep 30 16:42:58 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -241,12 +241,16 @@ listeners = listeners.prepend(sl); } - /** Remove symbol from this scope. Used when an inner class - * attribute tells us that the class isn't a package member. + /** Remove symbol from this scope. */ - public void remove(Symbol sym) { + public void remove(final Symbol sym) { Assert.check(shared == 0); - Entry e = lookup(sym.name); + Entry e = lookup(sym.name, new Filter<Symbol>() { + @Override + public boolean accepts(Symbol candidate) { + return candidate == sym; + } + }); if (e.scope == null) return; // remove e from table and shadowed list;
--- a/src/share/classes/com/sun/tools/javac/code/Symbol.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java Wed Sep 30 16:42:58 2015 +0100 @@ -1153,6 +1153,16 @@ public <R, P> R accept(Symbol.Visitor<R, P> v, P p) { return v.visitClassSymbol(this, p); } + + public void markAbstractIfNeeded(Types types) { + if (types.enter.getEnv(this) != null && + (flags() & ENUM) != 0 && types.supertype(type).tsym == types.syms.enumSym && + (flags() & (FINAL | ABSTRACT)) == 0) { + if (types.firstUnimplementedAbstract(this) != null) + // add the ABSTRACT flag to an enum + flags_field |= ABSTRACT; + } + } }
--- a/src/share/classes/com/sun/tools/javac/code/Types.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Wed Sep 30 16:42:58 2015 +0100 @@ -47,6 +47,7 @@ import com.sun.tools.javac.util.*; import static com.sun.tools.javac.code.BoundKind.*; import static com.sun.tools.javac.code.Flags.*; +import static com.sun.tools.javac.code.Kinds.MTH; import static com.sun.tools.javac.code.Scope.*; import static com.sun.tools.javac.code.Symbol.*; import static com.sun.tools.javac.code.Type.*; @@ -85,6 +86,7 @@ final boolean allowBoxing; final boolean allowCovariantReturns; final boolean allowObjectToPrimitiveCast; + final boolean allowDefaultMethods; final ClassReader reader; final Check chk; final Enter enter; @@ -111,6 +113,7 @@ allowBoxing = source.allowBoxing(); allowCovariantReturns = source.allowCovariantReturns(); allowObjectToPrimitiveCast = source.allowObjectToPrimitiveCast(); + allowDefaultMethods = source.allowDefaultMethods(); reader = ClassReader.instance(context); chk = Check.instance(context); enter = Enter.instance(context); @@ -2691,78 +2694,155 @@ // </editor-fold> // <editor-fold defaultstate="collapsed" desc="compute transitive closure of all members in given site"> - class MembersClosureCache extends SimpleVisitor<CompoundScope, Boolean> { - - private WeakHashMap<TypeSymbol, Entry> _map = - new WeakHashMap<TypeSymbol, Entry>(); - - class Entry { - final boolean skipInterfaces; - final CompoundScope compoundScope; - - public Entry(boolean skipInterfaces, CompoundScope compoundScope) { - this.skipInterfaces = skipInterfaces; - this.compoundScope = compoundScope; + class MembersClosureCache extends SimpleVisitor<Scope.CompoundScope, Void> { + + private Map<TypeSymbol, CompoundScope> _map = new HashMap<>(); + + Set<TypeSymbol> seenTypes = new HashSet<>(); + + class MembersScope extends CompoundScope { + + CompoundScope scope; + + public MembersScope(CompoundScope scope) { + super(scope.owner); + this.scope = scope; } - boolean matches(boolean skipInterfaces) { - return this.skipInterfaces == skipInterfaces; + Filter<Symbol> combine(final Filter<Symbol> sf) { + return new Filter<Symbol>() { + @Override + public boolean accepts(Symbol s) { + return !s.owner.isInterface() && (sf == null || sf.accepts(s)); + } + }; + } + + @Override + public Iterable<Symbol> getElements(Filter<Symbol> sf) { + return scope.getElements(combine(sf)); + } + + @Override + public Iterable<Symbol> getElementsByName(Name name, Filter<Symbol> sf) { + return scope.getElementsByName(name, combine(sf)); + } + + @Override + public int getMark() { + return scope.getMark(); } } - List<TypeSymbol> seenTypes = List.nil(); + CompoundScope nilScope; /** members closure visitor methods **/ - public CompoundScope visitType(Type t, Boolean skipInterface) { - return null; + public CompoundScope visitType(Type t, Void _unused) { + if (nilScope == null) { + nilScope = new CompoundScope(syms.noSymbol); + } + return nilScope; } @Override - public CompoundScope visitClassType(ClassType t, Boolean skipInterface) { - if (seenTypes.contains(t.tsym)) { + public CompoundScope visitClassType(ClassType t, Void _unused) { + if (!seenTypes.add(t.tsym)) { //this is possible when an interface is implemented in multiple - //superclasses, or when a classs hierarchy is circular - in such + //superclasses, or when a class hierarchy is circular - in such //cases we don't need to recurse (empty scope is returned) return new CompoundScope(t.tsym); } try { - seenTypes = seenTypes.prepend(t.tsym); + seenTypes.add(t.tsym); ClassSymbol csym = (ClassSymbol)t.tsym; - Entry e = _map.get(csym); - if (e == null || !e.matches(skipInterface)) { - CompoundScope membersClosure = new CompoundScope(csym); - if (!skipInterface) { - for (Type i : interfaces(t)) { - membersClosure.addSubScope(visit(i, skipInterface)); - } + CompoundScope membersClosure = _map.get(csym); + if (membersClosure == null) { + membersClosure = new CompoundScope(csym); + for (Type i : interfaces(t)) { + membersClosure.addSubScope(visit(i, null)); } - membersClosure.addSubScope(visit(supertype(t), skipInterface)); + membersClosure.addSubScope(visit(supertype(t), null)); membersClosure.addSubScope(csym.members()); - e = new Entry(skipInterface, membersClosure); - _map.put(csym, e); + _map.put(csym, membersClosure); } - return e.compoundScope; + return membersClosure; } finally { - seenTypes = seenTypes.tail; + seenTypes.remove(t.tsym); } } @Override - public CompoundScope visitTypeVar(TypeVar t, Boolean skipInterface) { - return visit(t.getUpperBound(), skipInterface); + public CompoundScope visitTypeVar(TypeVar t, Void _unused) { + return visit(t.getUpperBound(), null); } } private MembersClosureCache membersCache = new MembersClosureCache(); public CompoundScope membersClosure(Type site, boolean skipInterface) { - return membersCache.visit(site, skipInterface); + CompoundScope cs = membersCache.visit(site, null); + if (cs == null) + Assert.error("type " + site); + return skipInterface ? membersCache.new MembersScope(cs) : cs; } // </editor-fold> + /** Return first abstract member of class `sym'. + */ + public MethodSymbol firstUnimplementedAbstract(ClassSymbol sym) { + try { + return firstUnimplementedAbstractImpl(sym, sym); + } catch (CompletionFailure ex) { + chk.completionError(enter.getEnv(sym).tree.pos(), ex); + return null; + } + } + //where: + private MethodSymbol firstUnimplementedAbstractImpl(ClassSymbol impl, ClassSymbol c) { + MethodSymbol undef = null; + // Do not bother to search in classes that are not abstract, + // since they cannot have abstract members. + if (c == impl || (c.flags() & (ABSTRACT | INTERFACE)) != 0) { + Scope s = c.members(); + for (Scope.Entry e = s.elems; + undef == null && e != null; + e = e.sibling) { + if (e.sym.kind == MTH && + (e.sym.flags() & (ABSTRACT|IPROXY|DEFAULT)) == ABSTRACT) { + MethodSymbol absmeth = (MethodSymbol)e.sym; + MethodSymbol implmeth = absmeth.implementation(impl, this, true); + if (implmeth == null || implmeth == absmeth) { + //look for default implementations + if (allowDefaultMethods) { + MethodSymbol prov = interfaceCandidates(impl.type, absmeth).head; + if (prov != null && prov.overrides(absmeth, impl, this, true)) { + implmeth = prov; + } + } + } + if (implmeth == null || implmeth == absmeth) { + undef = absmeth; + } + } + } + if (undef == null) { + Type st = supertype(c.type); + if (st.hasTag(CLASS)) + undef = firstUnimplementedAbstractImpl(impl, (ClassSymbol)st.tsym); + } + for (List<Type> l = interfaces(c.type); + undef == null && l.nonEmpty(); + l = l.tail) { + undef = firstUnimplementedAbstractImpl(impl, (ClassSymbol)l.head.tsym); + } + } + return undef; + } + + //where public List<MethodSymbol> interfaceCandidates(Type site, MethodSymbol ms) { Filter<Symbol> filter = new MethodFilter(ms, site);
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Wed Sep 30 16:42:58 2015 +0100 @@ -825,9 +825,18 @@ } public void visitClassDef(JCClassDecl tree) { - // Local classes have not been entered yet, so we need to do it now: - if ((env.info.scope.owner.kind & (VAR | MTH)) != 0) + // Local and anonymous classes have not been entered yet, so we need to + // do it now. + if ((env.info.scope.owner.kind & (VAR | MTH)) != 0) { enter.classEnter(tree, env); + } else { + // If this class declaration is part of a class level annotation, + // as in @MyAnno(new Object() {}) class MyClass {}, enter it in + // order to simplify later steps and allow for sensible error + // messages. + if (env.tree.hasTag(NEWCLASS) && TreeInfo.isInAnnotation(env, tree)) + enter.classEnter(tree, env); + } ClassSymbol c = tree.sym; if (c == null) { @@ -4269,6 +4278,8 @@ chk.validate(tree.implementing, env); } + c.markAbstractIfNeeded(types); + // If this is a non-abstract class, check that it has no abstract // methods or unimplemented methods of an implemented interface. if ((c.flags() & (ABSTRACT | INTERFACE)) == 0) {
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Wed Sep 30 16:42:58 2015 +0100 @@ -2049,70 +2049,15 @@ * @param c The class. */ void checkAllDefined(DiagnosticPosition pos, ClassSymbol c) { - try { - MethodSymbol undef = firstUndef(c, c); - if (undef != null) { - if ((c.flags() & ENUM) != 0 && - types.supertype(c.type).tsym == syms.enumSym && - (c.flags() & FINAL) == 0) { - // add the ABSTRACT flag to an enum - c.flags_field |= ABSTRACT; - } else { - MethodSymbol undef1 = - new MethodSymbol(undef.flags(), undef.name, - types.memberType(c.type, undef), undef.owner); - log.error(pos, "does.not.override.abstract", - c, undef1, undef1.location()); - } - } - } catch (CompletionFailure ex) { - completionError(pos, ex); + MethodSymbol undef = types.firstUnimplementedAbstract(c); + if (undef != null) { + MethodSymbol undef1 = + new MethodSymbol(undef.flags(), undef.name, + types.memberType(c.type, undef), undef.owner); + log.error(pos, "does.not.override.abstract", + c, undef1, undef1.location()); } } -//where - /** Return first abstract member of class `c' that is not defined - * in `impl', null if there is none. - */ - private MethodSymbol firstUndef(ClassSymbol impl, ClassSymbol c) { - MethodSymbol undef = null; - // Do not bother to search in classes that are not abstract, - // since they cannot have abstract members. - if (c == impl || (c.flags() & (ABSTRACT | INTERFACE)) != 0) { - Scope s = c.members(); - for (Scope.Entry e = s.elems; - undef == null && e != null; - e = e.sibling) { - if (e.sym.kind == MTH && - (e.sym.flags() & (ABSTRACT|IPROXY|DEFAULT)) == ABSTRACT) { - MethodSymbol absmeth = (MethodSymbol)e.sym; - MethodSymbol implmeth = absmeth.implementation(impl, types, true); - if (implmeth == null || implmeth == absmeth) { - //look for default implementations - if (allowDefaultMethods) { - MethodSymbol prov = types.interfaceCandidates(impl.type, absmeth).head; - if (prov != null && prov.overrides(absmeth, impl, types, true)) { - implmeth = prov; - } - } - } - if (implmeth == null || implmeth == absmeth) { - undef = absmeth; - } - } - } - if (undef == null) { - Type st = types.supertype(c.type); - if (st.hasTag(CLASS)) - undef = firstUndef(impl, (ClassSymbol)st.tsym); - } - for (List<Type> l = types.interfaces(c.type); - undef == null && l.nonEmpty(); - l = l.tail) { - undef = firstUndef(impl, (ClassSymbol)l.head.tsym); - } - } - return undef; - } void checkNonCyclicDecl(JCClassDecl tree) { CycleChecker cc = new CycleChecker();
--- a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Wed Sep 30 16:42:58 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -224,7 +224,8 @@ DeferredStuckPolicy deferredStuckPolicy; if (resultInfo.pt.hasTag(NONE) || resultInfo.pt.isErroneous()) { deferredStuckPolicy = dummyStuckPolicy; - } else if (resultInfo.checkContext.deferredAttrContext().mode == AttrMode.SPECULATIVE) { + } else if (resultInfo.checkContext.deferredAttrContext().mode == AttrMode.SPECULATIVE || + resultInfo.checkContext.deferredAttrContext().insideOverloadPhase()) { deferredStuckPolicy = new OverloadStuckPolicy(resultInfo, this); } else { deferredStuckPolicy = new CheckStuckPolicy(resultInfo, this); @@ -1255,6 +1256,9 @@ return isSimpleReceiver(((JCAnnotatedType)rec).underlyingType); case APPLY: return true; + case NEWCLASS: + JCNewClass nc = (JCNewClass) rec; + return nc.encl == null && nc.def == null && !TreeInfo.isDiamond(nc); default: return false; } @@ -1309,17 +1313,24 @@ Type site; if (rec != null) { - if (rec.hasTag(APPLY)) { - Symbol recSym = quicklyResolveMethod(env, (JCMethodInvocation) rec); - if (recSym == null) - return null; - Symbol resolvedReturnType = - analyzeCandidateMethods(recSym, syms.errSymbol, returnSymbolAnalyzer); - if (resolvedReturnType == null) - return null; - site = resolvedReturnType.type; - } else { - site = attribSpeculative(rec, env, attr.unknownTypeExprInfo).type; + switch (rec.getTag()) { + case APPLY: + Symbol recSym = quicklyResolveMethod(env, (JCMethodInvocation) rec); + if (recSym == null) + return null; + Symbol resolvedReturnType = + analyzeCandidateMethods(recSym, syms.errSymbol, returnSymbolAnalyzer); + if (resolvedReturnType == null) + return null; + site = resolvedReturnType.type; + break; + case NEWCLASS: + JCNewClass nc = (JCNewClass) rec; + site = attribSpeculative(nc.clazz, env, attr.unknownTypeExprInfo).type; + break; + default: + site = attribSpeculative(rec, env, attr.unknownTypeExprInfo).type; + break; } } else { site = env.enclClass.sym.type;
--- a/src/share/classes/com/sun/tools/javac/comp/Flow.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java Wed Sep 30 16:42:58 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -353,17 +353,17 @@ this.tree = tree; } - void resolveJump(JCTree tree) { + void resolveJump() { //do nothing } } - abstract void markDead(JCTree tree); + abstract void markDead(); /** Record an outward transfer of control. */ - void recordExit(JCTree tree, P pe) { + void recordExit(P pe) { pendingExits.append(pe); - markDead(tree); + markDead(); } /** Resolve all jumps of this statement. */ @@ -377,7 +377,7 @@ P exit = exits.head; if (exit.tree.hasTag(jk.treeTag) && jk.getTarget(exit.tree) == tree) { - exit.resolveJump(tree); + exit.resolveJump(); resolved = true; } else { pendingExits.append(exit); @@ -420,7 +420,7 @@ private boolean alive; @Override - void markDead(JCTree tree) { + void markDead() { alive = false; } @@ -464,7 +464,7 @@ ListBuffer<PendingExit> pendingExitsPrev = pendingExits; Lint lintPrev = lint; - pendingExits = new ListBuffer<PendingExit>(); + pendingExits = new ListBuffer<>(); lint = lint.augment(tree.sym); try { @@ -513,7 +513,7 @@ log.error(TreeInfo.diagEndPos(tree.body), "missing.ret.stmt"); List<PendingExit> exits = pendingExits.toList(); - pendingExits = new ListBuffer<PendingExit>(); + pendingExits = new ListBuffer<>(); while (exits.nonEmpty()) { PendingExit exit = exits.head; exits = exits.tail; @@ -542,7 +542,7 @@ public void visitDoLoop(JCDoWhileLoop tree) { ListBuffer<PendingExit> prevPendingExits = pendingExits; - pendingExits = new ListBuffer<PendingExit>(); + pendingExits = new ListBuffer<>(); scanStat(tree.body); alive |= resolveContinues(tree); scan(tree.cond); @@ -552,7 +552,7 @@ public void visitWhileLoop(JCWhileLoop tree) { ListBuffer<PendingExit> prevPendingExits = pendingExits; - pendingExits = new ListBuffer<PendingExit>(); + pendingExits = new ListBuffer<>(); scan(tree.cond); alive = !tree.cond.type.isFalse(); scanStat(tree.body); @@ -564,7 +564,7 @@ public void visitForLoop(JCForLoop tree) { ListBuffer<PendingExit> prevPendingExits = pendingExits; scanStats(tree.init); - pendingExits = new ListBuffer<PendingExit>(); + pendingExits = new ListBuffer<>(); if (tree.cond != null) { scan(tree.cond); alive = !tree.cond.type.isFalse(); @@ -582,7 +582,7 @@ visitVarDef(tree.var); ListBuffer<PendingExit> prevPendingExits = pendingExits; scan(tree.expr); - pendingExits = new ListBuffer<PendingExit>(); + pendingExits = new ListBuffer<>(); scanStat(tree.body); alive |= resolveContinues(tree); resolveBreaks(tree, prevPendingExits); @@ -591,14 +591,14 @@ public void visitLabelled(JCLabeledStatement tree) { ListBuffer<PendingExit> prevPendingExits = pendingExits; - pendingExits = new ListBuffer<PendingExit>(); + pendingExits = new ListBuffer<>(); scanStat(tree.body); alive |= resolveBreaks(tree, prevPendingExits); } public void visitSwitch(JCSwitch tree) { ListBuffer<PendingExit> prevPendingExits = pendingExits; - pendingExits = new ListBuffer<PendingExit>(); + pendingExits = new ListBuffer<>(); scan(tree.selector); boolean hasDefault = false; for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) { @@ -625,7 +625,7 @@ public void visitTry(JCTry tree) { ListBuffer<PendingExit> prevPendingExits = pendingExits; - pendingExits = new ListBuffer<PendingExit>(); + pendingExits = new ListBuffer<>(); for (JCTree resource : tree.resources) { if (resource instanceof JCVariableDecl) { JCVariableDecl vdecl = (JCVariableDecl) resource; @@ -688,21 +688,21 @@ } public void visitBreak(JCBreak tree) { - recordExit(tree, new PendingExit(tree)); + recordExit(new PendingExit(tree)); } public void visitContinue(JCContinue tree) { - recordExit(tree, new PendingExit(tree)); + recordExit(new PendingExit(tree)); } public void visitReturn(JCReturn tree) { scan(tree.expr); - recordExit(tree, new PendingExit(tree)); + recordExit(new PendingExit(tree)); } public void visitThrow(JCThrow tree) { scan(tree.expr); - markDead(tree); + markDead(); } public void visitApply(JCMethodInvocation tree) { @@ -756,7 +756,7 @@ try { attrEnv = env; Flow.this.make = make; - pendingExits = new ListBuffer<PendingExit>(); + pendingExits = new ListBuffer<>(); alive = true; scan(tree); } finally { @@ -803,7 +803,7 @@ } @Override - void markDead(JCTree tree) { + void markDead() { //do nothing } @@ -1201,16 +1201,16 @@ } public void visitBreak(JCBreak tree) { - recordExit(tree, new FlowPendingExit(tree, null)); + recordExit(new FlowPendingExit(tree, null)); } public void visitContinue(JCContinue tree) { - recordExit(tree, new FlowPendingExit(tree, null)); + recordExit(new FlowPendingExit(tree, null)); } public void visitReturn(JCReturn tree) { scan(tree.expr); - recordExit(tree, new FlowPendingExit(tree, null)); + recordExit(new FlowPendingExit(tree, null)); } public void visitThrow(JCThrow tree) { @@ -1228,7 +1228,7 @@ else { markThrown(tree, tree.expr.type); } - markDead(tree); + markDead(); } public void visitApply(JCMethodInvocation tree) { @@ -1379,12 +1379,10 @@ * effectively-final local variables/parameters. */ - public abstract class AbstractAssignAnalyzer<P extends AbstractAssignAnalyzer<P>.AbstractAssignPendingExit> - extends BaseAnalyzer<P> { - + public class AssignAnalyzer extends BaseAnalyzer<AssignAnalyzer.AssignPendingExit> { /** The set of definitely assigned variables. */ - protected Bits inits; + final Bits inits; /** The set of definitely unassigned variables. */ @@ -1432,20 +1430,20 @@ */ Scope unrefdResources; - /** Set when processing a loop body the second time for DU analysis. */ + /** Modified when processing a loop body the second time for DU analysis. */ FlowKind flowKind = FlowKind.NORMAL; - /** The starting position of the analysed tree */ + /** The starting position of the analyzed tree */ int startPos; - public class AbstractAssignPendingExit extends BaseAnalyzer.PendingExit { + public class AssignPendingExit extends BaseAnalyzer.PendingExit { final Bits inits; final Bits uninits; final Bits exit_inits = new Bits(true); final Bits exit_uninits = new Bits(true); - public AbstractAssignPendingExit(JCTree tree, final Bits inits, final Bits uninits) { + public AssignPendingExit(JCTree tree, final Bits inits, final Bits uninits) { super(tree); this.inits = inits; this.uninits = uninits; @@ -1454,13 +1452,13 @@ } @Override - public void resolveJump(JCTree tree) { + void resolveJump() { inits.andSet(exit_inits); uninits.andSet(exit_uninits); } } - public AbstractAssignAnalyzer() { + public AssignAnalyzer() { this.inits = new Bits(); uninits = new Bits(); uninitsTry = new Bits(); @@ -1473,7 +1471,7 @@ private boolean isInitialConstructor = false; @Override - protected void markDead(JCTree tree) { + void markDead() { if (!isInitialConstructor) { inits.inclRange(returnadr, nextadr); } else { @@ -1520,35 +1518,41 @@ } sym.adr = nextadr; vardecls[nextadr] = varDecl; - exclVarFromInits(varDecl, nextadr); + inits.excl(nextadr); uninits.incl(nextadr); nextadr++; } - protected void exclVarFromInits(JCTree tree, int adr) { - inits.excl(adr); - } - - protected void assignToInits(JCTree tree, Bits bits) { - inits.assign(bits); - } - - protected void andSetInits(JCTree tree, Bits bits) { - inits.andSet(bits); - } - - protected void orSetInits(JCTree tree, Bits bits) { - inits.orSet(bits); - } - /** Record an initialization of a trackable variable. */ void letInit(DiagnosticPosition pos, VarSymbol sym) { if (sym.adr >= firstadr && trackable(sym)) { - if (uninits.isMember(sym.adr)) { - uninit(sym); + if ((sym.flags() & EFFECTIVELY_FINAL) != 0) { + if (!uninits.isMember(sym.adr)) { + //assignment targeting an effectively final variable + //makes the variable lose its status of effectively final + //if the variable is _not_ definitively unassigned + sym.flags_field &= ~EFFECTIVELY_FINAL; + } else { + uninit(sym); + } + } else if ((sym.flags() & FINAL) != 0) { + if ((sym.flags() & PARAMETER) != 0) { + if ((sym.flags() & UNION) != 0) { //multi-catch parameter + log.error(pos, "multicatch.parameter.may.not.be.assigned", sym); + } else { + log.error(pos, "final.parameter.may.not.be.assigned", + sym); + } + } else if (!uninits.isMember(sym.adr)) { + log.error(pos, flowKind.errKey, sym); + } else { + uninit(sym); + } } inits.incl(sym.adr); + } else if ((sym.flags() & FINAL) != 0) { + log.error(pos, "var.might.already.be.assigned", sym); } } //where @@ -1583,7 +1587,14 @@ checkInit(pos, sym, "var.might.not.have.been.initialized"); } - void checkInit(DiagnosticPosition pos, VarSymbol sym, String errkey) {} + void checkInit(DiagnosticPosition pos, VarSymbol sym, String errkey) { + if ((sym.adr >= firstadr || sym.owner.kind != TYP) && + trackable(sym) && + !inits.isMember(sym.adr)) { + log.error(pos, errkey, sym); + inits.incl(sym.adr); + } + } /** Utility method to reset several Bits instances. */ @@ -1607,7 +1618,7 @@ /** Merge (intersect) inits/uninits from WhenTrue/WhenFalse sets. */ - protected void merge(JCTree tree) { + protected void merge() { inits.assign(initsWhenFalse.andSet(initsWhenTrue)); uninits.assign(uninitsWhenFalse.andSet(uninitsWhenTrue)); } @@ -1623,7 +1634,7 @@ if (tree != null) { scan(tree); if (inits.isReset()) { - merge(tree); + merge(); } } } @@ -1641,7 +1652,7 @@ */ void scanCond(JCTree tree) { if (tree.type.isFalse()) { - if (inits.isReset()) merge(tree); + if (inits.isReset()) merge(); initsWhenTrue.assign(inits); initsWhenTrue.inclRange(firstadr, nextadr); uninitsWhenTrue.assign(uninits); @@ -1649,7 +1660,7 @@ initsWhenFalse.assign(inits); uninitsWhenFalse.assign(uninits); } else if (tree.type.isTrue()) { - if (inits.isReset()) merge(tree); + if (inits.isReset()) merge(); initsWhenFalse.assign(inits); initsWhenFalse.inclRange(firstadr, nextadr); uninitsWhenFalse.assign(uninits); @@ -1668,173 +1679,202 @@ /* ------------ Visitor methods for various sorts of trees -------------*/ - @Override public void visitClassDef(JCClassDecl tree) { if (tree.sym == null) { return; } - JCClassDecl classDefPrev = classDef; - int firstadrPrev = firstadr; - int nextadrPrev = nextadr; - ListBuffer<P> pendingExitsPrev = pendingExits; + Lint lintPrev = lint; + lint = lint.augment(tree.sym); + try { + if (tree.sym == null) { + return; + } + + JCClassDecl classDefPrev = classDef; + int firstadrPrev = firstadr; + int nextadrPrev = nextadr; + ListBuffer<AssignPendingExit> pendingExitsPrev = pendingExits; - pendingExits = new ListBuffer<P>(); - if (tree.name != names.empty) { - firstadr = nextadr; - } - classDef = tree; - try { - // define all the static fields - for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) { - if (l.head.hasTag(VARDEF)) { - JCVariableDecl def = (JCVariableDecl)l.head; - if ((def.mods.flags & STATIC) != 0) { - VarSymbol sym = def.sym; - if (trackable(sym)) { - newVar(def); + pendingExits = new ListBuffer<>(); + if (tree.name != names.empty) { + firstadr = nextadr; + } + classDef = tree; + try { + // define all the static fields + for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) { + if (l.head.hasTag(VARDEF)) { + JCVariableDecl def = (JCVariableDecl)l.head; + if ((def.mods.flags & STATIC) != 0) { + VarSymbol sym = def.sym; + if (trackable(sym)) { + newVar(def); + } } } } - } - // process all the static initializers - for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) { - if (!l.head.hasTag(METHODDEF) && - (TreeInfo.flags(l.head) & STATIC) != 0) { - scan(l.head); + // process all the static initializers + for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) { + if (!l.head.hasTag(METHODDEF) && + (TreeInfo.flags(l.head) & STATIC) != 0) { + scan(l.head); + } } - } - // define all the instance fields - for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) { - if (l.head.hasTag(VARDEF)) { - JCVariableDecl def = (JCVariableDecl)l.head; - if ((def.mods.flags & STATIC) == 0) { - VarSymbol sym = def.sym; - if (trackable(sym)) { - newVar(def); + // define all the instance fields + for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) { + if (l.head.hasTag(VARDEF)) { + JCVariableDecl def = (JCVariableDecl)l.head; + if ((def.mods.flags & STATIC) == 0) { + VarSymbol sym = def.sym; + if (trackable(sym)) { + newVar(def); + } } } } - } - - // process all the instance initializers - for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) { - if (!l.head.hasTag(METHODDEF) && - (TreeInfo.flags(l.head) & STATIC) == 0) { - scan(l.head); + // process all the instance initializers + for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) { + if (!l.head.hasTag(METHODDEF) && + (TreeInfo.flags(l.head) & STATIC) == 0) { + scan(l.head); + } } - } - // process all the methods - for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) { - if (l.head.hasTag(METHODDEF)) { - scan(l.head); + // process all the methods + for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) { + if (l.head.hasTag(METHODDEF)) { + scan(l.head); + } } + } finally { + pendingExits = pendingExitsPrev; + nextadr = nextadrPrev; + firstadr = firstadrPrev; + classDef = classDefPrev; } } finally { - pendingExits = pendingExitsPrev; - nextadr = nextadrPrev; - firstadr = firstadrPrev; - classDef = classDefPrev; + lint = lintPrev; } } - @Override public void visitMethodDef(JCMethodDecl tree) { if (tree.body == null) { return; } - /* Ignore synthetic methods, except for translated lambda methods. + + /* MemberEnter can generate synthetic methods ignore them */ - if ((tree.sym.flags() & (SYNTHETIC | LAMBDA_METHOD)) == SYNTHETIC) { + if ((tree.sym.flags() & SYNTHETIC) != 0) { return; } - final Bits initsPrev = new Bits(inits); - final Bits uninitsPrev = new Bits(uninits); - int nextadrPrev = nextadr; - int firstadrPrev = firstadr; - int returnadrPrev = returnadr; - - Assert.check(pendingExits.isEmpty()); - boolean lastInitialConstructor = isInitialConstructor; + Lint lintPrev = lint; + lint = lint.augment(tree.sym); try { - isInitialConstructor = TreeInfo.isInitialConstructor(tree); - - if (!isInitialConstructor) { - firstadr = nextadr; + if (tree.body == null) { + return; + } + /* Ignore synthetic methods, except for translated lambda methods. + */ + if ((tree.sym.flags() & (SYNTHETIC | LAMBDA_METHOD)) == SYNTHETIC) { + return; } - for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) { - JCVariableDecl def = l.head; - scan(def); - Assert.check((def.sym.flags() & PARAMETER) != 0, "Method parameter without PARAMETER flag"); - /* If we are executing the code from Gen, then there can be - * synthetic or mandated variables, ignore them. - */ - initParam(def); - } - // else we are in an instance initializer block; - // leave caught unchanged. - scan(tree.body); + + final Bits initsPrev = new Bits(inits); + final Bits uninitsPrev = new Bits(uninits); + int nextadrPrev = nextadr; + int firstadrPrev = firstadr; + int returnadrPrev = returnadr; + + Assert.check(pendingExits.isEmpty()); + boolean lastInitialConstructor = isInitialConstructor; + try { + isInitialConstructor = TreeInfo.isInitialConstructor(tree); - if (isInitialConstructor) { - boolean isSynthesized = (tree.sym.flags() & - GENERATEDCONSTR) != 0; - for (int i = firstadr; i < nextadr; i++) { - JCVariableDecl vardecl = vardecls[i]; - VarSymbol var = vardecl.sym; - if (var.owner == classDef.sym) { - // choose the diagnostic position based on whether - // the ctor is default(synthesized) or not - if (isSynthesized) { - checkInit(TreeInfo.diagnosticPositionFor(var, vardecl), - var, "var.not.initialized.in.default.constructor"); - } else { - checkInit(TreeInfo.diagEndPos(tree.body), var); + if (!isInitialConstructor) { + firstadr = nextadr; + } + for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) { + JCVariableDecl def = l.head; + scan(def); + Assert.check((def.sym.flags() & PARAMETER) != 0, "Method parameter without PARAMETER flag"); + /* If we are executing the code from Gen, then there can be + * synthetic or mandated variables, ignore them. + */ + initParam(def); + } + // else we are in an instance initializer block; + // leave caught unchanged. + scan(tree.body); + + if (isInitialConstructor) { + boolean isSynthesized = (tree.sym.flags() & + GENERATEDCONSTR) != 0; + for (int i = firstadr; i < nextadr; i++) { + JCVariableDecl vardecl = vardecls[i]; + VarSymbol var = vardecl.sym; + if (var.owner == classDef.sym) { + // choose the diagnostic position based on whether + // the ctor is default(synthesized) or not + if (isSynthesized) { + checkInit(TreeInfo.diagnosticPositionFor(var, vardecl), + var, "var.not.initialized.in.default.constructor"); + } else { + checkInit(TreeInfo.diagEndPos(tree.body), var); + } } } } - } - List<P> exits = pendingExits.toList(); - pendingExits = new ListBuffer<>(); - while (exits.nonEmpty()) { - P exit = exits.head; - exits = exits.tail; - Assert.check(exit.tree.hasTag(RETURN), exit.tree); - if (isInitialConstructor) { - assignToInits(exit.tree, exit.exit_inits); - for (int i = firstadr; i < nextadr; i++) { - checkInit(exit.tree.pos(), vardecls[i].sym); + List<AssignPendingExit> exits = pendingExits.toList(); + pendingExits = new ListBuffer<>(); + while (exits.nonEmpty()) { + AssignPendingExit exit = exits.head; + exits = exits.tail; + Assert.check(exit.tree.hasTag(RETURN), exit.tree); + if (isInitialConstructor) { + inits.assign(exit.exit_inits); + for (int i = firstadr; i < nextadr; i++) { + checkInit(exit.tree.pos(), vardecls[i].sym); + } } } + } finally { + inits.assign(initsPrev); + uninits.assign(uninitsPrev); + nextadr = nextadrPrev; + firstadr = firstadrPrev; + returnadr = returnadrPrev; + isInitialConstructor = lastInitialConstructor; } } finally { - assignToInits(tree, initsPrev); - uninits.assign(uninitsPrev); - nextadr = nextadrPrev; - firstadr = firstadrPrev; - returnadr = returnadrPrev; - isInitialConstructor = lastInitialConstructor; + lint = lintPrev; } } protected void initParam(JCVariableDecl def) { inits.incl(def.sym.adr); uninits.excl(def.sym.adr); - } + } public void visitVarDef(JCVariableDecl tree) { - boolean track = trackable(tree.sym); - if (track && tree.sym.owner.kind == MTH) { - newVar(tree); - } - if (tree.init != null) { - scanExpr(tree.init); - if (track) { - letInit(tree.pos(), tree.sym); + Lint lintPrev = lint; + lint = lint.augment(tree.sym); + try{ + boolean track = trackable(tree.sym); + if (track && tree.sym.owner.kind == MTH) { + newVar(tree); } + if (tree.init != null) { + scanExpr(tree.init); + if (track) { + letInit(tree.pos(), tree.sym); + } + } + } finally { + lint = lintPrev; } } @@ -1844,18 +1884,14 @@ nextadr = nextadrPrev; } - int getLogNumberOfErrors() { - return 0; - } - public void visitDoLoop(JCDoWhileLoop tree) { - ListBuffer<P> prevPendingExits = pendingExits; + ListBuffer<AssignPendingExit> prevPendingExits = pendingExits; FlowKind prevFlowKind = flowKind; flowKind = FlowKind.NORMAL; final Bits initsSkip = new Bits(true); final Bits uninitsSkip = new Bits(true); - pendingExits = new ListBuffer<P>(); - int prevErrors = getLogNumberOfErrors(); + pendingExits = new ListBuffer<>(); + int prevErrors = log.nerrors; do { final Bits uninitsEntry = new Bits(uninits); uninitsEntry.excludeFrom(nextadr); @@ -1866,28 +1902,28 @@ initsSkip.assign(initsWhenFalse); uninitsSkip.assign(uninitsWhenFalse); } - if (getLogNumberOfErrors() != prevErrors || + if (log.nerrors != prevErrors || flowKind.isFinal() || new Bits(uninitsEntry).diffSet(uninitsWhenTrue).nextBit(firstadr)==-1) break; - assignToInits(tree.cond, initsWhenTrue); + inits.assign(initsWhenTrue); uninits.assign(uninitsEntry.andSet(uninitsWhenTrue)); flowKind = FlowKind.SPECULATIVE_LOOP; } while (true); flowKind = prevFlowKind; - assignToInits(tree, initsSkip); + inits.assign(initsSkip); uninits.assign(uninitsSkip); resolveBreaks(tree, prevPendingExits); } public void visitWhileLoop(JCWhileLoop tree) { - ListBuffer<P> prevPendingExits = pendingExits; + ListBuffer<AssignPendingExit> prevPendingExits = pendingExits; FlowKind prevFlowKind = flowKind; flowKind = FlowKind.NORMAL; final Bits initsSkip = new Bits(true); final Bits uninitsSkip = new Bits(true); pendingExits = new ListBuffer<>(); - int prevErrors = getLogNumberOfErrors(); + int prevErrors = log.nerrors; final Bits uninitsEntry = new Bits(uninits); uninitsEntry.excludeFrom(nextadr); do { @@ -1896,11 +1932,11 @@ initsSkip.assign(initsWhenFalse) ; uninitsSkip.assign(uninitsWhenFalse); } - assignToInits(tree, initsWhenTrue); + inits.assign(initsWhenTrue); uninits.assign(uninitsWhenTrue); scan(tree.body); resolveContinues(tree); - if (getLogNumberOfErrors() != prevErrors || + if (log.nerrors != prevErrors || flowKind.isFinal() || new Bits(uninitsEntry).diffSet(uninits).nextBit(firstadr) == -1) { break; @@ -1911,21 +1947,21 @@ flowKind = prevFlowKind; //a variable is DA/DU after the while statement, if it's DA/DU assuming the //branch is not taken AND if it's DA/DU before any break statement - assignToInits(tree.body, initsSkip); + inits.assign(initsSkip); uninits.assign(uninitsSkip); resolveBreaks(tree, prevPendingExits); } public void visitForLoop(JCForLoop tree) { - ListBuffer<P> prevPendingExits = pendingExits; + ListBuffer<AssignPendingExit> prevPendingExits = pendingExits; FlowKind prevFlowKind = flowKind; flowKind = FlowKind.NORMAL; int nextadrPrev = nextadr; scan(tree.init); final Bits initsSkip = new Bits(true); final Bits uninitsSkip = new Bits(true); - pendingExits = new ListBuffer<P>(); - int prevErrors = getLogNumberOfErrors(); + pendingExits = new ListBuffer<>(); + int prevErrors = log.nerrors; do { final Bits uninitsEntry = new Bits(uninits); uninitsEntry.excludeFrom(nextadr); @@ -1935,7 +1971,7 @@ initsSkip.assign(initsWhenFalse); uninitsSkip.assign(uninitsWhenFalse); } - assignToInits(tree.body, initsWhenTrue); + inits.assign(initsWhenTrue); uninits.assign(uninitsWhenTrue); } else if (!flowKind.isFinal()) { initsSkip.assign(inits); @@ -1946,7 +1982,7 @@ scan(tree.body); resolveContinues(tree); scan(tree.step); - if (getLogNumberOfErrors() != prevErrors || + if (log.nerrors != prevErrors || flowKind.isFinal() || new Bits(uninitsEntry).diffSet(uninits).nextBit(firstadr) == -1) break; @@ -1956,7 +1992,7 @@ flowKind = prevFlowKind; //a variable is DA/DU after a for loop, if it's DA/DU assuming the //branch is not taken AND if it's DA/DU before any break statement - assignToInits(tree.body, initsSkip); + inits.assign(initsSkip); uninits.assign(uninitsSkip); resolveBreaks(tree, prevPendingExits); nextadr = nextadrPrev; @@ -1965,7 +2001,7 @@ public void visitForeachLoop(JCEnhancedForLoop tree) { visitVarDef(tree.var); - ListBuffer<P> prevPendingExits = pendingExits; + ListBuffer<AssignPendingExit> prevPendingExits = pendingExits; FlowKind prevFlowKind = flowKind; flowKind = FlowKind.NORMAL; int nextadrPrev = nextadr; @@ -1974,14 +2010,14 @@ final Bits uninitsStart = new Bits(uninits); letInit(tree.pos(), tree.var.sym); - pendingExits = new ListBuffer<P>(); - int prevErrors = getLogNumberOfErrors(); + pendingExits = new ListBuffer<>(); + int prevErrors = log.nerrors; do { final Bits uninitsEntry = new Bits(uninits); uninitsEntry.excludeFrom(nextadr); scan(tree.body); resolveContinues(tree); - if (getLogNumberOfErrors() != prevErrors || + if (log.nerrors != prevErrors || flowKind.isFinal() || new Bits(uninitsEntry).diffSet(uninits).nextBit(firstadr) == -1) break; @@ -1989,21 +2025,21 @@ flowKind = FlowKind.SPECULATIVE_LOOP; } while (true); flowKind = prevFlowKind; - assignToInits(tree.body, initsStart); + inits.assign(initsStart); uninits.assign(uninitsStart.andSet(uninits)); resolveBreaks(tree, prevPendingExits); nextadr = nextadrPrev; } public void visitLabelled(JCLabeledStatement tree) { - ListBuffer<P> prevPendingExits = pendingExits; - pendingExits = new ListBuffer<P>(); + ListBuffer<AssignPendingExit> prevPendingExits = pendingExits; + pendingExits = new ListBuffer<>(); scan(tree.body); resolveBreaks(tree, prevPendingExits); } public void visitSwitch(JCSwitch tree) { - ListBuffer<P> prevPendingExits = pendingExits; + ListBuffer<AssignPendingExit> prevPendingExits = pendingExits; pendingExits = new ListBuffer<>(); int nextadrPrev = nextadr; scanExpr(tree.selector); @@ -2011,7 +2047,7 @@ final Bits uninitsSwitch = new Bits(uninits); boolean hasDefault = false; for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) { - assignToInits(l.head, initsSwitch); + inits.assign(initsSwitch); uninits.assign(uninits.andSet(uninitsSwitch)); JCCase c = l.head; if (c.pat == null) { @@ -2020,19 +2056,19 @@ scanExpr(c.pat); } if (hasDefault) { - assignToInits(null, initsSwitch); + inits.assign(initsSwitch); uninits.assign(uninits.andSet(uninitsSwitch)); } scan(c.stats); addVars(c.stats, initsSwitch, uninitsSwitch); if (!hasDefault) { - assignToInits(l.head.stats.last(), initsSwitch); + inits.assign(initsSwitch); uninits.assign(uninits.andSet(uninitsSwitch)); } // Warn about fall-through if lint switch fallthrough enabled. } if (!hasDefault) { - andSetInits(null, initsSwitch); + inits.andSet(initsSwitch); } resolveBreaks(tree, prevPendingExits); nextadr = nextadrPrev; @@ -2051,16 +2087,10 @@ } } - boolean isEnabled(Lint.LintCategory lc) { - return false; - } - - void reportWarning(Lint.LintCategory lc, DiagnosticPosition pos, String key, Object ... args) {} - public void visitTry(JCTry tree) { ListBuffer<JCVariableDecl> resourceVarDecls = new ListBuffer<>(); final Bits uninitsTryPrev = new Bits(uninitsTry); - ListBuffer<P> prevPendingExits = pendingExits; + ListBuffer<AssignPendingExit> prevPendingExits = pendingExits; pendingExits = new ListBuffer<>(); final Bits initsTry = new Bits(inits); uninitsTry.assign(uninits); @@ -2083,10 +2113,10 @@ int nextadrCatch = nextadr; if (!resourceVarDecls.isEmpty() && - isEnabled(Lint.LintCategory.TRY)) { + lint.isEnabled(Lint.LintCategory.TRY)) { for (JCVariableDecl resVar : resourceVarDecls) { if (unrefdResources.includes(resVar.sym)) { - reportWarning(Lint.LintCategory.TRY, resVar.pos(), + log.warning(Lint.LintCategory.TRY, resVar.pos(), "try.resource.not.referenced", resVar.sym); unrefdResources.remove(resVar.sym); } @@ -2102,7 +2132,7 @@ for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) { JCVariableDecl param = l.head.param; - assignToInits(tree.body, initsCatchPrev); + inits.assign(initsCatchPrev); uninits.assign(uninitsCatchPrev); scan(param); /* If this is a TWR and we are executing the code from Gen, @@ -2115,9 +2145,9 @@ nextadr = nextadrCatch; } if (tree.finalizer != null) { - assignToInits(tree.finalizer, initsTry); + inits.assign(initsTry); uninits.assign(uninitsTry); - ListBuffer<P> exits = pendingExits; + ListBuffer<AssignPendingExit> exits = pendingExits; pendingExits = prevPendingExits; scan(tree.finalizer); if (!tree.finallyCanCompleteNormally) { @@ -2127,19 +2157,19 @@ // FIX: this doesn't preserve source order of exits in catch // versus finally! while (exits.nonEmpty()) { - P exit = exits.next(); + AssignPendingExit exit = exits.next(); if (exit.exit_inits != null) { exit.exit_inits.orSet(inits); exit.exit_uninits.andSet(uninits); } pendingExits.append(exit); } - orSetInits(tree, initsEnd); + inits.orSet(initsEnd); } } else { - assignToInits(tree, initsEnd); + inits.assign(initsEnd); uninits.assign(uninitsEnd); - ListBuffer<P> exits = pendingExits; + ListBuffer<AssignPendingExit> exits = pendingExits; pendingExits = prevPendingExits; while (exits.nonEmpty()) pendingExits.append(exits.next()); } @@ -2150,7 +2180,7 @@ scanCond(tree.cond); final Bits initsBeforeElse = new Bits(initsWhenFalse); final Bits uninitsBeforeElse = new Bits(uninitsWhenFalse); - assignToInits(tree.cond, initsWhenTrue); + inits.assign(initsWhenTrue); uninits.assign(uninitsWhenTrue); if (tree.truepart.type.hasTag(BOOLEAN) && tree.falsepart.type.hasTag(BOOLEAN)) { @@ -2163,7 +2193,7 @@ final Bits initsAfterThenWhenFalse = new Bits(initsWhenFalse); final Bits uninitsAfterThenWhenTrue = new Bits(uninitsWhenTrue); final Bits uninitsAfterThenWhenFalse = new Bits(uninitsWhenFalse); - assignToInits(tree.truepart, initsBeforeElse); + inits.assign(initsBeforeElse); uninits.assign(uninitsBeforeElse); scanCond(tree.falsepart); initsWhenTrue.andSet(initsAfterThenWhenTrue); @@ -2174,10 +2204,10 @@ scanExpr(tree.truepart); final Bits initsAfterThen = new Bits(inits); final Bits uninitsAfterThen = new Bits(uninits); - assignToInits(tree.truepart, initsBeforeElse); + inits.assign(initsBeforeElse); uninits.assign(uninitsBeforeElse); scanExpr(tree.falsepart); - andSetInits(tree.falsepart, initsAfterThen); + inits.andSet(initsAfterThen); uninits.andSet(uninitsAfterThen); } } @@ -2186,46 +2216,42 @@ scanCond(tree.cond); final Bits initsBeforeElse = new Bits(initsWhenFalse); final Bits uninitsBeforeElse = new Bits(uninitsWhenFalse); - assignToInits(tree.cond, initsWhenTrue); + inits.assign(initsWhenTrue); uninits.assign(uninitsWhenTrue); scan(tree.thenpart); if (tree.elsepart != null) { final Bits initsAfterThen = new Bits(inits); final Bits uninitsAfterThen = new Bits(uninits); - assignToInits(tree.thenpart, initsBeforeElse); + inits.assign(initsBeforeElse); uninits.assign(uninitsBeforeElse); scan(tree.elsepart); - andSetInits(tree.elsepart, initsAfterThen); + inits.andSet(initsAfterThen); uninits.andSet(uninitsAfterThen); } else { - andSetInits(tree.thenpart, initsBeforeElse); + inits.andSet(initsBeforeElse); uninits.andSet(uninitsBeforeElse); } } - protected P createNewPendingExit(JCTree tree, Bits inits, Bits uninits) { - return null; - } - @Override public void visitBreak(JCBreak tree) { - recordExit(tree, createNewPendingExit(tree, inits, uninits)); + recordExit(new AssignPendingExit(tree, inits, uninits)); } @Override public void visitContinue(JCContinue tree) { - recordExit(tree, createNewPendingExit(tree, inits, uninits)); + recordExit(new AssignPendingExit(tree, inits, uninits)); } @Override public void visitReturn(JCReturn tree) { scanExpr(tree.expr); - recordExit(tree, createNewPendingExit(tree, inits, uninits)); + recordExit(new AssignPendingExit(tree, inits, uninits)); } public void visitThrow(JCThrow tree) { scanExpr(tree.expr); - markDead(tree.expr); + markDead(); } public void visitApply(JCMethodInvocation tree) { @@ -2244,10 +2270,10 @@ final Bits prevUninits = new Bits(uninits); final Bits prevInits = new Bits(inits); int returnadrPrev = returnadr; - ListBuffer<P> prevPending = pendingExits; + ListBuffer<AssignPendingExit> prevPending = pendingExits; try { returnadr = nextadr; - pendingExits = new ListBuffer<P>(); + pendingExits = new ListBuffer<>(); for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) { JCVariableDecl def = l.head; scan(def); @@ -2263,7 +2289,7 @@ finally { returnadr = returnadrPrev; uninits.assign(prevUninits); - assignToInits(tree, prevInits); + inits.assign(prevInits); pendingExits = prevPending; } } @@ -2279,11 +2305,11 @@ scanCond(tree.cond); uninitsExit.andSet(uninitsWhenTrue); if (tree.detail != null) { - assignToInits(tree, initsWhenFalse); + inits.assign(initsWhenFalse); uninits.assign(uninitsWhenFalse); scanExpr(tree.detail); } - assignToInits(tree, initsExit); + inits.assign(initsExit); uninits.assign(uninitsExit); } @@ -2351,7 +2377,7 @@ scanCond(tree.lhs); final Bits initsWhenFalseLeft = new Bits(initsWhenFalse); final Bits uninitsWhenFalseLeft = new Bits(uninitsWhenFalse); - assignToInits(tree.lhs, initsWhenTrue); + inits.assign(initsWhenTrue); uninits.assign(uninitsWhenTrue); scanCond(tree.rhs); initsWhenFalse.andSet(initsWhenFalseLeft); @@ -2361,7 +2387,7 @@ scanCond(tree.lhs); final Bits initsWhenTrueLeft = new Bits(initsWhenTrue); final Bits uninitsWhenTrueLeft = new Bits(uninitsWhenTrue); - assignToInits(tree.lhs, initsWhenFalse); + inits.assign(initsWhenFalse); uninits.assign(uninitsWhenFalse); scanCond(tree.rhs); initsWhenTrue.andSet(initsWhenTrueLeft); @@ -2436,136 +2462,6 @@ } } - public class AssignAnalyzer extends AbstractAssignAnalyzer<AssignAnalyzer.AssignPendingExit> { - - public class AssignPendingExit extends AbstractAssignAnalyzer<AssignPendingExit>.AbstractAssignPendingExit { - - public AssignPendingExit(JCTree tree, final Bits inits, final Bits uninits) { - super(tree, inits, uninits); - } - } - - @Override - protected AssignPendingExit createNewPendingExit(JCTree tree, - Bits inits, Bits uninits) { - return new AssignPendingExit(tree, inits, uninits); - } - - /** Record an initialization of a trackable variable. - */ - @Override - void letInit(DiagnosticPosition pos, VarSymbol sym) { - if (sym.adr >= firstadr && trackable(sym)) { - if ((sym.flags() & EFFECTIVELY_FINAL) != 0) { - if (!uninits.isMember(sym.adr)) { - //assignment targeting an effectively final variable - //makes the variable lose its status of effectively final - //if the variable is _not_ definitively unassigned - sym.flags_field &= ~EFFECTIVELY_FINAL; - } else { - uninit(sym); - } - } - else if ((sym.flags() & FINAL) != 0) { - if ((sym.flags() & PARAMETER) != 0) { - if ((sym.flags() & UNION) != 0) { //multi-catch parameter - log.error(pos, "multicatch.parameter.may.not.be.assigned", sym); - } - else { - log.error(pos, "final.parameter.may.not.be.assigned", - sym); - } - } else if (!uninits.isMember(sym.adr)) { - log.error(pos, flowKind.errKey, sym); - } else { - uninit(sym); - } - } - inits.incl(sym.adr); - } else if ((sym.flags() & FINAL) != 0) { - log.error(pos, "var.might.already.be.assigned", sym); - } - } - - @Override - void checkInit(DiagnosticPosition pos, VarSymbol sym, String errkey) { - if ((sym.adr >= firstadr || sym.owner.kind != TYP) && - trackable(sym) && - !inits.isMember(sym.adr)) { - log.error(pos, errkey, sym); - inits.incl(sym.adr); - } - } - - @Override - void reportWarning(Lint.LintCategory lc, DiagnosticPosition pos, - String key, Object ... args) { - log.warning(lc, pos, key, args); - } - - @Override - int getLogNumberOfErrors() { - return log.nerrors; - } - - @Override - boolean isEnabled(Lint.LintCategory lc) { - return lint.isEnabled(lc); - } - - @Override - public void visitClassDef(JCClassDecl tree) { - if (tree.sym == null) { - return; - } - - Lint lintPrev = lint; - lint = lint.augment(tree.sym); - try { - super.visitClassDef(tree); - } finally { - lint = lintPrev; - } - } - - @Override - public void visitMethodDef(JCMethodDecl tree) { - if (tree.body == null) { - return; - } - - /* MemberEnter can generate synthetic methods ignore them - */ - if ((tree.sym.flags() & SYNTHETIC) != 0) { - return; - } - - Lint lintPrev = lint; - lint = lint.augment(tree.sym); - try { - super.visitMethodDef(tree); - } finally { - lint = lintPrev; - } - } - - @Override - public void visitVarDef(JCVariableDecl tree) { - if (tree.init == null) { - super.visitVarDef(tree); - } else { - Lint lintPrev = lint; - lint = lint.augment(tree.sym); - try{ - super.visitVarDef(tree); - } finally { - lint = lintPrev; - } - } - } - - } - /** * This pass implements the last step of the dataflow analysis, namely * the effectively-final analysis check. This checks that every local variable @@ -2578,7 +2474,7 @@ JCTree currentTree; //local class or lambda @Override - void markDead(JCTree tree) { + void markDead() { //do nothing } @@ -2715,7 +2611,7 @@ try { attrEnv = env; Flow.this.make = make; - pendingExits = new ListBuffer<PendingExit>(); + pendingExits = new ListBuffer<>(); scan(tree); } finally { pendingExits = null;
--- a/src/share/classes/com/sun/tools/javac/comp/Infer.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Wed Sep 30 16:42:58 2015 +0100 @@ -315,11 +315,9 @@ for (Type aLowerBound : from.getBounds(InferenceBound.LOWER)) { for (Type anotherLowerBound : from.getBounds(InferenceBound.LOWER)) { if (aLowerBound != anotherLowerBound && - commonSuperWithDiffParameterization(aLowerBound, anotherLowerBound)) { - /* self comment check if any lower bound may be and undetVar, - * in that case the result of this call may be a false positive. - * Should this be restricted to non free types? - */ + !inferenceContext.free(aLowerBound) && + !inferenceContext.free(anotherLowerBound) && + commonSuperWithDiffParameterization(aLowerBound, anotherLowerBound)) { return generateReferenceToTargetConstraint(tree, from, to, resultInfo, inferenceContext); }
--- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Wed Sep 30 16:42:58 2015 +0100 @@ -265,7 +265,7 @@ @Override public void visitLambda(JCLambda tree) { LambdaTranslationContext localContext = (LambdaTranslationContext)context; - MethodSymbol sym = (MethodSymbol)localContext.translatedSym; + MethodSymbol sym = localContext.translatedSym; MethodType lambdaType = (MethodType) sym.type; { @@ -1755,7 +1755,7 @@ Map<LambdaSymbolKind, Map<Symbol, Symbol>> translatedSymbols; /** the synthetic symbol for the method hoisting the translated lambda */ - Symbol translatedSym; + MethodSymbol translatedSym; List<JCVariableDecl> syntheticParams; @@ -1883,7 +1883,7 @@ * Translate a symbol of a given kind into something suitable for the * synthetic lambda body */ - Symbol translate(Name name, final Symbol sym, LambdaSymbolKind skind) { + Symbol translate(final Symbol sym, LambdaSymbolKind skind) { Symbol ret; switch (skind) { case CAPTURED_THIS: @@ -1891,7 +1891,7 @@ break; case TYPE_VAR: // Just erase the type var - ret = new VarSymbol(sym.flags(), name, + ret = new VarSymbol(sym.flags(), sym.name, types.erasure(sym.type), sym.owner); /* this information should also be kept for LVT generation at Gen @@ -1900,7 +1900,7 @@ ((VarSymbol)ret).pos = ((VarSymbol)sym).pos; break; case CAPTURED_VAR: - ret = new VarSymbol(SYNTHETIC | FINAL | PARAMETER, name, types.erasure(sym.type), translatedSym) { + ret = new VarSymbol(SYNTHETIC | FINAL | PARAMETER, sym.name, types.erasure(sym.type), translatedSym) { @Override public Symbol baseSymbol() { //keep mapping with original captured symbol @@ -1909,16 +1909,16 @@ }; break; case LOCAL_VAR: - ret = new VarSymbol(sym.flags() & FINAL, name, sym.type, translatedSym); + ret = new VarSymbol(sym.flags() & FINAL, sym.name, sym.type, translatedSym); ((VarSymbol) ret).pos = ((VarSymbol) sym).pos; break; case PARAM: - ret = new VarSymbol((sym.flags() & FINAL) | PARAMETER, name, types.erasure(sym.type), translatedSym); + ret = new VarSymbol((sym.flags() & FINAL) | PARAMETER, sym.name, types.erasure(sym.type), translatedSym); ((VarSymbol) ret).pos = ((VarSymbol) sym).pos; break; default: - ret = makeSyntheticVar(FINAL, name, types.erasure(sym.type), translatedSym); - ((VarSymbol) ret).pos = ((VarSymbol) sym).pos; + Assert.error(skind.name()); + throw new AssertionError(); } if (ret != sym) { ret.setDeclarationAttributes(sym.getRawAttributes()); @@ -1929,27 +1929,8 @@ void addSymbol(Symbol sym, LambdaSymbolKind skind) { Map<Symbol, Symbol> transMap = getSymbolMap(skind); - Name preferredName; - switch (skind) { - case CAPTURED_THIS: - preferredName = names.fromString("encl$" + transMap.size()); - break; - case CAPTURED_VAR: - preferredName = names.fromString("cap$" + transMap.size()); - break; - case LOCAL_VAR: - preferredName = sym.name; - break; - case PARAM: - preferredName = sym.name; - break; - case TYPE_VAR: - preferredName = sym.name; - break; - default: throw new AssertionError(); - } if (!transMap.containsKey(sym)) { - transMap.put(sym, translate(preferredName, sym, skind)); + transMap.put(sym, translate(sym, skind)); } } @@ -1997,6 +1978,7 @@ //compute synthetic params ListBuffer<JCVariableDecl> params = new ListBuffer<>(); + ListBuffer<VarSymbol> parameterSymbols = new ListBuffer<>(); // The signature of the method is augmented with the following // synthetic parameters: @@ -2005,19 +1987,16 @@ // 2) enclosing locals captured by the lambda expression for (Symbol thisSym : getSymbolMap(CAPTURED_VAR).values()) { params.append(make.VarDef((VarSymbol) thisSym, null)); - } - if (methodReferenceReceiver != null) { - params.append(make.VarDef( - make.Modifiers(PARAMETER|FINAL), - names.fromString("$rcvr$"), - make.Type(methodReferenceReceiver.type), - null)); + parameterSymbols.append((VarSymbol) thisSym); } for (Symbol thisSym : getSymbolMap(PARAM).values()) { params.append(make.VarDef((VarSymbol) thisSym, null)); + parameterSymbols.append((VarSymbol) thisSym); } syntheticParams = params.toList(); + translatedSym.params = parameterSymbols.toList(); + // Compute and set the lambda name translatedSym.name = isSerializable() ? serializedLambdaName()
--- a/src/share/classes/com/sun/tools/javac/comp/Lower.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java Wed Sep 30 16:42:58 2015 +0100 @@ -2540,7 +2540,7 @@ currentMethodSym = currentMethodSymPrev; // Return empty block {} as a placeholder for an inner class. - result = make_at(tree.pos()).Block(0, List.<JCStatement>nil()); + result = make_at(tree.pos()).Block(SYNTHETIC, List.<JCStatement>nil()); } /** Translate an enum class. */
--- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Wed Sep 30 16:42:58 2015 +0100 @@ -271,7 +271,7 @@ * the one of its outer environment */ protected static boolean isStatic(Env<AttrContext> env) { - return env.info.staticLevel > env.outer.info.staticLevel; + return env.outer != null && env.info.staticLevel > env.outer.info.staticLevel; } /** An environment is an "initializer" if it is a constructor or @@ -836,20 +836,19 @@ List<Type> formals, Warner warn) { super.argumentsAcceptable(env, deferredAttrContext, argtypes, formals, warn); - //should we expand formals? + // should we check varargs element type accessibility? if (deferredAttrContext.phase.isVarargsRequired()) { - Type typeToCheck = null; - if (!checkVarargsAccessAfterResolution) { - typeToCheck = types.elemtype(formals.last()); - } else if (deferredAttrContext.mode == AttrMode.CHECK) { - typeToCheck = types.erasure(types.elemtype(formals.last())); - } - if (typeToCheck != null) { - varargsAccessible(env, typeToCheck, deferredAttrContext.inferenceContext); + if (deferredAttrContext.mode == AttrMode.CHECK || !checkVarargsAccessAfterResolution) { + varargsAccessible(env, types.elemtype(formals.last()), deferredAttrContext.inferenceContext); } } } + /** + * Test that the runtime array element type corresponding to 't' is accessible. 't' should be the + * varargs element type of either the method invocation type signature (after inference completes) + * or the method declaration signature (before inference completes). + */ private void varargsAccessible(final Env<AttrContext> env, final Type t, final InferenceContext inferenceContext) { if (inferenceContext.free(t)) { inferenceContext.addFreeTypeListener(List.of(t), new FreeTypeListener() { @@ -859,7 +858,7 @@ } }); } else { - if (!isAccessible(env, t)) { + if (!isAccessible(env, types.erasure(t))) { Symbol location = env.enclClass.sym; reportMC(env.tree, MethodCheckDiag.INACCESSIBLE_VARARGS, inferenceContext, t, Kinds.kindName(location), location); } @@ -4087,7 +4086,7 @@ s : new MethodSymbol( s.flags(), s.name, - types.createMethodTypeWithThrown(mt, allThrown), + types.createMethodTypeWithThrown(s.type, allThrown), s.owner); } }
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Wed Sep 30 16:42:58 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1779,15 +1779,17 @@ // The method wasn't found: emit a warning and recover JavaFileObject prevSource = log.useSource(requestingOwner.classfile); try { - if (failure == null) { - log.warning("annotation.method.not.found", - container, - name); - } else { - log.warning("annotation.method.not.found.reason", - container, - name, - failure.getDetailValue());//diagnostic, if present + if (lintClassfile) { + if (failure == null) { + log.warning("annotation.method.not.found", + container, + name); + } else { + log.warning("annotation.method.not.found.reason", + container, + name, + failure.getDetailValue()); //diagnostic, if present + } } } finally { log.useSource(prevSource);
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Wed Sep 30 16:42:58 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1027,6 +1027,7 @@ l.nonEmpty(); l = l.tail) { ClassSymbol inner = l.head; + inner.markAbstractIfNeeded(types); char flags = (char) adjustFlags(inner.flags_field); if ((flags & INTERFACE) != 0) flags |= ABSTRACT; // Interfaces are always ABSTRACT if (inner.name.isEmpty()) flags &= ~FINAL; // Anonymous class: unset FINAL flag @@ -1186,7 +1187,7 @@ Assert.check(r.start_pc >= 0 && r.start_pc <= code.cp); databuf.appendChar(r.start_pc); - Assert.check(r.length >= 0 + Assert.check(r.length > 0 && (r.start_pc + r.length) <= code.cp); databuf.appendChar(r.length); VarSymbol sym = var.sym;
--- a/src/share/classes/com/sun/tools/javac/jvm/Code.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java Wed Sep 30 16:42:58 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -182,8 +182,6 @@ final MethodSymbol meth; - final LVTRanges lvtRanges; - /** Construct a code object, given the settings of the fatcode, * debugging info switches and the CharacterRangeTable. */ @@ -196,8 +194,7 @@ CRTable crt, Symtab syms, Types types, - Pool pool, - LVTRanges lvtRanges) { + Pool pool) { this.meth = meth; this.fatcode = fatcode; this.lineMap = lineMap; @@ -219,7 +216,6 @@ state = new State(); lvar = new LocalVar[20]; this.pool = pool; - this.lvtRanges = lvtRanges; } @@ -1193,7 +1189,9 @@ public int entryPoint(State state) { int pc = curCP(); alive = true; - this.state = state.dup(); + State newState = state.dup(); + setDefined(newState.defined); + this.state = newState; Assert.check(state.stacksize <= max_stack); if (debugCode) System.err.println("entry point " + state); pendingStackMap = needStackMap; @@ -1206,7 +1204,9 @@ public int entryPoint(State state, Type pushed) { int pc = curCP(); alive = true; - this.state = state.dup(); + State newState = state.dup(); + setDefined(newState.defined); + this.state = newState; Assert.check(state.stacksize <= max_stack); this.state.push(pushed); if (debugCode) System.err.println("entry point " + state); @@ -2008,27 +2008,6 @@ state.defined.excl(adr); } - - public void closeAliveRanges(JCTree tree) { - closeAliveRanges(tree, cp); - } - - public void closeAliveRanges(JCTree tree, int closingCP) { - List<VarSymbol> locals = lvtRanges.getVars(meth, tree); - for (LocalVar localVar: lvar) { - for (VarSymbol aliveLocal : locals) { - if (localVar != null) { - if (localVar.sym == aliveLocal && localVar.lastRange() != null) { - char length = (char)(closingCP - localVar.lastRange().start_pc); - if (length < Character.MAX_VALUE) { - localVar.closeRange(length); - } - } - } - } - } - } - void adjustAliveRanges(int oldCP, int delta) { for (LocalVar localVar: lvar) { if (localVar != null) { @@ -2193,7 +2172,11 @@ boolean keepLocalVariables = varDebugInfo || (var.sym.isExceptionParameter() && var.sym.hasTypeAnnotations()); if (!keepLocalVariables) return; - if ((var.sym.flags() & Flags.SYNTHETIC) != 0) return; + //don't keep synthetic vars, unless they are lambda method parameters + boolean ignoredSyntheticVar = (var.sym.flags() & Flags.SYNTHETIC) != 0 && + ((var.sym.owner.flags() & Flags.LAMBDA_METHOD) == 0 || + (var.sym.flags() & Flags.PARAMETER) == 0); + if (ignoredSyntheticVar) return; if (varBuffer == null) varBuffer = new LocalVar[20]; else
--- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java Wed Sep 30 16:42:58 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -101,10 +101,6 @@ */ private Pool pool; - /** LVTRanges info. - */ - private LVTRanges lvtRanges; - private final boolean typeAnnoAsserts; protected Gen(Context context) { @@ -137,9 +133,6 @@ options.isUnset(G_CUSTOM) ? options.isSet(G) : options.isSet(G_CUSTOM, "vars"); - if (varDebugInfo) { - lvtRanges = LVTRanges.instance(context); - } genCrt = options.isSet(XJCOV); debugCode = options.isSet("debugcode"); allowInvokedynamic = target.hasInvokedynamic() || options.isSet("invokedynamic"); @@ -493,7 +486,7 @@ JCBlock block = (JCBlock)def; if ((block.flags & STATIC) != 0) clinitCode.append(block); - else + else if ((block.flags & SYNTHETIC) == 0) initCode.append(block); break; case METHODDEF: @@ -521,6 +514,10 @@ clinitTAs.addAll(getAndRemoveNonFieldTAs(sym)); } else { checkStringConstant(vdef.init.pos(), sym.getConstValue()); + /* if the init contains a reference to an external class, add it to the + * constant's pool + */ + vdef.init.accept(classReferenceVisitor); } } break; @@ -1103,8 +1100,7 @@ : null, syms, types, - pool, - varDebugInfo ? lvtRanges : null); + pool); items = new Items(pool, code, syms, types); if (code.debugCode) { System.err.println(meth + " for body " + tree); @@ -1207,30 +1203,14 @@ Chain loopDone = c.jumpFalse(); code.resolve(c.trueJumps); genStat(body, loopEnv, CRT_STATEMENT | CRT_FLOW_TARGET); - if (varDebugInfo) { - checkLoopLocalVarRangeEnding(loop, body, - LoopLocalVarRangeEndingPoint.BEFORE_STEPS); - } code.resolve(loopEnv.info.cont); genStats(step, loopEnv); - if (varDebugInfo) { - checkLoopLocalVarRangeEnding(loop, body, - LoopLocalVarRangeEndingPoint.AFTER_STEPS); - } code.resolve(code.branch(goto_), startpc); code.resolve(loopDone); } else { genStat(body, loopEnv, CRT_STATEMENT | CRT_FLOW_TARGET); - if (varDebugInfo) { - checkLoopLocalVarRangeEnding(loop, body, - LoopLocalVarRangeEndingPoint.BEFORE_STEPS); - } code.resolve(loopEnv.info.cont); genStats(step, loopEnv); - if (varDebugInfo) { - checkLoopLocalVarRangeEnding(loop, body, - LoopLocalVarRangeEndingPoint.AFTER_STEPS); - } CondItem c; if (cond != null) { code.statBegin(cond.pos); @@ -1247,44 +1227,6 @@ } } - private enum LoopLocalVarRangeEndingPoint { - BEFORE_STEPS, - AFTER_STEPS, - } - - /** - * Checks whether we have reached an alive range ending point for local - * variables after a loop. - * - * Local variables alive range ending point for loops varies depending - * on the loop type. The range can be closed before or after the code - * for the steps sentences has been generated. - * - * - While loops has no steps so in that case the range is closed just - * after the body of the loop. - * - * - For-like loops may have steps so as long as the steps sentences - * can possibly contain non-synthetic local variables, the alive range - * for local variables must be closed after the steps in this case. - */ - private void checkLoopLocalVarRangeEnding(JCTree loop, JCTree body, - LoopLocalVarRangeEndingPoint endingPoint) { - if (varDebugInfo && lvtRanges.containsKey(code.meth, body)) { - switch (endingPoint) { - case BEFORE_STEPS: - if (!loop.hasTag(FORLOOP)) { - code.closeAliveRanges(body); - } - break; - case AFTER_STEPS: - if (loop.hasTag(FORLOOP)) { - code.closeAliveRanges(body); - } - break; - } - } - } - public void visitForeachLoop(JCEnhancedForLoop tree) { throw new AssertionError(); // should have been removed by Lower. } @@ -1398,9 +1340,6 @@ // Generate code for the statements in this case. genStats(c.stats, switchEnv, CRT_FLOW_TARGET); - if (varDebugInfo && lvtRanges.containsKey(code.meth, c.stats.last())) { - code.closeAliveRanges(c.stats.last()); - } } // Resolve all breaks. @@ -1557,9 +1496,6 @@ genFinalizer(env); code.statBegin(TreeInfo.endPos(env.tree)); Chain exitChain = code.branch(goto_); - if (varDebugInfo && lvtRanges.containsKey(code.meth, body)) { - code.closeAliveRanges(body); - } endFinalizerGap(env); if (startpc != endpc) for (List<JCCatch> l = catchers; l.nonEmpty(); l = l.tail) { // start off with exception on stack @@ -1815,17 +1751,11 @@ code.resolve(c.trueJumps); genStat(tree.thenpart, env, CRT_STATEMENT | CRT_FLOW_TARGET); thenExit = code.branch(goto_); - if (varDebugInfo && lvtRanges.containsKey(code.meth, tree.thenpart)) { - code.closeAliveRanges(tree.thenpart, code.cp); - } } if (elseChain != null) { code.resolve(elseChain); if (tree.elsepart != null) { genStat(tree.elsepart, env,CRT_STATEMENT | CRT_FLOW_TARGET); - if (varDebugInfo && lvtRanges.containsKey(code.meth, tree.elsepart)) { - code.closeAliveRanges(tree.elsepart); - } } } code.resolve(thenExit); @@ -2505,25 +2435,18 @@ && !allowGenerics // no Miranda methods available with generics ) implementInterfaceMethods(c); - cdef.defs = normalizeDefs(cdef.defs, c); c.pool = pool; pool.reset(); + /* method normalizeDefs() can add references to external classes into the constant pool + * so it should be called after pool.reset() + */ + cdef.defs = normalizeDefs(cdef.defs, c); generateReferencesToPrunedTree(c, pool); Env<GenContext> localEnv = new Env<GenContext>(cdef, new GenContext()); localEnv.toplevel = env.toplevel; localEnv.enclClass = cdef; - /* We must not analyze synthetic methods - */ - if (varDebugInfo && (cdef.sym.flags() & SYNTHETIC) == 0) { - try { - new LVTAssignAnalyzer().analyzeTree(localEnv); - } catch (Throwable e) { - throw e; - } - } - for (List<JCTree> l = cdef.defs; l.nonEmpty(); l = l.tail) { genDef(l.head, localEnv); } @@ -2609,282 +2532,4 @@ } } - class LVTAssignAnalyzer - extends Flow.AbstractAssignAnalyzer<LVTAssignAnalyzer.LVTAssignPendingExit> { - - final LVTBits lvtInits; - - /* This class is anchored to a context dependent tree. The tree can - * vary inside the same instruction for example in the switch instruction - * the same FlowBits instance can be anchored to the whole tree, or - * to a given case. The aim is to always anchor the bits to the tree - * capable of closing a DA range. - */ - class LVTBits extends Bits { - - JCTree currentTree; - private int[] oldBits = null; - BitsState stateBeforeOp; - - @Override - public void clear() { - generalOp(null, -1, BitsOpKind.CLEAR); - } - - @Override - protected void internalReset() { - super.internalReset(); - oldBits = null; - } - - @Override - public Bits assign(Bits someBits) { - // bits can be null - oldBits = bits; - stateBeforeOp = currentState; - super.assign(someBits); - changed(); - return this; - } - - @Override - public void excludeFrom(int start) { - generalOp(null, start, BitsOpKind.EXCL_RANGE); - } - - @Override - public void excl(int x) { - Assert.check(x >= 0); - generalOp(null, x, BitsOpKind.EXCL_BIT); - } - - @Override - public Bits andSet(Bits xs) { - return generalOp(xs, -1, BitsOpKind.AND_SET); - } - - @Override - public Bits orSet(Bits xs) { - return generalOp(xs, -1, BitsOpKind.OR_SET); - } - - @Override - public Bits diffSet(Bits xs) { - return generalOp(xs, -1, BitsOpKind.DIFF_SET); - } - - @Override - public Bits xorSet(Bits xs) { - return generalOp(xs, -1, BitsOpKind.XOR_SET); - } - - private Bits generalOp(Bits xs, int i, BitsOpKind opKind) { - Assert.check(currentState != BitsState.UNKNOWN); - oldBits = dupBits(); - stateBeforeOp = currentState; - switch (opKind) { - case AND_SET: - super.andSet(xs); - break; - case OR_SET: - super.orSet(xs); - break; - case XOR_SET: - super.xorSet(xs); - break; - case DIFF_SET: - super.diffSet(xs); - break; - case CLEAR: - super.clear(); - break; - case EXCL_BIT: - super.excl(i); - break; - case EXCL_RANGE: - super.excludeFrom(i); - break; - } - changed(); - return this; - } - - /* The tree we need to anchor the bits instance to. - */ - LVTBits at(JCTree tree) { - this.currentTree = tree; - return this; - } - - /* If the instance should be changed but the tree is not a closing - * tree then a reset is needed or the former tree can mistakingly be - * used. - */ - LVTBits resetTree() { - this.currentTree = null; - return this; - } - - /** This method will be called after any operation that causes a change to - * the bits. Subclasses can thus override it in order to extract information - * from the changes produced to the bits by the given operation. - */ - public void changed() { - if (currentTree != null && - stateBeforeOp != BitsState.UNKNOWN && - trackTree(currentTree)) { - List<VarSymbol> locals = lvtRanges - .getVars(currentMethod, currentTree); - locals = locals != null ? - locals : List.<VarSymbol>nil(); - for (JCVariableDecl vardecl : vardecls) { - //once the first is null, the rest will be so. - if (vardecl == null) { - break; - } - if (trackVar(vardecl.sym) && bitChanged(vardecl.sym.adr)) { - locals = locals.prepend(vardecl.sym); - } - } - if (!locals.isEmpty()) { - lvtRanges.setEntry(currentMethod, - currentTree, locals); - } - } - } - - boolean bitChanged(int x) { - boolean isMemberOfBits = isMember(x); - int[] tmp = bits; - bits = oldBits; - boolean isMemberOfOldBits = isMember(x); - bits = tmp; - return (!isMemberOfBits && isMemberOfOldBits); - } - - boolean trackVar(VarSymbol var) { - return (var.owner.kind == MTH && - (var.flags() & PARAMETER) == 0 && - trackable(var)); - } - - boolean trackTree(JCTree tree) { - switch (tree.getTag()) { - // of course a method closes the alive range of a local variable. - case METHODDEF: - // for while loops we want only the body - case WHILELOOP: - return false; - } - return true; - } - - } - - public class LVTAssignPendingExit extends - Flow.AbstractAssignAnalyzer<LVTAssignPendingExit>.AbstractAssignPendingExit { - - LVTAssignPendingExit(JCTree tree, final Bits inits, final Bits uninits) { - super(tree, inits, uninits); - } - - @Override - public void resolveJump(JCTree tree) { - lvtInits.at(tree); - super.resolveJump(tree); - } - } - - private LVTAssignAnalyzer() { - flow.super(); - lvtInits = new LVTBits(); - inits = lvtInits; - } - - @Override - protected void markDead(JCTree tree) { - lvtInits.at(tree).inclRange(returnadr, nextadr); - super.markDead(tree); - } - - @Override - protected void merge(JCTree tree) { - lvtInits.at(tree); - super.merge(tree); - } - - boolean isSyntheticOrMandated(Symbol sym) { - return (sym.flags() & (SYNTHETIC | MANDATED)) != 0; - } - - @Override - protected boolean trackable(VarSymbol sym) { - if (isSyntheticOrMandated(sym)) { - //fast check to avoid tracking synthetic or mandated variables - return false; - } - return super.trackable(sym); - } - - @Override - protected void initParam(JCVariableDecl def) { - if (!isSyntheticOrMandated(def.sym)) { - super.initParam(def); - } - } - - @Override - protected void assignToInits(JCTree tree, Bits bits) { - lvtInits.at(tree); - lvtInits.assign(bits); - } - - @Override - protected void andSetInits(JCTree tree, Bits bits) { - lvtInits.at(tree); - lvtInits.andSet(bits); - } - - @Override - protected void orSetInits(JCTree tree, Bits bits) { - lvtInits.at(tree); - lvtInits.orSet(bits); - } - - @Override - protected void exclVarFromInits(JCTree tree, int adr) { - lvtInits.at(tree); - lvtInits.excl(adr); - } - - @Override - protected LVTAssignPendingExit createNewPendingExit(JCTree tree, Bits inits, Bits uninits) { - return new LVTAssignPendingExit(tree, inits, uninits); - } - - MethodSymbol currentMethod; - - @Override - public void visitMethodDef(JCMethodDecl tree) { - if ((tree.sym.flags() & (SYNTHETIC | GENERATEDCONSTR)) != 0 - && (tree.sym.flags() & LAMBDA_METHOD) == 0) { - return; - } - if (tree.name.equals(names.clinit)) { - return; - } - boolean enumClass = (tree.sym.owner.flags() & ENUM) != 0; - if (enumClass && - (tree.name.equals(names.valueOf) || - tree.name.equals(names.values) || - tree.name.equals(names.init))) { - return; - } - currentMethod = tree.sym; - - super.visitMethodDef(tree); - } - - } - }
--- a/src/share/classes/com/sun/tools/javac/jvm/LVTRanges.java Fri Sep 18 04:09:09 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.javac.jvm; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.WeakHashMap; - -import com.sun.tools.javac.code.Symbol.MethodSymbol; -import com.sun.tools.javac.code.Symbol.VarSymbol; -import com.sun.tools.javac.tree.JCTree; -import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.List; - -/** This class contains a one to many relation between a tree and a set of variables. - * The relation implies that the given tree closes the DA (definite assignment) - * range for the set of variables. - * - * <p><b>This is NOT part of any supported API. - * If you write code that depends on this, you do so at your own risk. - * This code and its internal interfaces are subject to change or - * deletion without notice.</b> - */ -public class LVTRanges { - /** The context key for the LVT ranges. */ - protected static final Context.Key<LVTRanges> lvtRangesKey = new Context.Key<>(); - - /** Get the LVTRanges instance for this context. */ - public static LVTRanges instance(Context context) { - LVTRanges instance = context.get(lvtRangesKey); - if (instance == null) { - instance = new LVTRanges(context); - } - return instance; - } - - private static final long serialVersionUID = 1812267524140424433L; - - protected Context context; - - protected Map<MethodSymbol, Map<JCTree, List<VarSymbol>>> - aliveRangeClosingTrees = new WeakHashMap<>(); - - public LVTRanges(Context context) { - this.context = context; - context.put(lvtRangesKey, this); - } - - public List<VarSymbol> getVars(MethodSymbol method, JCTree tree) { - Map<JCTree, List<VarSymbol>> varMap = aliveRangeClosingTrees.get(method); - return (varMap != null) ? varMap.get(tree) : null; - } - - public boolean containsKey(MethodSymbol method, JCTree tree) { - Map<JCTree, List<VarSymbol>> varMap = aliveRangeClosingTrees.get(method); - if (varMap == null) { - return false; - } - return varMap.containsKey(tree); - } - - public void setEntry(MethodSymbol method, JCTree tree, List<VarSymbol> vars) { - Map<JCTree, List<VarSymbol>> varMap = aliveRangeClosingTrees.get(method); - if (varMap != null) { - varMap.put(tree, vars); - } else { - varMap = new WeakHashMap<>(); - varMap.put(tree, vars); - aliveRangeClosingTrees.put(method, varMap); - } - } - - public List<VarSymbol> removeEntry(MethodSymbol method, JCTree tree) { - Map<JCTree, List<VarSymbol>> varMap = aliveRangeClosingTrees.get(method); - if (varMap != null) { - List<VarSymbol> result = varMap.remove(tree); - if (varMap.isEmpty()) { - aliveRangeClosingTrees.remove(method); - } - return result; - } - return null; - } - - /* This method should be used for debugging LVT related issues. - */ - @Override - public String toString() { - String result = ""; - for (Entry<MethodSymbol, Map<JCTree, List<VarSymbol>>> mainEntry: aliveRangeClosingTrees.entrySet()) { - result += "Method: \n" + mainEntry.getKey().flatName() + "\n"; - int i = 1; - for (Entry<JCTree, List<VarSymbol>> treeEntry: mainEntry.getValue().entrySet()) { - result += " Tree " + i + ": \n" + treeEntry.getKey().toString() + "\n"; - result += " Variables closed:\n"; - for (VarSymbol var: treeEntry.getValue()) { - result += " " + var.toString(); - } - result += "\n"; - i++; - } - } - return result; - } - -}
--- a/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Wed Sep 30 16:42:58 2015 +0100 @@ -1039,7 +1039,7 @@ } /** - * @see <a href="http://docs.oracle.com/javase/7/docs/technotes/tools/solaris/javadoc.html#javadoctags">Javadoc Tags</a> + * @see <a href="https://docs.oracle.com/javase/7/docs/technotes/tools/solaris/javadoc.html#javadoctags">Javadoc Tags</a> */ private void initTagParsers() { TagParser[] parsers = {
--- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Wed Sep 30 16:42:58 2015 +0100 @@ -2720,7 +2720,7 @@ } else { JCExpression t = term(EXPR | TYPE); if ((lastmode & TYPE) != 0 && LAX_IDENTIFIER.accepts(token.kind)) { - return variableDeclarators(modifiersOpt(), t, stats).toList(); + return variableDeclarators(mods(pos, 0, List.<JCAnnotation>nil()), t, stats).toList(); } else if ((lastmode & TYPE) != 0 && token.kind == COLON) { error(pos, "bad.initializer", "for-loop"); return List.of((JCStatement)F.at(pos).VarDef(null, null, t, null)); @@ -2829,16 +2829,20 @@ default: break; } - /* A modifiers tree with no modifier tokens or annotations - * has no text position. */ - if ((flags & (Flags.ModifierFlags | Flags.ANNOTATION)) == 0 && annotations.isEmpty()) - pos = Position.NOPOS; - - JCModifiers mods = F.at(pos).Modifiers(flags, annotations.toList()); - if (pos != Position.NOPOS) - storeEnd(mods, S.prevToken().endPos); - return mods; + return mods(pos, flags, annotations.toList()); } + //where + JCModifiers mods(int pos, long flags, List<JCAnnotation> annotations) { + /* A modifiers tree with no modifier tokens or annotations + * has no text position. */ + if ((flags & (Flags.ModifierFlags | Flags.ANNOTATION)) == 0 && annotations.isEmpty()) + pos = Position.NOPOS; + + JCModifiers mods = F.at(pos).Modifiers(flags, annotations); + if (pos != Position.NOPOS) + storeEnd(mods, S.prevToken().endPos); + return mods; + } /** Annotation = "@" Qualident [ "(" AnnotationFieldValues ")" ] *
--- a/src/share/classes/com/sun/tools/javac/resources/javac.properties Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/javac/resources/javac.properties Wed Sep 30 16:42:58 2015 +0100 @@ -232,8 +232,8 @@ javac.msg.bug=\ An exception has occurred in the compiler ({0}). \ -Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) \ -after checking the Bug Parade for duplicates. \ +Please file a bug at the Java Bug Database (http://bugreport.java.com/bugreport/) \ +after checking the database for duplicates. \ Include your program and the following diagnostic in your report. Thank you. javac.msg.io=\
--- a/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties Wed Sep 30 16:42:58 2015 +0100 @@ -1,5 +1,5 @@ # -# Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -133,7 +133,7 @@ javac.msg.usage.nonstandard.footer=\u3053\u308C\u3089\u306F\u975E\u6A19\u6E96\u30AA\u30D7\u30B7\u30E7\u30F3\u3067\u3042\u308A\u4E88\u544A\u306A\u3057\u306B\u5909\u66F4\u3055\u308C\u308B\u3053\u3068\u304C\u3042\u308A\u307E\u3059\u3002 -javac.msg.bug=\u30B3\u30F3\u30D1\u30A4\u30E9\u3067\u4F8B\u5916\u304C\u767A\u751F\u3057\u307E\u3057\u305F({0})\u3002Bug Parade\u3067\u91CD\u8907\u304C\u306A\u3044\u304B\u3092\u3054\u78BA\u8A8D\u306E\u3046\u3048\u3001Java Developer Connection (http://java.sun.com/webapps/bugreport)\u3067bug\u306E\u767B\u9332\u3092\u304A\u9858\u3044\u3044\u305F\u3057\u307E\u3059\u3002\u30EC\u30DD\u30FC\u30C8\u306B\u306F\u3001\u305D\u306E\u30D7\u30ED\u30B0\u30E9\u30E0\u3068\u4E0B\u8A18\u306E\u8A3A\u65AD\u5185\u5BB9\u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u3054\u5354\u529B\u3042\u308A\u304C\u3068\u3046\u3054\u3056\u3044\u307E\u3059\u3002 +javac.msg.bug=\u30B3\u30F3\u30D1\u30A4\u30E9\u3067\u4F8B\u5916\u304C\u767A\u751F\u3057\u307E\u3057\u305F({0})\u3002\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u3067\u91CD\u8907\u304C\u306A\u3044\u304B\u3092\u3054\u78BA\u8A8D\u306E\u3046\u3048\u3001Java Bug Database (http://bugreport.java.com/bugreport/)\u3067bug\u306E\u767B\u9332\u3092\u304A\u9858\u3044\u3044\u305F\u3057\u307E\u3059\u3002\u30EC\u30DD\u30FC\u30C8\u306B\u306F\u3001\u305D\u306E\u30D7\u30ED\u30B0\u30E9\u30E0\u3068\u4E0B\u8A18\u306E\u8A3A\u65AD\u5185\u5BB9\u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u3054\u5354\u529B\u3042\u308A\u304C\u3068\u3046\u3054\u3056\u3044\u307E\u3059\u3002 javac.msg.io=\n\n\u5165\u51FA\u529B\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\n\u8A73\u7D30\u306F\u6B21\u306E\u30B9\u30BF\u30C3\u30AF\u30FB\u30C8\u30EC\u30FC\u30B9\u3067\u8ABF\u67FB\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n
--- a/src/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties Wed Sep 30 16:42:58 2015 +0100 @@ -1,5 +1,5 @@ # -# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -133,7 +133,7 @@ javac.msg.usage.nonstandard.footer=\u8FD9\u4E9B\u9009\u9879\u90FD\u662F\u975E\u6807\u51C6\u9009\u9879, \u5982\u6709\u66F4\u6539, \u6055\u4E0D\u53E6\u884C\u901A\u77E5\u3002 -javac.msg.bug=\u7F16\u8BD1\u5668 ({0}) \u4E2D\u51FA\u73B0\u5F02\u5E38\u9519\u8BEF\u3002 \u5982\u679C\u5728 Bug Parade \u4E2D\u6CA1\u6709\u627E\u5230\u8BE5\u9519\u8BEF, \u8BF7\u5728 Java Developer Connection (http://java.sun.com/webapps/bugreport) \u4E2D\u5EFA\u7ACB Bug\u3002\u8BF7\u5728\u62A5\u544A\u4E2D\u9644\u4E0A\u60A8\u7684\u7A0B\u5E8F\u548C\u4EE5\u4E0B\u8BCA\u65AD\u4FE1\u606F\u3002\u8C22\u8C22\u3002 +javac.msg.bug=\u7F16\u8BD1\u5668 ({0}) \u4E2D\u51FA\u73B0\u5F02\u5E38\u9519\u8BEF\u3002\u5982\u679C\u5728 Java Bug Database (http://bugreport.java.com/bugreport/) \u4E2D\u6CA1\u6709\u627E\u5230\u8BE5\u9519\u8BEF, \u8BF7\u5728\u8BE5\u6570\u636E\u5E93\u4E2D\u5EFA\u7ACB Bug\u3002\u8BF7\u5728\u62A5\u544A\u4E2D\u9644\u4E0A\u60A8\u7684\u7A0B\u5E8F\u548C\u4EE5\u4E0B\u8BCA\u65AD\u4FE1\u606F\u3002\u8C22\u8C22\u3002 javac.msg.io=\n\n\u53D1\u751F\u8F93\u5165/\u8F93\u51FA\u9519\u8BEF\u3002\n\u6709\u5173\u8BE6\u7EC6\u4FE1\u606F, \u8BF7\u53C2\u9605\u4EE5\u4E0B\u5806\u6808\u8DDF\u8E2A\u3002\n
--- a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Wed Sep 30 16:42:58 2015 +0100 @@ -28,6 +28,7 @@ import com.sun.source.tree.Tree; +import com.sun.source.util.TreePath; import com.sun.tools.javac.code.*; import com.sun.tools.javac.comp.AttrContext; import com.sun.tools.javac.comp.Env; @@ -351,6 +352,18 @@ return (lit.typetag == BOT); } + /** Return true iff this tree is a child of some annotation. */ + public static boolean isInAnnotation(Env<?> env, JCTree tree) { + TreePath tp = TreePath.getPath(env.toplevel, tree); + if (tp != null) { + for (Tree t : tp) { + if (t.getKind() == Tree.Kind.ANNOTATION) + return true; + } + } + return false; + } + public static String getCommentText(Env<?> env, JCTree tree) { DocCommentTable docComments = (tree.hasTag(JCTree.Tag.TOPLEVEL)) ? ((JCCompilationUnit) tree).docComments
--- a/src/share/classes/com/sun/tools/javac/util/Bits.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/javac/util/Bits.java Wed Sep 30 16:42:58 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -84,20 +84,6 @@ } - public enum BitsOpKind { - INIT, - CLEAR, - INCL_BIT, - EXCL_BIT, - ASSIGN, - AND_SET, - OR_SET, - DIFF_SET, - XOR_SET, - INCL_RANGE, - EXCL_RANGE, - } - private final static int wordlen = 32; private final static int wordshift = 5; private final static int wordmask = wordlen - 1;
--- a/src/share/classes/com/sun/tools/javac/util/Convert.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/javac/util/Convert.java Wed Sep 30 16:42:58 2015 +0100 @@ -36,9 +36,9 @@ * <p> * See also: * <ul> - * <li><a href="http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.4.7"> + * <li><a href="https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.4.7"> * JVMS 4.4.7 </a></li> - * <li><a href="http://docs.oracle.com/javase/7/docs/api/java/io/DataInput.html#modified-utf-8"> + * <li><a href="https://docs.oracle.com/javase/7/docs/api/java/io/DataInput.html#modified-utf-8"> java.io.DataInput: Modified UTF-8 </a></li> <li><a href="https://en.wikipedia.org/wiki/UTF-8#Modified_UTF-8"> Modified UTF-8 (wikipedia) </a></li>
--- a/src/share/classes/com/sun/tools/jdeps/Analyzer.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/jdeps/Analyzer.java Wed Sep 30 16:42:58 2015 +0100 @@ -223,7 +223,7 @@ Archive targetArchive = findArchive(t); if (filter.accepts(o, archive, t, targetArchive)) { addDep(o, t); - if (!requires.contains(targetArchive)) { + if (archive != targetArchive && !requires.contains(targetArchive)) { requires.add(targetArchive); } }
--- a/src/share/classes/com/sun/tools/jdeps/JdepsTask.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/jdeps/JdepsTask.java Wed Sep 30 16:42:58 2015 +0100 @@ -489,9 +489,11 @@ List<Archive> archives = new ArrayList<>(); Deque<String> roots = new LinkedList<>(); + List<Path> paths = new ArrayList<>(); for (String s : classes) { Path p = Paths.get(s); if (Files.exists(p)) { + paths.add(p); archives.add(Archive.getInstance(p)); } else { if (isValidClassName(s)) { @@ -504,7 +506,7 @@ sourceLocations.addAll(archives); List<Archive> classpaths = new ArrayList<>(); // for class file lookup - classpaths.addAll(getClassPathArchives(options.classpath)); + classpaths.addAll(getClassPathArchives(options.classpath, paths)); if (options.includePattern != null) { archives.addAll(classpaths); } @@ -545,6 +547,9 @@ deque.add(cn); } a.addClass(d.getOrigin(), d.getTarget()); + } else { + // ensure that the parsed class is added the archive + a.addClass(d.getOrigin()); } } for (String name : a.reader().skippedEntries()) { @@ -592,6 +597,9 @@ if (!doneClasses.contains(cn) && !deque.contains(cn)) { deque.add(cn); } + } else { + // ensure that the parsed class is added the archive + a.addClass(d.getOrigin()); } } } @@ -743,36 +751,52 @@ } } - private List<Archive> getClassPathArchives(String paths) throws IOException { + /* + * Returns the list of Archive specified in cpaths and not included + * initialArchives + */ + private List<Archive> getClassPathArchives(String cpaths, List<Path> initialArchives) + throws IOException + { List<Archive> result = new ArrayList<>(); - if (paths.isEmpty()) { + if (cpaths.isEmpty()) { return result; } - for (String p : paths.split(File.pathSeparator)) { + + List<Path> paths = new ArrayList<>(); + for (String p : cpaths.split(File.pathSeparator)) { if (p.length() > 0) { - List<Path> files = new ArrayList<>(); // wildcard to parse all JAR files e.g. -classpath dir/* int i = p.lastIndexOf(".*"); if (i > 0) { Path dir = Paths.get(p.substring(0, i)); try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, "*.jar")) { for (Path entry : stream) { - files.add(entry); + paths.add(entry); } } } else { - files.add(Paths.get(p)); - } - for (Path f : files) { - if (Files.exists(f)) { - result.add(Archive.getInstance(f)); - } + paths.add(Paths.get(p)); } } } + for (Path p : paths) { + if (Files.exists(p) && !hasSameFile(initialArchives, p)) { + result.add(Archive.getInstance(p)); + } + } return result; } + private boolean hasSameFile(List<Path> paths, Path p2) throws IOException { + for (Path p1 : paths) { + if (Files.isSameFile(p1, p2)) { + return true; + } + } + return false; + } + class RawOutputFormatter implements Analyzer.Visitor { private final PrintWriter writer; private String pkg = "";
--- a/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java Fri Sep 18 04:09:09 2015 +0100 +++ b/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java Wed Sep 30 16:42:58 2015 +0100 @@ -46,7 +46,7 @@ */ class PlatformClassPath { private static final List<String> NON_PLATFORM_JARFILES = - Arrays.asList("alt-rt.jar", "jfxrt.jar", "ant-javafx.jar", "javafx-mx.jar"); + Arrays.asList("alt-rt.jar", "ant-javafx.jar", "javafx-mx.jar"); private static final List<Archive> javaHomeArchives = init(); static List<Archive> getArchives() { @@ -124,6 +124,14 @@ */ static class JDKArchive extends Archive { private static List<String> PROFILE_JARS = Arrays.asList("rt.jar", "jce.jar"); + // Workaround: The following packages are not annotated as jdk.Exported + private static List<String> EXPORTED_PACKAGES = Arrays.asList( + "javax.jnlp", + "org.w3c.dom.css", + "org.w3c.dom.html", + "org.w3c.dom.stylesheets", + "org.w3c.dom.xpath" + ); public static boolean isProfileArchive(Archive archive) { if (archive instanceof JDKArchive) { return PROFILE_JARS.contains(archive.getName()); @@ -155,7 +163,11 @@ * Tests if a given package name is exported. */ public boolean isExportedPackage(String pn) { - if (Profile.getProfile(pn) != null || "javax.jnlp".equals(pn)) { + if (Profile.getProfile(pn) != null) { + return true; + } + // special case for JavaFX and APIs that are not annotated with @jdk.Exported) + if (EXPORTED_PACKAGES.contains(pn) || pn.startsWith("javafx.")) { return true; } return exportedPackages.containsKey(pn) ? exportedPackages.get(pn) : false;
--- a/test/Makefile Fri Sep 18 04:09:09 2015 +0100 +++ b/test/Makefile Wed Sep 30 16:42:58 2015 +0100 @@ -21,7 +21,6 @@ ifeq ($(OSNAME), SunOS) SLASH_JAVA = /java PLATFORM = solaris - JT_PLATFORM = solaris ARCH = $(shell uname -p) ifeq ($(ARCH), i386) ARCH=i586 @@ -30,7 +29,6 @@ ifeq ($(OSNAME), Linux) SLASH_JAVA = /java PLATFORM = linux - JT_PLATFORM = linux ARCH = $(shell uname -m) ifeq ($(ARCH), i386) ARCH=i586 @@ -38,7 +36,6 @@ endif ifeq ($(OSNAME), Darwin) PLATFORM = bsd - JT_PLATFORM = linux ARCH = $(shell uname -m) ifeq ($(ARCH), i386) ARCH=i586 @@ -55,7 +52,6 @@ ifeq ($(PLATFORM), windows) SLASH_JAVA = J: - JT_PLATFORM = win32 ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),ia64) ARCH=ia64 else @@ -93,8 +89,8 @@ else JTREG_HOME = $(SLASH_JAVA)/re/jtreg/4.1/promoted/latest/binaries/jtreg endif -JTREG = $(JTREG_HOME)/$(JT_PLATFORM)/bin/jtreg -JTDIFF = $(JTREG_HOME)/$(JT_PLATFORM)/bin/jtdiff +JTREG = $(JTREG_HOME)/bin/jtreg +JTDIFF = $(JTREG_HOME)/bin/jtdiff # Default JCK to run ifdef JPRT_JCK_HOME
--- a/test/com/sun/javadoc/testDocRootLink/TestDocRootLink.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/com/sun/javadoc/testDocRootLink/TestDocRootLink.java Wed Sep 30 16:42:58 2015 +0100 @@ -60,21 +60,21 @@ }; private static final String[][] NEGATED_TEST1 = { {BUG_ID + FS + "pkg1" + FS + "C1.html", - "<a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">" + "<a href=\"https://docs.oracle.com/javase/7/docs/technotes/guides/index.html\">" }, {BUG_ID + FS + "pkg1" + FS + "C1.html", - "<a href=\"http://download.oracle.com/javase/7/docs/pkg2/C2.html\">" + "<a href=\"https://docs.oracle.com/javase/7/docs/pkg2/C2.html\">" }, {BUG_ID + FS + "pkg1" + FS + "package-summary.html", - "<a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">" + "<a href=\"https://docs.oracle.com/javase/7/docs/technotes/guides/index.html\">" }, {BUG_ID + FS + "pkg1" + FS + "package-summary.html", - "<a href=\"http://download.oracle.com/javase/7/docs/pkg2/C2.html\">" + "<a href=\"https://docs.oracle.com/javase/7/docs/pkg2/C2.html\">" } }; private static final String[][] TEST2 = { {BUG_ID + "-1" + FS + "pkg2" + FS + "C2.html", - "Refer <a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">Here</a>" + "Refer <a href=\"https://docs.oracle.com/javase/7/docs/technotes/guides/index.html\">Here</a>" }, {BUG_ID + "-1" + FS + "pkg2" + FS + "C2.html", "This <a href=\"../pkg1/C1.html\">Here</a> should not be replaced" + NL + @@ -85,7 +85,7 @@ " <a href=\"../pkg1/C1.html\">Link 2</a>." }, {BUG_ID + "-1" + FS + "pkg2" + FS + "package-summary.html", - "<a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">" + NL + + "<a href=\"https://docs.oracle.com/javase/7/docs/technotes/guides/index.html\">" + NL + " Test document 1</a>" }, {BUG_ID + "-1" + FS + "pkg2" + FS + "package-summary.html", @@ -100,13 +100,13 @@ "<a href=\"../../technotes/guides/index.html\">" }, {BUG_ID + "-1" + FS + "pkg2" + FS + "C2.html", - "<a href=\"http://download.oracle.com/javase/7/docs/pkg1/C1.html\">" + "<a href=\"https://docs.oracle.com/javase/7/docs/pkg1/C1.html\">" }, {BUG_ID + "-1" + FS + "pkg2" + FS + "package-summary.html", "<a href=\"../../technotes/guides/index.html\">" }, {BUG_ID + "-1" + FS + "pkg2" + FS + "package-summary.html", - "<a href=\"http://download.oracle.com/javase/7/docs/pkg1/C1.html\">" + "<a href=\"https://docs.oracle.com/javase/7/docs/pkg1/C1.html\">" } }; private static final String[] ARGS1 = @@ -115,7 +115,7 @@ }; private static final String[] ARGS2 = new String[]{ - "-d", BUG_ID + "-1", "-Xdocrootparent", "http://download.oracle.com/javase/7/docs", "-sourcepath", SRC_DIR, "pkg1", "pkg2" + "-d", BUG_ID + "-1", "-Xdocrootparent", "https://docs.oracle.com/javase/7/docs", "-sourcepath", SRC_DIR, "pkg1", "pkg2" }; /**
--- a/test/com/sun/javadoc/testStylesheet/TestStylesheet.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/com/sun/javadoc/testStylesheet/TestStylesheet.java Wed Sep 30 16:42:58 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 4494033 7028815 7052425 8007338 8023608 8008164 8016549 + * @bug 4494033 7028815 7052425 8007338 8023608 8008164 8016549 8072461 * @summary Run tests on doclet stylesheet. * @author jamieh * @library ../lib/ @@ -34,7 +34,7 @@ public class TestStylesheet extends JavadocTester { //Test information. - private static final String BUG_ID = "4494033-7028815-7052425-8007338"; + private static final String BUG_ID = "4494033-7028815-7052425-8007338-8072461"; //Javadoc arguments. private static final String[] ARGS = new String[] { @@ -123,6 +123,23 @@ "}"}, {BUG_ID + FS + "stylesheet.css", "@import url('resources/fonts/dejavu.css');"}, + // Test the formatting styles for proper content display in use and constant values pages. + {BUG_ID + FS + "stylesheet.css", + ".overviewSummary td.colFirst, .overviewSummary th.colFirst," + NL + + ".useSummary td.colFirst, .useSummary th.colFirst," + NL + + ".overviewSummary td.colOne, .overviewSummary th.colOne," + NL + + ".memberSummary td.colFirst, .memberSummary th.colFirst," + NL + + ".memberSummary td.colOne, .memberSummary th.colOne," + NL + + ".typeSummary td.colFirst{" + NL + + " width:25%;" + NL + + " vertical-align:top;" + NL + + "}"}, + {BUG_ID + FS + "stylesheet.css", + ".overviewSummary td, .memberSummary td, .typeSummary td," + NL + + ".useSummary td, .constantsSummary td, .deprecatedSummary td {" + NL + + " text-align:left;" + NL + + " padding:0px 0px 12px 10px;" + NL + + "}"}, // Test whether a link to the stylesheet file is inserted properly // in the class documentation. {BUG_ID + FS + "pkg" + FS + "A.html",
--- a/test/tools/javac/7153958/CPoolRefClassContainingInlinedCts.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/javac/7153958/CPoolRefClassContainingInlinedCts.java Wed Sep 30 16:42:58 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,9 +25,9 @@ /* * @test - * @bug 7153958 + * @bug 7153958 8073372 * @summary add constant pool reference to class containing inlined constants - * @compile pkg/ClassToBeStaticallyImported.java CPoolRefClassContainingInlinedCts.java + * @compile pkg/ClassToBeStaticallyImportedA.java pkg/ClassToBeStaticallyImportedB.java CPoolRefClassContainingInlinedCts.java * @run main CPoolRefClassContainingInlinedCts */ @@ -38,7 +38,8 @@ import java.io.File; import java.io.IOException; -import static pkg.ClassToBeStaticallyImported.staticField; +import static pkg.ClassToBeStaticallyImportedA.staticFieldA; +import static pkg.ClassToBeStaticallyImportedB.staticFieldB; public class CPoolRefClassContainingInlinedCts { @@ -54,10 +55,14 @@ void checkClassName(String className) { switch (className) { - case "SimpleAssignClass" : case "BinaryExpClass": - case "UnaryExpClass" : case "CastClass": - case "ParensClass" : case "CondClass": - case "IfClass" : case "pkg/ClassToBeStaticallyImported": + case "SimpleAssignClassA" : case "BinaryExpClassA": + case "UnaryExpClassA" : case "CastClassA": + case "ParensClassA" : case "CondClassA": + case "IfClassA" : case "pkg/ClassToBeStaticallyImportedA": + case "SimpleAssignClassB" : case "BinaryExpClassB": + case "UnaryExpClassB" : case "CastClassB": + case "ParensClassB" : case "CondClassB": + case "IfClassB" : case "pkg/ClassToBeStaticallyImportedB": numberOfReferencedClassesToBeChecked++; } } @@ -76,59 +81,111 @@ } i += cpInfo.size(); } - if (numberOfReferencedClassesToBeChecked != 8) { + if (numberOfReferencedClassesToBeChecked != 16) { throw new AssertionError("Class reference missing in the constant pool"); } } - private int assign = SimpleAssignClass.x; - private int binary = BinaryExpClass.x + 1; - private int unary = -UnaryExpClass.x; - private int cast = (int)CastClass.x; - private int parens = (ParensClass.x); - private int cond = (CondClass.x == 1) ? 1 : 2; - private static int ifConstant; - private static int importStatic; + private int assignA = SimpleAssignClassA.x; + private int binaryA = BinaryExpClassA.x + 1; + private int unaryA = -UnaryExpClassA.x; + private int castA = (int)CastClassA.x; + private int parensA = (ParensClassA.x); + private int condA = (CondClassA.x == 1) ? 1 : 2; + private static int ifConstantA; + private static int importStaticA; static { - if (IfClass.x == 1) { - ifConstant = 1; + if (IfClassA.x == 1) { + ifConstantA = 1; } else { - ifConstant = 2; + ifConstantA = 2; } } static { - if (staticField == 1) { - importStatic = 1; + if (staticFieldA == 1) { + importStaticA = 1; } else { - importStatic = 2; + importStaticA = 2; + } + } + + // now as final constants + private static final int assignB = SimpleAssignClassB.x; + private static final int binaryB = BinaryExpClassB.x + 1; + private static final int unaryB = -UnaryExpClassB.x; + private static final int castB = (int)CastClassB.x; + private static final int parensB = (ParensClassB.x); + private static final int condB = (CondClassB.x == 1) ? 1 : 2; + private static final int ifConstantB; + private static final int importStaticB; + static { + if (IfClassB.x == 1) { + ifConstantB = 1; + } else { + ifConstantB = 2; + } + } + static { + if (staticFieldB == 1) { + importStaticB = 1; + } else { + importStaticB = 2; } } } -class SimpleAssignClass { +class SimpleAssignClassA { + public static final int x = 1; +} + +class SimpleAssignClassB { + public static final int x = 1; +} + +class BinaryExpClassA { public static final int x = 1; } -class BinaryExpClass { +class BinaryExpClassB { public static final int x = 1; } -class UnaryExpClass { +class UnaryExpClassA { + public static final int x = 1; +} + +class UnaryExpClassB { + public static final int x = 1; +} + +class CastClassA { public static final int x = 1; } -class CastClass { +class CastClassB { public static final int x = 1; } -class ParensClass { +class ParensClassA { + public static final int x = 1; +} + +class ParensClassB { public static final int x = 1; } -class CondClass { +class CondClassA { + public static final int x = 1; +} + +class CondClassB { public static final int x = 1; } -class IfClass { +class IfClassA { public static final int x = 1; } + +class IfClassB { + public static final int x = 1; +}
--- a/test/tools/javac/7153958/pkg/ClassToBeStaticallyImported.java Fri Sep 18 04:09:09 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package pkg; - -public class ClassToBeStaticallyImported { - public static final int staticField = 1; -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/7153958/pkg/ClassToBeStaticallyImportedA.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package pkg; + +public class ClassToBeStaticallyImportedA { + public static final int staticFieldA = 1; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/7153958/pkg/ClassToBeStaticallyImportedB.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package pkg; + +public class ClassToBeStaticallyImportedB { + public static final int staticFieldB = 1; +}
--- a/test/tools/javac/MethodParameters/ClassFileVisitor.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/javac/MethodParameters/ClassFileVisitor.java Wed Sep 30 16:42:58 2015 +0100 @@ -147,6 +147,7 @@ public int mAttrs; public int mNumParams; public boolean mSynthetic; + public boolean mIsLambda; public boolean mIsConstructor; public boolean mIsClinit; public boolean mIsBridge; @@ -165,6 +166,7 @@ mIsClinit = mName.equals("<clinit>"); prefix = cname + "." + mName + "() - "; mIsBridge = method.access_flags.is(AccessFlags.ACC_BRIDGE); + mIsLambda = mSynthetic && mName.startsWith("lambda$"); if (mIsClinit) { sb = new StringBuilder(); // Discard output @@ -225,7 +227,7 @@ // IMPL: Whether MethodParameters attributes will be generated // for some synthetics is unresolved. For now, assume no. - if (mSynthetic) { + if (mSynthetic && !mIsLambda) { warn(prefix + "synthetic has MethodParameter attribute"); } @@ -349,10 +351,12 @@ } else if (isEnum && mNumParams == 1 && index == 0 && mName.equals("valueOf")) { expect = "name"; allowMandated = true; - } else if (mIsBridge) { + } else if (mIsBridge || mIsLambda) { allowSynthetic = true; /* you can't expect an special name for bridges' parameters. - * The name of the original parameters are now copied. + * The name of the original parameters are now copied. Likewise + * for a method encoding the lambda expression, names are derived + * from source lambda's parameters and captured enclosing locals. */ expect = null; }
--- a/test/tools/javac/MethodParameters/LambdaTest.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/javac/MethodParameters/LambdaTest.java Wed Sep 30 16:42:58 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8006582 + * @bug 8006582 8037546 * @summary javac should generate method parameters correctly. * @build Tester * @compile -parameters LambdaTest.java @@ -31,8 +31,8 @@ */ /** - * Parameter names are not recorded for lambdas. This test verifies - * that there are no MethodParameters attribute for lambdas. + * Post https://bugs.openjdk.java.net/browse/JDK-8037546, this test verifies + * that MethodParameters attribute for lambdas are emitted properly. */ class LambdaTest {
--- a/test/tools/javac/MethodParameters/LambdaTest.out Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/javac/MethodParameters/LambdaTest.out Wed Sep 30 16:42:58 2015 +0100 @@ -1,7 +1,7 @@ class LambdaTest -- LambdaTest.<init>() LambdaTest.foo(i) -LambdaTest.lambda$static$1(arg0)/*synthetic*/ -LambdaTest.lambda$null$0(arg0, arg1)/*synthetic*/ +LambdaTest.lambda$static$1(x1/*synthetic*/)/*synthetic*/ +LambdaTest.lambda$null$0(final x1/*synthetic*/, x2/*synthetic*/)/*synthetic*/ static interface LambdaTest$I -- inner LambdaTest$I.m(x)
--- a/test/tools/javac/MethodParameters/ReflectionVisitor.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/javac/MethodParameters/ReflectionVisitor.java Wed Sep 30 16:42:58 2015 +0100 @@ -277,7 +277,7 @@ param = "final " + param; } sb.append(sep).append(param); - if (!m.isBridge() && !expect.equals(param)) { + if (!m.isBridge() && !m.getName().startsWith("lambda$") && !expect.equals(param)) { error(prefix + "param[" + i + "]='" + param + "' expected '" + expect + "'"); break;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T8049305/WrongStackframeGenerationTest1.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8049305 + * @summary Verification error due to a bad stackmap frame generated by javac + */ + +public class WrongStackframeGenerationTest1 { + public static void main(String[] args) {} + + static void foo(){ + while (true) { + int i = 0; + break; + } + switch (1) { + case 1: + int j = 0; + case 2: + bar(); + } + } + + static void bar() {} +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T8049305/WrongStackframeGenerationTest2.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8049305 + * @summary Verification error due to a bad stackmap frame generated by javac + */ + +public class WrongStackframeGenerationTest2 { + public static void main(String[] args) {} + + static void foo() { + int len; + for (;;) { + try { + len = 1; + break; + } catch (Exception e) { + } + } + + try { + if (len == -1) { + len = 0; + } + } finally { + } + } +}
--- a/test/tools/javac/annotations/6214965/T6214965.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/javac/annotations/6214965/T6214965.java Wed Sep 30 16:42:58 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,9 +23,10 @@ /** * @test - * @bug 6214965 6365854 + * @bug 6214965 6365854 8068639 * @summary Compiler crash on redefing nested annotation types * @compile CompilerAnnotationTest.java CompilerAnnotationTest2.java * @compile CompilerAnnotationTest2bad.java - * @compile/ref=T6214965.out -XDrawDiagnostics CompilerAnnotationTest2bad.java + * @compile/ref=T6214965.out -XDrawDiagnostics -Xlint:classfile CompilerAnnotationTest2bad.java + * @compile -Werror CompilerAnnotationTest2bad.java */
--- a/test/tools/javac/annotations/6365854/T6365854.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/javac/annotations/6365854/T6365854.java Wed Sep 30 16:42:58 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /** * @test - * @bug 6365854 + * @bug 6365854 8068639 * @summary javac crashes when compiling against an annotated class * @compile TestAnnotation.java TestCore.java * @clean test.annotation.TestAnnotation @@ -33,11 +33,11 @@ * * @compile TestAnnotation.java TestCore.java * @clean test.annotation.TestAnnotation - * @compile/ref=test1.out -XDrawDiagnostics T6365854.java + * @compile/ref=test1.out -XDrawDiagnostics -Xlint:classfile T6365854.java * @run main T6365854 - * @compile/ref=test2.out -XDrawDiagnostics evolve/TestAnnotation.java T6365854.java + * @compile/ref=test2.out -XDrawDiagnostics -Xlint:classfile evolve/TestAnnotation.java T6365854.java * @run main T6365854 - * @compile/ref=test2.out -XDrawDiagnostics T6365854.java + * @compile/ref=test2.out -XDrawDiagnostics -Xlint:classfile T6365854.java * @run main T6365854 */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/neg/AnonSubclass.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,13 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8028389 + * @summary javac should output a proper error message when given something + * like new Object(){} as annotation argument. + * + * @compile/fail/ref=AnonSubclass.out -XDrawDiagnostics AnonSubclass.java + */ + +@AnonSubclass(new Object(){}) +@interface AnonSubclass { + String value(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/neg/AnonSubclass.out Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,2 @@ +AnonSubclass.java:10:15: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.anonymous.class: java.lang.Object, java.lang.String) +1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/neg/pkg/AnonSubclassOnPkg.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg; + +@interface AnonSubclassOnPkg { + String value(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/neg/pkg/package-info.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,12 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8028389 + * @summary javac should output a proper error message when given something + * like new Object(){} as annotation argument. + * + * @compile AnonSubclassOnPkg.java + * @compile/fail/ref=package-info.out -XDrawDiagnostics package-info.java + */ + +@AnonSubclassOnPkg(new Object(){}) +package pkg;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/neg/pkg/package-info.out Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,2 @@ +package-info.java:11:20: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.anonymous.class: java.lang.Object, java.lang.String) +1 error
--- a/test/tools/javac/annotations/typeAnnotations/classfile/TestAnonInnerClasses.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/javac/annotations/typeAnnotations/classfile/TestAnonInnerClasses.java Wed Sep 30 16:42:58 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/classfiles/InnerClasses/T8068517.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** @test + * @bug 8068517 + * @summary Verify that nested enums have correct abstract flag in the InnerClasses attribute. + * @library /tools/javac/lib + * @build ToolBox T8068517 + * @run main T8068517 + */ + +import com.sun.tools.javac.util.Assert; +import java.io.File; +import java.nio.file.Files; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import javax.tools.JavaCompiler; +import javax.tools.ToolProvider; + +public class T8068517 { + + public static void main(String[] args) throws Exception { + new T8068517().run(); + } + + void run() throws Exception { + runTest("class A {\n" + + " enum AInner implements Runnable {\n" + + " A {\n" + + " public void run() {}\n" + + " };\n" + + " }\n" + + "}\n", + "class B {\n" + + " A.AInner a;\n" + + "}"); + runTest("class A {\n" + + " enum AInner implements Runnable {\n" + + " A {\n" + + " public void run() {}\n" + + " };\n" + + " }\n" + + " AInner aInner;\n" + + "}\n", + "class B {\n" + + " void test(A a) {;\n" + + " switch (a.aInner) {\n" + + " case A: break;\n" + + " }\n" + + " };\n" + + "}"); + runTest("class A {\n" + + " enum AInner implements Runnable {\n" + + " A {\n" + + " public void run() {}\n" + + " };\n" + + " }\n" + + " AInner aInner;\n" + + "}\n", + "class B {\n" + + " void test(A a) {;\n" + + " System.err.println(a.aInner.toString());\n" + + " };\n" + + "}"); + runTest("class A {\n" + + " enum AInner implements Runnable {\n" + + " A {\n" + + " public void run() {}\n" + + " };\n" + + " }\n" + + " AInner aInner() {\n" + + " return null;\n" + + " }\n" + + "}\n", + "class B {\n" + + " void test(A a) {;\n" + + " System.err.println(a.aInner().toString());\n" + + " };\n" + + "}"); + } + + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + int testN = 0; + + void runTest(String aJava, String bJava) throws Exception { + File testClasses = new File(System.getProperty("test.classes")); + File target1 = new File(testClasses, "T8068517s" + testN++); + doCompile(target1, aJava, bJava); + File target2 = new File(testClasses, "T8068517s" + testN++); + doCompile(target2, bJava, aJava); + + Assert.check(Arrays.equals(Files.readAllBytes(new File(target1, "B.class").toPath()), + Files.readAllBytes(new File(target2, "B.class").toPath()))); + } + + void doCompile(File target, String... sources) throws Exception { + target.mkdirs(); + List<String> options = Arrays.asList("-d", target.getAbsolutePath()); + List<ToolBox.JavaSource> files = Stream.of(sources) + .map(ToolBox.JavaSource::new) + .collect(Collectors.toList()); + compiler.getTask(null, null, null, options, null, files).call(); + } +}
--- a/test/tools/javac/diags/examples/MrefInferAndExplicitParams.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/javac/diags/examples/MrefInferAndExplicitParams.java Wed Sep 30 16:42:58 2015 +0100 @@ -8,7 +8,7 @@ * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). *
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/enum/8069181/T8069181.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8069181 + * @summary java.lang.AssertionError when compiling JDK 1.4 code in JDK 8 + * + * @compile -source 1.4 T8069181.java + */ +import java.util.Enumeration; +import java.util.Hashtable; +class T8069181 { + void test() { + Hashtable hTable = new Hashtable(); + hTable.put("hello", "value"); + for (Enumeration enum = hTable.keys();;){ + if(!enum.hasMoreElements()) + break; + enum.nextElement(); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/expression/DeeplyChainedNonPolyExpressionTest.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8079613 + * @summary Ensure that compiler ascertains a class of patently non-poly expressions as such + * @run main/timeout=10 DeeplyChainedNonPolyExpressionTest + */ + +public class DeeplyChainedNonPolyExpressionTest { + static class JSO { + + JSO put(String s, Object y) { + return null; + } + + JSO put(java.lang.String x, java.util.Collection<String> y) { + return null; + } + + JSO put(java.lang.String x, int y) { + return null; + } + + JSO put(java.lang.String x, long y) { + return null; + } + + JSO put(java.lang.String x, double y) { + return null; + } + + JSO put(java.lang.String x, java.util.Map<String, String> y) { + return null; + } + + JSO put(java.lang.String x, boolean y) { + return null; + } + } + + static class JSA { + + JSA put(Object o) { + return null; + } + + JSA put(int i, Object x) { + return null; + } + + JSA put(boolean x) { + return null; + } + + JSA put(int x) { + return null; + } + + JSA put(int i, int x) { + return null; + } + + JSA put(int x, boolean y) { + return null; + } + + JSA put(int i, long x) { + return null; + } + + JSA put(long x) { + return null; + } + + JSA put(java.util.Collection<String> x) { + return null; + } + + JSA put(int i, java.util.Collection<String> x) { + return null; + } + + JSA put(int i, java.util.Map<String, String> x) { + return null; + } + + JSA put(java.util.Map<String, String> x) { + return null; + } + + JSA put(int i, double x) { + return null; + } + + JSA put(double x) { + return null; + } + } + + public static void main(String [] args) { + } + public static void foo() { + new JSO() + .put("s", new JSA()) + .put("s", new JSA()) + .put("s", new JSO() + .put("s", new JSO() + .put("s", new JSA().put("s")) + .put("s", new JSA()) + .put("s", new JSO() + .put("s", new JSO() + .put("s", new JSA().put("s").put("s")) + .put("s", new JSA()) + .put("s", new JSO() + .put("s", new JSO() + .put("s", new JSA().put("s").put("s").put("s") + .put("s").put("s").put("s") + .put("s").put("s")) + .put("s", new JSA()) + .put("s", new JSO() + .put("s", new JSO() + .put("s", new JSA().put("s")) + .put("s", new JSA()) + ) + ) + ) + ) + ) + .put("s", new JSO() + .put("s", new JSA().put("s")) + .put("s", new JSA()) + .put("s", new JSO() + .put("s", new JSO() + .put("s", new JSA().put("s").put("s")) + .put("s", new JSA()) + .put("s", new JSO() + .put("s", new JSO() + .put("s", new JSA().put("s").put("s").put("s") + .put("s").put("s").put("s") + .put("s").put("s")) + .put("s", new JSA()) + .put("s", new JSO() + .put("s", new JSO() + .put("s", new JSA().put("s")) + .put("s", new JSA())) + ) + ) + ) + ) + ) + ) + ) + ) + ); + } +}
--- a/test/tools/javac/flow/LVTHarness.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/javac/flow/LVTHarness.java Wed Sep 30 16:42:58 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 7047734 8027660 8037937 8047719 8058708 + * @bug 7047734 8027660 8037937 8047719 8058708 8064857 * @summary The LVT is not generated correctly during some try/catch scenarios * javac crash while creating LVT entry for a local variable defined in * an inner block @@ -144,7 +144,7 @@ } void checkMethod(ConstantPool constantPool, Method method, AliveRanges ranges) - throws InvalidIndex, UnexpectedEntry { + throws InvalidIndex, UnexpectedEntry, ConstantPoolException { Code_attribute code = (Code_attribute) method.attributes.get(Attribute.Code); LocalVariableTable_attribute lvt = (LocalVariableTable_attribute) (code.attributes.get(Attribute.LocalVariableTable)); @@ -166,7 +166,7 @@ } if (i < infoFromRanges.size()) { - error(infoFromLVT, infoFromRanges); + error(infoFromLVT, infoFromRanges, method.getName(constantPool).toString()); } } @@ -202,9 +202,10 @@ return sb.toString(); } - protected void error(List<String> infoFromLVT, List<String> infoFromRanges) { + protected void error(List<String> infoFromLVT, List<String> infoFromRanges, String methodName) { nerrors++; System.err.printf("Error occurred while checking file: %s\n", jfo.getName()); + System.err.printf("at method: %s\n", methodName); System.err.println("The range info from the annotations is"); printStringListToErrOutput(infoFromRanges); System.err.println();
--- a/test/tools/javac/flow/tests/TestCaseFor.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/javac/flow/tests/TestCaseFor.java Wed Sep 30 16:42:58 2015 +0100 @@ -2,7 +2,7 @@ public class TestCaseFor { - @AliveRange(varName="o", bytecodeStart=10, bytecodeLength=8) + @AliveRange(varName="o", bytecodeStart=10, bytecodeLength=11) @AliveRange(varName="o", bytecodeStart=24, bytecodeLength=1) void m1(String[] args) { Object o; @@ -13,7 +13,7 @@ o = ""; } - @AliveRange(varName="o", bytecodeStart=10, bytecodeLength=8) + @AliveRange(varName="o", bytecodeStart=10, bytecodeLength=11) @AliveRange(varName="o", bytecodeStart=24, bytecodeLength=1) void m2(String[] args) { Object o;
--- a/test/tools/javac/flow/tests/TestCaseForEach.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/javac/flow/tests/TestCaseForEach.java Wed Sep 30 16:42:58 2015 +0100 @@ -2,7 +2,7 @@ public class TestCaseForEach { - @AliveRange(varName="o", bytecodeStart=25, bytecodeLength=8) + @AliveRange(varName="o", bytecodeStart=25, bytecodeLength=11) @AliveRange(varName="o", bytecodeStart=39, bytecodeLength=1) void m(String[] args) { Object o;
--- a/test/tools/javac/flow/tests/TestCaseIfElse.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/javac/flow/tests/TestCaseIfElse.java Wed Sep 30 16:42:58 2015 +0100 @@ -60,4 +60,19 @@ } return null; } + + @AliveRange(varName="i", bytecodeStart=6, bytecodeLength=2) + int m4(boolean flag) { + int i; + label: + { + if (flag) { + i = 1; + } else { + break label; + } + return i; + } + return -1; + } }
--- a/test/tools/javac/flow/tests/TestCaseSwitch.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/javac/flow/tests/TestCaseSwitch.java Wed Sep 30 16:42:58 2015 +0100 @@ -81,4 +81,26 @@ o = "finish"; } + @AliveRange(varName="oCache", bytecodeStart=30, bytecodeLength=6) + @AliveRange(varName="cache", bytecodeStart=41, bytecodeLength=3) + @AliveRange(varName="cache", bytecodeStart=54, bytecodeLength=2) + @AliveRange(varName="service", bytecodeStart=39, bytecodeLength=5) + Object m4(int i) { + Object cache; + switch (i) { + case 0: + Object oCache = null; + if (oCache != null) { + return oCache; + } + case 1: + Object service = null; + cache = null; + break; + default: + throw new AssertionError(""); + } + return cache; + } + }
--- a/test/tools/javac/flow/tests/TestCaseTry.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/javac/flow/tests/TestCaseTry.java Wed Sep 30 16:42:58 2015 +0100 @@ -17,7 +17,8 @@ } @AliveRange(varName="o", bytecodeStart=3, bytecodeLength=16) - @AliveRange(varName="o", bytecodeStart=23, bytecodeLength=23) + @AliveRange(varName="o", bytecodeStart=23, bytecodeLength=8) + @AliveRange(varName="o", bytecodeStart=35, bytecodeLength=11) void m1() { Object o; try { @@ -33,7 +34,8 @@ } @AliveRange(varName="o", bytecodeStart=3, bytecodeLength=16) - @AliveRange(varName="o", bytecodeStart=23, bytecodeLength=31) + @AliveRange(varName="o", bytecodeStart=23, bytecodeLength=16) + @AliveRange(varName="o", bytecodeStart=43, bytecodeLength=11) void m2() { Object o; try { @@ -51,7 +53,8 @@ } @AliveRange(varName="o", bytecodeStart=22, bytecodeLength=38) - @AliveRange(varName="o", bytecodeStart=103, bytecodeLength=8) + @AliveRange(varName="o", bytecodeStart=103, bytecodeLength=3) + @AliveRange(varName="o", bytecodeStart=110, bytecodeLength=1) void m3() { Object o; try (BufferedReader br =
--- a/test/tools/javac/flow/tests/TestCaseWhile.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/javac/flow/tests/TestCaseWhile.java Wed Sep 30 16:42:58 2015 +0100 @@ -2,7 +2,7 @@ public class TestCaseWhile { - @AliveRange(varName="o", bytecodeStart=9, bytecodeLength=5) + @AliveRange(varName="o", bytecodeStart=9, bytecodeLength=8) @AliveRange(varName="o", bytecodeStart=20, bytecodeLength=1) void m(String[] args) { Object o;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/8064803/T8064803.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8064803 + * @summary Javac erroneously uses instantiated signatures when merging abstract most-specific methods + */ +public class T8064803 { + interface ParentA<T> { + T process() throws Exception; + } + + interface ParentB<T> { + T process() throws Exception; + } + + interface Child<T> extends ParentA<T>, ParentB<T> { } + + static class ChildImpl<T> implements Child<T> { + @Override + public T process() { + return null; + } + } + + public static void main(String[] args) throws Exception { + Child<String> child = new ChildImpl<String>(); + child.process(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/inference/8055963/T8055963.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8055963 + * @summary Inference failure with nested invocation + * @compile T8055963.java + */ +class T8055963 { + + static class C<T> {} + + <T> T choose(T first, T second) { return null; } + + void test() { + C<String> cs = choose(new C<String>(), new C<>()); + } +}
--- a/test/tools/javac/lambda/8016177/T8016177g.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/javac/lambda/8016177/T8016177g.java Wed Sep 30 16:42:58 2015 +0100 @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 8016081 8016178 + * @bug 8016081 8016178 8069545 * @summary structural most specific and stuckness * @compile/fail/ref=T8016177g.out -XDrawDiagnostics T8016177g.java */
--- a/test/tools/javac/lambda/8016177/T8016177g.out Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/javac/lambda/8016177/T8016177g.out Wed Sep 30 16:42:58 2015 +0100 @@ -1,2 +1,3 @@ -T8016177g.java:35:20: compiler.err.prob.found.req: (compiler.misc.possible.loss.of.precision: double, int) -1 error +T8016177g.java:34:14: compiler.err.cant.apply.symbol: kindname.method, print, java.lang.String, Test.Person, kindname.class, Test, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inferred.do.not.conform.to.upper.bounds: Test.Person, java.lang.String,java.lang.Object)) +T8016177g.java:35:20: compiler.err.cant.apply.symbol: kindname.method, abs, int, java.lang.Double, kindname.class, Test, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.no.conforming.instance.exists: , R, int)) +2 errors
--- a/test/tools/javac/lambda/8023389/T8023389.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/javac/lambda/8023389/T8023389.java Wed Sep 30 16:42:58 2015 +0100 @@ -8,7 +8,7 @@ * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). *
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/8068399/T8068399.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @bug 8068399 + * @summary structural most specific and stuckness + */ + +import java.util.function.Function; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class T8068399 { + + public static class Spectrum { + public double[] getEnergy() { + return new double[0]; + } + } + + protected Spectrum spectrum; + + public static class Ref<T> { + + T value; + + public Ref() { + } + + public Ref(T value) { + this.value = value; + } + + public boolean isNull() { + return value == null; + } + + public T get() { + return value; + } + + public void set(T value) { + this.value = value; + } + } + + public static <T>T maxKey(Stream<T> stream, Function<T, Double> function) { + Ref<Double> max = new Ref<>(); + Ref<T> index = new Ref<>(); + stream.forEach(v -> { + Double value = function.apply(v); + + if (max.isNull() || value > max.get()) { + max.set(value); + index.set(v); + } + }); + + return index.get(); + } + + public static int interpolate(int x, int x0, int x1, int y0, int y1) { + return y0 + (x - x0) * (y1 - y0) / (x1 - x0); + } + + public static double interpolate(double x, double x0, double x1, double y0, double y1) { + return y0 + (x - x0) * (y1 - y0) / (x1 - x0); + } + + protected int getXByFrequency(double frequency) { + return (int) Math.round(interpolate(frequency, + getMinSpectrumCoord(), + getMaxSpectrumCoord(), + 0, getWidth())); + } + + private int getWidth() { + return 0; + } + + private double getMaxSpectrumCoord() { + return 0; + } + + private double getMinSpectrumCoord() { + return 0; + } + + void foo() { + int maxBpmIndex = 0; + int xcur = getXByFrequency(maxKey(IntStream.range(0, maxBpmIndex).boxed(), + i -> Math.abs(spectrum.getEnergy()[i]))); + } + + public static void main(String [] args) { + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/8068430/T8068430.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8068430 + * @summary structural most specific and stuckness + */ + +import java.util.HashMap; +import java.util.Map; + +public class T8068430 { + public static void main(String[] args) { + Map<Integer, String> mp = new HashMap<>(); + mp.put(1, "a"); + mp.put(2, "b"); + mp.put(3, "c"); + mp.put(4, "d"); + System.out.println(mp.entrySet().stream().reduce(0, + (i, e) -> i + e.getKey(), + (i1, i2) -> i1 + i2)); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/8071432/T8071432.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,50 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8071432 + * @summary structural most specific and stuckness + * @compile/fail/ref=T8071432.out -XDrawDiagnostics T8071432.java + */ + +import java.util.Arrays; +import java.util.Collection; + +class T8071432 { + + static class Point { + + private double x, y; + + public Point(double x, double y) { + this.x = x; + this.y = y; + } + + public double getX() { + return x; + } + + public double getY() { + return y; + } + + public double distance(Point p) { + return Math.sqrt((this.x - p.x) * (this.x - p.x) + + (this.y - p.y) * (this.y - p.y)); + } + + public double distance() { + return Math.sqrt(this.x * this.x + this.y * this.y); + } + + public String toString() { + return "(" + x + ":" + y + ")"; + } + } + + public static void main(String[] args) { + Collection<Point> c = Arrays.asList(new Point(1.0, 0.1)); + System.out.println("------- 1 ---------------"); + System.out.println(c.stream().reduce(0.0, + (s, p) -> s += p.distance(), (d1, d2) -> 0)); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/8071432/T8071432.out Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,3 @@ +T8071432.java:47:45: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: U, (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.Double))) +T8071432.java:47:27: compiler.err.cant.apply.symbol: kindname.method, println, java.lang.Object, <any>, kindname.class, java.io.PrintStream, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.no.conforming.assignment.exists: U, (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.Double)))) +2 errors
--- a/test/tools/javac/lambda/LambdaExprLeadsToMissingClassFilesTest.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/javac/lambda/LambdaExprLeadsToMissingClassFilesTest.java Wed Sep 30 16:42:58 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it
--- a/test/tools/javac/lambda/LocalVariableTable.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/javac/lambda/LocalVariableTable.java Wed Sep 30 16:42:58 2015 +0100 @@ -23,7 +23,7 @@ /* * @test - * @bug 8025998 8026749 + * @bug 8025998 8026749 8054220 8058227 * @summary Missing LV table in lambda bodies * @compile -g LocalVariableTable.java * @run main LocalVariableTable @@ -183,7 +183,7 @@ Run1 r = (a) -> { int x = a; }; } - @Expect({ "a", "x" }) + @Expect({ "a", "x", "v" }) static class Lambda_Args1_Local1_Captured1 { void m() { int v = 0; @@ -191,7 +191,7 @@ } } - @Expect({ "a1", "a2", "x1", "x2", "this" }) + @Expect({ "a1", "a2", "x1", "x2", "this", "v1", "v2" }) static class Lambda_Args2_Local2_Captured2_this { int v; void m() { @@ -204,7 +204,7 @@ } } - @Expect({ "e" }) + @Expect({ "e", "c" }) static class Lambda_Try_Catch { private static Runnable asUncheckedRunnable(Closeable c) { return () -> {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/linenumbers/NestedLineNumberTest.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8061778 + * @summary Wrong LineNumberTable for default constructors + */ + +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.ConstantPoolException; +import com.sun.tools.classfile.Method; +import com.sun.tools.classfile.Attribute; +import com.sun.tools.classfile.Code_attribute; +import com.sun.tools.classfile.LineNumberTable_attribute; +import com.sun.tools.classfile.LineNumberTable_attribute.Entry; + +import java.io.IOException; + +public class NestedLineNumberTest { + + public static void main(String[] args) throws Exception { + Entry[] lines = findEntries(); + if (lines == null || lines.length != 1) { + int found = lines == null ? 0 : lines.length; + error(String.format("LineNumberTable contains wrong number of entries - expected %d, found %d", 1, found)); + } + + int line = lines[0].line_number; + if (line != 78) { + error(String.format("LineNumberTable contains wrong line number - expected %d, found %d", 78, line)); + } + } + + static Entry[] findEntries() throws IOException, ConstantPoolException { + ClassFile self = ClassFile.read(NestedLineNumberTest.Test.class.getResourceAsStream("NestedLineNumberTest$Test.class")); + for (Method m : self.methods) { + if ("<init>".equals(m.getName(self.constant_pool))) { + Code_attribute code_attribute = (Code_attribute)m.attributes.get(Attribute.Code); + for (Attribute at : code_attribute.attributes) { + if (Attribute.LineNumberTable.equals(at.getName(self.constant_pool))) { + return ((LineNumberTable_attribute)at).line_number_table; + } + } + } + } + return null; + } + + static void error(String msg) { + throw new AssertionError(msg); + } + + // The default constructor in this class should get only one LineNumberTable entry, + // pointing to the first line of the declaration of class Test. + static class Test { + static class Empty { } + } +}
--- a/test/tools/javac/resolve/tests/PrimitiveVsReferenceSamePhase.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/javac/resolve/tests/PrimitiveVsReferenceSamePhase.java Wed Sep 30 16:42:58 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/scope/RemoveSymbolTest.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8080842 + * @summary Ensure Scope impl can cope with remove() when a field and method share the name. + * @run main RemoveSymbolTest + */ + +import java.util.Iterator; +import java.util.LinkedList; + +public class RemoveSymbolTest<W> implements Iterable<W> { + static class Widget { + private String name; + Widget(String s) { name = s; } + @Override public String toString() { return name; } + } + + private LinkedList<W> data; + // Instantiate an Iterable instance using a Lambda expression. + // Causes ClassFormatError if a local variable of type Widget is named after one of the methods. + private final Iterable<W> myIterator1 = () -> new Iterator<W>() { + private W hasNext = null; + private int index = 0; + @Override public boolean hasNext() { return index < data.size(); } + @Override public W next() { return data.get(index++); } + }; + + // Instantiate an Iterable instance using an anonymous class. + // Always works fine regardless of the name of the local variable. + private final Iterable<W> myIterator2 = + new Iterable<W>() { + @Override + public Iterator<W> iterator() { + return new Iterator<W>() { + private W hasNext = null; + private int index = 0; + @Override public boolean hasNext() { return index < data.size(); } + @Override public W next() { return data.get(index++); } + }; + } + }; + public RemoveSymbolTest() { data = new LinkedList<>(); } + public void add(W e) { data.add(e); } + @Override public String toString() { return data.toString(); } + @Override public Iterator<W> iterator() { return myIterator1.iterator(); } + public static void main(String[] args) { + RemoveSymbolTest<Widget> widgets = new RemoveSymbolTest<>(); + widgets.add(new Widget("W1")); + widgets.add(new Widget("W2")); + widgets.add(new Widget("W3")); + System.out.println(".foreach() call: "); + widgets.forEach(w -> System.out.println(w + " ")); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/scope/RemoveSymbolUnitTest.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8080842 + * @summary Ensure Scope impl can cope with remove() when a field and method share the name. + */ + +import com.sun.tools.javac.util.*; +import com.sun.tools.javac.code.*; +import com.sun.tools.javac.code.Scope.*; +import com.sun.tools.javac.code.Symbol.*; +import com.sun.tools.javac.file.JavacFileManager; + +public class RemoveSymbolUnitTest { + + Context context; + Names names; + Symtab symtab; + + public static void main(String... args) throws Exception { + new RemoveSymbolUnitTest().run(); + } + + public void run() { + context = new Context(); + JavacFileManager.preRegister(context); // required by ClassReader which is required by Symtab + names = Names.instance(context); + symtab = Symtab.instance(context); + + Name hasNext = names.fromString("hasNext"); + ClassSymbol clazz = new ClassSymbol(0, + names.fromString("X"), + Type.noType, + symtab.unnamedPackage); + + VarSymbol v = new VarSymbol(0, hasNext, Type.noType, clazz); + MethodSymbol m = new MethodSymbol(0, hasNext, Type.noType, clazz); + + // Try enter and remove in different shuffled combinations. + // working with fresh scope each time. + Scope cs = new Scope(clazz); + cs.enter(v); + cs.enter(m); + cs.remove(v); + Symbol s = cs.lookup(hasNext).sym; + if (s != m) + throw new AssertionError("Wrong symbol"); + + cs = new Scope(clazz); + cs.enter(m); + cs.enter(v); + cs.remove(v); + s = cs.lookup(hasNext).sym; + if (s != m) + throw new AssertionError("Wrong symbol"); + + cs = new Scope(clazz); + cs.enter(v); + cs.enter(m); + cs.remove(m); + s = cs.lookup(hasNext).sym; + if (s != v) + throw new AssertionError("Wrong symbol"); + + cs = new Scope(clazz); + cs.enter(m); + cs.enter(v); + cs.remove(m); + s = cs.lookup(hasNext).sym; + if (s != v) + throw new AssertionError("Wrong symbol"); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/types/ScopeListenerTest.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8039262 + * @summary Ensure that using Types.membersClosure does not increase the number of listeners on the + * class's members Scope. + */ + +import com.sun.tools.javac.code.Scope; +import com.sun.tools.javac.code.Symbol; +import com.sun.tools.javac.code.Symtab; +import com.sun.tools.javac.code.Types; +import com.sun.tools.javac.file.JavacFileManager; +import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.Names; +import java.lang.reflect.Field; +import java.util.Collection; + +public class ScopeListenerTest { + + public static void main(String[] args) throws Exception { + new ScopeListenerTest().run(); + } + + void run() throws Exception { + Context context = new Context(); + JavacFileManager.preRegister(context); + Types types = Types.instance(context); + Symtab syms = Symtab.instance(context); + Names names = Names.instance(context); + types.membersClosure(syms.stringType, true); + types.membersClosure(syms.stringType, false); + + Field listenersField = Scope.class.getDeclaredField("listeners"); + + listenersField.setAccessible(true); + + int listenerCount = + ((Collection) listenersField.get(syms.stringType.tsym.members())).size(); + + for (int i = 0; i < 100; i++) { + types.membersClosure(syms.stringType, true); + types.membersClosure(syms.stringType, false); + } + + int newListenerCount + = ((Collection) listenersField.get(syms.stringType.tsym.members())).size(); + + if (listenerCount != newListenerCount) { + throw new AssertionError("Orig listener count: " + listenerCount + + "; new listener count: " + newListenerCount); + } + + for (Symbol s : types.membersClosure(syms.stringType, true).getElements()) + ; + for (Symbol s : types.membersClosure(syms.stringType, false).getElementsByName(names.fromString("substring"))) + ; + } + +}
--- a/test/tools/javac/varargs/T8049075/VarargsAndWildcardParameterizedTypeTest.java Fri Sep 18 04:09:09 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8049075 - * @summary javac, wildcards and generic vararg method invocation not accepted - * @compile VarargsAndWildcardParameterizedTypeTest.java - */ - -class VarargsAndWildcardParameterizedTypeTest { - interface I<T> { - String m(T... t); - } - - void m() { - I<? super Integer> i = null; - i.m(Integer.valueOf(1), Integer.valueOf(1)); - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/access/OtherPackage.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * Auxiliary file for VarargsInferredPrivateType + */ + +package otherpackage; + +public class OtherPackage { + public static Private getPrivate() { + return new Private(); + } + + private static class Private {} +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/access/VarargsAndWildcardParameterizedTypeTest.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8049075 + * @summary javac, wildcards and generic vararg method invocation not accepted + * @compile VarargsAndWildcardParameterizedTypeTest.java + * @compile -source 8 VarargsAndWildcardParameterizedTypeTest.java + * @compile -source 7 VarargsAndWildcardParameterizedTypeTest.java + */ + +class VarargsAndWildcardParameterizedTypeTest { + interface I<T> { + String m(T... t); + } + + void m() { + I<? super Integer> i = null; + i.m(Integer.valueOf(1), Integer.valueOf(1)); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/access/VarargsAndWildcardParameterizedTypeTest2.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8075520 + * @summary Varargs access check mishandles capture variables + * @compile VarargsAndWildcardParameterizedTypeTest2.java + * @compile -source 8 VarargsAndWildcardParameterizedTypeTest2.java + * @compile -source 7 VarargsAndWildcardParameterizedTypeTest2.java + */ + +class VarargsAndWildcardParameterizedTypeTest2 { + interface I { + <T> void m(T... t); + } + + interface Box<T> { + T get(); + } + + void m(I i, Box<? extends Number> b) { + i.m(b.get()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/access/VarargsAndWildcardParameterizedTypeTest3.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8075520 + * @summary Varargs access check mishandles capture variables + * @compile VarargsAndWildcardParameterizedTypeTest3.java + * @compile -source 8 VarargsAndWildcardParameterizedTypeTest3.java + * @compile -source 7 VarargsAndWildcardParameterizedTypeTest3.java + */ + +class VarargsAndWildcardParameterizedTypeTest2 { + interface I { + <T> void m(Box<? extends T> iter, T... t); + } + + interface Box<T> {} + + void m(I i, Box<? extends Number> b) { + i.m(b); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/access/VarargsAndWildcardParameterizedTypeTest4.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8075520 + * @summary Varargs access check mishandles capture variables + * @compile VarargsAndWildcardParameterizedTypeTest4.java + * @compile -source 8 VarargsAndWildcardParameterizedTypeTest4.java + * @compile -source 7 VarargsAndWildcardParameterizedTypeTest4.java + */ + +class VarargsAndWildcardParameterizedTypeTest2 { + interface I { + <T> void m(Box<T> iter, T... t); + } + + interface Box<T> {} + + void m(I i, Box<? extends Number> b) { + i.m(b); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/access/VarargsInferredPrivateType-source7.out Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,4 @@ +VarargsInferredPrivateType.java:16:10: compiler.err.cant.apply.symbol: kindname.method, m, T[], otherpackage.OtherPackage.Private, kindname.interface, VarargsInferredPrivateType.I, (compiler.misc.inaccessible.varargs.type: otherpackage.OtherPackage.Private, kindname.class, VarargsInferredPrivateType) +- compiler.note.unchecked.filename: VarargsInferredPrivateType.java +- compiler.note.unchecked.recompile +1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/access/VarargsInferredPrivateType.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,18 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8077786 + * @summary Check varargs access against inferred signature + * @compile/fail/ref=VarargsInferredPrivateType.out -nowarn -XDrawDiagnostics VarargsInferredPrivateType.java OtherPackage.java + * @compile/fail/ref=VarargsInferredPrivateType.out -source 8 -nowarn -XDrawDiagnostics VarargsInferredPrivateType.java OtherPackage.java + * @compile/fail/ref=VarargsInferredPrivateType-source7.out -source 7 -nowarn -XDrawDiagnostics VarargsInferredPrivateType.java OtherPackage.java + */ + +class VarargsInferredPrivateType { + interface I { + <T> void m(T... t); + } + + void m(I i) { + i.m(otherpackage.OtherPackage.getPrivate()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/access/VarargsInferredPrivateType.out Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,4 @@ +VarargsInferredPrivateType.java:16:12: compiler.err.prob.found.req: (compiler.misc.inaccessible.varargs.type: otherpackage.OtherPackage.Private, kindname.class, VarargsInferredPrivateType) +- compiler.note.unchecked.filename: VarargsInferredPrivateType.java +- compiler.note.unchecked.recompile +1 error
--- a/test/tools/jdeps/APIDeps.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/jdeps/APIDeps.java Wed Sep 30 16:42:58 2015 +0100 @@ -90,8 +90,9 @@ new String[] {"-classpath", testDir.getPath(), "-verbose:class", "-filter:none", "-P"}); test(new File(mDir, "Gee.class"), new String[] {"g.G", "sun.misc.Lock", "com.sun.tools.classfile.ClassFile", - "com.sun.management.ThreadMXBean", "com.sun.source.tree.BinaryTree"}, - new String[] {testDirBasename, "JDK internal API", "compact3", ""}, + "com.sun.management.ThreadMXBean", "com.sun.source.tree.BinaryTree", + "org.w3c.dom.css.CSSValue"}, + new String[] {testDirBasename, "JDK internal API", "compact2", "compact3", ""}, new String[] {"-classpath", testDir.getPath(), "-verbose", "-P"}); // -jdkinternals
--- a/test/tools/jdeps/Basic.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/jdeps/Basic.java Wed Sep 30 16:42:58 2015 +0100 @@ -23,9 +23,9 @@ /* * @test - * @bug 8003562 8005428 8015912 8027481 8048063 + * @bug 8003562 8005428 8015912 8027481 8048063 8068937 * @summary Basic tests for jdeps tool - * @build Test p.Foo p.Bar javax.activity.NotCompactProfile + * @build Test p.Foo p.Bar p.C p.SubClass q.Gee javax.activity.NotCompactProfile * @run main Basic */ @@ -111,6 +111,19 @@ new String[] {"compact1"}, new String[] {"-verbose:package", "-e", "java\\.lang\\..*"}); + // parse p.C, p.SubClass and q.* + // p.SubClass have no dependency other than p.C + // q.Gee depends on p.SubClass that should be found + test(testDir, + new String[] {"java.lang", "p"}, + new String[] {"compact1", testDir.getName()}, + new String[] {"-include", "p.C|p.SubClass|q\\..*"}); + test(testDir, + new String[] {"java.lang", "p"}, + new String[] {"compact1", testDir.getName()}, + new String[] {"-classpath", testDir.getPath(), "-include", "p.C|p.SubClass|q\\..*"}); + + // test -classpath and -include options test(null, new String[] {"java.lang", "java.util", "java.lang.management",
--- a/test/tools/jdeps/m/Gee.java Fri Sep 18 04:09:09 2015 +0100 +++ b/test/tools/jdeps/m/Gee.java Wed Sep 30 16:42:58 2015 +0100 @@ -29,4 +29,5 @@ public com.sun.tools.classfile.ClassFile cf; // @jdk.Exported(false) public com.sun.source.tree.BinaryTree tree; // @jdk.Exported public com.sun.management.ThreadMXBean mxbean; // @jdk.Exported on package-info + public org.w3c.dom.css.CSSValue value; // special case }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/jdeps/p/C.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package p; + +public class C { + public String name() { + return "C"; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/jdeps/p/SubClass.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package p; + +// SubClass only references types in package p +public class SubClass extends C { +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/jdeps/q/Gee.java Wed Sep 30 16:42:58 2015 +0100 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package q; + +public class Gee extends p.SubClass { +}