Thu, 29 May 2014 13:46:36 -0700
Merge
.hgtags | file | annotate | diff | comparison | revisions | |
test/tools/javac/lambda/ErroneousLambdaExpr.java | file | annotate | diff | comparison | revisions | |
test/tools/javac/lambda/ErroneousLambdaExpr.out | file | annotate | diff | comparison | revisions | |
test/tools/javac/lambda/TargetType16.out | file | annotate | diff | comparison | revisions |
1.1 --- a/.hgtags Mon May 19 22:00:11 2014 -0700 1.2 +++ b/.hgtags Thu May 29 13:46:36 2014 -0700 1.3 @@ -245,7 +245,9 @@ 1.4 afe63d41c699e0e2ee910ef20c41b60603c852a1 jdk8-b121 1.5 232b9cf6303aaf451c7000c5f93dfea842e9e9ae jdk8-b122 1.6 a345cf28faca8cc49a28241a0a197fd520d25beb jdk8-b123 1.7 +d5aab8300d3b51e8043ab5fe5832ef6c6cbb5552 jdk8u20-b00 1.8 436176151e85455e74cd1441a2ba96e791c56785 jdk8-b124 1.9 +79dc4b992c0a385c1364592801781b747b85c6ca jdk8u20-b01 1.10 436176151e85455e74cd1441a2ba96e791c56785 jdk8-b125 1.11 ba24b63043626003929927f091e8b84190f39261 jdk8-b126 1.12 bb69217ed81202b1a490dc7150dc7cd073689341 jdk8-b127 1.13 @@ -277,4 +279,21 @@ 1.14 7803caf52e4b12f11e552565f55ef65aeb2be6a5 jdk8u11-b07 1.15 a47aa3203c0210def786ab5ee685e97d07e8bf77 jdk8u11-b08 1.16 e973a591a2182c0bdbdd9545ab13f83325acf1e6 jdk8u11-b09 1.17 +51cade4632608a6c0b8da33f420bd546aecf6faf jdk8u11-b10 1.18 +26b33a6ea08810853af37e81c9b435465b289c98 jdk8u20-b02 1.19 +a07271bca831cf1bab35a2ffbcebd8e060b2734b jdk8u20-b03 1.20 +613c1d9930c9f650e3fc6926215931a85b679c66 jdk8u20-b04 1.21 +27c08b9195d17f8e13cb90f6a7c9b6877062464f jdk8u20-b05 1.22 +9d81ae1c417a4748f58921c1f8def7f3c401cecd jdk8-b130 1.23 +196ab3dcbd28fac1578590684a337f1c7cf505c9 jdk8-b131 1.24 +c8a87a58eb3efdd64055566b502c9d4a72ca0996 jdk8-b132 1.25 +c6d0108aca9f8f45b9cddeb6e483d464509e0127 jdk8u20-b06 1.26 +1a57c569cb811a897691e42049eca33da8f8d761 jdk8u20-b07 1.27 +0f821eb7e92b242c878dca68ef63f9626643ee8f jdk8u20-b08 1.28 +aa0cb3af23d376e012a142b0531c4f42032fdacf jdk8u20-b09 1.29 +a0d9c18a1041c4217db9cda1817f0e348f1be885 jdk8u20-b10 1.30 +7ad480b982bf95b8a7290c8769b2698f6aacaf6b jdk8u20-b11 1.31 +e101a12a45a777268a2e729803499a7514255e5b jdk8u20-b12 1.32 +b5c2375893e2bca1883e5571bd911b6f0b533bf4 jdk8u20-b13 1.33 +5d39c29950f4d65e737f99e468427ae6454fa586 jdk8u20-b14 1.34 f491f1581f196950c2cb858508dd06601968c417 jdk8u25-b00
2.1 --- a/src/share/classes/com/sun/tools/classfile/Attribute.java Mon May 19 22:00:11 2014 -0700 2.2 +++ b/src/share/classes/com/sun/tools/classfile/Attribute.java Thu May 29 13:46:36 2014 -0700 2.3 @@ -71,10 +71,6 @@ 2.4 // defer init of standardAttributeClasses until after options set up 2.5 } 2.6 2.7 - public void setCompat(boolean compat) { 2.8 - this.compat = compat; 2.9 - } 2.10 - 2.11 public Attribute createAttribute(ClassReader cr, int name_index, byte[] data) 2.12 throws IOException { 2.13 if (standardAttributes == null) { 2.14 @@ -109,9 +105,10 @@ 2.15 protected void init() { 2.16 standardAttributes = new HashMap<String,Class<? extends Attribute>>(); 2.17 standardAttributes.put(AnnotationDefault, AnnotationDefault_attribute.class); 2.18 - standardAttributes.put(BootstrapMethods, BootstrapMethods_attribute.class); 2.19 + standardAttributes.put(BootstrapMethods, BootstrapMethods_attribute.class); 2.20 standardAttributes.put(CharacterRangeTable, CharacterRangeTable_attribute.class); 2.21 standardAttributes.put(Code, Code_attribute.class); 2.22 + standardAttributes.put(CompilationID, CompilationID_attribute.class); 2.23 standardAttributes.put(ConstantValue, ConstantValue_attribute.class); 2.24 standardAttributes.put(Deprecated, Deprecated_attribute.class); 2.25 standardAttributes.put(EnclosingMethod, EnclosingMethod_attribute.class); 2.26 @@ -120,29 +117,23 @@ 2.27 standardAttributes.put(LineNumberTable, LineNumberTable_attribute.class); 2.28 standardAttributes.put(LocalVariableTable, LocalVariableTable_attribute.class); 2.29 standardAttributes.put(LocalVariableTypeTable, LocalVariableTypeTable_attribute.class); 2.30 - 2.31 - if (!compat) { // old javap does not recognize recent attributes 2.32 - standardAttributes.put(MethodParameters, MethodParameters_attribute.class); 2.33 - standardAttributes.put(CompilationID, CompilationID_attribute.class); 2.34 - standardAttributes.put(RuntimeInvisibleAnnotations, RuntimeInvisibleAnnotations_attribute.class); 2.35 - standardAttributes.put(RuntimeInvisibleParameterAnnotations, RuntimeInvisibleParameterAnnotations_attribute.class); 2.36 - standardAttributes.put(RuntimeVisibleAnnotations, RuntimeVisibleAnnotations_attribute.class); 2.37 - standardAttributes.put(RuntimeVisibleParameterAnnotations, RuntimeVisibleParameterAnnotations_attribute.class); 2.38 - standardAttributes.put(RuntimeVisibleTypeAnnotations, RuntimeVisibleTypeAnnotations_attribute.class); 2.39 - standardAttributes.put(RuntimeInvisibleTypeAnnotations, RuntimeInvisibleTypeAnnotations_attribute.class); 2.40 - standardAttributes.put(Signature, Signature_attribute.class); 2.41 - standardAttributes.put(SourceID, SourceID_attribute.class); 2.42 - } 2.43 - 2.44 + standardAttributes.put(MethodParameters, MethodParameters_attribute.class); 2.45 + standardAttributes.put(RuntimeInvisibleAnnotations, RuntimeInvisibleAnnotations_attribute.class); 2.46 + standardAttributes.put(RuntimeInvisibleParameterAnnotations, RuntimeInvisibleParameterAnnotations_attribute.class); 2.47 + standardAttributes.put(RuntimeVisibleAnnotations, RuntimeVisibleAnnotations_attribute.class); 2.48 + standardAttributes.put(RuntimeVisibleParameterAnnotations, RuntimeVisibleParameterAnnotations_attribute.class); 2.49 + standardAttributes.put(RuntimeVisibleTypeAnnotations, RuntimeVisibleTypeAnnotations_attribute.class); 2.50 + standardAttributes.put(RuntimeInvisibleTypeAnnotations, RuntimeInvisibleTypeAnnotations_attribute.class); 2.51 + standardAttributes.put(Signature, Signature_attribute.class); 2.52 standardAttributes.put(SourceDebugExtension, SourceDebugExtension_attribute.class); 2.53 standardAttributes.put(SourceFile, SourceFile_attribute.class); 2.54 + standardAttributes.put(SourceID, SourceID_attribute.class); 2.55 standardAttributes.put(StackMap, StackMap_attribute.class); 2.56 standardAttributes.put(StackMapTable, StackMapTable_attribute.class); 2.57 standardAttributes.put(Synthetic, Synthetic_attribute.class); 2.58 } 2.59 2.60 private Map<String,Class<? extends Attribute>> standardAttributes; 2.61 - private boolean compat; // don't support recent attrs in compatibility mode 2.62 } 2.63 2.64 public static Attribute read(ClassReader cr) throws IOException {
3.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_ja.properties Mon May 19 22:00:11 2014 -0700 3.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_ja.properties Thu May 29 13:46:36 2014 -0700 3.3 @@ -29,7 +29,7 @@ 3.4 doclet.Href_Enum_Title={0}\u5185\u306E\u5217\u6319\u578B 3.5 doclet.Href_Type_Param_Title={0}\u5185\u306E\u578B\u30D1\u30E9\u30E1\u30FC\u30BF 3.6 doclet.Href_Class_Or_Interface_Title={0}\u5185\u306E\u30AF\u30E9\u30B9\u307E\u305F\u306F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9 3.7 -doclet.Summary=\u6982\u8981: 3.8 +doclet.Summary=\u30B5\u30DE\u30EA\u30FC: 3.9 doclet.Detail=\u8A73\u7D30: 3.10 doclet.navNested=\u30CD\u30B9\u30C8 3.11 doclet.navAnnotationTypeOptionalMember=\u30AA\u30D7\u30B7\u30E7\u30F3 3.12 @@ -117,18 +117,18 @@ 3.13 doclet.Window_Source_title=\u30BD\u30FC\u30B9\u30FB\u30B3\u30FC\u30C9 3.14 doclet.Window_Help_title=API\u30D8\u30EB\u30D7 3.15 doclet.Help_line_1=API\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u69CB\u6210 3.16 -doclet.Help_line_2=\u3053\u306EAPI(Application Programming Interface)\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306B\u306F\u3001\u6B21\u306B\u8AAC\u660E\u3059\u308B\u30CA\u30D3\u30B2\u30FC\u30B7\u30E7\u30F3\u30FB\u30D0\u30FC\u306B\u3042\u308B\u9805\u76EE\u306B\u5BFE\u5FDC\u3059\u308B\u30DA\u30FC\u30B8\u304C\u542B\u307E\u308C\u307E\u3059\u3002 3.17 -doclet.Help_line_3={0}\u30DA\u30FC\u30B8\u306FAPI\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u30D5\u30ED\u30F3\u30C8\u30FB\u30DA\u30FC\u30B8\u3067\u3001\u5404\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u6982\u8981\u3092\u542B\u3080\u5168\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u30EA\u30B9\u30C8\u304C\u8868\u793A\u3055\u308C\u307E\u3059\u3002\u4E00\u9023\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u6982\u8981\u8AAC\u660E\u3082\u8868\u793A\u3055\u308C\u307E\u3059\u3002 3.18 -doclet.Help_line_4=\u5404\u30D1\u30C3\u30B1\u30FC\u30B8\u306B\u306F\u3001\u305D\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u30AF\u30E9\u30B9\u304A\u3088\u3073\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306E\u30EA\u30B9\u30C8\u3068\u3001\u305D\u308C\u305E\u308C\u306E\u6982\u8981\u3092\u542B\u3080\u30DA\u30FC\u30B8\u304C\u3042\u308A\u307E\u3059\u3002\u3053\u306E\u30DA\u30FC\u30B8\u306F6\u3064\u306E\u30AB\u30C6\u30B4\u30EA\u3067\u69CB\u6210\u3055\u308C\u307E\u3059\u3002 3.19 +doclet.Help_line_2=\u3053\u306EAPI (Application Programming Interface)\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306B\u306F\u3001\u6B21\u306B\u8AAC\u660E\u3059\u308B\u30CA\u30D3\u30B2\u30FC\u30B7\u30E7\u30F3\u30FB\u30D0\u30FC\u306B\u3042\u308B\u9805\u76EE\u306B\u5BFE\u5FDC\u3059\u308B\u30DA\u30FC\u30B8\u304C\u542B\u307E\u308C\u307E\u3059\u3002 3.20 +doclet.Help_line_3={0}\u30DA\u30FC\u30B8\u306FAPI\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u30D5\u30ED\u30F3\u30C8\u30FB\u30DA\u30FC\u30B8\u3067\u3001\u5404\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u30B5\u30DE\u30EA\u30FC\u3092\u542B\u3080\u5168\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u30EA\u30B9\u30C8\u304C\u8868\u793A\u3055\u308C\u307E\u3059\u3002\u4E00\u9023\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u5168\u4F53\u7684\u306A\u8AAC\u660E\u3082\u8868\u793A\u3055\u308C\u307E\u3059\u3002 3.21 +doclet.Help_line_4=\u5404\u30D1\u30C3\u30B1\u30FC\u30B8\u306B\u306F\u3001\u305D\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u30AF\u30E9\u30B9\u304A\u3088\u3073\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306E\u30EA\u30B9\u30C8\u3068\u3001\u305D\u308C\u305E\u308C\u306E\u30B5\u30DE\u30EA\u30FC\u3092\u542B\u3080\u30DA\u30FC\u30B8\u304C\u3042\u308A\u307E\u3059\u3002\u3053\u306E\u30DA\u30FC\u30B8\u306F6\u3064\u306E\u30AB\u30C6\u30B4\u30EA\u3067\u69CB\u6210\u3055\u308C\u307E\u3059\u3002 3.22 doclet.Help_line_5=\u30AF\u30E9\u30B9\u307E\u305F\u306F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9 3.23 -doclet.Help_line_6=\u5404\u30AF\u30E9\u30B9\u3001\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3001\u30CD\u30B9\u30C8\u3055\u308C\u305F\u30AF\u30E9\u30B9\u304A\u3088\u3073\u30CD\u30B9\u30C8\u3055\u308C\u305F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306B\u306F\u500B\u5225\u306E\u30DA\u30FC\u30B8\u304C\u3042\u308A\u307E\u3059\u3002\u5404\u30DA\u30FC\u30B8\u306B\u306F\u6B21\u306E\u3088\u3046\u306B\u3001\u30AF\u30E9\u30B9\u307E\u305F\u306F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306E\u8AAC\u660E\u3068\u3001\u6982\u8981\u8868\u304A\u3088\u3073\u30E1\u30F3\u30D0\u30FC\u306E\u8A73\u7D30\u8AAC\u660E\u304C\u542B\u307E\u308C\u307E\u3059\u3002 3.24 +doclet.Help_line_6=\u5404\u30AF\u30E9\u30B9\u3001\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3001\u30CD\u30B9\u30C8\u3055\u308C\u305F\u30AF\u30E9\u30B9\u304A\u3088\u3073\u30CD\u30B9\u30C8\u3055\u308C\u305F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306B\u306F\u500B\u5225\u306E\u30DA\u30FC\u30B8\u304C\u3042\u308A\u307E\u3059\u3002\u5404\u30DA\u30FC\u30B8\u306B\u306F\u6B21\u306E\u3088\u3046\u306B\u3001\u30AF\u30E9\u30B9\u307E\u305F\u306F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306E\u8AAC\u660E\u3068\u3001\u30B5\u30DE\u30EA\u30FC\u8868\u304A\u3088\u3073\u30E1\u30F3\u30D0\u30FC\u306E\u8A73\u7D30\u8AAC\u660E\u304C\u542B\u307E\u308C\u307E\u3059\u3002 3.25 doclet.Help_line_7=\u30AF\u30E9\u30B9\u968E\u5C64\u8868\u793A 3.26 doclet.Help_line_8=\u76F4\u7CFB\u306E\u30B5\u30D6\u30AF\u30E9\u30B9 3.27 doclet.Help_line_9=\u65E2\u77E5\u306E\u30B5\u30D6\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306E\u30EA\u30B9\u30C8 3.28 doclet.Help_line_10=\u65E2\u77E5\u306E\u5B9F\u88C5\u30AF\u30E9\u30B9\u306E\u30EA\u30B9\u30C8 3.29 doclet.Help_line_11=\u30AF\u30E9\u30B9\u307E\u305F\u306F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306E\u5BA3\u8A00 3.30 doclet.Help_line_12=\u30AF\u30E9\u30B9\u307E\u305F\u306F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306E\u8AAC\u660E 3.31 -doclet.Help_line_13=\u5404\u6982\u8981\u30A8\u30F3\u30C8\u30EA\u306B\u306F\u3001\u305D\u306E\u9805\u76EE\u306E\u8A73\u7D30\u306A\u8AAC\u660E\u306E\u4E2D\u304B\u30891\u884C\u76EE\u306E\u6587\u304C\u8868\u793A\u3055\u308C\u307E\u3059\u3002\u8A73\u7D30\u306A\u8AAC\u660E\u306F\u30BD\u30FC\u30B9\u30FB\u30B3\u30FC\u30C9\u306B\u73FE\u308C\u308B\u9806\u306B\u4E26\u3079\u3089\u308C\u307E\u3059\u304C\u3001\u6982\u8981\u30A8\u30F3\u30C8\u30EA\u306F\u30A2\u30EB\u30D5\u30A1\u30D9\u30C3\u30C8\u9806\u306B\u4E26\u3079\u3089\u308C\u307E\u3059\u3002\u3053\u308C\u306B\u3088\u3063\u3066\u3001\u30D7\u30ED\u30B0\u30E9\u30DE\u304C\u8A2D\u5B9A\u3057\u305F\u8AD6\u7406\u7684\u306A\u30B0\u30EB\u30FC\u30D7\u5206\u3051\u304C\u4FDD\u6301\u3055\u308C\u307E\u3059\u3002 3.32 +doclet.Help_line_13=\u5404\u30B5\u30DE\u30EA\u30FC\u30FB\u30A8\u30F3\u30C8\u30EA\u306B\u306F\u3001\u305D\u306E\u9805\u76EE\u306E\u8A73\u7D30\u8AAC\u660E\u306E\u4E2D\u304B\u30891\u884C\u76EE\u306E\u6587\u304C\u8868\u793A\u3055\u308C\u307E\u3059\u3002\u30B5\u30DE\u30EA\u30FC\u30FB\u30A8\u30F3\u30C8\u30EA\u306F\u30A2\u30EB\u30D5\u30A1\u30D9\u30C3\u30C8\u9806\u3067\u3059\u304C\u3001\u8A73\u7D30\u8AAC\u660E\u306F\u30BD\u30FC\u30B9\u30FB\u30B3\u30FC\u30C9\u306B\u73FE\u308C\u308B\u9806\u306B\u306A\u3063\u3066\u3044\u307E\u3059\u3002\u3053\u308C\u306B\u3088\u3063\u3066\u3001\u30D7\u30ED\u30B0\u30E9\u30DE\u304C\u8A2D\u5B9A\u3057\u305F\u8AD6\u7406\u7684\u306A\u30B0\u30EB\u30FC\u30D7\u5206\u3051\u304C\u4FDD\u6301\u3055\u308C\u307E\u3059\u3002 3.33 doclet.Help_line_14=\u4F7F\u7528 3.34 doclet.Help_line_15=\u5404\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u5316\u3055\u308C\u305F\u30D1\u30C3\u30B1\u30FC\u30B8\u3001\u30AF\u30E9\u30B9\u304A\u3088\u3073\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306B\u306F\u305D\u308C\u305E\u308C\u300C\u4F7F\u7528\u300D\u30DA\u30FC\u30B8\u304C\u3042\u308A\u307E\u3059\u3002\u3053\u306E\u30DA\u30FC\u30B8\u306B\u306F\u3001\u3069\u306E\u3088\u3046\u306A\u30D1\u30C3\u30B1\u30FC\u30B8\u3001\u30AF\u30E9\u30B9\u3001\u30E1\u30BD\u30C3\u30C9\u3001\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u304A\u3088\u3073\u30D5\u30A3\u30FC\u30EB\u30C9\u304C\u3001\u7279\u5B9A\u306E\u30AF\u30E9\u30B9\u307E\u305F\u306F\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u4E00\u90E8\u3092\u4F7F\u7528\u3057\u3066\u3044\u308B\u304B\u304C\u8A18\u8FF0\u3055\u308C\u3066\u3044\u307E\u3059\u3002\u305F\u3068\u3048\u3070\u3001\u30AF\u30E9\u30B9A\u307E\u305F\u306F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9A\u306E\u5834\u5408\u3001\u305D\u306E\u300C\u4F7F\u7528\u300D\u30DA\u30FC\u30B8\u306B\u306F\u3001A\u306E\u30B5\u30D6\u30AF\u30E9\u30B9\u3001A\u3068\u3057\u3066\u5BA3\u8A00\u3055\u308C\u308B\u30D5\u30A3\u30FC\u30EB\u30C9\u3001A\u3092\u8FD4\u3059\u30E1\u30BD\u30C3\u30C9\u3068\u3001\u578BA\u3092\u6301\u3064\u30E1\u30BD\u30C3\u30C9\u304A\u3088\u3073\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u304C\u542B\u307E\u308C\u307E\u3059\u3002\u3053\u306E\u30DA\u30FC\u30B8\u306B\u30A2\u30AF\u30BB\u30B9\u3059\u308B\u306B\u306F\u3001\u307E\u305A\u305D\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u3001\u30AF\u30E9\u30B9\u307E\u305F\u306F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306B\u79FB\u52D5\u3057\u3001\u30CA\u30D3\u30B2\u30FC\u30B7\u30E7\u30F3\u30FB\u30D0\u30FC\u306E\u300C\u4F7F\u7528\u300D\u30EA\u30F3\u30AF\u3092\u30AF\u30EA\u30C3\u30AF\u3057\u3066\u304F\u3060\u3055\u3044\u3002 3.35 doclet.Help_line_16=\u968E\u5C64\u30C4\u30EA\u30FC(\u30AF\u30E9\u30B9\u968E\u5C64)
4.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_ja.properties Mon May 19 22:00:11 2014 -0700 4.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_ja.properties Thu May 29 13:46:36 2014 -0700 4.3 @@ -66,22 +66,22 @@ 4.4 doclet.malformed_html_link_tag=<a> \u30BF\u30B0\u306E\u5F62\u5F0F\u304C\u4E0D\u6B63:\n"{0}" 4.5 doclet.tag_misuse={0}\u30BF\u30B0\u306F{1}\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u5185\u3067\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093\u3002\u4F7F\u7528\u3067\u304D\u308B\u306E\u306F\u6B21\u306E\u30BF\u30A4\u30D7\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u5185\u306E\u307F\u3067\u3059: {2}\u3002 4.6 doclet.javafx_tag_misuse=\u30BF\u30B0@propertyGetter\u3001@propertySetter\u304A\u3088\u3073@propertyDescription\u306F\u3001JavaFX\u306E\u30D7\u30ED\u30D1\u30C6\u30A3getter\u3068setter\u306E\u307F\u3067\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002 4.7 -doclet.Package_Summary=\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u6982\u8981 4.8 +doclet.Package_Summary=\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u30B5\u30DE\u30EA\u30FC 4.9 doclet.Profile_Summary=\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u30FB\u30B5\u30DE\u30EA\u30FC 4.10 -doclet.Interface_Summary=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306E\u6982\u8981 4.11 -doclet.Annotation_Types_Summary=\u6CE8\u91C8\u578B\u306E\u6982\u8981 4.12 -doclet.Enum_Summary=\u5217\u6319\u578B\u306E\u6982\u8981 4.13 -doclet.Exception_Summary=\u4F8B\u5916\u306E\u6982\u8981 4.14 -doclet.Error_Summary=\u30A8\u30E9\u30FC\u306E\u6982\u8981 4.15 -doclet.Class_Summary=\u30AF\u30E9\u30B9\u306E\u6982\u8981 4.16 -doclet.Nested_Class_Summary=\u30CD\u30B9\u30C8\u3055\u308C\u305F\u30AF\u30E9\u30B9\u306E\u6982\u8981 4.17 -doclet.Annotation_Type_Optional_Member_Summary=\u4EFB\u610F\u8981\u7D20\u306E\u6982\u8981 4.18 -doclet.Annotation_Type_Required_Member_Summary=\u5FC5\u9808\u8981\u7D20\u306E\u6982\u8981 4.19 -doclet.Field_Summary=\u30D5\u30A3\u30FC\u30EB\u30C9\u306E\u6982\u8981 4.20 -doclet.Property_Summary=\u30D7\u30ED\u30D1\u30C6\u30A3\u306E\u6982\u8981 4.21 -doclet.Enum_Constant_Summary=\u5217\u6319\u578B\u5B9A\u6570\u306E\u6982\u8981 4.22 -doclet.Constructor_Summary=\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u306E\u6982\u8981 4.23 -doclet.Method_Summary=\u30E1\u30BD\u30C3\u30C9\u306E\u6982\u8981 4.24 +doclet.Interface_Summary=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306E\u30B5\u30DE\u30EA\u30FC 4.25 +doclet.Annotation_Types_Summary=\u6CE8\u91C8\u578B\u306E\u30B5\u30DE\u30EA\u30FC 4.26 +doclet.Enum_Summary=\u5217\u6319\u578B\u306E\u30B5\u30DE\u30EA\u30FC 4.27 +doclet.Exception_Summary=\u4F8B\u5916\u306E\u30B5\u30DE\u30EA\u30FC 4.28 +doclet.Error_Summary=\u30A8\u30E9\u30FC\u306E\u30B5\u30DE\u30EA\u30FC 4.29 +doclet.Class_Summary=\u30AF\u30E9\u30B9\u306E\u30B5\u30DE\u30EA\u30FC 4.30 +doclet.Nested_Class_Summary=\u30CD\u30B9\u30C8\u3055\u308C\u305F\u30AF\u30E9\u30B9\u306E\u30B5\u30DE\u30EA\u30FC 4.31 +doclet.Annotation_Type_Optional_Member_Summary=\u4EFB\u610F\u8981\u7D20\u306E\u30B5\u30DE\u30EA\u30FC 4.32 +doclet.Annotation_Type_Required_Member_Summary=\u5FC5\u9808\u8981\u7D20\u306E\u30B5\u30DE\u30EA\u30FC 4.33 +doclet.Field_Summary=\u30D5\u30A3\u30FC\u30EB\u30C9\u306E\u30B5\u30DE\u30EA\u30FC 4.34 +doclet.Property_Summary=\u30D7\u30ED\u30D1\u30C6\u30A3\u306E\u30B5\u30DE\u30EA\u30FC 4.35 +doclet.Enum_Constant_Summary=\u5217\u6319\u578B\u5B9A\u6570\u306E\u30B5\u30DE\u30EA\u30FC 4.36 +doclet.Constructor_Summary=\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u306E\u30B5\u30DE\u30EA\u30FC 4.37 +doclet.Method_Summary=\u30E1\u30BD\u30C3\u30C9\u306E\u30B5\u30DE\u30EA\u30FC 4.38 doclet.Interfaces=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9 4.39 doclet.Enums=\u5217\u6319\u578B 4.40 doclet.AnnotationTypes=\u6CE8\u91C8\u578B
5.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java Mon May 19 22:00:11 2014 -0700 5.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java Thu May 29 13:46:36 2014 -0700 5.3 @@ -1,5 +1,5 @@ 5.4 /* 5.5 - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. 5.6 + * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. 5.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.8 * 5.9 * This code is free software; you can redistribute it and/or modify it 5.10 @@ -177,7 +177,7 @@ 5.11 try { 5.12 url = adjustEndFileSeparator(url); 5.13 if (isUrl(pkglisturl)) { 5.14 - readPackageListFromURL(url, toURL(pkglisturl)); 5.15 + readPackageListFromURL(url, toURL(adjustEndFileSeparator(pkglisturl))); 5.16 } else { 5.17 readPackageListFromFile(url, DocFile.createFileForInput(configuration, pkglisturl)); 5.18 }
6.1 --- a/src/share/classes/com/sun/tools/javac/code/Source.java Mon May 19 22:00:11 2014 -0700 6.2 +++ b/src/share/classes/com/sun/tools/javac/code/Source.java Thu May 29 13:46:36 2014 -0700 6.3 @@ -1,5 +1,5 @@ 6.4 /* 6.5 - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. 6.6 + * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. 6.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.8 * 6.9 * This code is free software; you can redistribute it and/or modify it 6.10 @@ -191,6 +191,9 @@ 6.11 public boolean allowObjectToPrimitiveCast() { 6.12 return compareTo(JDK1_7) >= 0; 6.13 } 6.14 + public boolean enforceThisDotInit() { 6.15 + return compareTo(JDK1_7) >= 0; 6.16 + } 6.17 public boolean allowPoly() { 6.18 return compareTo(JDK1_8) >= 0; 6.19 } 6.20 @@ -215,6 +218,9 @@ 6.21 public boolean allowTypeAnnotations() { 6.22 return compareTo(JDK1_8) >= 0; 6.23 } 6.24 + public boolean allowAnnotationsAfterTypeParams() { 6.25 + return compareTo(JDK1_8) >= 0; 6.26 + } 6.27 public boolean allowRepeatedAnnotations() { 6.28 return compareTo(JDK1_8) >= 0; 6.29 } 6.30 @@ -224,7 +230,7 @@ 6.31 public boolean allowGraphInference() { 6.32 return compareTo(JDK1_8) >= 0; 6.33 } 6.34 - public boolean allowStructuralMostSpecific() { 6.35 + public boolean allowFunctionalInterfaceMostSpecific() { 6.36 return compareTo(JDK1_8) >= 0; 6.37 } 6.38 public static SourceVersion toSourceVersion(Source source) {
7.1 --- a/src/share/classes/com/sun/tools/javac/code/Symbol.java Mon May 19 22:00:11 2014 -0700 7.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java Thu May 29 13:46:36 2014 -0700 7.3 @@ -1,5 +1,5 @@ 7.4 /* 7.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 7.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 7.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7.8 * 7.9 * This code is free software; you can redistribute it and/or modify it 7.10 @@ -392,7 +392,7 @@ 7.11 /** A class is an inner class if it it has an enclosing instance class. 7.12 */ 7.13 public boolean isInner() { 7.14 - return type.getEnclosingType().hasTag(CLASS); 7.15 + return kind == TYP && type.getEnclosingType().hasTag(CLASS); 7.16 } 7.17 7.18 /** An inner class has an outer instance if it is not an interface 7.19 @@ -467,11 +467,24 @@ 7.20 7.21 private boolean hiddenIn(ClassSymbol clazz, Types types) { 7.22 Symbol sym = hiddenInInternal(clazz, types); 7.23 - return sym != null && sym != this; 7.24 + Assert.check(sym != null, "the result of hiddenInInternal() can't be null"); 7.25 + /* If we find the current symbol then there is no symbol hiding it 7.26 + */ 7.27 + return sym != this; 7.28 } 7.29 7.30 - private Symbol hiddenInInternal(ClassSymbol c, Types types) { 7.31 - Scope.Entry e = c.members().lookup(name); 7.32 + /** This method looks in the supertypes graph that has the current class as the 7.33 + * initial node, till it finds the current symbol or another symbol that hides it. 7.34 + * If the current class has more than one supertype (extends one class and 7.35 + * implements one or more interfaces) then null can be returned, meaning that 7.36 + * a wrong path in the supertypes graph was selected. Null can only be returned 7.37 + * as a temporary value, as a result of the recursive call. 7.38 + */ 7.39 + private Symbol hiddenInInternal(ClassSymbol currentClass, Types types) { 7.40 + if (currentClass == owner) { 7.41 + return this; 7.42 + } 7.43 + Scope.Entry e = currentClass.members().lookup(name); 7.44 while (e.scope != null) { 7.45 if (e.sym.kind == kind && 7.46 (kind != MTH || 7.47 @@ -481,18 +494,19 @@ 7.48 } 7.49 e = e.next(); 7.50 } 7.51 - List<Symbol> hiddenSyms = List.nil(); 7.52 - for (Type st : types.interfaces(c.type).prepend(types.supertype(c.type))) { 7.53 + Symbol hiddenSym = null; 7.54 + for (Type st : types.interfaces(currentClass.type) 7.55 + .prepend(types.supertype(currentClass.type))) { 7.56 if (st != null && (st.hasTag(CLASS))) { 7.57 Symbol sym = hiddenInInternal((ClassSymbol)st.tsym, types); 7.58 - if (sym != null) { 7.59 - hiddenSyms = hiddenSyms.prepend(hiddenInInternal((ClassSymbol)st.tsym, types)); 7.60 + if (sym == this) { 7.61 + return this; 7.62 + } else if (sym != null) { 7.63 + hiddenSym = sym; 7.64 } 7.65 } 7.66 } 7.67 - return hiddenSyms.contains(this) ? 7.68 - this : 7.69 - (hiddenSyms.isEmpty() ? null : hiddenSyms.head); 7.70 + return hiddenSym; 7.71 } 7.72 7.73 /** Is this symbol inherited into a given class? 7.74 @@ -689,10 +703,10 @@ 7.75 } 7.76 7.77 /** 7.78 - * A total ordering between type symbols that refines the 7.79 + * A partial ordering between type symbols that refines the 7.80 * class inheritance graph. 7.81 * 7.82 - * Typevariables always precede other kinds of symbols. 7.83 + * Type variables always precede other kinds of symbols. 7.84 */ 7.85 public final boolean precedes(TypeSymbol that, Types types) { 7.86 if (this == that)
8.1 --- a/src/share/classes/com/sun/tools/javac/code/Type.java Mon May 19 22:00:11 2014 -0700 8.2 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java Thu May 29 13:46:36 2014 -0700 8.3 @@ -1,5 +1,5 @@ 8.4 /* 8.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 8.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 8.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8.8 * 8.9 * This code is free software; you can redistribute it and/or modify it 8.10 @@ -1445,12 +1445,19 @@ 8.11 * Inference variable bound kinds 8.12 */ 8.13 public enum InferenceBound { 8.14 - /** upper bounds */ 8.15 - UPPER, 8.16 - /** lower bounds */ 8.17 - LOWER, 8.18 - /** equality constraints */ 8.19 - EQ; 8.20 + UPPER { 8.21 + public InferenceBound complement() { return LOWER; } 8.22 + }, 8.23 + /** lower bounds */ 8.24 + LOWER { 8.25 + public InferenceBound complement() { return UPPER; } 8.26 + }, 8.27 + /** equality constraints */ 8.28 + EQ { 8.29 + public InferenceBound complement() { return EQ; } 8.30 + }; 8.31 + 8.32 + public abstract InferenceBound complement(); 8.33 } 8.34 8.35 /** inference variable bounds */ 8.36 @@ -1481,8 +1488,21 @@ 8.37 } 8.38 8.39 public String toString() { 8.40 - if (inst != null) return inst.toString(); 8.41 - else return qtype + "?"; 8.42 + return (inst == null) ? qtype + "?" : inst.toString(); 8.43 + } 8.44 + 8.45 + public String debugString() { 8.46 + String result = "inference var = " + qtype + "\n"; 8.47 + if (inst != null) { 8.48 + result += "inst = " + inst + '\n'; 8.49 + } 8.50 + for (InferenceBound bound: InferenceBound.values()) { 8.51 + List<Type> aboundList = bounds.get(bound); 8.52 + if (aboundList.size() > 0) { 8.53 + result += bound + " = " + aboundList + '\n'; 8.54 + } 8.55 + } 8.56 + return result; 8.57 } 8.58 8.59 @Override 8.60 @@ -1492,8 +1512,7 @@ 8.61 8.62 @Override 8.63 public Type baseType() { 8.64 - if (inst != null) return inst.baseType(); 8.65 - else return this; 8.66 + return (inst == null) ? this : inst.baseType(); 8.67 } 8.68 8.69 /** get all bounds of a given kind */ 8.70 @@ -1624,6 +1643,9 @@ 8.71 //only change bounds if request comes from substBounds 8.72 super.addBound(ib, bound, types, update); 8.73 } 8.74 + else if (bound.hasTag(UNDETVAR) && !((UndetVar) bound).isCaptured()) { 8.75 + ((UndetVar) bound).addBound(ib.complement(), this, types, false); 8.76 + } 8.77 } 8.78 8.79 @Override
9.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java Mon May 19 22:00:11 2014 -0700 9.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Thu May 29 13:46:36 2014 -0700 9.3 @@ -1,5 +1,5 @@ 9.4 /* 9.5 - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. 9.6 + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. 9.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9.8 * 9.9 * This code is free software; you can redistribute it and/or modify it 9.10 @@ -43,6 +43,7 @@ 9.11 import com.sun.tools.javac.comp.Enter; 9.12 import com.sun.tools.javac.comp.Env; 9.13 import com.sun.tools.javac.jvm.ClassReader; 9.14 +import com.sun.tools.javac.tree.JCTree; 9.15 import com.sun.tools.javac.util.*; 9.16 import static com.sun.tools.javac.code.BoundKind.*; 9.17 import static com.sun.tools.javac.code.Flags.*; 9.18 @@ -84,7 +85,6 @@ 9.19 final boolean allowBoxing; 9.20 final boolean allowCovariantReturns; 9.21 final boolean allowObjectToPrimitiveCast; 9.22 - final boolean allowDefaultMethods; 9.23 final ClassReader reader; 9.24 final Check chk; 9.25 final Enter enter; 9.26 @@ -111,7 +111,6 @@ 9.27 allowBoxing = source.allowBoxing(); 9.28 allowCovariantReturns = source.allowCovariantReturns(); 9.29 allowObjectToPrimitiveCast = source.allowObjectToPrimitiveCast(); 9.30 - allowDefaultMethods = source.allowDefaultMethods(); 9.31 reader = ClassReader.instance(context); 9.32 chk = Check.instance(context); 9.33 enter = Enter.instance(context); 9.34 @@ -153,31 +152,31 @@ 9.35 }; 9.36 // </editor-fold> 9.37 9.38 - // <editor-fold defaultstate="collapsed" desc="lowerBound"> 9.39 + // <editor-fold defaultstate="collapsed" desc="wildLowerBound"> 9.40 /** 9.41 - * The "lvalue conversion".<br> 9.42 - * The lower bound of most types is the type 9.43 - * itself. Wildcards, on the other hand have upper 9.44 - * and lower bounds. 9.45 + * Get a wildcard's lower bound, returning non-wildcards unchanged. 9.46 + * @param t a type argument, either a wildcard or a type 9.47 + */ 9.48 + public Type wildLowerBound(Type t) { 9.49 + if (t.hasTag(WILDCARD)) { 9.50 + WildcardType w = (WildcardType) t; 9.51 + return w.isExtendsBound() ? syms.botType : wildLowerBound(w.type); 9.52 + } 9.53 + else return t; 9.54 + } 9.55 + // </editor-fold> 9.56 + 9.57 + // <editor-fold defaultstate="collapsed" desc="cvarLowerBound"> 9.58 + /** 9.59 + * Get a capture variable's lower bound, returning other types unchanged. 9.60 * @param t a type 9.61 - * @return the lower bound of the given type 9.62 */ 9.63 - public Type lowerBound(Type t) { 9.64 - return lowerBound.visit(t); 9.65 + public Type cvarLowerBound(Type t) { 9.66 + if (t.hasTag(TYPEVAR) && ((TypeVar) t).isCaptured()) { 9.67 + return cvarLowerBound(t.getLowerBound()); 9.68 + } 9.69 + else return t; 9.70 } 9.71 - // where 9.72 - private final MapVisitor<Void> lowerBound = new MapVisitor<Void>() { 9.73 - 9.74 - @Override 9.75 - public Type visitWildcardType(WildcardType t, Void ignored) { 9.76 - return t.isExtendsBound() ? syms.botType : visit(t.type); 9.77 - } 9.78 - 9.79 - @Override 9.80 - public Type visitCapturedType(CapturedType t, Void ignored) { 9.81 - return visit(t.getLowerBound()); 9.82 - } 9.83 - }; 9.84 // </editor-fold> 9.85 9.86 // <editor-fold defaultstate="collapsed" desc="isUnbounded"> 9.87 @@ -307,8 +306,8 @@ 9.88 } 9.89 9.90 /** 9.91 - * Is t a subtype of or convertiable via boxing/unboxing 9.92 - * convertions to s? 9.93 + * Is t a subtype of or convertible via boxing/unboxing 9.94 + * conversions to s? 9.95 */ 9.96 public boolean isConvertible(Type t, Type s) { 9.97 return isConvertible(t, s, noWarnings); 9.98 @@ -829,9 +828,15 @@ 9.99 return true; 9.100 } 9.101 9.102 - Type lower = lowerBound(s); 9.103 - if (s != lower) 9.104 - return isSubtype(capture ? capture(t) : t, lower, false); 9.105 + // Generally, if 's' is a type variable, recur on lower bound; but 9.106 + // for inference variables and intersections, we need to keep 's' 9.107 + // (see JLS 4.10.2 for intersections and 18.2.3 for inference vars) 9.108 + if (!t.hasTag(UNDETVAR) && !t.isCompound()) { 9.109 + // TODO: JDK-8039198, bounds checking sometimes passes in a wildcard as s 9.110 + Type lower = cvarLowerBound(wildLowerBound(s)); 9.111 + if (s != lower) 9.112 + return isSubtype(capture ? capture(t) : t, lower, false); 9.113 + } 9.114 9.115 return isSubtype.visit(capture ? capture(t) : t, s); 9.116 } 9.117 @@ -915,14 +920,11 @@ 9.118 @Override 9.119 public Boolean visitClassType(ClassType t, Type s) { 9.120 Type sup = asSuper(t, s.tsym); 9.121 - return sup != null 9.122 - && sup.tsym == s.tsym 9.123 - // You're not allowed to write 9.124 - // Vector<Object> vec = new Vector<String>(); 9.125 - // But with wildcards you can write 9.126 - // Vector<? extends Object> vec = new Vector<String>(); 9.127 - // which means that subtype checking must be done 9.128 - // here instead of same-type checking (via containsType). 9.129 + if (sup == null) return false; 9.130 + // If t is an intersection, sup might not be a class type 9.131 + if (!sup.hasTag(CLASS)) return isSubtypeNoCapture(sup, s); 9.132 + return sup.tsym == s.tsym 9.133 + // Check type variable containment 9.134 && (!s.isParameterized() || containsTypeRecursive(s, sup)) 9.135 && isSubtypeNoCapture(sup.getEnclosingType(), 9.136 s.getEnclosingType()); 9.137 @@ -1138,7 +1140,7 @@ 9.138 return visit(s, t); 9.139 9.140 if (s.isSuperBound() && !s.isExtendsBound()) 9.141 - return visit(t, upperBound(s)) && visit(t, lowerBound(s)); 9.142 + return visit(t, upperBound(s)) && visit(t, wildLowerBound(s)); 9.143 9.144 if (t.isCompound() && s.isCompound()) { 9.145 if (!visit(supertype(t), supertype(s))) 9.146 @@ -1293,7 +1295,7 @@ 9.147 break; 9.148 } 9.149 case SUPER: { 9.150 - Type bound = lowerBound(s); 9.151 + Type bound = wildLowerBound(s); 9.152 undetvar.addBound(InferenceBound.LOWER, bound, this); 9.153 break; 9.154 } 9.155 @@ -1386,9 +1388,9 @@ 9.156 // t.isSuperBound() 9.157 // || isSubtypeNoCapture(upperBound(s), U(t))); 9.158 // System.err.format(" %s L(%s) <: L(%s) %s = %s%n", 9.159 -// L(t), t, s, lowerBound(s), 9.160 +// L(t), t, s, wildLowerBound(s), 9.161 // t.isExtendsBound() 9.162 -// || isSubtypeNoCapture(L(t), lowerBound(s))); 9.163 +// || isSubtypeNoCapture(L(t), wildLowerBound(s))); 9.164 // System.err.println(); 9.165 // } 9.166 9.167 @@ -1400,7 +1402,7 @@ 9.168 // debugContainsType(t, s); 9.169 return isSameWildcard(t, s) 9.170 || isCaptureOf(s, t) 9.171 - || ((t.isExtendsBound() || isSubtypeNoCapture(L(t), lowerBound(s))) && 9.172 + || ((t.isExtendsBound() || isSubtypeNoCapture(L(t), wildLowerBound(s))) && 9.173 (t.isSuperBound() || isSubtypeNoCapture(upperBound(s), U(t)))); 9.174 } 9.175 } 9.176 @@ -1762,7 +1764,7 @@ 9.177 if (s.isExtendsBound()) 9.178 return !isCastableRecursive(t.type, upperBound(s)); 9.179 else if (s.isSuperBound()) 9.180 - return notSoftSubtypeRecursive(lowerBound(s), t.type); 9.181 + return notSoftSubtypeRecursive(wildLowerBound(s), t.type); 9.182 } else if (t.isSuperBound()) { 9.183 if (s.isExtendsBound()) 9.184 return notSoftSubtypeRecursive(t.type, upperBound(s)); 9.185 @@ -1772,19 +1774,13 @@ 9.186 }; 9.187 // </editor-fold> 9.188 9.189 - // <editor-fold defaultstate="collapsed" desc="lowerBoundArgtypes"> 9.190 - /** 9.191 - * Returns the lower bounds of the formals of a method. 9.192 - */ 9.193 - public List<Type> lowerBoundArgtypes(Type t) { 9.194 - return lowerBounds(t.getParameterTypes()); 9.195 + // <editor-fold defaultstate="collapsed" desc="cvarLowerBounds"> 9.196 + public List<Type> cvarLowerBounds(List<Type> ts) { 9.197 + return map(ts, cvarLowerBoundMapping); 9.198 } 9.199 - public List<Type> lowerBounds(List<Type> ts) { 9.200 - return map(ts, lowerBoundMapping); 9.201 - } 9.202 - private final Mapping lowerBoundMapping = new Mapping("lowerBound") { 9.203 + private final Mapping cvarLowerBoundMapping = new Mapping("cvarLowerBound") { 9.204 public Type apply(Type t) { 9.205 - return lowerBound(t); 9.206 + return cvarLowerBound(t); 9.207 } 9.208 }; 9.209 // </editor-fold> 9.210 @@ -1936,6 +1932,17 @@ 9.211 * @param sym a symbol 9.212 */ 9.213 public Type asSuper(Type t, Symbol sym) { 9.214 + /* Some examples: 9.215 + * 9.216 + * (Enum<E>, Comparable) => Comparable<E> 9.217 + * (c.s.s.d.AttributeTree.ValueKind, Enum) => Enum<c.s.s.d.AttributeTree.ValueKind> 9.218 + * (c.s.s.t.ExpressionTree, c.s.s.t.Tree) => c.s.s.t.Tree 9.219 + * (j.u.List<capture#160 of ? extends c.s.s.d.DocTree>, Iterable) => 9.220 + * Iterable<capture#160 of ? extends c.s.s.d.DocTree> 9.221 + */ 9.222 + if (sym.type == syms.objectType) { //optimization 9.223 + return syms.objectType; 9.224 + } 9.225 return asSuper.visit(t, sym); 9.226 } 9.227 // where 9.228 @@ -1951,16 +1958,18 @@ 9.229 return t; 9.230 9.231 Type st = supertype(t); 9.232 - if (st.hasTag(CLASS) || st.hasTag(TYPEVAR) || st.hasTag(ERROR)) { 9.233 + if (st.hasTag(CLASS) || st.hasTag(TYPEVAR)) { 9.234 Type x = asSuper(st, sym); 9.235 if (x != null) 9.236 return x; 9.237 } 9.238 if ((sym.flags() & INTERFACE) != 0) { 9.239 for (List<Type> l = interfaces(t); l.nonEmpty(); l = l.tail) { 9.240 - Type x = asSuper(l.head, sym); 9.241 - if (x != null) 9.242 - return x; 9.243 + if (!l.head.hasTag(ERROR)) { 9.244 + Type x = asSuper(l.head, sym); 9.245 + if (x != null) 9.246 + return x; 9.247 + } 9.248 } 9.249 } 9.250 return null; 9.251 @@ -2242,7 +2251,8 @@ 9.252 9.253 // <editor-fold defaultstate="collapsed" desc="makeCompoundType"> 9.254 /** 9.255 - * Make a compound type from non-empty list of types 9.256 + * Make a compound type from non-empty list of types. The list should be 9.257 + * ordered according to {@link Symbol#precedes(TypeSymbol,Types)}. 9.258 * 9.259 * @param bounds the types from which the compound type is formed 9.260 * @param supertype is objectType if all bounds are interfaces, 9.261 @@ -3332,12 +3342,15 @@ 9.262 * Insert a type in a closure 9.263 */ 9.264 public List<Type> insert(List<Type> cl, Type t) { 9.265 - if (cl.isEmpty() || t.tsym.precedes(cl.head.tsym, this)) { 9.266 + if (cl.isEmpty()) { 9.267 return cl.prepend(t); 9.268 - } else if (cl.head.tsym.precedes(t.tsym, this)) { 9.269 + } else if (t.tsym == cl.head.tsym) { 9.270 + return cl; 9.271 + } else if (t.tsym.precedes(cl.head.tsym, this)) { 9.272 + return cl.prepend(t); 9.273 + } else { 9.274 + // t comes after head, or the two are unrelated 9.275 return insert(cl.tail, t).prepend(cl.head); 9.276 - } else { 9.277 - return cl; 9.278 } 9.279 } 9.280 9.281 @@ -3349,12 +3362,15 @@ 9.282 return cl2; 9.283 } else if (cl2.isEmpty()) { 9.284 return cl1; 9.285 + } else if (cl1.head.tsym == cl2.head.tsym) { 9.286 + return union(cl1.tail, cl2.tail).prepend(cl1.head); 9.287 } else if (cl1.head.tsym.precedes(cl2.head.tsym, this)) { 9.288 return union(cl1.tail, cl2).prepend(cl1.head); 9.289 } else if (cl2.head.tsym.precedes(cl1.head.tsym, this)) { 9.290 return union(cl1, cl2.tail).prepend(cl2.head); 9.291 } else { 9.292 - return union(cl1.tail, cl2.tail).prepend(cl1.head); 9.293 + // unrelated types 9.294 + return union(cl1.tail, cl2).prepend(cl1.head); 9.295 } 9.296 } 9.297 9.298 @@ -3464,18 +3480,31 @@ 9.299 private List<Type> closureMin(List<Type> cl) { 9.300 ListBuffer<Type> classes = new ListBuffer<>(); 9.301 ListBuffer<Type> interfaces = new ListBuffer<>(); 9.302 + Set<Type> toSkip = new HashSet<>(); 9.303 while (!cl.isEmpty()) { 9.304 Type current = cl.head; 9.305 - if (current.isInterface()) 9.306 - interfaces.append(current); 9.307 - else 9.308 - classes.append(current); 9.309 - ListBuffer<Type> candidates = new ListBuffer<>(); 9.310 - for (Type t : cl.tail) { 9.311 - if (!isSubtypeNoCapture(current, t)) 9.312 - candidates.append(t); 9.313 + boolean keep = !toSkip.contains(current); 9.314 + if (keep && current.hasTag(TYPEVAR)) { 9.315 + // skip lower-bounded variables with a subtype in cl.tail 9.316 + for (Type t : cl.tail) { 9.317 + if (isSubtypeNoCapture(t, current)) { 9.318 + keep = false; 9.319 + break; 9.320 + } 9.321 + } 9.322 } 9.323 - cl = candidates.toList(); 9.324 + if (keep) { 9.325 + if (current.isInterface()) 9.326 + interfaces.append(current); 9.327 + else 9.328 + classes.append(current); 9.329 + for (Type t : cl.tail) { 9.330 + // skip supertypes of 'current' in cl.tail 9.331 + if (isSubtypeNoCapture(current, t)) 9.332 + toSkip.add(t); 9.333 + } 9.334 + } 9.335 + cl = cl.tail; 9.336 } 9.337 return classes.appendList(interfaces).toList(); 9.338 } 9.339 @@ -3635,7 +3664,19 @@ 9.340 return s; 9.341 9.342 List<Type> closure = union(closure(t), closure(s)); 9.343 - List<Type> bounds = closureMin(closure); 9.344 + return glbFlattened(closure, t); 9.345 + } 9.346 + //where 9.347 + /** 9.348 + * Perform glb for a list of non-primitive, non-error, non-compound types; 9.349 + * redundant elements are removed. Bounds should be ordered according to 9.350 + * {@link Symbol#precedes(TypeSymbol,Types)}. 9.351 + * 9.352 + * @param flatBounds List of type to glb 9.353 + * @param errT Original type to use if the result is an error type 9.354 + */ 9.355 + private Type glbFlattened(List<Type> flatBounds, Type errT) { 9.356 + List<Type> bounds = closureMin(flatBounds); 9.357 9.358 if (bounds.isEmpty()) { // length == 0 9.359 return syms.objectType; 9.360 @@ -3643,11 +3684,21 @@ 9.361 return bounds.head; 9.362 } else { // length > 1 9.363 int classCount = 0; 9.364 - for (Type bound : bounds) 9.365 - if (!bound.isInterface()) 9.366 + List<Type> lowers = List.nil(); 9.367 + for (Type bound : bounds) { 9.368 + if (!bound.isInterface()) { 9.369 classCount++; 9.370 - if (classCount > 1) 9.371 - return createErrorType(t); 9.372 + Type lower = cvarLowerBound(bound); 9.373 + if (bound != lower && !lower.hasTag(BOT)) 9.374 + lowers = insert(lowers, lower); 9.375 + } 9.376 + } 9.377 + if (classCount > 1) { 9.378 + if (lowers.isEmpty()) 9.379 + return createErrorType(errT); 9.380 + else 9.381 + return glbFlattened(union(bounds, lowers), errT); 9.382 + } 9.383 } 9.384 return makeCompoundType(bounds); 9.385 } 9.386 @@ -3871,9 +3922,11 @@ 9.387 } 9.388 return buf.reverse(); 9.389 } 9.390 + 9.391 public Type capture(Type t) { 9.392 - if (!t.hasTag(CLASS)) 9.393 + if (!t.hasTag(CLASS)) { 9.394 return t; 9.395 + } 9.396 if (t.getEnclosingType() != Type.noType) { 9.397 Type capturedEncl = capture(t.getEnclosingType()); 9.398 if (capturedEncl != t.getEnclosingType()) { 9.399 @@ -4125,7 +4178,7 @@ 9.400 if (source.isExtendsBound()) 9.401 adaptRecursive(upperBound(source), upperBound(target)); 9.402 else if (source.isSuperBound()) 9.403 - adaptRecursive(lowerBound(source), lowerBound(target)); 9.404 + adaptRecursive(wildLowerBound(source), wildLowerBound(target)); 9.405 return null; 9.406 } 9.407 9.408 @@ -4137,7 +4190,7 @@ 9.409 Type val = mapping.get(source.tsym); 9.410 if (val != null) { 9.411 if (val.isSuperBound() && target.isSuperBound()) { 9.412 - val = isSubtype(lowerBound(val), lowerBound(target)) 9.413 + val = isSubtype(wildLowerBound(val), wildLowerBound(target)) 9.414 ? target : val; 9.415 } else if (val.isExtendsBound() && target.isExtendsBound()) { 9.416 val = isSubtype(upperBound(val), upperBound(target)) 9.417 @@ -4251,7 +4304,7 @@ 9.418 } 9.419 9.420 public Type visitType(Type t, Void s) { 9.421 - return high ? upperBound(t) : lowerBound(t); 9.422 + return high ? upperBound(t) : t; 9.423 } 9.424 9.425 @Override
10.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Mon May 19 22:00:11 2014 -0700 10.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Thu May 29 13:46:36 2014 -0700 10.3 @@ -1,5 +1,5 @@ 10.4 /* 10.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 10.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 10.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10.8 * 10.9 * This code is free software; you can redistribute it and/or modify it 10.10 @@ -249,7 +249,7 @@ 10.11 if (!owntype.hasTag(ERROR) && !resultInfo.pt.hasTag(METHOD) && !resultInfo.pt.hasTag(FORALL)) { 10.12 if (allowPoly && inferenceContext.free(found)) { 10.13 if ((ownkind & ~resultInfo.pkind) == 0) { 10.14 - owntype = resultInfo.check(tree, inferenceContext.asFree(owntype)); 10.15 + owntype = resultInfo.check(tree, inferenceContext.asUndetVar(owntype)); 10.16 } else { 10.17 log.error(tree.pos(), "unexpected.type", 10.18 kindNames(resultInfo.pkind), 10.19 @@ -518,6 +518,10 @@ 10.20 return new ResultInfo(pkind, pt, newContext); 10.21 } 10.22 10.23 + protected ResultInfo dup(Type newPt, CheckContext newContext) { 10.24 + return new ResultInfo(pkind, newPt, newContext); 10.25 + } 10.26 + 10.27 @Override 10.28 public String toString() { 10.29 if (pt != null) { 10.30 @@ -812,6 +816,10 @@ 10.31 boolean classExpected, 10.32 boolean interfaceExpected, 10.33 boolean checkExtensible) { 10.34 + if (t.tsym.isAnonymous()) { 10.35 + log.error(tree.pos(), "cant.inherit.from.anon"); 10.36 + return types.createErrorType(t); 10.37 + } 10.38 if (t.isErroneous()) 10.39 return t; 10.40 if (t.hasTag(TYPEVAR) && !classExpected && !interfaceExpected) { 10.41 @@ -2139,6 +2147,11 @@ 10.42 cdef.extending = clazz; 10.43 } 10.44 10.45 + if (resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK && 10.46 + isSerializable(clazztype)) { 10.47 + localEnv.info.isSerializable = true; 10.48 + } 10.49 + 10.50 attribStat(cdef, localEnv); 10.51 10.52 checkLambdaCandidate(tree, cdef.sym, clazztype); 10.53 @@ -2294,6 +2307,9 @@ 10.54 resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK; 10.55 try { 10.56 Type currentTarget = pt(); 10.57 + if (needsRecovery && isSerializable(currentTarget)) { 10.58 + localEnv.info.isSerializable = true; 10.59 + } 10.60 List<Type> explicitParamTypes = null; 10.61 if (that.paramKind == JCLambda.ParameterKind.EXPLICIT) { 10.62 //attribute lambda parameters 10.63 @@ -2398,7 +2414,7 @@ 10.64 //add thrown types as bounds to the thrown types free variables if needed: 10.65 if (resultInfo.checkContext.inferenceContext().free(lambdaType.getThrownTypes())) { 10.66 List<Type> inferredThrownTypes = flow.analyzeLambdaThrownTypes(env, that, make); 10.67 - List<Type> thrownTypes = resultInfo.checkContext.inferenceContext().asFree(lambdaType.getThrownTypes()); 10.68 + List<Type> thrownTypes = resultInfo.checkContext.inferenceContext().asUndetVars(lambdaType.getThrownTypes()); 10.69 10.70 chk.unhandled(inferredThrownTypes, thrownTypes); 10.71 } 10.72 @@ -2539,7 +2555,7 @@ 10.73 @Override 10.74 public boolean compatible(Type found, Type req, Warner warn) { 10.75 //return type must be compatible in both current context and assignment context 10.76 - return chk.basicHandler.compatible(found, inferenceContext().asFree(req), warn); 10.77 + return chk.basicHandler.compatible(found, inferenceContext().asUndetVar(req), warn); 10.78 } 10.79 10.80 @Override 10.81 @@ -2572,7 +2588,7 @@ 10.82 * types must be compatible with the return type of the expected descriptor. 10.83 */ 10.84 private void checkLambdaCompatible(JCLambda tree, Type descriptor, CheckContext checkContext) { 10.85 - Type returnType = checkContext.inferenceContext().asFree(descriptor.getReturnType()); 10.86 + Type returnType = checkContext.inferenceContext().asUndetVar(descriptor.getReturnType()); 10.87 10.88 //return values have already been checked - but if lambda has no return 10.89 //values, we must ensure that void/value compatibility is correct; 10.90 @@ -2584,7 +2600,7 @@ 10.91 diags.fragment("missing.ret.val", returnType))); 10.92 } 10.93 10.94 - List<Type> argTypes = checkContext.inferenceContext().asFree(descriptor.getParameterTypes()); 10.95 + List<Type> argTypes = checkContext.inferenceContext().asUndetVars(descriptor.getParameterTypes()); 10.96 if (!types.isSameTypes(argTypes, TreeInfo.types(tree.params))) { 10.97 checkContext.report(tree, diags.fragment("incompatible.arg.types.in.lambda")); 10.98 } 10.99 @@ -2614,7 +2630,7 @@ 10.100 * - an instance field, we use the first constructor. 10.101 * - a static field, we create a fake clinit method. 10.102 */ 10.103 - private Env<AttrContext> lambdaEnv(JCLambda that, Env<AttrContext> env) { 10.104 + public Env<AttrContext> lambdaEnv(JCLambda that, Env<AttrContext> env) { 10.105 Env<AttrContext> lambdaEnv; 10.106 Symbol owner = env.info.scope.owner; 10.107 if (owner.kind == VAR && owner.owner.kind == TYP) { 10.108 @@ -2698,17 +2714,20 @@ 10.109 typeargtypes = attribTypes(that.typeargs, localEnv); 10.110 } 10.111 10.112 - Type target; 10.113 Type desc; 10.114 - if (pt() != Type.recoveryType) { 10.115 - target = targetChecker.visit(pt(), that); 10.116 - desc = types.findDescriptorType(target); 10.117 + Type currentTarget = pt(); 10.118 + boolean isTargetSerializable = 10.119 + resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK && 10.120 + isSerializable(currentTarget); 10.121 + if (currentTarget != Type.recoveryType) { 10.122 + currentTarget = targetChecker.visit(currentTarget, that); 10.123 + desc = types.findDescriptorType(currentTarget); 10.124 } else { 10.125 - target = Type.recoveryType; 10.126 + currentTarget = Type.recoveryType; 10.127 desc = fallbackDescriptorType(that); 10.128 } 10.129 10.130 - setFunctionalInfo(localEnv, that, pt(), desc, target, resultInfo.checkContext); 10.131 + setFunctionalInfo(localEnv, that, pt(), desc, currentTarget, resultInfo.checkContext); 10.132 List<Type> argtypes = desc.getParameterTypes(); 10.133 Resolve.MethodCheck referenceCheck = rs.resolveMethodCheck; 10.134 10.135 @@ -2750,7 +2769,7 @@ 10.136 targetError = false; 10.137 } 10.138 10.139 - JCDiagnostic detailsDiag = ((Resolve.ResolveError)refSym).getDiagnostic(JCDiagnostic.DiagnosticType.FRAGMENT, 10.140 + JCDiagnostic detailsDiag = ((Resolve.ResolveError)refSym.baseSymbol()).getDiagnostic(JCDiagnostic.DiagnosticType.FRAGMENT, 10.141 that, exprType.tsym, exprType, that.name, argtypes, typeargtypes); 10.142 10.143 JCDiagnostic.DiagnosticType diagKind = targetError ? 10.144 @@ -2759,10 +2778,10 @@ 10.145 JCDiagnostic diag = diags.create(diagKind, log.currentSource(), that, 10.146 "invalid.mref", Kinds.kindName(that.getMode()), detailsDiag); 10.147 10.148 - if (targetError && target == Type.recoveryType) { 10.149 + if (targetError && currentTarget == Type.recoveryType) { 10.150 //a target error doesn't make sense during recovery stage 10.151 //as we don't know what actual parameter types are 10.152 - result = that.type = target; 10.153 + result = that.type = currentTarget; 10.154 return; 10.155 } else { 10.156 if (targetError) { 10.157 @@ -2770,7 +2789,7 @@ 10.158 } else { 10.159 log.report(diag); 10.160 } 10.161 - result = that.type = types.createErrorType(target); 10.162 + result = that.type = types.createErrorType(currentTarget); 10.163 return; 10.164 } 10.165 } 10.166 @@ -2781,7 +2800,7 @@ 10.167 10.168 if (desc.getReturnType() == Type.recoveryType) { 10.169 // stop here 10.170 - result = that.type = target; 10.171 + result = that.type = currentTarget; 10.172 return; 10.173 } 10.174 10.175 @@ -2799,7 +2818,7 @@ 10.176 //static ref with class type-args 10.177 log.error(that.expr.pos(), "invalid.mref", Kinds.kindName(that.getMode()), 10.178 diags.fragment("static.mref.with.targs")); 10.179 - result = that.type = types.createErrorType(target); 10.180 + result = that.type = types.createErrorType(currentTarget); 10.181 return; 10.182 } 10.183 10.184 @@ -2808,7 +2827,7 @@ 10.185 //no static bound mrefs 10.186 log.error(that.expr.pos(), "invalid.mref", Kinds.kindName(that.getMode()), 10.187 diags.fragment("static.bound.mref")); 10.188 - result = that.type = types.createErrorType(target); 10.189 + result = that.type = types.createErrorType(currentTarget); 10.190 return; 10.191 } 10.192 10.193 @@ -2816,19 +2835,24 @@ 10.194 // Check that super-qualified symbols are not abstract (JLS) 10.195 rs.checkNonAbstract(that.pos(), that.sym); 10.196 } 10.197 + 10.198 + if (isTargetSerializable) { 10.199 + chk.checkElemAccessFromSerializableLambda(that); 10.200 + } 10.201 } 10.202 10.203 ResultInfo checkInfo = 10.204 resultInfo.dup(newMethodTemplate( 10.205 desc.getReturnType().hasTag(VOID) ? Type.noType : desc.getReturnType(), 10.206 - that.kind.isUnbound() ? argtypes.tail : argtypes, typeargtypes)); 10.207 + that.kind.isUnbound() ? argtypes.tail : argtypes, typeargtypes), 10.208 + new FunctionalReturnContext(resultInfo.checkContext)); 10.209 10.210 Type refType = checkId(that, lookupHelper.site, refSym, localEnv, checkInfo); 10.211 10.212 if (that.kind.isUnbound() && 10.213 resultInfo.checkContext.inferenceContext().free(argtypes.head)) { 10.214 //re-generate inference constraints for unbound receiver 10.215 - if (!types.isSubtype(resultInfo.checkContext.inferenceContext().asFree(argtypes.head), exprType)) { 10.216 + if (!types.isSubtype(resultInfo.checkContext.inferenceContext().asUndetVar(argtypes.head), exprType)) { 10.217 //cannot happen as this has already been checked - we just need 10.218 //to regenerate the inference constraints, as that has been lost 10.219 //as a result of the call to inferenceContext.save() 10.220 @@ -2847,9 +2871,9 @@ 10.221 resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.SPECULATIVE; 10.222 checkReferenceCompatible(that, desc, refType, resultInfo.checkContext, isSpeculativeRound); 10.223 if (!isSpeculativeRound) { 10.224 - checkAccessibleTypes(that, localEnv, resultInfo.checkContext.inferenceContext(), desc, target); 10.225 + checkAccessibleTypes(that, localEnv, resultInfo.checkContext.inferenceContext(), desc, currentTarget); 10.226 } 10.227 - result = check(that, target, VAL, resultInfo); 10.228 + result = check(that, currentTarget, VAL, resultInfo); 10.229 } catch (Types.FunctionDescriptorLookupError ex) { 10.230 JCDiagnostic cause = ex.getDiagnostic(); 10.231 resultInfo.checkContext.report(that, cause); 10.232 @@ -2866,7 +2890,7 @@ 10.233 10.234 @SuppressWarnings("fallthrough") 10.235 void checkReferenceCompatible(JCMemberReference tree, Type descriptor, Type refType, CheckContext checkContext, boolean speculativeAttr) { 10.236 - Type returnType = checkContext.inferenceContext().asFree(descriptor.getReturnType()); 10.237 + Type returnType = checkContext.inferenceContext().asUndetVar(descriptor.getReturnType()); 10.238 10.239 Type resType; 10.240 switch (tree.getMode()) { 10.241 @@ -2898,7 +2922,7 @@ 10.242 } 10.243 10.244 if (!speculativeAttr) { 10.245 - List<Type> thrownTypes = checkContext.inferenceContext().asFree(descriptor.getThrownTypes()); 10.246 + List<Type> thrownTypes = checkContext.inferenceContext().asUndetVars(descriptor.getThrownTypes()); 10.247 if (chk.unhandled(refType.getThrownTypes(), thrownTypes).nonEmpty()) { 10.248 log.error(tree, "incompatible.thrown.types.in.mref", refType.getThrownTypes()); 10.249 } 10.250 @@ -3009,15 +3033,6 @@ 10.251 Type ctype = cfolder.fold1(opc, argtype); 10.252 if (ctype != null) { 10.253 owntype = cfolder.coerce(ctype, owntype); 10.254 - 10.255 - // Remove constant types from arguments to 10.256 - // conserve space. The parser will fold concatenations 10.257 - // of string literals; the code here also 10.258 - // gets rid of intermediate results when some of the 10.259 - // operands are constant identifiers. 10.260 - if (tree.arg.type.tsym == syms.stringType.tsym) { 10.261 - tree.arg.type = syms.stringType; 10.262 - } 10.263 } 10.264 } 10.265 } 10.266 @@ -3051,18 +3066,6 @@ 10.267 Type ctype = cfolder.fold2(opc, left, right); 10.268 if (ctype != null) { 10.269 owntype = cfolder.coerce(ctype, owntype); 10.270 - 10.271 - // Remove constant types from arguments to 10.272 - // conserve space. The parser will fold concatenations 10.273 - // of string literals; the code here also 10.274 - // gets rid of intermediate results when some of the 10.275 - // operands are constant identifiers. 10.276 - if (tree.lhs.type.tsym == syms.stringType.tsym) { 10.277 - tree.lhs.type = syms.stringType; 10.278 - } 10.279 - if (tree.rhs.type.tsym == syms.stringType.tsym) { 10.280 - tree.rhs.type = syms.stringType; 10.281 - } 10.282 } 10.283 } 10.284 10.285 @@ -3210,6 +3213,11 @@ 10.286 while (env1.outer != null && !rs.isAccessible(env, env1.enclClass.sym.type, sym)) 10.287 env1 = env1.outer; 10.288 } 10.289 + 10.290 + if (env.info.isSerializable) { 10.291 + chk.checkElemAccessFromSerializableLambda(tree); 10.292 + } 10.293 + 10.294 result = checkId(tree, env1.enclClass.sym.type, sym, env, resultInfo); 10.295 } 10.296 10.297 @@ -3334,6 +3342,10 @@ 10.298 } 10.299 } 10.300 10.301 + if (env.info.isSerializable) { 10.302 + chk.checkElemAccessFromSerializableLambda(tree); 10.303 + } 10.304 + 10.305 env.info.selectSuper = selectSuperPrev; 10.306 result = checkId(tree, site, sym, env, resultInfo); 10.307 } 10.308 @@ -4212,6 +4224,11 @@ 10.309 ((c.flags_field & (Flags.ENUM | Flags.COMPOUND)) == 0)) { 10.310 log.error(env.tree.pos(), "enum.types.not.extensible"); 10.311 } 10.312 + 10.313 + if (isSerializable(c.type)) { 10.314 + env.info.isSerializable = true; 10.315 + } 10.316 + 10.317 attribClassBody(env, c); 10.318 10.319 chk.checkDeprecatedAnnotation(env.tree.pos(), c); 10.320 @@ -4325,7 +4342,7 @@ 10.321 10.322 // Check for proper use of serialVersionUID 10.323 if (env.info.lint.isEnabled(LintCategory.SERIAL) && 10.324 - isSerializable(c) && 10.325 + isSerializable(c.type) && 10.326 (c.flags() & Flags.ENUM) == 0 && 10.327 checkForSerial(c)) { 10.328 checkSerialVersionUID(tree, c); 10.329 @@ -4365,15 +4382,15 @@ 10.330 return null; 10.331 } 10.332 10.333 - /** check if a class is a subtype of Serializable, if that is available. */ 10.334 - private boolean isSerializable(ClassSymbol c) { 10.335 + /** check if a type is a subtype of Serializable, if that is available. */ 10.336 + boolean isSerializable(Type t) { 10.337 try { 10.338 syms.serializableType.complete(); 10.339 } 10.340 catch (CompletionFailure e) { 10.341 return false; 10.342 } 10.343 - return types.isSubtype(c.type, syms.serializableType); 10.344 + return types.isSubtype(t, syms.serializableType); 10.345 } 10.346 10.347 /** Check that an appropriate serialVersionUID member is defined. */ 10.348 @@ -4653,10 +4670,19 @@ 10.349 10.350 private void initTypeIfNeeded(JCTree that) { 10.351 if (that.type == null) { 10.352 - that.type = syms.unknownType; 10.353 + if (that.hasTag(METHODDEF)) { 10.354 + that.type = dummyMethodType(); 10.355 + } else { 10.356 + that.type = syms.unknownType; 10.357 + } 10.358 } 10.359 } 10.360 10.361 + private Type dummyMethodType() { 10.362 + return new MethodType(List.<Type>nil(), syms.unknownType, 10.363 + List.<Type>nil(), syms.methodClass); 10.364 + } 10.365 + 10.366 @Override 10.367 public void scan(JCTree tree) { 10.368 if (tree == null) return; 10.369 @@ -4712,7 +4738,8 @@ 10.370 @Override 10.371 public void visitNewClass(JCNewClass that) { 10.372 if (that.constructor == null) { 10.373 - that.constructor = new MethodSymbol(0, names.init, syms.unknownType, syms.noSymbol); 10.374 + that.constructor = new MethodSymbol(0, names.init, 10.375 + dummyMethodType(), syms.noSymbol); 10.376 } 10.377 if (that.constructorType == null) { 10.378 that.constructorType = syms.unknownType; 10.379 @@ -4722,22 +4749,28 @@ 10.380 10.381 @Override 10.382 public void visitAssignop(JCAssignOp that) { 10.383 - if (that.operator == null) 10.384 - that.operator = new OperatorSymbol(names.empty, syms.unknownType, -1, syms.noSymbol); 10.385 + if (that.operator == null) { 10.386 + that.operator = new OperatorSymbol(names.empty, dummyMethodType(), 10.387 + -1, syms.noSymbol); 10.388 + } 10.389 super.visitAssignop(that); 10.390 } 10.391 10.392 @Override 10.393 public void visitBinary(JCBinary that) { 10.394 - if (that.operator == null) 10.395 - that.operator = new OperatorSymbol(names.empty, syms.unknownType, -1, syms.noSymbol); 10.396 + if (that.operator == null) { 10.397 + that.operator = new OperatorSymbol(names.empty, dummyMethodType(), 10.398 + -1, syms.noSymbol); 10.399 + } 10.400 super.visitBinary(that); 10.401 } 10.402 10.403 @Override 10.404 public void visitUnary(JCUnary that) { 10.405 - if (that.operator == null) 10.406 - that.operator = new OperatorSymbol(names.empty, syms.unknownType, -1, syms.noSymbol); 10.407 + if (that.operator == null) { 10.408 + that.operator = new OperatorSymbol(names.empty, dummyMethodType(), 10.409 + -1, syms.noSymbol); 10.410 + } 10.411 super.visitUnary(that); 10.412 } 10.413 10.414 @@ -4753,7 +4786,8 @@ 10.415 public void visitReference(JCMemberReference that) { 10.416 super.visitReference(that); 10.417 if (that.sym == null) { 10.418 - that.sym = new MethodSymbol(0, names.empty, syms.unknownType, syms.noSymbol); 10.419 + that.sym = new MethodSymbol(0, names.empty, dummyMethodType(), 10.420 + syms.noSymbol); 10.421 } 10.422 if (that.targets == null) { 10.423 that.targets = List.nil();
11.1 --- a/src/share/classes/com/sun/tools/javac/comp/AttrContext.java Mon May 19 22:00:11 2014 -0700 11.2 +++ b/src/share/classes/com/sun/tools/javac/comp/AttrContext.java Thu May 29 13:46:36 2014 -0700 11.3 @@ -1,5 +1,5 @@ 11.4 /* 11.5 - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. 11.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 11.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11.8 * 11.9 * This code is free software; you can redistribute it and/or modify it 11.10 @@ -54,6 +54,10 @@ 11.11 */ 11.12 boolean selectSuper = false; 11.13 11.14 + /** Is the current target of lambda expression or method reference serializable? 11.15 + */ 11.16 + boolean isSerializable = false; 11.17 + 11.18 /** Are arguments to current function applications boxed into an array for varargs? 11.19 */ 11.20 Resolve.MethodResolutionPhase pendingResolutionPhase = null; 11.21 @@ -89,6 +93,7 @@ 11.22 info.enclVar = enclVar; 11.23 info.returnResult = returnResult; 11.24 info.defaultSuperCallSite = defaultSuperCallSite; 11.25 + info.isSerializable = isSerializable; 11.26 return info; 11.27 } 11.28
12.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Mon May 19 22:00:11 2014 -0700 12.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Thu May 29 13:46:36 2014 -0700 12.3 @@ -1,5 +1,5 @@ 12.4 /* 12.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 12.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 12.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 12.8 * 12.9 * This code is free software; you can redistribute it and/or modify it 12.10 @@ -82,6 +82,7 @@ 12.11 private final TreeInfo treeinfo; 12.12 private final JavaFileManager fileManager; 12.13 private final Profile profile; 12.14 + private final boolean warnOnAccessToSensitiveMembers; 12.15 12.16 // The set of lint options currently in effect. It is initialized 12.17 // from the context, and then is set/reset as needed by Attr as it 12.18 @@ -131,6 +132,7 @@ 12.19 warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts"); 12.20 suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile"); 12.21 enableSunApiLintControl = options.isSet("enableSunApiLintControl"); 12.22 + warnOnAccessToSensitiveMembers = options.isSet("warnOnAccessToSensitiveMembers"); 12.23 12.24 Target target = Target.instance(context); 12.25 syntheticNameChar = target.syntheticNameChar(); 12.26 @@ -510,6 +512,11 @@ 12.27 public DeferredAttrContext deferredAttrContext() { 12.28 return deferredAttr.emptyDeferredAttrContext; 12.29 } 12.30 + 12.31 + @Override 12.32 + public String toString() { 12.33 + return "CheckContext: basicHandler"; 12.34 + } 12.35 }; 12.36 12.37 /** Check that a given type is assignable to a given proto-type. 12.38 @@ -616,7 +623,7 @@ 12.39 } else if (a.isExtendsBound()) { 12.40 return types.isCastable(bound, types.upperBound(a), types.noWarnings); 12.41 } else if (a.isSuperBound()) { 12.42 - return !types.notSoftSubtype(types.lowerBound(a), bound); 12.43 + return !types.notSoftSubtype(types.wildLowerBound(a), bound); 12.44 } 12.45 return true; 12.46 } 12.47 @@ -2583,6 +2590,44 @@ 12.48 } 12.49 } 12.50 12.51 + void checkElemAccessFromSerializableLambda(final JCTree tree) { 12.52 + if (warnOnAccessToSensitiveMembers) { 12.53 + Symbol sym = TreeInfo.symbol(tree); 12.54 + if ((sym.kind & (VAR | MTH)) == 0) { 12.55 + return; 12.56 + } 12.57 + 12.58 + if (sym.kind == VAR) { 12.59 + if ((sym.flags() & PARAMETER) != 0 || 12.60 + sym.isLocal() || 12.61 + sym.name == names._this || 12.62 + sym.name == names._super) { 12.63 + return; 12.64 + } 12.65 + } 12.66 + 12.67 + if (!types.isSubtype(sym.owner.type, syms.serializableType) && 12.68 + isEffectivelyNonPublic(sym)) { 12.69 + log.warning(tree.pos(), 12.70 + "access.to.sensitive.member.from.serializable.element", sym); 12.71 + } 12.72 + } 12.73 + } 12.74 + 12.75 + private boolean isEffectivelyNonPublic(Symbol sym) { 12.76 + if (sym.packge() == syms.rootPackage) { 12.77 + return false; 12.78 + } 12.79 + 12.80 + while (sym.kind != Kinds.PCK) { 12.81 + if ((sym.flags() & PUBLIC) == 0) { 12.82 + return true; 12.83 + } 12.84 + sym = sym.owner; 12.85 + } 12.86 + return false; 12.87 + } 12.88 + 12.89 /** Report a conflict between a user symbol and a synthetic symbol. 12.90 */ 12.91 private void syntheticError(DiagnosticPosition pos, Symbol sym) { 12.92 @@ -2680,7 +2725,7 @@ 12.93 if (types.isSameType(type, syms.stringType)) return; 12.94 if ((type.tsym.flags() & Flags.ENUM) != 0) return; 12.95 if ((type.tsym.flags() & Flags.ANNOTATION) != 0) return; 12.96 - if (types.lowerBound(type).tsym == syms.classType.tsym) return; 12.97 + if (types.cvarLowerBound(type).tsym == syms.classType.tsym) return; 12.98 if (types.isArray(type) && !types.isArray(types.elemtype(type))) { 12.99 validateAnnotationType(pos, types.elemtype(type)); 12.100 return; 12.101 @@ -2779,7 +2824,7 @@ 12.102 validateDocumented(t.tsym, s, pos); 12.103 validateInherited(t.tsym, s, pos); 12.104 validateTarget(t.tsym, s, pos); 12.105 - validateDefault(t.tsym, s, pos); 12.106 + validateDefault(t.tsym, pos); 12.107 } 12.108 12.109 private void validateValue(TypeSymbol container, TypeSymbol contained, DiagnosticPosition pos) { 12.110 @@ -2898,7 +2943,9 @@ 12.111 12.112 12.113 /** Checks that s is a subset of t, with respect to ElementType 12.114 - * semantics, specifically {ANNOTATION_TYPE} is a subset of {TYPE} 12.115 + * semantics, specifically {ANNOTATION_TYPE} is a subset of {TYPE}, 12.116 + * and {TYPE_USE} covers the set {ANNOTATION_TYPE, TYPE, TYPE_USE, 12.117 + * TYPE_PARAMETER}. 12.118 */ 12.119 private boolean isTargetSubsetOf(Set<Name> s, Set<Name> t) { 12.120 // Check that all elements in s are present in t 12.121 @@ -2911,6 +2958,12 @@ 12.122 } else if (n1 == names.TYPE && n2 == names.ANNOTATION_TYPE) { 12.123 currentElementOk = true; 12.124 break; 12.125 + } else if (n1 == names.TYPE_USE && 12.126 + (n2 == names.TYPE || 12.127 + n2 == names.ANNOTATION_TYPE || 12.128 + n2 == names.TYPE_PARAMETER)) { 12.129 + currentElementOk = true; 12.130 + break; 12.131 } 12.132 } 12.133 if (!currentElementOk) 12.134 @@ -2919,7 +2972,7 @@ 12.135 return true; 12.136 } 12.137 12.138 - private void validateDefault(Symbol container, Symbol contained, DiagnosticPosition pos) { 12.139 + private void validateDefault(Symbol container, DiagnosticPosition pos) { 12.140 // validate that all other elements of containing type has defaults 12.141 Scope scope = container.members(); 12.142 for(Symbol elm : scope.getElements()) {
13.1 --- a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Mon May 19 22:00:11 2014 -0700 13.2 +++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Thu May 29 13:46:36 2014 -0700 13.3 @@ -1,5 +1,5 @@ 13.4 /* 13.5 - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 13.6 + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. 13.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 13.8 * 13.9 * This code is free software; you can redistribute it and/or modify it 13.10 @@ -25,7 +25,7 @@ 13.11 13.12 package com.sun.tools.javac.comp; 13.13 13.14 -import com.sun.source.tree.MemberReferenceTree; 13.15 +import com.sun.source.tree.LambdaExpressionTree.BodyKind; 13.16 import com.sun.tools.javac.code.*; 13.17 import com.sun.tools.javac.tree.*; 13.18 import com.sun.tools.javac.util.*; 13.19 @@ -35,10 +35,8 @@ 13.20 import com.sun.tools.javac.comp.Attr.ResultInfo; 13.21 import com.sun.tools.javac.comp.Infer.InferenceContext; 13.22 import com.sun.tools.javac.comp.Resolve.MethodResolutionPhase; 13.23 -import com.sun.tools.javac.comp.Resolve.ReferenceLookupHelper; 13.24 import com.sun.tools.javac.tree.JCTree.*; 13.25 13.26 - 13.27 import java.util.ArrayList; 13.28 import java.util.Collections; 13.29 import java.util.EnumSet; 13.30 @@ -48,6 +46,7 @@ 13.31 import java.util.Set; 13.32 import java.util.WeakHashMap; 13.33 13.34 +import static com.sun.tools.javac.code.Kinds.VAL; 13.35 import static com.sun.tools.javac.code.TypeTag.*; 13.36 import static com.sun.tools.javac.tree.JCTree.Tag.*; 13.37 13.38 @@ -76,6 +75,8 @@ 13.39 final Symtab syms; 13.40 final TreeMaker make; 13.41 final Types types; 13.42 + final Flow flow; 13.43 + final Names names; 13.44 13.45 public static DeferredAttr instance(Context context) { 13.46 DeferredAttr instance = context.get(deferredAttrKey); 13.47 @@ -96,7 +97,8 @@ 13.48 syms = Symtab.instance(context); 13.49 make = TreeMaker.instance(context); 13.50 types = Types.instance(context); 13.51 - Names names = Names.instance(context); 13.52 + flow = Flow.instance(context); 13.53 + names = Names.instance(context); 13.54 stuckTree = make.Ident(names.empty).setType(Type.stuckType); 13.55 emptyDeferredAttrContext = 13.56 new DeferredAttrContext(AttrMode.CHECK, null, MethodResolutionPhase.BOX, infer.emptyContext, null, null) { 13.57 @@ -108,6 +110,11 @@ 13.58 void complete() { 13.59 Assert.error("Empty deferred context!"); 13.60 } 13.61 + 13.62 + @Override 13.63 + public String toString() { 13.64 + return "Empty deferred context!"; 13.65 + } 13.66 }; 13.67 } 13.68 13.69 @@ -139,6 +146,11 @@ 13.70 return DEFERRED; 13.71 } 13.72 13.73 + @Override 13.74 + public String toString() { 13.75 + return "DeferredType"; 13.76 + } 13.77 + 13.78 /** 13.79 * A speculative cache is used to keep track of all overload resolution rounds 13.80 * that triggered speculative attribution on a given deferred type. Each entry 13.81 @@ -378,7 +390,9 @@ 13.82 } 13.83 } 13.84 //where 13.85 - protected TreeScanner unenterScanner = new TreeScanner() { 13.86 + protected UnenterScanner unenterScanner = new UnenterScanner(); 13.87 + 13.88 + class UnenterScanner extends TreeScanner { 13.89 @Override 13.90 public void visitClassDef(JCClassDecl tree) { 13.91 ClassSymbol csym = tree.sym; 13.92 @@ -391,7 +405,7 @@ 13.93 syms.classes.remove(csym.flatname); 13.94 super.visitClassDef(tree); 13.95 } 13.96 - }; 13.97 + } 13.98 13.99 /** 13.100 * A deferred context is created on each method check. A deferred context is 13.101 @@ -595,19 +609,111 @@ 13.102 public void visitLambda(JCLambda tree) { 13.103 Check.CheckContext checkContext = resultInfo.checkContext; 13.104 Type pt = resultInfo.pt; 13.105 - if (inferenceContext.inferencevars.contains(pt)) { 13.106 - //ok 13.107 - return; 13.108 - } else { 13.109 + if (!inferenceContext.inferencevars.contains(pt)) { 13.110 //must be a functional descriptor 13.111 + Type descriptorType = null; 13.112 try { 13.113 - Type desc = types.findDescriptorType(pt); 13.114 - if (desc.getParameterTypes().length() != tree.params.length()) { 13.115 - checkContext.report(tree, diags.fragment("incompatible.arg.types.in.lambda")); 13.116 - } 13.117 + descriptorType = types.findDescriptorType(pt); 13.118 } catch (Types.FunctionDescriptorLookupError ex) { 13.119 checkContext.report(null, ex.getDiagnostic()); 13.120 } 13.121 + 13.122 + if (descriptorType.getParameterTypes().length() != tree.params.length()) { 13.123 + checkContext.report(tree, 13.124 + diags.fragment("incompatible.arg.types.in.lambda")); 13.125 + } 13.126 + 13.127 + Type currentReturnType = descriptorType.getReturnType(); 13.128 + boolean returnTypeIsVoid = currentReturnType.hasTag(VOID); 13.129 + if (tree.getBodyKind() == BodyKind.EXPRESSION) { 13.130 + boolean isExpressionCompatible = !returnTypeIsVoid || 13.131 + TreeInfo.isExpressionStatement((JCExpression)tree.getBody()); 13.132 + if (!isExpressionCompatible) { 13.133 + resultInfo.checkContext.report(tree.pos(), 13.134 + diags.fragment("incompatible.ret.type.in.lambda", 13.135 + diags.fragment("missing.ret.val", currentReturnType))); 13.136 + } 13.137 + } else { 13.138 + LambdaBodyStructChecker lambdaBodyChecker = 13.139 + new LambdaBodyStructChecker(); 13.140 + 13.141 + tree.body.accept(lambdaBodyChecker); 13.142 + boolean isVoidCompatible = lambdaBodyChecker.isVoidCompatible; 13.143 + 13.144 + if (returnTypeIsVoid) { 13.145 + if (!isVoidCompatible) { 13.146 + resultInfo.checkContext.report(tree.pos(), 13.147 + diags.fragment("unexpected.ret.val")); 13.148 + } 13.149 + } else { 13.150 + boolean isValueCompatible = lambdaBodyChecker.isPotentiallyValueCompatible 13.151 + && !canLambdaBodyCompleteNormally(tree); 13.152 + if (!isValueCompatible && !isVoidCompatible) { 13.153 + log.error(tree.body.pos(), 13.154 + "lambda.body.neither.value.nor.void.compatible"); 13.155 + } 13.156 + 13.157 + if (!isValueCompatible) { 13.158 + resultInfo.checkContext.report(tree.pos(), 13.159 + diags.fragment("incompatible.ret.type.in.lambda", 13.160 + diags.fragment("missing.ret.val", currentReturnType))); 13.161 + } 13.162 + } 13.163 + } 13.164 + } 13.165 + } 13.166 + 13.167 + boolean canLambdaBodyCompleteNormally(JCLambda tree) { 13.168 + JCLambda newTree = new TreeCopier<>(make).copy(tree); 13.169 + /* attr.lambdaEnv will create a meaningful env for the 13.170 + * lambda expression. This is specially useful when the 13.171 + * lambda is used as the init of a field. But we need to 13.172 + * remove any added symbol. 13.173 + */ 13.174 + Env<AttrContext> localEnv = attr.lambdaEnv(newTree, env); 13.175 + try { 13.176 + List<JCVariableDecl> tmpParams = newTree.params; 13.177 + while (tmpParams.nonEmpty()) { 13.178 + tmpParams.head.vartype = make.at(tmpParams.head).Type(syms.errType); 13.179 + tmpParams = tmpParams.tail; 13.180 + } 13.181 + 13.182 + attr.attribStats(newTree.params, localEnv); 13.183 + 13.184 + /* set pt to Type.noType to avoid generating any bound 13.185 + * which may happen if lambda's return type is an 13.186 + * inference variable 13.187 + */ 13.188 + Attr.ResultInfo bodyResultInfo = attr.new ResultInfo(VAL, Type.noType); 13.189 + localEnv.info.returnResult = bodyResultInfo; 13.190 + 13.191 + // discard any log output 13.192 + Log.DiagnosticHandler diagHandler = new Log.DiscardDiagnosticHandler(log); 13.193 + try { 13.194 + JCBlock body = (JCBlock)newTree.body; 13.195 + /* we need to attribute the lambda body before 13.196 + * doing the aliveness analysis. This is because 13.197 + * constant folding occurs during attribution 13.198 + * and the reachability of some statements depends 13.199 + * on constant values, for example: 13.200 + * 13.201 + * while (true) {...} 13.202 + */ 13.203 + attr.attribStats(body.stats, localEnv); 13.204 + 13.205 + attr.preFlow(newTree); 13.206 + /* make an aliveness / reachability analysis of the lambda 13.207 + * to determine if it can complete normally 13.208 + */ 13.209 + flow.analyzeLambda(localEnv, newTree, make, true); 13.210 + } finally { 13.211 + log.popDiagnosticHandler(diagHandler); 13.212 + } 13.213 + return newTree.canCompleteNormally; 13.214 + } finally { 13.215 + JCBlock body = (JCBlock)newTree.body; 13.216 + unenterScanner.scan(body.stats); 13.217 + localEnv.info.scope.leave(); 13.218 } 13.219 } 13.220 13.221 @@ -625,10 +731,7 @@ 13.222 public void visitReference(JCMemberReference tree) { 13.223 Check.CheckContext checkContext = resultInfo.checkContext; 13.224 Type pt = resultInfo.pt; 13.225 - if (inferenceContext.inferencevars.contains(pt)) { 13.226 - //ok 13.227 - return; 13.228 - } else { 13.229 + if (!inferenceContext.inferencevars.contains(pt)) { 13.230 try { 13.231 types.findDescriptorType(pt); 13.232 } catch (Types.FunctionDescriptorLookupError ex) { 13.233 @@ -658,6 +761,40 @@ 13.234 } 13.235 } 13.236 } 13.237 + 13.238 + /* This visitor looks for return statements, its analysis will determine if 13.239 + * a lambda body is void or value compatible. We must analyze return 13.240 + * statements contained in the lambda body only, thus any return statement 13.241 + * contained in an inner class or inner lambda body, should be ignored. 13.242 + */ 13.243 + class LambdaBodyStructChecker extends TreeScanner { 13.244 + boolean isVoidCompatible = true; 13.245 + boolean isPotentiallyValueCompatible = true; 13.246 + 13.247 + @Override 13.248 + public void visitClassDef(JCClassDecl tree) { 13.249 + // do nothing 13.250 + } 13.251 + 13.252 + @Override 13.253 + public void visitLambda(JCLambda tree) { 13.254 + // do nothing 13.255 + } 13.256 + 13.257 + @Override 13.258 + public void visitNewClass(JCNewClass tree) { 13.259 + // do nothing 13.260 + } 13.261 + 13.262 + @Override 13.263 + public void visitReturn(JCReturn tree) { 13.264 + if (tree.expr != null) { 13.265 + isVoidCompatible = false; 13.266 + } else { 13.267 + isPotentiallyValueCompatible = false; 13.268 + } 13.269 + } 13.270 + } 13.271 } 13.272 13.273 /** an empty deferred attribution context - all methods throw exceptions */ 13.274 @@ -769,7 +906,7 @@ 13.275 /** 13.276 * handler that is executed when a node has been discarded 13.277 */ 13.278 - abstract void skip(JCTree tree); 13.279 + void skip(JCTree tree) {} 13.280 } 13.281 13.282 /** 13.283 @@ -781,11 +918,6 @@ 13.284 PolyScanner() { 13.285 super(EnumSet.of(CONDEXPR, PARENS, LAMBDA, REFERENCE)); 13.286 } 13.287 - 13.288 - @Override 13.289 - void skip(JCTree tree) { 13.290 - //do nothing 13.291 - } 13.292 } 13.293 13.294 /** 13.295 @@ -798,11 +930,6 @@ 13.296 super(EnumSet.of(BLOCK, CASE, CATCH, DOLOOP, FOREACHLOOP, 13.297 FORLOOP, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP)); 13.298 } 13.299 - 13.300 - @Override 13.301 - void skip(JCTree tree) { 13.302 - //do nothing 13.303 - } 13.304 } 13.305 13.306 /**
14.1 --- a/src/share/classes/com/sun/tools/javac/comp/Flow.java Mon May 19 22:00:11 2014 -0700 14.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java Thu May 29 13:46:36 2014 -0700 14.3 @@ -1,5 +1,5 @@ 14.4 /* 14.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 14.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 14.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 14.8 * 14.9 * This code is free software; you can redistribute it and/or modify it 14.10 @@ -45,7 +45,7 @@ 14.11 import static com.sun.tools.javac.tree.JCTree.Tag.*; 14.12 14.13 /** This pass implements dataflow analysis for Java programs though 14.14 - * different AST visitor steps. Liveness analysis (see AliveAlanyzer) checks that 14.15 + * different AST visitor steps. Liveness analysis (see AliveAnalyzer) checks that 14.16 * every statement is reachable. Exception analysis (see FlowAnalyzer) ensures that 14.17 * every checked exception that is thrown is declared or caught. Definite assignment analysis 14.18 * (see AssignAnalyzer) ensures that each variable is assigned when used. Definite 14.19 @@ -197,6 +197,7 @@ 14.20 private final boolean allowImprovedRethrowAnalysis; 14.21 private final boolean allowImprovedCatchAnalysis; 14.22 private final boolean allowEffectivelyFinalInInnerClasses; 14.23 + private final boolean enforceThisDotInit; 14.24 14.25 public static Flow instance(Context context) { 14.26 Flow instance = context.get(flowKey); 14.27 @@ -207,7 +208,7 @@ 14.28 14.29 public void analyzeTree(Env<AttrContext> env, TreeMaker make) { 14.30 new AliveAnalyzer().analyzeTree(env, make); 14.31 - new AssignAnalyzer(log, syms, lint, names).analyzeTree(env); 14.32 + new AssignAnalyzer(log, syms, lint, names, enforceThisDotInit).analyzeTree(env); 14.33 new FlowAnalyzer().analyzeTree(env, make); 14.34 new CaptureAnalyzer().analyzeTree(env, make); 14.35 } 14.36 @@ -239,7 +240,7 @@ 14.37 //related errors, which will allow for more errors to be detected 14.38 Log.DiagnosticHandler diagHandler = new Log.DiscardDiagnosticHandler(log); 14.39 try { 14.40 - new AssignAnalyzer(log, syms, lint, names).analyzeTree(env); 14.41 + new AssignAnalyzer(log, syms, lint, names, enforceThisDotInit).analyzeTree(env); 14.42 LambdaFlowAnalyzer flowAnalyzer = new LambdaFlowAnalyzer(); 14.43 flowAnalyzer.analyzeTree(env, that, make); 14.44 return flowAnalyzer.inferredThrownTypes; 14.45 @@ -289,6 +290,7 @@ 14.46 allowImprovedRethrowAnalysis = source.allowImprovedRethrowAnalysis(); 14.47 allowImprovedCatchAnalysis = source.allowImprovedCatchAnalysis(); 14.48 allowEffectivelyFinalInInnerClasses = source.allowEffectivelyFinalInInnerClasses(); 14.49 + enforceThisDotInit = source.enforceThisDotInit(); 14.50 } 14.51 14.52 /** 14.53 @@ -1427,6 +1429,8 @@ 14.54 14.55 protected Names names; 14.56 14.57 + final boolean enforceThisDotInit; 14.58 + 14.59 public static class AbstractAssignPendingExit extends BaseAnalyzer.PendingExit { 14.60 14.61 final Bits inits; 14.62 @@ -1449,7 +1453,7 @@ 14.63 } 14.64 } 14.65 14.66 - public AbstractAssignAnalyzer(Bits inits, Symtab syms, Names names) { 14.67 + public AbstractAssignAnalyzer(Bits inits, Symtab syms, Names names, boolean enforceThisDotInit) { 14.68 this.inits = inits; 14.69 uninits = new Bits(); 14.70 uninitsTry = new Bits(); 14.71 @@ -1459,11 +1463,22 @@ 14.72 uninitsWhenFalse = new Bits(true); 14.73 this.syms = syms; 14.74 this.names = names; 14.75 + this.enforceThisDotInit = enforceThisDotInit; 14.76 } 14.77 14.78 + private boolean isInitialConstructor = false; 14.79 + 14.80 @Override 14.81 protected void markDead(JCTree tree) { 14.82 - inits.inclRange(returnadr, nextadr); 14.83 + if (!isInitialConstructor) { 14.84 + inits.inclRange(returnadr, nextadr); 14.85 + } else { 14.86 + for (int address = returnadr; address < nextadr; address++) { 14.87 + if (!(isFinalUninitializedStaticField(vardecls[address].sym))) { 14.88 + inits.incl(address); 14.89 + } 14.90 + } 14.91 + } 14.92 uninits.inclRange(returnadr, nextadr); 14.93 } 14.94 14.95 @@ -1476,8 +1491,17 @@ 14.96 return 14.97 sym.pos >= startPos && 14.98 ((sym.owner.kind == MTH || 14.99 - ((sym.flags() & (FINAL | HASINIT | PARAMETER)) == FINAL && 14.100 - classDef.sym.isEnclosedBy((ClassSymbol)sym.owner)))); 14.101 + isFinalUninitializedField(sym))); 14.102 + } 14.103 + 14.104 + boolean isFinalUninitializedField(VarSymbol sym) { 14.105 + return sym.owner.kind == TYP && 14.106 + ((sym.flags() & (FINAL | HASINIT | PARAMETER)) == FINAL && 14.107 + classDef.sym.isEnclosedBy((ClassSymbol)sym.owner)); 14.108 + } 14.109 + 14.110 + boolean isFinalUninitializedStaticField(VarSymbol sym) { 14.111 + return isFinalUninitializedField(sym) && sym.isStatic(); 14.112 } 14.113 14.114 /** Initialize new trackable variable by setting its address field 14.115 @@ -1731,10 +1755,9 @@ 14.116 int returnadrPrev = returnadr; 14.117 14.118 Assert.check(pendingExits.isEmpty()); 14.119 - 14.120 + boolean lastInitialConstructor = isInitialConstructor; 14.121 try { 14.122 - boolean isInitialConstructor = 14.123 - TreeInfo.isInitialConstructor(tree); 14.124 + isInitialConstructor = TreeInfo.isInitialConstructor(tree); 14.125 14.126 if (!isInitialConstructor) { 14.127 firstadr = nextadr; 14.128 @@ -1789,6 +1812,7 @@ 14.129 nextadr = nextadrPrev; 14.130 firstadr = firstadrPrev; 14.131 returnadr = returnadrPrev; 14.132 + isInitialConstructor = lastInitialConstructor; 14.133 } 14.134 } 14.135 14.136 @@ -2261,12 +2285,34 @@ 14.137 14.138 public void visitAssign(JCAssign tree) { 14.139 JCTree lhs = TreeInfo.skipParens(tree.lhs); 14.140 - if (!(lhs instanceof JCIdent)) { 14.141 + if (!isIdentOrThisDotIdent(lhs)) 14.142 scanExpr(lhs); 14.143 - } 14.144 scanExpr(tree.rhs); 14.145 letInit(lhs); 14.146 } 14.147 + private boolean isIdentOrThisDotIdent(JCTree lhs) { 14.148 + if (lhs.hasTag(IDENT)) 14.149 + return true; 14.150 + if (!lhs.hasTag(SELECT)) 14.151 + return false; 14.152 + 14.153 + JCFieldAccess fa = (JCFieldAccess)lhs; 14.154 + return fa.selected.hasTag(IDENT) && 14.155 + ((JCIdent)fa.selected).name == names._this; 14.156 + } 14.157 + 14.158 + // check fields accessed through this.<field> are definitely 14.159 + // assigned before reading their value 14.160 + public void visitSelect(JCFieldAccess tree) { 14.161 + super.visitSelect(tree); 14.162 + if (enforceThisDotInit && 14.163 + tree.selected.hasTag(IDENT) && 14.164 + ((JCIdent)tree.selected).name == names._this && 14.165 + tree.sym.kind == VAR) 14.166 + { 14.167 + checkInit(tree.pos(), (VarSymbol)tree.sym); 14.168 + } 14.169 + } 14.170 14.171 public void visitAssignop(JCAssignOp tree) { 14.172 scanExpr(tree.lhs); 14.173 @@ -2400,8 +2446,8 @@ 14.174 } 14.175 } 14.176 14.177 - public AssignAnalyzer(Log log, Symtab syms, Lint lint, Names names) { 14.178 - super(new Bits(), syms, names); 14.179 + public AssignAnalyzer(Log log, Symtab syms, Lint lint, Names names, boolean enforceThisDotInit) { 14.180 + super(new Bits(), syms, names, enforceThisDotInit); 14.181 this.log = log; 14.182 this.lint = lint; 14.183 }
15.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java Mon May 19 22:00:11 2014 -0700 15.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Thu May 29 13:46:36 2014 -0700 15.3 @@ -1,5 +1,5 @@ 15.4 /* 15.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 15.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 15.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 15.8 * 15.9 * This code is free software; you can redistribute it and/or modify it 15.10 @@ -142,24 +142,24 @@ 15.11 * Main inference entry point - instantiate a generic method type 15.12 * using given argument types and (possibly) an expected target-type. 15.13 */ 15.14 - public Type instantiateMethod(Env<AttrContext> env, 15.15 - List<Type> tvars, 15.16 - MethodType mt, 15.17 - Attr.ResultInfo resultInfo, 15.18 - Symbol msym, 15.19 - List<Type> argtypes, 15.20 - boolean allowBoxing, 15.21 - boolean useVarargs, 15.22 - Resolve.MethodResolutionContext resolveContext, 15.23 - Warner warn) throws InferenceException { 15.24 + Type instantiateMethod( Env<AttrContext> env, 15.25 + List<Type> tvars, 15.26 + MethodType mt, 15.27 + Attr.ResultInfo resultInfo, 15.28 + MethodSymbol msym, 15.29 + List<Type> argtypes, 15.30 + boolean allowBoxing, 15.31 + boolean useVarargs, 15.32 + Resolve.MethodResolutionContext resolveContext, 15.33 + Warner warn) throws InferenceException { 15.34 //-System.err.println("instantiateMethod(" + tvars + ", " + mt + ", " + argtypes + ")"); //DEBUG 15.35 - final InferenceContext inferenceContext = new InferenceContext(tvars); 15.36 + final InferenceContext inferenceContext = new InferenceContext(tvars); //B0 15.37 inferenceException.clear(); 15.38 try { 15.39 DeferredAttr.DeferredAttrContext deferredAttrContext = 15.40 resolveContext.deferredAttrContext(msym, inferenceContext, resultInfo, warn); 15.41 15.42 - resolveContext.methodCheck.argumentsAcceptable(env, deferredAttrContext, 15.43 + resolveContext.methodCheck.argumentsAcceptable(env, deferredAttrContext, //B2 15.44 argtypes, mt.getParameterTypes(), warn); 15.45 15.46 if (allowGraphInference && 15.47 @@ -167,7 +167,8 @@ 15.48 !warn.hasNonSilentLint(Lint.LintCategory.UNCHECKED)) { 15.49 //inject return constraints earlier 15.50 checkWithinBounds(inferenceContext, warn); //propagation 15.51 - Type newRestype = generateReturnConstraints(resultInfo, mt, inferenceContext); 15.52 + Type newRestype = generateReturnConstraints(env.tree, resultInfo, //B3 15.53 + mt, inferenceContext); 15.54 mt = (MethodType)types.createMethodTypeWithReturn(mt, newRestype); 15.55 //propagate outwards if needed 15.56 if (resultInfo.checkContext.inferenceContext().free(resultInfo.pt)) { 15.57 @@ -193,7 +194,7 @@ 15.58 inferenceContext.restvars().nonEmpty() && 15.59 resultInfo != null && 15.60 !warn.hasNonSilentLint(Lint.LintCategory.UNCHECKED)) { 15.61 - generateReturnConstraints(resultInfo, mt, inferenceContext); 15.62 + generateReturnConstraints(env.tree, resultInfo, mt, inferenceContext); 15.63 inferenceContext.solveLegacy(false, warn, LegacyInferenceSteps.EQ_UPPER.steps); //maximizeInst 15.64 mt = (MethodType)inferenceContext.asInstType(mt); 15.65 } 15.66 @@ -210,6 +211,12 @@ 15.67 } else { 15.68 inferenceContext.notifyChange(inferenceContext.boundedVars()); 15.69 } 15.70 + if (resultInfo == null) { 15.71 + /* if the is no result info then we can clear the capture types 15.72 + * cache without affecting any result info check 15.73 + */ 15.74 + inferenceContext.captureTypeCache.clear(); 15.75 + } 15.76 } 15.77 } 15.78 15.79 @@ -218,11 +225,12 @@ 15.80 * call occurs in a context where a type T is expected, use the expected 15.81 * type to derive more constraints on the generic method inference variables. 15.82 */ 15.83 - Type generateReturnConstraints(Attr.ResultInfo resultInfo, 15.84 + Type generateReturnConstraints(JCTree tree, Attr.ResultInfo resultInfo, 15.85 MethodType mt, InferenceContext inferenceContext) { 15.86 + InferenceContext rsInfoInfContext = resultInfo.checkContext.inferenceContext(); 15.87 Type from = mt.getReturnType(); 15.88 if (mt.getReturnType().containsAny(inferenceContext.inferencevars) && 15.89 - resultInfo.checkContext.inferenceContext() != emptyContext) { 15.90 + rsInfoInfContext != emptyContext) { 15.91 from = types.capture(from); 15.92 //add synthetic captured ivars 15.93 for (Type t : from.getTypeArguments()) { 15.94 @@ -231,13 +239,29 @@ 15.95 } 15.96 } 15.97 } 15.98 - Type qtype1 = inferenceContext.asFree(from); 15.99 - Type to = returnConstraintTarget(qtype1, resultInfo.pt); 15.100 - Assert.check(allowGraphInference || !resultInfo.checkContext.inferenceContext().free(to), 15.101 + Type qtype = inferenceContext.asUndetVar(from); 15.102 + Type to = resultInfo.pt; 15.103 + 15.104 + if (qtype.hasTag(VOID)) { 15.105 + to = syms.voidType; 15.106 + } else if (to.hasTag(NONE)) { 15.107 + to = from.isPrimitive() ? from : syms.objectType; 15.108 + } else if (qtype.hasTag(UNDETVAR)) { 15.109 + if (resultInfo.pt.isReference()) { 15.110 + to = generateReturnConstraintsUndetVarToReference( 15.111 + tree, (UndetVar)qtype, to, resultInfo, inferenceContext); 15.112 + } else { 15.113 + if (to.isPrimitive()) { 15.114 + to = generateReturnConstraintsPrimitive(tree, (UndetVar)qtype, to, 15.115 + resultInfo, inferenceContext); 15.116 + } 15.117 + } 15.118 + } 15.119 + Assert.check(allowGraphInference || !rsInfoInfContext.free(to), 15.120 "legacy inference engine cannot handle constraints on both sides of a subtyping assertion"); 15.121 //we need to skip capture? 15.122 Warner retWarn = new Warner(); 15.123 - if (!resultInfo.checkContext.compatible(qtype1, resultInfo.checkContext.inferenceContext().asFree(to), retWarn) || 15.124 + if (!resultInfo.checkContext.compatible(qtype, rsInfoInfContext.asUndetVar(to), retWarn) || 15.125 //unchecked conversion is not allowed in source 7 mode 15.126 (!allowGraphInference && retWarn.hasLint(Lint.LintCategory.UNCHECKED))) { 15.127 throw inferenceException 15.128 @@ -247,30 +271,96 @@ 15.129 return from; 15.130 } 15.131 15.132 - Type returnConstraintTarget(Type from, Type to) { 15.133 - if (from.hasTag(VOID)) { 15.134 - return syms.voidType; 15.135 - } else if (to.hasTag(NONE)) { 15.136 - return from.isPrimitive() ? from : syms.objectType; 15.137 - } else if (from.hasTag(UNDETVAR) && to.isPrimitive()) { 15.138 - if (!allowGraphInference) { 15.139 - //if legacy, just return boxed type 15.140 - return types.boxedClass(to).type; 15.141 + private Type generateReturnConstraintsPrimitive(JCTree tree, UndetVar from, 15.142 + Type to, Attr.ResultInfo resultInfo, InferenceContext inferenceContext) { 15.143 + if (!allowGraphInference) { 15.144 + //if legacy, just return boxed type 15.145 + return types.boxedClass(to).type; 15.146 + } 15.147 + //if graph inference we need to skip conflicting boxed bounds... 15.148 + for (Type t : from.getBounds(InferenceBound.EQ, InferenceBound.UPPER, 15.149 + InferenceBound.LOWER)) { 15.150 + Type boundAsPrimitive = types.unboxedType(t); 15.151 + if (boundAsPrimitive == null || boundAsPrimitive.hasTag(NONE)) { 15.152 + continue; 15.153 } 15.154 - //if graph inference we need to skip conflicting boxed bounds... 15.155 - UndetVar uv = (UndetVar)from; 15.156 - for (Type t : uv.getBounds(InferenceBound.EQ, InferenceBound.LOWER)) { 15.157 - Type boundAsPrimitive = types.unboxedType(t); 15.158 - if (boundAsPrimitive == null) continue; 15.159 - if (types.isConvertible(boundAsPrimitive, to)) { 15.160 - //effectively skip return-type constraint generation (compatibility) 15.161 - return syms.objectType; 15.162 + return generateReferenceToTargetConstraint(tree, from, to, 15.163 + resultInfo, inferenceContext); 15.164 + } 15.165 + return types.boxedClass(to).type; 15.166 + } 15.167 + 15.168 + private Type generateReturnConstraintsUndetVarToReference(JCTree tree, 15.169 + UndetVar from, Type to, Attr.ResultInfo resultInfo, 15.170 + InferenceContext inferenceContext) { 15.171 + Type captureOfTo = types.capture(to); 15.172 + /* T is a reference type, but is not a wildcard-parameterized type, and either 15.173 + */ 15.174 + if (captureOfTo == to) { //not a wildcard parameterized type 15.175 + /* i) B2 contains a bound of one of the forms alpha = S or S <: alpha, 15.176 + * where S is a wildcard-parameterized type, or 15.177 + */ 15.178 + for (Type t : from.getBounds(InferenceBound.EQ, InferenceBound.LOWER)) { 15.179 + Type captureOfBound = types.capture(t); 15.180 + if (captureOfBound != t) { 15.181 + return generateReferenceToTargetConstraint(tree, from, to, 15.182 + resultInfo, inferenceContext); 15.183 } 15.184 } 15.185 - return types.boxedClass(to).type; 15.186 - } else { 15.187 - return to; 15.188 + 15.189 + /* ii) B2 contains two bounds of the forms S1 <: alpha and S2 <: alpha, 15.190 + * where S1 and S2 have supertypes that are two different 15.191 + * parameterizations of the same generic class or interface. 15.192 + */ 15.193 + for (Type aLowerBound : from.getBounds(InferenceBound.LOWER)) { 15.194 + for (Type anotherLowerBound : from.getBounds(InferenceBound.LOWER)) { 15.195 + if (aLowerBound != anotherLowerBound && 15.196 + commonSuperWithDiffParameterization(aLowerBound, anotherLowerBound)) { 15.197 + /* self comment check if any lower bound may be and undetVar, 15.198 + * in that case the result of this call may be a false positive. 15.199 + * Should this be restricted to non free types? 15.200 + */ 15.201 + return generateReferenceToTargetConstraint(tree, from, to, 15.202 + resultInfo, inferenceContext); 15.203 + } 15.204 + } 15.205 + } 15.206 } 15.207 + 15.208 + /* T is a parameterization of a generic class or interface, G, 15.209 + * and B2 contains a bound of one of the forms alpha = S or S <: alpha, 15.210 + * where there exists no type of the form G<...> that is a 15.211 + * supertype of S, but the raw type G is a supertype of S 15.212 + */ 15.213 + if (to.isParameterized()) { 15.214 + for (Type t : from.getBounds(InferenceBound.EQ, InferenceBound.LOWER)) { 15.215 + Type sup = types.asSuper(t, to.tsym); 15.216 + if (sup != null && sup.isRaw()) { 15.217 + return generateReferenceToTargetConstraint(tree, from, to, 15.218 + resultInfo, inferenceContext); 15.219 + } 15.220 + } 15.221 + } 15.222 + return to; 15.223 + } 15.224 + 15.225 + private boolean commonSuperWithDiffParameterization(Type t, Type s) { 15.226 + Pair<Type, Type> supers = getParameterizedSupers(t, s); 15.227 + return (supers != null && !types.isSameType(supers.fst, supers.snd)); 15.228 + } 15.229 + 15.230 + private Type generateReferenceToTargetConstraint(JCTree tree, UndetVar from, 15.231 + Type to, Attr.ResultInfo resultInfo, 15.232 + InferenceContext inferenceContext) { 15.233 + inferenceContext.solve(List.of(from.qtype), new Warner()); 15.234 + Type capturedType = resultInfo.checkContext.inferenceContext() 15.235 + .cachedCapture(tree, from.inst, false); 15.236 + if (types.isConvertible(capturedType, 15.237 + resultInfo.checkContext.inferenceContext().asUndetVar(to))) { 15.238 + //effectively skip additional return-type constraint generation (compatibility) 15.239 + return syms.objectType; 15.240 + } 15.241 + return to; 15.242 } 15.243 15.244 /** 15.245 @@ -280,7 +370,7 @@ 15.246 ListBuffer<Type> todo = new ListBuffer<>(); 15.247 //step 1 - create fresh tvars 15.248 for (Type t : vars) { 15.249 - UndetVar uv = (UndetVar)inferenceContext.asFree(t); 15.250 + UndetVar uv = (UndetVar)inferenceContext.asUndetVar(t); 15.251 List<Type> upperBounds = uv.getBounds(InferenceBound.UPPER); 15.252 if (Type.containsAny(upperBounds, vars)) { 15.253 TypeSymbol fresh_tvar = new TypeVariableSymbol(Flags.SYNTHETIC, uv.qtype.tsym.name, null, uv.qtype.tsym.owner); 15.254 @@ -399,7 +489,7 @@ 15.255 return types.createErrorType(funcInterface); 15.256 } 15.257 for (Type p : descParameterTypes) { 15.258 - if (!types.isSameType(funcInterfaceContext.asFree(p), paramTypes.head)) { 15.259 + if (!types.isSameType(funcInterfaceContext.asUndetVar(p), paramTypes.head)) { 15.260 checkContext.report(pos, diags.fragment("no.suitable.functional.intf.inst", funcInterface)); 15.261 return types.createErrorType(funcInterface); 15.262 } 15.263 @@ -515,6 +605,32 @@ 15.264 /** max number of incorporation rounds */ 15.265 static final int MAX_INCORPORATION_STEPS = 100; 15.266 15.267 + /* If for two types t and s there is a least upper bound that is a 15.268 + * parameterized type G, then there exists a supertype of 't' of the form 15.269 + * G<T1, ..., Tn> and a supertype of 's' of the form G<S1, ..., Sn> 15.270 + * which will be returned by this method. If no such supertypes exists then 15.271 + * null is returned. 15.272 + * 15.273 + * As an example for the following input: 15.274 + * 15.275 + * t = java.util.ArrayList<java.lang.String> 15.276 + * s = java.util.List<T> 15.277 + * 15.278 + * we get this ouput: 15.279 + * 15.280 + * Pair[java.util.List<java.lang.String>,java.util.List<T>] 15.281 + */ 15.282 + private Pair<Type, Type> getParameterizedSupers(Type t, Type s) { 15.283 + Type lubResult = types.lub(t, s); 15.284 + if (lubResult == syms.errType || lubResult == syms.botType || 15.285 + !lubResult.isParameterized()) { 15.286 + return null; 15.287 + } 15.288 + Type asSuperOfT = types.asSuper(t, lubResult.tsym); 15.289 + Type asSuperOfS = types.asSuper(s, lubResult.tsym); 15.290 + return new Pair<>(asSuperOfT, asSuperOfS); 15.291 + } 15.292 + 15.293 /** 15.294 * This enumeration defines an entry point for doing inference variable 15.295 * bound incorporation - it can be used to inject custom incorporation 15.296 @@ -533,22 +649,23 @@ 15.297 if (uv.inst != null) { 15.298 Type inst = uv.inst; 15.299 for (Type u : uv.getBounds(InferenceBound.UPPER)) { 15.300 - if (!isSubtype(inst, inferenceContext.asFree(u), warn, infer)) { 15.301 + if (!isSubtype(inst, inferenceContext.asUndetVar(u), warn, infer)) { 15.302 infer.reportBoundError(uv, BoundErrorKind.UPPER); 15.303 } 15.304 } 15.305 for (Type l : uv.getBounds(InferenceBound.LOWER)) { 15.306 - if (!isSubtype(inferenceContext.asFree(l), inst, warn, infer)) { 15.307 + if (!isSubtype(inferenceContext.asUndetVar(l), inst, warn, infer)) { 15.308 infer.reportBoundError(uv, BoundErrorKind.LOWER); 15.309 } 15.310 } 15.311 for (Type e : uv.getBounds(InferenceBound.EQ)) { 15.312 - if (!isSameType(inst, inferenceContext.asFree(e), infer)) { 15.313 + if (!isSameType(inst, inferenceContext.asUndetVar(e), infer)) { 15.314 infer.reportBoundError(uv, BoundErrorKind.EQ); 15.315 } 15.316 } 15.317 } 15.318 } 15.319 + 15.320 @Override 15.321 boolean accepts(UndetVar uv, InferenceContext inferenceContext) { 15.322 //applies to all undetvars 15.323 @@ -594,12 +711,12 @@ 15.324 for (Type e : uv.getBounds(InferenceBound.EQ)) { 15.325 if (e.containsAny(inferenceContext.inferenceVars())) continue; 15.326 for (Type u : uv.getBounds(InferenceBound.UPPER)) { 15.327 - if (!isSubtype(e, inferenceContext.asFree(u), warn, infer)) { 15.328 + if (!isSubtype(e, inferenceContext.asUndetVar(u), warn, infer)) { 15.329 infer.reportBoundError(uv, BoundErrorKind.BAD_EQ_UPPER); 15.330 } 15.331 } 15.332 for (Type l : uv.getBounds(InferenceBound.LOWER)) { 15.333 - if (!isSubtype(inferenceContext.asFree(l), e, warn, infer)) { 15.334 + if (!isSubtype(inferenceContext.asUndetVar(l), e, warn, infer)) { 15.335 infer.reportBoundError(uv, BoundErrorKind.BAD_EQ_LOWER); 15.336 } 15.337 } 15.338 @@ -615,7 +732,7 @@ 15.339 Infer infer = inferenceContext.infer(); 15.340 for (Type b1 : uv.getBounds(InferenceBound.UPPER)) { 15.341 for (Type b2 : uv.getBounds(InferenceBound.LOWER)) { 15.342 - isSubtype(inferenceContext.asFree(b2), inferenceContext.asFree(b1), warn , infer); 15.343 + isSubtype(inferenceContext.asUndetVar(b2), inferenceContext.asUndetVar(b1), warn , infer); 15.344 } 15.345 } 15.346 } 15.347 @@ -629,7 +746,7 @@ 15.348 Infer infer = inferenceContext.infer(); 15.349 for (Type b1 : uv.getBounds(InferenceBound.UPPER)) { 15.350 for (Type b2 : uv.getBounds(InferenceBound.EQ)) { 15.351 - isSubtype(inferenceContext.asFree(b2), inferenceContext.asFree(b1), warn, infer); 15.352 + isSubtype(inferenceContext.asUndetVar(b2), inferenceContext.asUndetVar(b1), warn, infer); 15.353 } 15.354 } 15.355 } 15.356 @@ -643,12 +760,59 @@ 15.357 Infer infer = inferenceContext.infer(); 15.358 for (Type b1 : uv.getBounds(InferenceBound.EQ)) { 15.359 for (Type b2 : uv.getBounds(InferenceBound.LOWER)) { 15.360 - isSubtype(inferenceContext.asFree(b2), inferenceContext.asFree(b1), warn, infer); 15.361 + isSubtype(inferenceContext.asUndetVar(b2), inferenceContext.asUndetVar(b1), warn, infer); 15.362 } 15.363 } 15.364 } 15.365 }, 15.366 /** 15.367 + * Given a bound set containing {@code alpha <: P<T>} and 15.368 + * {@code alpha <: P<S>} where P is a parameterized type, 15.369 + * perform {@code T = S} (which could lead to new bounds). 15.370 + */ 15.371 + CROSS_UPPER_UPPER() { 15.372 + @Override 15.373 + public void apply(UndetVar uv, InferenceContext inferenceContext, Warner warn) { 15.374 + Infer infer = inferenceContext.infer(); 15.375 + List<Type> boundList = uv.getBounds(InferenceBound.UPPER); 15.376 + List<Type> boundListTail = boundList.tail; 15.377 + while (boundList.nonEmpty()) { 15.378 + List<Type> tmpTail = boundListTail; 15.379 + while (tmpTail.nonEmpty()) { 15.380 + Type b1 = boundList.head; 15.381 + Type b2 = tmpTail.head; 15.382 + if (b1 != b2) { 15.383 + Pair<Type, Type> commonSupers = infer.getParameterizedSupers(b1, b2); 15.384 + if (commonSupers != null) { 15.385 + List<Type> allParamsSuperBound1 = commonSupers.fst.allparams(); 15.386 + List<Type> allParamsSuperBound2 = commonSupers.snd.allparams(); 15.387 + while (allParamsSuperBound1.nonEmpty() && allParamsSuperBound2.nonEmpty()) { 15.388 + //traverse the list of all params comparing them 15.389 + if (!allParamsSuperBound1.head.hasTag(WILDCARD) && 15.390 + !allParamsSuperBound2.head.hasTag(WILDCARD)) { 15.391 + isSameType(inferenceContext.asUndetVar(allParamsSuperBound1.head), 15.392 + inferenceContext.asUndetVar(allParamsSuperBound2.head), infer); 15.393 + } 15.394 + allParamsSuperBound1 = allParamsSuperBound1.tail; 15.395 + allParamsSuperBound2 = allParamsSuperBound2.tail; 15.396 + } 15.397 + Assert.check(allParamsSuperBound1.isEmpty() && allParamsSuperBound2.isEmpty()); 15.398 + } 15.399 + } 15.400 + tmpTail = tmpTail.tail; 15.401 + } 15.402 + boundList = boundList.tail; 15.403 + boundListTail = boundList.tail; 15.404 + } 15.405 + } 15.406 + 15.407 + @Override 15.408 + boolean accepts(UndetVar uv, InferenceContext inferenceContext) { 15.409 + return !uv.isCaptured() && 15.410 + uv.getBounds(InferenceBound.UPPER).nonEmpty(); 15.411 + } 15.412 + }, 15.413 + /** 15.414 * Given a bound set containing {@code alpha == S} and {@code alpha == T} 15.415 * perform {@code S == T} (which could lead to new bounds). 15.416 */ 15.417 @@ -658,7 +822,7 @@ 15.418 for (Type b1 : uv.getBounds(InferenceBound.EQ)) { 15.419 for (Type b2 : uv.getBounds(InferenceBound.EQ)) { 15.420 if (b1 != b2) { 15.421 - isSameType(inferenceContext.asFree(b2), inferenceContext.asFree(b1), infer); 15.422 + isSameType(inferenceContext.asUndetVar(b2), inferenceContext.asUndetVar(b1), infer); 15.423 } 15.424 } 15.425 } 15.426 @@ -673,7 +837,7 @@ 15.427 Infer infer = inferenceContext.infer(); 15.428 for (Type b : uv.getBounds(InferenceBound.UPPER)) { 15.429 if (inferenceContext.inferenceVars().contains(b)) { 15.430 - UndetVar uv2 = (UndetVar)inferenceContext.asFree(b); 15.431 + UndetVar uv2 = (UndetVar)inferenceContext.asUndetVar(b); 15.432 if (uv2.isCaptured()) continue; 15.433 //alpha <: beta 15.434 //0. set beta :> alpha 15.435 @@ -699,7 +863,7 @@ 15.436 Infer infer = inferenceContext.infer(); 15.437 for (Type b : uv.getBounds(InferenceBound.LOWER)) { 15.438 if (inferenceContext.inferenceVars().contains(b)) { 15.439 - UndetVar uv2 = (UndetVar)inferenceContext.asFree(b); 15.440 + UndetVar uv2 = (UndetVar)inferenceContext.asUndetVar(b); 15.441 if (uv2.isCaptured()) continue; 15.442 //alpha :> beta 15.443 //0. set beta <: alpha 15.444 @@ -725,7 +889,7 @@ 15.445 Infer infer = inferenceContext.infer(); 15.446 for (Type b : uv.getBounds(InferenceBound.EQ)) { 15.447 if (inferenceContext.inferenceVars().contains(b)) { 15.448 - UndetVar uv2 = (UndetVar)inferenceContext.asFree(b); 15.449 + UndetVar uv2 = (UndetVar)inferenceContext.asUndetVar(b); 15.450 if (uv2.isCaptured()) continue; 15.451 //alpha == beta 15.452 //0. set beta == alpha 15.453 @@ -1243,7 +1407,7 @@ 15.454 Type solve(UndetVar uv, InferenceContext inferenceContext) { 15.455 Infer infer = inferenceContext.infer(); 15.456 List<Type> hibounds = filterBounds(uv, inferenceContext); 15.457 - //note: lobounds should have at least one element 15.458 + //note: hibounds should have at least one element 15.459 Type owntype = hibounds.tail.tail == null ? hibounds.head : infer.types.glb(hibounds); 15.460 if (owntype.isPrimitive() || owntype.hasTag(ERROR)) { 15.461 throw infer.inferenceException 15.462 @@ -1475,7 +1639,7 @@ 15.463 StringBuilder buf = new StringBuilder(); 15.464 String sep = ""; 15.465 for (Type from : data) { 15.466 - UndetVar uv = (UndetVar)inferenceContext.asFree(from); 15.467 + UndetVar uv = (UndetVar)inferenceContext.asUndetVar(from); 15.468 for (Type bound : uv.getBounds(InferenceBound.values())) { 15.469 if (bound.containsAny(List.from(to.data))) { 15.470 buf.append(sep); 15.471 @@ -1684,7 +1848,7 @@ 15.472 Set<Type> optDepsByNode = stuckDeps.get(i); 15.473 for (Node n_j : nodes) { 15.474 Type j = n_j.data.first(); 15.475 - UndetVar uv_i = (UndetVar)inferenceContext.asFree(i); 15.476 + UndetVar uv_i = (UndetVar)inferenceContext.asUndetVar(i); 15.477 if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) { 15.478 //update i's bound dependencies 15.479 n_i.addDependency(DependencyKind.BOUND, n_j); 15.480 @@ -1833,6 +1997,8 @@ 15.481 }); 15.482 } 15.483 15.484 + /* Returns the corresponding inference variables. 15.485 + */ 15.486 private List<Type> filterVars(Filter<UndetVar> fu) { 15.487 ListBuffer<Type> res = new ListBuffer<>(); 15.488 for (Type t : undetvars) { 15.489 @@ -1890,14 +2056,14 @@ 15.490 * undet vars (used ahead of subtyping/compatibility checks to allow propagation 15.491 * of inference constraints). 15.492 */ 15.493 - final Type asFree(Type t) { 15.494 + final Type asUndetVar(Type t) { 15.495 return types.subst(t, inferencevars, undetvars); 15.496 } 15.497 15.498 - final List<Type> asFree(List<Type> ts) { 15.499 + final List<Type> asUndetVars(List<Type> ts) { 15.500 ListBuffer<Type> buf = new ListBuffer<>(); 15.501 for (Type t : ts) { 15.502 - buf.append(asFree(t)); 15.503 + buf.append(asUndetVar(t)); 15.504 } 15.505 return buf.toList(); 15.506 } 15.507 @@ -2005,8 +2171,10 @@ 15.508 * Copy variable in this inference context to the given context 15.509 */ 15.510 void dupTo(final InferenceContext that) { 15.511 - that.inferencevars = that.inferencevars.appendList(inferencevars); 15.512 - that.undetvars = that.undetvars.appendList(undetvars); 15.513 + that.inferencevars = that.inferencevars.appendList( 15.514 + inferencevars.diff(that.inferencevars)); 15.515 + that.undetvars = that.undetvars.appendList( 15.516 + undetvars.diff(that.undetvars)); 15.517 //set up listeners to notify original inference contexts as 15.518 //propagated vars are inferred in new context 15.519 for (Type t : inferencevars) { 15.520 @@ -2073,7 +2241,7 @@ 15.521 private boolean solveBasic(List<Type> varsToSolve, EnumSet<InferenceStep> steps) { 15.522 boolean changed = false; 15.523 for (Type t : varsToSolve.intersect(restvars())) { 15.524 - UndetVar uv = (UndetVar)asFree(t); 15.525 + UndetVar uv = (UndetVar)asUndetVar(t); 15.526 for (InferenceStep step : steps) { 15.527 if (step.accepts(uv, this)) { 15.528 uv.inst = step.solve(uv, this); 15.529 @@ -2119,6 +2287,36 @@ 15.530 //back-door to infer 15.531 return Infer.this; 15.532 } 15.533 + 15.534 + @Override 15.535 + public String toString() { 15.536 + return "Inference vars: " + inferencevars + '\n' + 15.537 + "Undet vars: " + undetvars; 15.538 + } 15.539 + 15.540 + /* Method Types.capture() generates a new type every time it's applied 15.541 + * to a wildcard parameterized type. This is intended functionality but 15.542 + * there are some cases when what you need is not to generate a new 15.543 + * captured type but to check that a previously generated captured type 15.544 + * is correct. There are cases when caching a captured type for later 15.545 + * reuse is sound. In general two captures from the same AST are equal. 15.546 + * This is why the tree is used as the key of the map below. This map 15.547 + * stores a Type per AST. 15.548 + */ 15.549 + Map<JCTree, Type> captureTypeCache = new HashMap<>(); 15.550 + 15.551 + Type cachedCapture(JCTree tree, Type t, boolean readOnly) { 15.552 + Type captured = captureTypeCache.get(tree); 15.553 + if (captured != null) { 15.554 + return captured; 15.555 + } 15.556 + 15.557 + Type result = types.capture(t); 15.558 + if (result != t && !readOnly) { // then t is a wildcard parameterized type 15.559 + captureTypeCache.put(tree, result); 15.560 + } 15.561 + return result; 15.562 + } 15.563 } 15.564 15.565 final InferenceContext emptyContext = new InferenceContext(List.<Type>nil());
16.1 --- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Mon May 19 22:00:11 2014 -0700 16.2 +++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Thu May 29 13:46:36 2014 -0700 16.3 @@ -1,5 +1,5 @@ 16.4 /* 16.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 16.6 + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. 16.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 16.8 * 16.9 * This code is free software; you can redistribute it and/or modify it 16.10 @@ -36,6 +36,7 @@ 16.11 import com.sun.tools.javac.code.Symbol.ClassSymbol; 16.12 import com.sun.tools.javac.code.Symbol.DynamicMethodSymbol; 16.13 import com.sun.tools.javac.code.Symbol.MethodSymbol; 16.14 +import com.sun.tools.javac.code.Symbol.TypeSymbol; 16.15 import com.sun.tools.javac.code.Symbol.VarSymbol; 16.16 import com.sun.tools.javac.code.Symtab; 16.17 import com.sun.tools.javac.code.Type; 16.18 @@ -50,8 +51,10 @@ 16.19 16.20 import java.util.EnumMap; 16.21 import java.util.HashMap; 16.22 +import java.util.HashSet; 16.23 import java.util.LinkedHashMap; 16.24 import java.util.Map; 16.25 +import java.util.Set; 16.26 16.27 import static com.sun.tools.javac.comp.LambdaToMethod.LambdaSymbolKind.*; 16.28 import static com.sun.tools.javac.code.Flags.*; 16.29 @@ -96,6 +99,9 @@ 16.30 /** dump statistics about lambda code generation */ 16.31 private boolean dumpLambdaToMethodStats; 16.32 16.33 + /** force serializable representation, for stress testing **/ 16.34 + private final boolean forceSerializable; 16.35 + 16.36 /** Flag for alternate metafactories indicating the lambda object is intended to be serializable */ 16.37 public static final int FLAG_SERIALIZABLE = 1 << 0; 16.38 16.39 @@ -131,6 +137,7 @@ 16.40 Options options = Options.instance(context); 16.41 dumpLambdaToMethodStats = options.isSet("dumpLambdaToMethodStats"); 16.42 attr = Attr.instance(context); 16.43 + forceSerializable = options.isSet("forceSerializable"); 16.44 } 16.45 // </editor-fold> 16.46 16.47 @@ -434,13 +441,9 @@ 16.48 public void visitVarDef(JCVariableDecl tree) { 16.49 LambdaTranslationContext lambdaContext = (LambdaTranslationContext)context; 16.50 if (context != null && lambdaContext.getSymbolMap(LOCAL_VAR).containsKey(tree.sym)) { 16.51 - JCExpression init = translate(tree.init); 16.52 - int prevPos = make.pos; 16.53 - try { 16.54 - result = make.at(tree).VarDef((VarSymbol)lambdaContext.getSymbolMap(LOCAL_VAR).get(tree.sym), init); 16.55 - } finally { 16.56 - make.at(prevPos); 16.57 - } 16.58 + tree.init = translate(tree.init); 16.59 + tree.sym = (VarSymbol) lambdaContext.getSymbolMap(LOCAL_VAR).get(tree.sym); 16.60 + result = tree; 16.61 } else if (context != null && lambdaContext.getSymbolMap(TYPE_VAR).containsKey(tree.sym)) { 16.62 JCExpression init = translate(tree.init); 16.63 VarSymbol xsym = (VarSymbol)lambdaContext.getSymbolMap(TYPE_VAR).get(tree.sym); 16.64 @@ -1282,7 +1285,10 @@ 16.65 16.66 @Override 16.67 public void visitNewClass(JCNewClass tree) { 16.68 - if (lambdaNewClassFilter(context(), tree)) { 16.69 + TypeSymbol def = tree.type.tsym; 16.70 + boolean inReferencedClass = currentlyInClass(def); 16.71 + boolean isLocal = def.isLocal(); 16.72 + if ((inReferencedClass && isLocal || lambdaNewClassFilter(context(), tree))) { 16.73 TranslationContext<?> localContext = context(); 16.74 while (localContext != null) { 16.75 if (localContext.tree.getTag() == LAMBDA) { 16.76 @@ -1292,16 +1298,16 @@ 16.77 localContext = localContext.prev; 16.78 } 16.79 } 16.80 - if (context() != null && tree.type.tsym.owner.kind == MTH) { 16.81 + if (context() != null && !inReferencedClass && isLocal) { 16.82 LambdaTranslationContext lambdaContext = (LambdaTranslationContext)context(); 16.83 - captureLocalClassDefs(tree.type.tsym, lambdaContext); 16.84 + captureLocalClassDefs(def, lambdaContext); 16.85 } 16.86 super.visitNewClass(tree); 16.87 } 16.88 //where 16.89 void captureLocalClassDefs(Symbol csym, final LambdaTranslationContext lambdaContext) { 16.90 JCClassDecl localCDef = localClassDefs.get(csym); 16.91 - if (localCDef != null && localCDef.pos < lambdaContext.tree.pos) { 16.92 + if (localCDef != null && lambdaContext.freeVarProcessedLocalClasses.add(csym)) { 16.93 BasicFreeVarCollector fvc = lower.new BasicFreeVarCollector() { 16.94 @Override 16.95 void addFreeVars(ClassSymbol c) { 16.96 @@ -1327,6 +1333,18 @@ 16.97 fvc.scan(localCDef); 16.98 } 16.99 } 16.100 + //where 16.101 + boolean currentlyInClass(Symbol csym) { 16.102 + for (Frame frame : frameStack) { 16.103 + if (frame.tree.hasTag(JCTree.Tag.CLASSDEF)) { 16.104 + JCClassDecl cdef = (JCClassDecl) frame.tree; 16.105 + if (cdef.sym == csym) { 16.106 + return true; 16.107 + } 16.108 + } 16.109 + } 16.110 + return false; 16.111 + } 16.112 16.113 /** 16.114 * Method references to local class constructors, may, if the local 16.115 @@ -1694,6 +1712,9 @@ 16.116 16.117 /** does this functional expression require serialization support? */ 16.118 boolean isSerializable() { 16.119 + if (forceSerializable) { 16.120 + return true; 16.121 + } 16.122 for (Type target : tree.targets) { 16.123 if (types.asSuper(target, syms.serializableType.tsym) != null) { 16.124 return true; 16.125 @@ -1749,6 +1770,11 @@ 16.126 16.127 List<JCVariableDecl> syntheticParams; 16.128 16.129 + /** 16.130 + * to prevent recursion, track local classes processed 16.131 + */ 16.132 + final Set<Symbol> freeVarProcessedLocalClasses; 16.133 + 16.134 LambdaTranslationContext(JCLambda tree) { 16.135 super(tree); 16.136 Frame frame = frameStack.head; 16.137 @@ -1778,6 +1804,8 @@ 16.138 translatedSymbols.put(CAPTURED_VAR, new LinkedHashMap<Symbol, Symbol>()); 16.139 translatedSymbols.put(CAPTURED_THIS, new LinkedHashMap<Symbol, Symbol>()); 16.140 translatedSymbols.put(TYPE_VAR, new LinkedHashMap<Symbol, Symbol>()); 16.141 + 16.142 + freeVarProcessedLocalClasses = new HashSet<>(); 16.143 } 16.144 16.145 /** 16.146 @@ -1888,11 +1916,11 @@ 16.147 }; 16.148 break; 16.149 case LOCAL_VAR: 16.150 - ret = new VarSymbol(FINAL, name, types.erasure(sym.type), translatedSym); 16.151 + ret = new VarSymbol(sym.flags() & FINAL, name, sym.type, translatedSym); 16.152 ((VarSymbol) ret).pos = ((VarSymbol) sym).pos; 16.153 break; 16.154 case PARAM: 16.155 - ret = new VarSymbol(FINAL | PARAMETER, name, types.erasure(sym.type), translatedSym); 16.156 + ret = new VarSymbol((sym.flags() & FINAL) | PARAMETER, name, types.erasure(sym.type), translatedSym); 16.157 ((VarSymbol) ret).pos = ((VarSymbol) sym).pos; 16.158 break; 16.159 default:
17.1 --- a/src/share/classes/com/sun/tools/javac/comp/Lower.java Mon May 19 22:00:11 2014 -0700 17.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java Thu May 29 13:46:36 2014 -0700 17.3 @@ -1,5 +1,5 @@ 17.4 /* 17.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 17.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 17.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 17.8 * 17.9 * This code is free software; you can redistribute it and/or modify it 17.10 @@ -2360,6 +2360,7 @@ 17.11 /** Visitor method: Translate a single node. 17.12 * Attach the source position from the old tree to its replacement tree. 17.13 */ 17.14 + @Override 17.15 public <T extends JCTree> T translate(T tree) { 17.16 if (tree == null) { 17.17 return null;
18.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Mon May 19 22:00:11 2014 -0700 18.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Thu May 29 13:46:36 2014 -0700 18.3 @@ -1,5 +1,5 @@ 18.4 /* 18.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 18.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 18.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 18.8 * 18.9 * This code is free software; you can redistribute it and/or modify it 18.10 @@ -92,11 +92,10 @@ 18.11 TreeInfo treeinfo; 18.12 Types types; 18.13 JCDiagnostic.Factory diags; 18.14 - public final boolean boxingEnabled; // = source.allowBoxing(); 18.15 - public final boolean varargsEnabled; // = source.allowVarargs(); 18.16 + public final boolean boxingEnabled; 18.17 + public final boolean varargsEnabled; 18.18 public final boolean allowMethodHandles; 18.19 - public final boolean allowDefaultMethods; 18.20 - public final boolean allowStructuralMostSpecific; 18.21 + public final boolean allowFunctionalInterfaceMostSpecific; 18.22 private final boolean debugResolve; 18.23 private final boolean compactMethodDiags; 18.24 final EnumSet<VerboseResolutionMode> verboseResolutionMode; 18.25 @@ -137,8 +136,7 @@ 18.26 verboseResolutionMode = VerboseResolutionMode.getVerboseResolutionMode(options); 18.27 Target target = Target.instance(context); 18.28 allowMethodHandles = target.hasMethodHandles(); 18.29 - allowDefaultMethods = source.allowDefaultMethods(); 18.30 - allowStructuralMostSpecific = source.allowStructuralMostSpecific(); 18.31 + allowFunctionalInterfaceMostSpecific = source.allowFunctionalInterfaceMostSpecific(); 18.32 polymorphicSignatureScope = new Scope(syms.noSymbol); 18.33 18.34 inapplicableMethodException = new InapplicableMethodException(diags); 18.35 @@ -567,7 +565,7 @@ 18.36 tvars, 18.37 (MethodType)mt, 18.38 resultInfo, 18.39 - m, 18.40 + (MethodSymbol)m, 18.41 argtypes, 18.42 allowBoxing, 18.43 useVarargs, 18.44 @@ -775,6 +773,7 @@ 18.45 public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) { 18.46 return nilMethodCheck; 18.47 } 18.48 + 18.49 } 18.50 18.51 /** 18.52 @@ -786,6 +785,11 @@ 18.53 void checkArg(DiagnosticPosition pos, boolean varargs, Type actual, Type formal, DeferredAttrContext deferredAttrContext, Warner warn) { 18.54 //do nothing - actual always compatible to formals 18.55 } 18.56 + 18.57 + @Override 18.58 + public String toString() { 18.59 + return "arityMethodCheck"; 18.60 + } 18.61 }; 18.62 18.63 List<Type> dummyArgs(int length) { 18.64 @@ -871,6 +875,11 @@ 18.65 public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) { 18.66 return new MostSpecificCheck(strict, actuals); 18.67 } 18.68 + 18.69 + @Override 18.70 + public String toString() { 18.71 + return "resolveMethodCheck"; 18.72 + } 18.73 }; 18.74 18.75 /** 18.76 @@ -901,8 +910,10 @@ 18.77 18.78 @Override 18.79 public boolean compatible(Type found, Type req, Warner warn) { 18.80 - found = pendingInferenceContext.asFree(found); 18.81 - req = infer.returnConstraintTarget(found, req); 18.82 + found = pendingInferenceContext.asUndetVar(found); 18.83 + if (found.hasTag(UNDETVAR) && req.isPrimitive()) { 18.84 + req = types.boxedClass(req).type; 18.85 + } 18.86 return super.compatible(found, req, warn); 18.87 } 18.88 18.89 @@ -938,8 +949,8 @@ 18.90 18.91 public boolean compatible(Type found, Type req, Warner warn) { 18.92 return strict ? 18.93 - types.isSubtypeUnchecked(found, deferredAttrContext.inferenceContext.asFree(req), warn) : 18.94 - types.isConvertible(found, deferredAttrContext.inferenceContext.asFree(req), warn); 18.95 + types.isSubtypeUnchecked(found, deferredAttrContext.inferenceContext.asUndetVar(req), warn) : 18.96 + types.isConvertible(found, deferredAttrContext.inferenceContext.asUndetVar(req), warn); 18.97 } 18.98 18.99 public void report(DiagnosticPosition pos, JCDiagnostic details) { 18.100 @@ -957,6 +968,12 @@ 18.101 public DeferredAttrContext deferredAttrContext() { 18.102 return deferredAttrContext; 18.103 } 18.104 + 18.105 + @Override 18.106 + public String toString() { 18.107 + return "MethodReferenceCheck"; 18.108 + } 18.109 + 18.110 } 18.111 18.112 /** 18.113 @@ -975,7 +992,12 @@ 18.114 DeferredType dt = (DeferredType)found; 18.115 return dt.check(this); 18.116 } else { 18.117 - return super.check(pos, chk.checkNonVoid(pos, types.capture(U(found.baseType())))); 18.118 + Type uResult = U(found.baseType()); 18.119 + Type capturedType = pos == null || pos.getTree() == null ? 18.120 + types.capture(uResult) : 18.121 + checkContext.inferenceContext() 18.122 + .cachedCapture(pos.getTree(), uResult, true); 18.123 + return super.check(pos, chk.checkNonVoid(pos, capturedType)); 18.124 } 18.125 } 18.126 18.127 @@ -1059,50 +1081,47 @@ 18.128 } 18.129 18.130 public boolean compatible(Type found, Type req, Warner warn) { 18.131 - if (!allowStructuralMostSpecific || actual == null) { 18.132 - return super.compatible(found, req, warn); 18.133 - } else { 18.134 - switch (actual.getTag()) { 18.135 - case DEFERRED: 18.136 - DeferredType dt = (DeferredType) actual; 18.137 - DeferredType.SpeculativeCache.Entry e = dt.speculativeCache.get(deferredAttrContext.msym, deferredAttrContext.phase); 18.138 - return (e == null || e.speculativeTree == deferredAttr.stuckTree) 18.139 - ? super.compatible(found, req, warn) : 18.140 - mostSpecific(found, req, e.speculativeTree, warn); 18.141 - default: 18.142 - return standaloneMostSpecific(found, req, actual, warn); 18.143 + if (allowFunctionalInterfaceMostSpecific && 18.144 + unrelatedFunctionalInterfaces(found, req) && 18.145 + (actual != null && actual.getTag() == DEFERRED)) { 18.146 + DeferredType dt = (DeferredType) actual; 18.147 + DeferredType.SpeculativeCache.Entry e = 18.148 + dt.speculativeCache.get(deferredAttrContext.msym, deferredAttrContext.phase); 18.149 + if (e != null && e.speculativeTree != deferredAttr.stuckTree) { 18.150 + return functionalInterfaceMostSpecific(found, req, e.speculativeTree, warn); 18.151 } 18.152 } 18.153 + return super.compatible(found, req, warn); 18.154 } 18.155 18.156 - private boolean mostSpecific(Type t, Type s, JCTree tree, Warner warn) { 18.157 - MostSpecificChecker msc = new MostSpecificChecker(t, s, warn); 18.158 + /** Whether {@code t} and {@code s} are unrelated functional interface types. */ 18.159 + private boolean unrelatedFunctionalInterfaces(Type t, Type s) { 18.160 + return types.isFunctionalInterface(t.tsym) && 18.161 + types.isFunctionalInterface(s.tsym) && 18.162 + types.asSuper(t, s.tsym) == null && 18.163 + types.asSuper(s, t.tsym) == null; 18.164 + } 18.165 + 18.166 + /** Parameters {@code t} and {@code s} are unrelated functional interface types. */ 18.167 + private boolean functionalInterfaceMostSpecific(Type t, Type s, JCTree tree, Warner warn) { 18.168 + FunctionalInterfaceMostSpecificChecker msc = new FunctionalInterfaceMostSpecificChecker(t, s, warn); 18.169 msc.scan(tree); 18.170 return msc.result; 18.171 } 18.172 18.173 - boolean polyMostSpecific(Type t1, Type t2, Warner warn) { 18.174 - return (!t1.isPrimitive() && t2.isPrimitive()) 18.175 - ? true : super.compatible(t1, t2, warn); 18.176 - } 18.177 - 18.178 - boolean standaloneMostSpecific(Type t1, Type t2, Type exprType, Warner warn) { 18.179 - return (exprType.isPrimitive() == t1.isPrimitive() 18.180 - && exprType.isPrimitive() != t2.isPrimitive()) 18.181 - ? true : super.compatible(t1, t2, warn); 18.182 - } 18.183 - 18.184 /** 18.185 - * Structural checker for most specific. 18.186 + * Tests whether one functional interface type can be considered more specific 18.187 + * than another unrelated functional interface type for the scanned expression. 18.188 */ 18.189 - class MostSpecificChecker extends DeferredAttr.PolyScanner { 18.190 + class FunctionalInterfaceMostSpecificChecker extends DeferredAttr.PolyScanner { 18.191 18.192 final Type t; 18.193 final Type s; 18.194 final Warner warn; 18.195 boolean result; 18.196 18.197 - MostSpecificChecker(Type t, Type s, Warner warn) { 18.198 + /** Parameters {@code t} and {@code s} are unrelated functional interface types. */ 18.199 + FunctionalInterfaceMostSpecificChecker(Type t, Type s, Warner warn) { 18.200 this.t = t; 18.201 this.s = s; 18.202 this.warn = warn; 18.203 @@ -1111,102 +1130,96 @@ 18.204 18.205 @Override 18.206 void skip(JCTree tree) { 18.207 - result &= standaloneMostSpecific(t, s, tree.type, warn); 18.208 + result &= false; 18.209 } 18.210 18.211 @Override 18.212 public void visitConditional(JCConditional tree) { 18.213 - if (tree.polyKind == PolyKind.STANDALONE) { 18.214 - result &= standaloneMostSpecific(t, s, tree.type, warn); 18.215 + scan(tree.truepart); 18.216 + scan(tree.falsepart); 18.217 + } 18.218 + 18.219 + @Override 18.220 + public void visitReference(JCMemberReference tree) { 18.221 + Type desc_t = types.findDescriptorType(t); 18.222 + Type desc_s = types.findDescriptorType(s); 18.223 + // use inference variables here for more-specific inference (18.5.4) 18.224 + if (!types.isSameTypes(desc_t.getParameterTypes(), 18.225 + inferenceContext().asUndetVars(desc_s.getParameterTypes()))) { 18.226 + result &= false; 18.227 } else { 18.228 - super.visitConditional(tree); 18.229 + // compare return types 18.230 + Type ret_t = desc_t.getReturnType(); 18.231 + Type ret_s = desc_s.getReturnType(); 18.232 + if (ret_s.hasTag(VOID)) { 18.233 + result &= true; 18.234 + } else if (ret_t.hasTag(VOID)) { 18.235 + result &= false; 18.236 + } else if (ret_t.isPrimitive() != ret_s.isPrimitive()) { 18.237 + boolean retValIsPrimitive = 18.238 + tree.refPolyKind == PolyKind.STANDALONE && 18.239 + tree.sym.type.getReturnType().isPrimitive(); 18.240 + result &= (retValIsPrimitive == ret_t.isPrimitive()) && 18.241 + (retValIsPrimitive != ret_s.isPrimitive()); 18.242 + } else { 18.243 + result &= MostSpecificCheckContext.super.compatible(ret_t, ret_s, warn); 18.244 + } 18.245 } 18.246 } 18.247 18.248 @Override 18.249 - public void visitApply(JCMethodInvocation tree) { 18.250 - result &= (tree.polyKind == PolyKind.STANDALONE) 18.251 - ? standaloneMostSpecific(t, s, tree.type, warn) 18.252 - : polyMostSpecific(t, s, warn); 18.253 - } 18.254 - 18.255 - @Override 18.256 - public void visitNewClass(JCNewClass tree) { 18.257 - result &= (tree.polyKind == PolyKind.STANDALONE) 18.258 - ? standaloneMostSpecific(t, s, tree.type, warn) 18.259 - : polyMostSpecific(t, s, warn); 18.260 - } 18.261 - 18.262 - @Override 18.263 - public void visitReference(JCMemberReference tree) { 18.264 - if (types.isFunctionalInterface(t.tsym) && 18.265 - types.isFunctionalInterface(s.tsym)) { 18.266 - Type desc_t = types.findDescriptorType(t); 18.267 - Type desc_s = types.findDescriptorType(s); 18.268 - if (types.isSameTypes(desc_t.getParameterTypes(), 18.269 - inferenceContext().asFree(desc_s.getParameterTypes()))) { 18.270 - if (types.asSuper(t, s.tsym) != null || 18.271 - types.asSuper(s, t.tsym) != null) { 18.272 - result &= MostSpecificCheckContext.super.compatible(t, s, warn); 18.273 - } else if (!desc_s.getReturnType().hasTag(VOID)) { 18.274 - //perform structural comparison 18.275 - Type ret_t = desc_t.getReturnType(); 18.276 - Type ret_s = desc_s.getReturnType(); 18.277 - result &= ((tree.refPolyKind == PolyKind.STANDALONE) 18.278 - ? standaloneMostSpecific(ret_t, ret_s, tree.sym.type.getReturnType(), warn) 18.279 - : polyMostSpecific(ret_t, ret_s, warn)); 18.280 - } else { 18.281 - return; 18.282 + public void visitLambda(JCLambda tree) { 18.283 + Type desc_t = types.findDescriptorType(t); 18.284 + Type desc_s = types.findDescriptorType(s); 18.285 + // use inference variables here for more-specific inference (18.5.4) 18.286 + if (!types.isSameTypes(desc_t.getParameterTypes(), 18.287 + inferenceContext().asUndetVars(desc_s.getParameterTypes()))) { 18.288 + result &= false; 18.289 + } else { 18.290 + // compare return types 18.291 + Type ret_t = desc_t.getReturnType(); 18.292 + Type ret_s = desc_s.getReturnType(); 18.293 + if (ret_s.hasTag(VOID)) { 18.294 + result &= true; 18.295 + } else if (ret_t.hasTag(VOID)) { 18.296 + result &= false; 18.297 + } else if (unrelatedFunctionalInterfaces(ret_t, ret_s)) { 18.298 + for (JCExpression expr : lambdaResults(tree)) { 18.299 + result &= functionalInterfaceMostSpecific(ret_t, ret_s, expr, warn); 18.300 } 18.301 + } else if (ret_t.isPrimitive() != ret_s.isPrimitive()) { 18.302 + for (JCExpression expr : lambdaResults(tree)) { 18.303 + boolean retValIsPrimitive = expr.isStandalone() && expr.type.isPrimitive(); 18.304 + result &= (retValIsPrimitive == ret_t.isPrimitive()) && 18.305 + (retValIsPrimitive != ret_s.isPrimitive()); 18.306 + } 18.307 + } else { 18.308 + result &= MostSpecificCheckContext.super.compatible(ret_t, ret_s, warn); 18.309 } 18.310 - } else { 18.311 - result &= false; 18.312 - } 18.313 - } 18.314 - 18.315 - @Override 18.316 - public void visitLambda(JCLambda tree) { 18.317 - if (types.isFunctionalInterface(t.tsym) && 18.318 - types.isFunctionalInterface(s.tsym)) { 18.319 - Type desc_t = types.findDescriptorType(t); 18.320 - Type desc_s = types.findDescriptorType(s); 18.321 - if (types.isSameTypes(desc_t.getParameterTypes(), 18.322 - inferenceContext().asFree(desc_s.getParameterTypes()))) { 18.323 - if (types.asSuper(t, s.tsym) != null || 18.324 - types.asSuper(s, t.tsym) != null) { 18.325 - result &= MostSpecificCheckContext.super.compatible(t, s, warn); 18.326 - } else if (!desc_s.getReturnType().hasTag(VOID)) { 18.327 - //perform structural comparison 18.328 - Type ret_t = desc_t.getReturnType(); 18.329 - Type ret_s = desc_s.getReturnType(); 18.330 - scanLambdaBody(tree, ret_t, ret_s); 18.331 - } else { 18.332 - return; 18.333 - } 18.334 - } 18.335 - } else { 18.336 - result &= false; 18.337 } 18.338 } 18.339 //where 18.340 18.341 - void scanLambdaBody(JCLambda lambda, final Type t, final Type s) { 18.342 + private List<JCExpression> lambdaResults(JCLambda lambda) { 18.343 if (lambda.getBodyKind() == JCTree.JCLambda.BodyKind.EXPRESSION) { 18.344 - result &= MostSpecificCheckContext.this.mostSpecific(t, s, lambda.body, warn); 18.345 + return List.of((JCExpression) lambda.body); 18.346 } else { 18.347 + final ListBuffer<JCExpression> buffer = new ListBuffer<>(); 18.348 DeferredAttr.LambdaReturnScanner lambdaScanner = 18.349 new DeferredAttr.LambdaReturnScanner() { 18.350 @Override 18.351 public void visitReturn(JCReturn tree) { 18.352 if (tree.expr != null) { 18.353 - result &= MostSpecificCheckContext.this.mostSpecific(t, s, tree.expr, warn); 18.354 + buffer.append(tree.expr); 18.355 } 18.356 } 18.357 }; 18.358 lambdaScanner.scan(lambda.body); 18.359 + return buffer.toList(); 18.360 } 18.361 } 18.362 } 18.363 + 18.364 } 18.365 18.366 public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) { 18.367 @@ -1410,7 +1423,7 @@ 18.368 return bestSoFar; 18.369 } else if (useVarargs && (sym.flags() & VARARGS) == 0) { 18.370 return bestSoFar.kind >= ERRONEOUS ? 18.371 - new BadVarargsMethod((ResolveError)bestSoFar) : 18.372 + new BadVarargsMethod((ResolveError)bestSoFar.baseSymbol()) : 18.373 bestSoFar; 18.374 } 18.375 Assert.check(sym.kind < AMBIGUOUS); 18.376 @@ -1502,14 +1515,22 @@ 18.377 if (m2SignatureMoreSpecific) return m2; 18.378 return ambiguityError(m1, m2); 18.379 case AMBIGUOUS: 18.380 - //check if m1 is more specific than all ambiguous methods in m2 18.381 + //compare m1 to ambiguous methods in m2 18.382 AmbiguityError e = (AmbiguityError)m2.baseSymbol(); 18.383 + boolean m1MoreSpecificThanAnyAmbiguous = true; 18.384 + boolean allAmbiguousMoreSpecificThanM1 = true; 18.385 for (Symbol s : e.ambiguousSyms) { 18.386 - if (mostSpecific(argtypes, m1, s, env, site, allowBoxing, useVarargs) != m1) { 18.387 - return e.addAmbiguousSymbol(m1); 18.388 - } 18.389 + Symbol moreSpecific = mostSpecific(argtypes, m1, s, env, site, allowBoxing, useVarargs); 18.390 + m1MoreSpecificThanAnyAmbiguous &= moreSpecific == m1; 18.391 + allAmbiguousMoreSpecificThanM1 &= moreSpecific == s; 18.392 } 18.393 - return m1; 18.394 + if (m1MoreSpecificThanAnyAmbiguous) 18.395 + return m1; 18.396 + //if m1 is more specific than some ambiguous methods, but other ambiguous methods are 18.397 + //more specific than m1, add it as a new ambiguous method: 18.398 + if (!allAmbiguousMoreSpecificThanM1) 18.399 + e.addAmbiguousSymbol(m1); 18.400 + return e; 18.401 default: 18.402 throw new AssertionError(); 18.403 } 18.404 @@ -1527,7 +1548,7 @@ 18.405 currentResolutionContext.methodCheck = 18.406 prevResolutionContext.methodCheck.mostSpecificCheck(actuals, !allowBoxing); 18.407 Type mst = instantiate(env, site, m2, null, 18.408 - adjustArgs(types.lowerBounds(types.memberType(site, m1).getParameterTypes()), m1, maxLength, useVarargs), null, 18.409 + adjustArgs(types.cvarLowerBounds(types.memberType(site, m1).getParameterTypes()), m1, maxLength, useVarargs), null, 18.410 allowBoxing, useVarargs, noteWarner); 18.411 return mst != null && 18.412 !noteWarner.hasLint(Lint.LintCategory.UNCHECKED); 18.413 @@ -1681,7 +1702,6 @@ 18.414 bestSoFar : methodNotFound; 18.415 18.416 for (InterfaceLookupPhase iphase2 : InterfaceLookupPhase.values()) { 18.417 - if (iphase2 == InterfaceLookupPhase.DEFAULT_OK && !allowDefaultMethods) break; 18.418 //keep searching for abstract methods 18.419 for (Type itype : itypes[iphase2.ordinal()]) { 18.420 if (!itype.isInterface()) continue; //skip j.l.Object (included by Types.closure()) 18.421 @@ -1714,10 +1734,8 @@ 18.422 //from superinterfaces) 18.423 if ((s.flags() & (ABSTRACT | INTERFACE | ENUM)) != 0) { 18.424 return this; 18.425 - } else if (rs.allowDefaultMethods) { 18.426 + } else { 18.427 return DEFAULT_OK; 18.428 - } else { 18.429 - return null; 18.430 } 18.431 } 18.432 }, 18.433 @@ -2173,7 +2191,7 @@ 18.434 List<Type> typeargtypes, 18.435 LogResolveHelper logResolveHelper) { 18.436 if (sym.kind >= AMBIGUOUS) { 18.437 - ResolveError errSym = (ResolveError)sym; 18.438 + ResolveError errSym = (ResolveError)sym.baseSymbol(); 18.439 sym = errSym.access(name, qualified ? site.tsym : syms.noSymbol); 18.440 argtypes = logResolveHelper.getArgumentTypes(errSym, sym, name, argtypes); 18.441 if (logResolveHelper.resolveDiagnosticNeeded(site, argtypes, typeargtypes)) { 18.442 @@ -2562,7 +2580,7 @@ 18.443 sym = super.access(env, pos, location, sym); 18.444 } else { 18.445 final JCDiagnostic details = sym.kind == WRONG_MTH ? 18.446 - ((InapplicableSymbolError)sym).errCandidate().snd : 18.447 + ((InapplicableSymbolError)sym.baseSymbol()).errCandidate().snd : 18.448 null; 18.449 sym = new InapplicableSymbolError(sym.kind, "diamondError", currentResolutionContext) { 18.450 @Override 18.451 @@ -2970,12 +2988,12 @@ 18.452 return true; 18.453 case WRONG_MTH: 18.454 InapplicableSymbolError errSym = 18.455 - (InapplicableSymbolError)s; 18.456 + (InapplicableSymbolError)s.baseSymbol(); 18.457 return new Template(MethodCheckDiag.ARITY_MISMATCH.regex()) 18.458 .matches(errSym.errCandidate().snd); 18.459 case WRONG_MTHS: 18.460 InapplicableSymbolsError errSyms = 18.461 - (InapplicableSymbolsError)s; 18.462 + (InapplicableSymbolsError)s.baseSymbol(); 18.463 return errSyms.filterCandidates(errSyms.mapCandidates()).isEmpty(); 18.464 case WRONG_STATICNESS: 18.465 return false; 18.466 @@ -3157,7 +3175,7 @@ 18.467 if (TreeInfo.isStaticSelector(referenceTree.expr, names) && 18.468 argtypes.nonEmpty() && 18.469 (argtypes.head.hasTag(NONE) || 18.470 - types.isSubtypeUnchecked(inferenceContext.asFree(argtypes.head), site))) { 18.471 + types.isSubtypeUnchecked(inferenceContext.asUndetVar(argtypes.head), site))) { 18.472 return new UnboundMethodReferenceLookupHelper(referenceTree, name, 18.473 site, argtypes, typeargtypes, maxPhase); 18.474 } else { 18.475 @@ -3341,9 +3359,9 @@ 18.476 if ((env1.enclClass.sym.flags() & STATIC) != 0) staticOnly = true; 18.477 env1 = env1.outer; 18.478 } 18.479 - if (allowDefaultMethods && c.isInterface() && 18.480 - name == names._super && !isStatic(env) && 18.481 - types.isDirectSuperInterface(c, env.enclClass.sym)) { 18.482 + if (c.isInterface() && 18.483 + name == names._super && !isStatic(env) && 18.484 + types.isDirectSuperInterface(c, env.enclClass.sym)) { 18.485 //this might be a default super call if one of the superinterfaces is 'c' 18.486 for (Type t : pruneInterfaces(env.enclClass.type)) { 18.487 if (t.tsym == c) { 18.488 @@ -4270,7 +4288,11 @@ 18.489 } 18.490 18.491 DeferredAttrContext deferredAttrContext(Symbol sym, InferenceContext inferenceContext, ResultInfo pendingResult, Warner warn) { 18.492 - return deferredAttr.new DeferredAttrContext(attrMode, sym, step, inferenceContext, pendingResult != null ? pendingResult.checkContext.deferredAttrContext() : deferredAttr.emptyDeferredAttrContext, warn); 18.493 + DeferredAttrContext parent = (pendingResult == null) 18.494 + ? deferredAttr.emptyDeferredAttrContext 18.495 + : pendingResult.checkContext.deferredAttrContext(); 18.496 + return deferredAttr.new DeferredAttrContext(attrMode, sym, step, 18.497 + inferenceContext, parent, warn); 18.498 } 18.499 18.500 /**
19.1 --- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Mon May 19 22:00:11 2014 -0700 19.2 +++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Thu May 29 13:46:36 2014 -0700 19.3 @@ -1,5 +1,5 @@ 19.4 /* 19.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 19.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 19.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 19.8 * 19.9 * This code is free software; you can redistribute it and/or modify it 19.10 @@ -835,6 +835,8 @@ 19.11 public void visitReference(JCMemberReference tree) { 19.12 tree.expr = translate(tree.expr, erasure(tree.expr.type)); 19.13 tree.type = erasure(tree.type); 19.14 + if (tree.varargsElement != null) 19.15 + tree.varargsElement = erasure(tree.varargsElement); 19.16 result = tree; 19.17 } 19.18
20.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Mon May 19 22:00:11 2014 -0700 20.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Thu May 29 13:46:36 2014 -0700 20.3 @@ -1,5 +1,5 @@ 20.4 /* 20.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 20.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 20.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 20.8 * 20.9 * This code is free software; you can redistribute it and/or modify it 20.10 @@ -116,10 +116,6 @@ 20.11 */ 20.12 boolean lintClassfile; 20.13 20.14 - /** Switch: allow default methods 20.15 - */ 20.16 - boolean allowDefaultMethods; 20.17 - 20.18 /** Switch: preserve parameter names from the variable table. 20.19 */ 20.20 public boolean saveParameterNames; 20.21 @@ -307,7 +303,6 @@ 20.22 allowVarargs = source.allowVarargs(); 20.23 allowAnnotations = source.allowAnnotations(); 20.24 allowSimplifiedVarargs = source.allowSimplifiedVarargs(); 20.25 - allowDefaultMethods = source.allowDefaultMethods(); 20.26 20.27 saveParameterNames = options.isSet("save-parameter-names"); 20.28 cacheCompletionFailure = options.isUnset("dev"); 20.29 @@ -517,14 +512,14 @@ 20.30 break; 20.31 case CONSTANT_Fieldref: { 20.32 ClassSymbol owner = readClassSymbol(getChar(index + 1)); 20.33 - NameAndType nt = (NameAndType)readPool(getChar(index + 3)); 20.34 + NameAndType nt = readNameAndType(getChar(index + 3)); 20.35 poolObj[i] = new VarSymbol(0, nt.name, nt.uniqueType.type, owner); 20.36 break; 20.37 } 20.38 case CONSTANT_Methodref: 20.39 case CONSTANT_InterfaceMethodref: { 20.40 ClassSymbol owner = readClassSymbol(getChar(index + 1)); 20.41 - NameAndType nt = (NameAndType)readPool(getChar(index + 3)); 20.42 + NameAndType nt = readNameAndType(getChar(index + 3)); 20.43 poolObj[i] = new MethodSymbol(0, nt.name, nt.uniqueType.type, owner); 20.44 break; 20.45 } 20.46 @@ -593,13 +588,34 @@ 20.47 /** Read class entry. 20.48 */ 20.49 ClassSymbol readClassSymbol(int i) { 20.50 - return (ClassSymbol) (readPool(i)); 20.51 + Object obj = readPool(i); 20.52 + if (obj != null && !(obj instanceof ClassSymbol)) 20.53 + throw badClassFile("bad.const.pool.entry", 20.54 + currentClassFile.toString(), 20.55 + "CONSTANT_Class_info", i); 20.56 + return (ClassSymbol)obj; 20.57 } 20.58 20.59 /** Read name. 20.60 */ 20.61 Name readName(int i) { 20.62 - return (Name) (readPool(i)); 20.63 + Object obj = readPool(i); 20.64 + if (obj != null && !(obj instanceof Name)) 20.65 + throw badClassFile("bad.const.pool.entry", 20.66 + currentClassFile.toString(), 20.67 + "CONSTANT_Utf8_info or CONSTANT_String_info", i); 20.68 + return (Name)obj; 20.69 + } 20.70 + 20.71 + /** Read name and type. 20.72 + */ 20.73 + NameAndType readNameAndType(int i) { 20.74 + Object obj = readPool(i); 20.75 + if (obj != null && !(obj instanceof NameAndType)) 20.76 + throw badClassFile("bad.const.pool.entry", 20.77 + currentClassFile.toString(), 20.78 + "CONSTANT_NameAndType_info", i); 20.79 + return (NameAndType)obj; 20.80 } 20.81 20.82 /************************************************************************ 20.83 @@ -1250,7 +1266,7 @@ 20.84 sym.owner.members().remove(sym); 20.85 ClassSymbol self = (ClassSymbol)sym; 20.86 ClassSymbol c = readClassSymbol(nextChar()); 20.87 - NameAndType nt = (NameAndType)readPool(nextChar()); 20.88 + NameAndType nt = readNameAndType(nextChar()); 20.89 20.90 if (c.members_field == null) 20.91 throw badClassFile("bad.enclosing.class", self, c);
21.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Mon May 19 22:00:11 2014 -0700 21.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Thu May 29 13:46:36 2014 -0700 21.3 @@ -1038,7 +1038,7 @@ 21.4 } 21.5 databuf.appendChar(pool.get(inner)); 21.6 databuf.appendChar( 21.7 - inner.owner.kind == TYP ? pool.get(inner.owner) : 0); 21.8 + inner.owner.kind == TYP && !inner.name.isEmpty() ? pool.get(inner.owner) : 0); 21.9 databuf.appendChar( 21.10 !inner.name.isEmpty() ? pool.get(inner.name) : 0); 21.11 databuf.appendChar(flags);
22.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Code.java Mon May 19 22:00:11 2014 -0700 22.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java Thu May 29 13:46:36 2014 -0700 22.3 @@ -1,5 +1,5 @@ 22.4 /* 22.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 22.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 22.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 22.8 * 22.9 * This code is free software; you can redistribute it and/or modify it 22.10 @@ -2189,9 +2189,9 @@ 22.11 // Keep local variables if 22.12 // 1) we need them for debug information 22.13 // 2) it is an exception type and it contains type annotations 22.14 - if (!varDebugInfo && 22.15 - (!var.sym.isExceptionParameter() || 22.16 - var.sym.hasTypeAnnotations())) return; 22.17 + boolean keepLocalVariables = varDebugInfo || 22.18 + (var.sym.isExceptionParameter() && var.sym.hasTypeAnnotations()); 22.19 + if (!keepLocalVariables) return; 22.20 if ((var.sym.flags() & Flags.SYNTHETIC) != 0) return; 22.21 if (varBuffer == null) 22.22 varBuffer = new LocalVar[20];
23.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java Mon May 19 22:00:11 2014 -0700 23.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java Thu May 29 13:46:36 2014 -0700 23.3 @@ -1,5 +1,5 @@ 23.4 /* 23.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 23.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 23.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 23.8 * 23.9 * This code is free software; you can redistribute it and/or modify it 23.10 @@ -2818,7 +2818,7 @@ 23.11 } 23.12 23.13 private LVTAssignAnalyzer(LVTRanges lvtRanges, Symtab syms, Names names) { 23.14 - super(new LVTBits(), syms, names); 23.15 + super(new LVTBits(), syms, names, false); 23.16 lvtInits = (LVTBits)inits; 23.17 this.lvtRanges = lvtRanges; 23.18 }
24.1 --- a/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Mon May 19 22:00:11 2014 -0700 24.2 +++ b/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Thu May 29 13:46:36 2014 -0700 24.3 @@ -35,9 +35,6 @@ 24.4 import java.util.Queue; 24.5 import java.util.ResourceBundle; 24.6 import java.util.Set; 24.7 -import java.util.logging.Handler; 24.8 -import java.util.logging.Level; 24.9 -import java.util.logging.Logger; 24.10 24.11 import javax.annotation.processing.Processor; 24.12 import javax.lang.model.SourceVersion; 24.13 @@ -1304,11 +1301,16 @@ 24.14 * Perform dataflow checks on an attributed parse tree. 24.15 */ 24.16 protected void flow(Env<AttrContext> env, Queue<Env<AttrContext>> results) { 24.17 + if (compileStates.isDone(env, CompileState.FLOW)) { 24.18 + results.add(env); 24.19 + return; 24.20 + } 24.21 + 24.22 try { 24.23 if (shouldStop(CompileState.FLOW)) 24.24 return; 24.25 24.26 - if (relax || compileStates.isDone(env, CompileState.FLOW)) { 24.27 + if (relax) { 24.28 results.add(env); 24.29 return; 24.30 }
25.1 --- a/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Mon May 19 22:00:11 2014 -0700 25.2 +++ b/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Thu May 29 13:46:36 2014 -0700 25.3 @@ -1,5 +1,5 @@ 25.4 /* 25.5 - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 25.6 + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. 25.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 25.8 * 25.9 * This code is free software; you can redistribute it and/or modify it 25.10 @@ -1172,8 +1172,10 @@ 25.11 DCText string = quotedString(); 25.12 if (string != null) { 25.13 skipWhitespace(); 25.14 - if (ch == '@') 25.15 + if (ch == '@' 25.16 + || ch == EOI && bp == buf.length - 1) { 25.17 return m.at(pos).See(List.<DCTree>of(string)); 25.18 + } 25.19 } 25.20 break; 25.21
26.1 --- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Mon May 19 22:00:11 2014 -0700 26.2 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Thu May 29 13:46:36 2014 -0700 26.3 @@ -161,6 +161,7 @@ 26.4 this.allowStaticInterfaceMethods = source.allowStaticInterfaceMethods(); 26.5 this.allowIntersectionTypesInCast = source.allowIntersectionTypesInCast(); 26.6 this.allowTypeAnnotations = source.allowTypeAnnotations(); 26.7 + this.allowAnnotationsAfterTypeParams = source.allowAnnotationsAfterTypeParams(); 26.8 this.keepDocComments = keepDocComments; 26.9 docComments = newDocCommentTable(keepDocComments, fac); 26.10 this.keepLineMap = keepLineMap; 26.11 @@ -254,6 +255,10 @@ 26.12 */ 26.13 boolean allowTypeAnnotations; 26.14 26.15 + /** Switch: should we allow annotations after the method type parameters? 26.16 + */ 26.17 + boolean allowAnnotationsAfterTypeParams; 26.18 + 26.19 /** Switch: is "this" allowed as an identifier? 26.20 * This is needed to parse receiver types. 26.21 */ 26.22 @@ -2020,7 +2025,7 @@ 26.23 /** Creator = [Annotations] Qualident [TypeArguments] ( ArrayCreatorRest | ClassCreatorRest ) 26.24 */ 26.25 JCExpression creator(int newpos, List<JCExpression> typeArgs) { 26.26 - List<JCAnnotation> newAnnotations = annotationsOpt(Tag.ANNOTATION); 26.27 + List<JCAnnotation> newAnnotations = typeAnnotationsOpt(); 26.28 26.29 switch (token.kind) { 26.30 case BYTE: case SHORT: case CHAR: case INT: case LONG: case FLOAT: 26.31 @@ -3401,16 +3406,28 @@ 26.32 * | ModifiersOpt 26.33 * ( Type Ident 26.34 * ( VariableDeclaratorsRest ";" | MethodDeclaratorRest ) 26.35 - * | VOID Ident MethodDeclaratorRest 26.36 - * | TypeParameters (Type | VOID) Ident MethodDeclaratorRest 26.37 + * | VOID Ident VoidMethodDeclaratorRest 26.38 + * | TypeParameters [Annotations] 26.39 + * ( Type Ident MethodDeclaratorRest 26.40 + * | VOID Ident VoidMethodDeclaratorRest 26.41 + * ) 26.42 * | Ident ConstructorDeclaratorRest 26.43 * | TypeParameters Ident ConstructorDeclaratorRest 26.44 * | ClassOrInterfaceOrEnumDeclaration 26.45 * ) 26.46 * InterfaceBodyDeclaration = 26.47 * ";" 26.48 - * | ModifiersOpt Type Ident 26.49 - * ( ConstantDeclaratorsRest | InterfaceMethodDeclaratorRest ";" ) 26.50 + * | ModifiersOpt 26.51 + * ( Type Ident 26.52 + * ( ConstantDeclaratorsRest ";" | MethodDeclaratorRest ) 26.53 + * | VOID Ident MethodDeclaratorRest 26.54 + * | TypeParameters [Annotations] 26.55 + * ( Type Ident MethodDeclaratorRest 26.56 + * | VOID Ident VoidMethodDeclaratorRest 26.57 + * ) 26.58 + * | ClassOrInterfaceOrEnumDeclaration 26.59 + * ) 26.60 + * 26.61 */ 26.62 protected List<JCTree> classOrInterfaceBodyDeclaration(Name className, boolean isInterface) { 26.63 if (token.kind == SEMI) { 26.64 @@ -3439,27 +3456,29 @@ 26.65 } 26.66 List<JCAnnotation> annosAfterParams = annotationsOpt(Tag.ANNOTATION); 26.67 26.68 + if (annosAfterParams.nonEmpty()) { 26.69 + checkAnnotationsAfterTypeParams(annosAfterParams.head.pos); 26.70 + mods.annotations = mods.annotations.appendList(annosAfterParams); 26.71 + if (mods.pos == Position.NOPOS) 26.72 + mods.pos = mods.annotations.head.pos; 26.73 + } 26.74 + 26.75 Token tk = token; 26.76 pos = token.pos; 26.77 JCExpression type; 26.78 boolean isVoid = token.kind == VOID; 26.79 if (isVoid) { 26.80 - if (annosAfterParams.nonEmpty()) 26.81 - illegal(annosAfterParams.head.pos); 26.82 type = to(F.at(pos).TypeIdent(TypeTag.VOID)); 26.83 nextToken(); 26.84 } else { 26.85 - if (annosAfterParams.nonEmpty()) { 26.86 - mods.annotations = mods.annotations.appendList(annosAfterParams); 26.87 - if (mods.pos == Position.NOPOS) 26.88 - mods.pos = mods.annotations.head.pos; 26.89 - } 26.90 // method returns types are un-annotated types 26.91 type = unannotatedType(); 26.92 } 26.93 if (token.kind == LPAREN && !isInterface && type.hasTag(IDENT)) { 26.94 if (isInterface || tk.name() != className) 26.95 error(pos, "invalid.meth.decl.ret.type.req"); 26.96 + else if (annosAfterParams.nonEmpty()) 26.97 + illegal(annosAfterParams.head.pos); 26.98 return List.of(methodDeclaratorRest( 26.99 pos, mods, null, names.init, typarams, 26.100 isInterface, true, dc)); 26.101 @@ -3491,13 +3510,9 @@ 26.102 } 26.103 26.104 /** MethodDeclaratorRest = 26.105 - * FormalParameters BracketsOpt [Throws TypeList] ( MethodBody | [DEFAULT AnnotationValue] ";") 26.106 + * FormalParameters BracketsOpt [THROWS TypeList] ( MethodBody | [DEFAULT AnnotationValue] ";") 26.107 * VoidMethodDeclaratorRest = 26.108 - * FormalParameters [Throws TypeList] ( MethodBody | ";") 26.109 - * InterfaceMethodDeclaratorRest = 26.110 - * FormalParameters BracketsOpt [THROWS TypeList] ";" 26.111 - * VoidInterfaceMethodDeclaratorRest = 26.112 - * FormalParameters [THROWS TypeList] ";" 26.113 + * FormalParameters [THROWS TypeList] ( MethodBody | ";") 26.114 * ConstructorDeclaratorRest = 26.115 * "(" FormalParameterListOpt ")" [THROWS TypeList] MethodBody 26.116 */ 26.117 @@ -4041,6 +4056,12 @@ 26.118 allowTypeAnnotations = true; 26.119 } 26.120 } 26.121 + void checkAnnotationsAfterTypeParams(int pos) { 26.122 + if (!allowAnnotationsAfterTypeParams) { 26.123 + log.error(pos, "annotations.after.type.params.not.supported.in.source", source.name); 26.124 + allowAnnotationsAfterTypeParams = true; 26.125 + } 26.126 + } 26.127 26.128 /* 26.129 * a functional source tree and end position mappings
27.1 --- a/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Mon May 19 22:00:11 2014 -0700 27.2 +++ b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Thu May 29 13:46:36 2014 -0700 27.3 @@ -762,14 +762,14 @@ 27.4 public Set<TypeElement> visitType(TypeElement e, Set<TypeElement> p) { 27.5 // Type parameters are not considered to be enclosed by a type 27.6 scan(e.getTypeParameters(), p); 27.7 - return scan(e.getEnclosedElements(), p); 27.8 + return super.visitType(e, p); 27.9 } 27.10 27.11 @Override 27.12 public Set<TypeElement> visitExecutable(ExecutableElement e, Set<TypeElement> p) { 27.13 // Type parameters are not considered to be enclosed by an executable 27.14 scan(e.getTypeParameters(), p); 27.15 - return scan(e.getEnclosedElements(), p); 27.16 + return super.visitExecutable(e, p); 27.17 } 27.18 27.19 void addAnnotations(Element e, Set<TypeElement> p) {
28.1 --- a/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java Mon May 19 22:00:11 2014 -0700 28.2 +++ b/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java Thu May 29 13:46:36 2014 -0700 28.3 @@ -1,5 +1,5 @@ 28.4 /* 28.5 - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 28.6 + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. 28.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 28.8 * 28.9 * This code is free software; you can redistribute it and/or modify it 28.10 @@ -26,11 +26,8 @@ 28.11 package com.sun.tools.javac.processing; 28.12 28.13 import java.lang.annotation.Annotation; 28.14 -import com.sun.tools.javac.tree.JCTree.*; 28.15 import javax.annotation.processing.*; 28.16 import javax.lang.model.element.*; 28.17 -import javax.lang.model.type.DeclaredType; 28.18 -import javax.lang.model.type.TypeMirror; 28.19 import javax.lang.model.util.*; 28.20 import java.util.*; 28.21 28.22 @@ -114,58 +111,48 @@ 28.23 */ 28.24 public Set<? extends Element> getElementsAnnotatedWith(TypeElement a) { 28.25 Set<Element> result = Collections.emptySet(); 28.26 - Types typeUtil = processingEnv.getTypeUtils(); 28.27 if (a.getKind() != ElementKind.ANNOTATION_TYPE) 28.28 throw new IllegalArgumentException(NOT_AN_ANNOTATION_TYPE + a); 28.29 28.30 - DeclaredType annotationTypeElement; 28.31 - TypeMirror tm = a.asType(); 28.32 - if ( tm instanceof DeclaredType ) 28.33 - annotationTypeElement = (DeclaredType) a.asType(); 28.34 - else 28.35 - throw new AssertionError("Bad implementation type for " + tm); 28.36 - 28.37 - ElementScanner8<Set<Element>, DeclaredType> scanner = 28.38 - new AnnotationSetScanner(result, typeUtil); 28.39 + ElementScanner8<Set<Element>, TypeElement> scanner = 28.40 + new AnnotationSetScanner(result); 28.41 28.42 for (Element element : rootElements) 28.43 - result = scanner.scan(element, annotationTypeElement); 28.44 + result = scanner.scan(element, a); 28.45 28.46 return result; 28.47 } 28.48 28.49 // Could be written as a local class inside getElementsAnnotatedWith 28.50 private class AnnotationSetScanner extends 28.51 - ElementScanner8<Set<Element>, DeclaredType> { 28.52 + ElementScanner8<Set<Element>, TypeElement> { 28.53 // Insertion-order preserving set 28.54 Set<Element> annotatedElements = new LinkedHashSet<Element>(); 28.55 - Types typeUtil; 28.56 28.57 - AnnotationSetScanner(Set<Element> defaultSet, Types typeUtil) { 28.58 + AnnotationSetScanner(Set<Element> defaultSet) { 28.59 super(defaultSet); 28.60 - this.typeUtil = typeUtil; 28.61 } 28.62 28.63 @Override 28.64 - public Set<Element> visitType(TypeElement e, DeclaredType p) { 28.65 + public Set<Element> visitType(TypeElement e, TypeElement p) { 28.66 // Type parameters are not considered to be enclosed by a type 28.67 scan(e.getTypeParameters(), p); 28.68 - return scan(e.getEnclosedElements(), p); 28.69 + return super.visitType(e, p); 28.70 } 28.71 28.72 @Override 28.73 - public Set<Element> visitExecutable(ExecutableElement e, DeclaredType p) { 28.74 + public Set<Element> visitExecutable(ExecutableElement e, TypeElement p) { 28.75 // Type parameters are not considered to be enclosed by an executable 28.76 scan(e.getTypeParameters(), p); 28.77 - return scan(e.getEnclosedElements(), p); 28.78 + return super.visitExecutable(e, p); 28.79 } 28.80 28.81 @Override 28.82 - public Set<Element> scan(Element e, DeclaredType p) { 28.83 + public Set<Element> scan(Element e, TypeElement p) { 28.84 java.util.List<? extends AnnotationMirror> annotationMirrors = 28.85 processingEnv.getElementUtils().getAllAnnotationMirrors(e); 28.86 for (AnnotationMirror annotationMirror : annotationMirrors) { 28.87 - if (typeUtil.isSameType(annotationMirror.getAnnotationType(), p)) 28.88 + if (p.equals(annotationMirror.getAnnotationType().asElement())) 28.89 annotatedElements.add(e); 28.90 } 28.91 e.accept(this, p);
29.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Mon May 19 22:00:11 2014 -0700 29.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Thu May 29 13:46:36 2014 -0700 29.3 @@ -1,5 +1,5 @@ 29.4 # 29.5 -# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 29.6 +# Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 29.7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 29.8 # 29.9 # This code is free software; you can redistribute it and/or modify it 29.10 @@ -123,6 +123,9 @@ 29.11 compiler.err.anon.class.impl.intf.no.qual.for.new=\ 29.12 anonymous class implements interface; cannot have qualifier for new 29.13 29.14 +compiler.err.cant.inherit.from.anon=\ 29.15 + cannot inherit from anonymous class 29.16 + 29.17 # 0: symbol, 1: symbol, 2: symbol 29.18 compiler.err.array.and.varargs=\ 29.19 cannot declare both {0} and {1} in {2} 29.20 @@ -732,6 +735,9 @@ 29.21 bad return type in method reference\n\ 29.22 {0} 29.23 29.24 +compiler.err.lambda.body.neither.value.nor.void.compatible=\ 29.25 + lambda body is neither value nor void compatible 29.26 + 29.27 # 0: list of type 29.28 compiler.err.incompatible.thrown.types.in.mref=\ 29.29 incompatible thrown types {0} in method reference 29.30 @@ -1611,6 +1617,10 @@ 29.31 compiler.warn.varargs.redundant.trustme.anno=\ 29.32 Redundant {0} annotation. {1} 29.33 29.34 +# 0: symbol 29.35 +compiler.warn.access.to.sensitive.member.from.serializable.element=\ 29.36 + access to sensitive member {0} from serializable element can be publicly accessible to untrusted code 29.37 + 29.38 ##### 29.39 29.40 ## The following are tokens which are non-terminals in the language. They should 29.41 @@ -1699,6 +1709,11 @@ 29.42 cannot access {0}\n\ 29.43 {1} 29.44 29.45 +# 0: file name, 1: expected CP entry type, 2: constant pool index 29.46 +compiler.misc.bad.const.pool.entry=\ 29.47 + bad constant pool entry in {0}\n\ 29.48 + expected {1} at index {2} 29.49 + 29.50 # 0: file name, 1: message segment 29.51 compiler.misc.bad.class.file.header=\ 29.52 bad class file: {0}\n\ 29.53 @@ -2311,6 +2326,11 @@ 29.54 (use -source 8 or higher to enable type annotations) 29.55 29.56 # 0: string 29.57 +compiler.err.annotations.after.type.params.not.supported.in.source=\ 29.58 + annotations after method type parameters are not supported in -source {0}\n\ 29.59 +(use -source 8 or higher to enable annotations after method type parameters) 29.60 + 29.61 +# 0: string 29.62 compiler.err.repeatable.annotations.not.supported.in.source=\ 29.63 repeated annotations are not supported in -source {0}\n\ 29.64 (use -source 8 or higher to enable repeated annotations)
30.1 --- a/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties Mon May 19 22:00:11 2014 -0700 30.2 +++ b/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties Thu May 29 13:46:36 2014 -0700 30.3 @@ -1,5 +1,5 @@ 30.4 # 30.5 -# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 30.6 +# Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 30.7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 30.8 # 30.9 # This code is free software; you can redistribute it and/or modify it 30.10 @@ -30,14 +30,14 @@ 30.11 javac.opt.g.lines.vars.source=\u3044\u304F\u3064\u304B\u306E\u30C7\u30D0\u30C3\u30B0\u60C5\u5831\u306E\u307F\u3092\u751F\u6210\u3059\u308B 30.12 javac.opt.nowarn=\u8B66\u544A\u3092\u767A\u751F\u3055\u305B\u306A\u3044 30.13 javac.opt.verbose=\u30B3\u30F3\u30D1\u30A4\u30E9\u306E\u52D5\u4F5C\u306B\u3064\u3044\u3066\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u51FA\u529B\u3059\u308B 30.14 -javac.opt.deprecation=\u975E\u63A8\u5968\u306EAPI\u304C\u4F7F\u7528\u3055\u308C\u3066\u3044\u308B\u30BD\u30FC\u30B9\u306E\u4F4D\u7F6E\u3092\u51FA\u529B\u3059\u308B 30.15 +javac.opt.deprecation=\u975E\u63A8\u5968\u306EAPI\u304C\u4F7F\u7528\u3055\u308C\u3066\u3044\u308B\u30BD\u30FC\u30B9\u306E\u5834\u6240\u3092\u51FA\u529B\u3059\u308B 30.16 javac.opt.classpath=\u30E6\u30FC\u30B6\u30FC\u30FB\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u304A\u3088\u3073\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u3092\u691C\u7D22\u3059\u308B\u4F4D\u7F6E\u3092\u6307\u5B9A\u3059\u308B 30.17 javac.opt.sourcepath=\u5165\u529B\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u691C\u7D22\u3059\u308B\u4F4D\u7F6E\u3092\u6307\u5B9A\u3059\u308B 30.18 -javac.opt.bootclasspath=\u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u30AF\u30E9\u30B9\u30FB\u30D1\u30B9\u306E\u4F4D\u7F6E\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B 30.19 +javac.opt.bootclasspath=\u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u30AF\u30E9\u30B9\u30FB\u30D1\u30B9\u306E\u5834\u6240\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B 30.20 javac.opt.Xbootclasspath.p=\u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u30AF\u30E9\u30B9\u30FB\u30D1\u30B9\u306B\u4ED8\u52A0\u3059\u308B 30.21 javac.opt.Xbootclasspath.a=\u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u30AF\u30E9\u30B9\u30FB\u30D1\u30B9\u306B\u8FFD\u52A0\u3059\u308B 30.22 -javac.opt.endorseddirs=\u63A8\u5968\u898F\u683C\u30D1\u30B9\u306E\u4F4D\u7F6E\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B 30.23 -javac.opt.extdirs=\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u6E08\u307F\u62E1\u5F35\u6A5F\u80FD\u306E\u4F4D\u7F6E\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B 30.24 +javac.opt.endorseddirs=\u63A8\u5968\u898F\u683C\u30D1\u30B9\u306E\u5834\u6240\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B 30.25 +javac.opt.extdirs=\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u6E08\u307F\u62E1\u5F35\u6A5F\u80FD\u306E\u5834\u6240\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B 30.26 javac.opt.processorpath=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u3092\u691C\u7D22\u3059\u308B\u4F4D\u7F6E\u3092\u6307\u5B9A\u3059\u308B 30.27 javac.opt.processor=\u5B9F\u884C\u3059\u308B\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u306E\u540D\u524D\u3002\u30C7\u30D5\u30A9\u30EB\u30C8\u306E\u691C\u51FA\u51E6\u7406\u3092\u30D0\u30A4\u30D1\u30B9 30.28 javac.opt.parameters=\u30E1\u30BD\u30C3\u30C9\u30FB\u30D1\u30E9\u30E1\u30FC\u30BF\u306B\u30EA\u30D5\u30EC\u30AF\u30B7\u30E7\u30F3\u7528\u306E\u30E1\u30BF\u30C7\u30FC\u30BF\u3092\u751F\u6210\u3057\u307E\u3059 30.29 @@ -133,7 +133,7 @@ 30.30 30.31 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 30.32 30.33 -javac.msg.bug=\u30B3\u30F3\u30D1\u30A4\u30E9\u3067\u4F8B\u5916\u304C\u767A\u751F\u3057\u307E\u3057\u305F({0})\u3002Bug Parade\u306B\u540C\u3058\u30D0\u30B0\u304C\u767B\u9332\u3055\u308C\u3066\u3044\u306A\u3044\u3053\u3068\u3092\u3054\u78BA\u8A8D\u306E\u4E0A\u3001Java Developer Connection(http://java.sun.com/webapps/bugreport)\u3067\u30D0\u30B0\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 30.34 +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 30.35 30.36 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 30.37
31.1 --- a/src/share/classes/com/sun/tools/javac/sym/Profiles.java Mon May 19 22:00:11 2014 -0700 31.2 +++ b/src/share/classes/com/sun/tools/javac/sym/Profiles.java Thu May 29 13:46:36 2014 -0700 31.3 @@ -1,5 +1,5 @@ 31.4 /* 31.5 - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. 31.6 + * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. 31.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 31.8 * 31.9 * This code is free software; you can redistribute it and/or modify it 31.10 @@ -153,6 +153,8 @@ 31.11 final int maxProfile = 4; // Three compact profiles plus full JRE 31.12 31.13 MakefileProfiles(Properties p) { 31.14 + // consider crypto, only if java/lang package exists 31.15 + boolean foundJavaLang = false; 31.16 for (int profile = 1; profile <= maxProfile; profile++) { 31.17 String prefix = (profile < maxProfile ? "PROFILE_" + profile : "FULL_JRE"); 31.18 String inclPackages = p.getProperty(prefix + "_RTJAR_INCLUDE_PACKAGES"); 31.19 @@ -161,6 +163,8 @@ 31.20 for (String pkg: inclPackages.substring(1).trim().split("\\s+")) { 31.21 if (pkg.endsWith("/")) 31.22 pkg = pkg.substring(0, pkg.length() - 1); 31.23 + if (foundJavaLang == false && pkg.equals("java/lang")) 31.24 + foundJavaLang = true; 31.25 includePackage(profile, pkg); 31.26 } 31.27 String inclTypes = p.getProperty(prefix + "_RTJAR_INCLUDE_TYPES"); 31.28 @@ -178,6 +182,15 @@ 31.29 } 31.30 } 31.31 } 31.32 + /* 31.33 + * A hack to force javax/crypto package into the compact1 profile, 31.34 + * because this package exists in jce.jar, and therefore not in 31.35 + * ct.sym. Note javax/crypto should exist in a profile along with 31.36 + * javax/net/ssl package. Thus, this package is added to compact1, 31.37 + * implying that it should exist in all three profiles. 31.38 + */ 31.39 + if (foundJavaLang) 31.40 + includePackage(1, "javax/crypto"); 31.41 } 31.42 31.43 @Override
32.1 --- a/src/share/classes/com/sun/tools/javac/tree/JCTree.java Mon May 19 22:00:11 2014 -0700 32.2 +++ b/src/share/classes/com/sun/tools/javac/tree/JCTree.java Thu May 29 13:46:36 2014 -0700 32.3 @@ -609,6 +609,9 @@ 32.4 super.setPos(pos); 32.5 return this; 32.6 } 32.7 + 32.8 + public boolean isPoly() { return false; } 32.9 + public boolean isStandalone() { return true; } 32.10 } 32.11 32.12 /** 32.13 @@ -629,6 +632,9 @@ 32.14 32.15 /** is this poly expression a 'true' poly expression? */ 32.16 public PolyKind polyKind; 32.17 + 32.18 + @Override public boolean isPoly() { return polyKind == PolyKind.POLY; } 32.19 + @Override public boolean isStandalone() { return polyKind == PolyKind.STANDALONE; } 32.20 } 32.21 32.22 /**
33.1 --- a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Mon May 19 22:00:11 2014 -0700 33.2 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Thu May 29 13:46:36 2014 -0700 33.3 @@ -1,5 +1,5 @@ 33.4 /* 33.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 33.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 33.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 33.8 * 33.9 * This code is free software; you can redistribute it and/or modify it 33.10 @@ -831,6 +831,8 @@ 33.11 return symbol(((JCTypeApply) tree).clazz); 33.12 case ANNOTATED_TYPE: 33.13 return symbol(((JCAnnotatedType) tree).underlyingType); 33.14 + case REFERENCE: 33.15 + return ((JCMemberReference) tree).sym; 33.16 default: 33.17 return null; 33.18 }
34.1 --- a/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java Mon May 19 22:00:11 2014 -0700 34.2 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java Thu May 29 13:46:36 2014 -0700 34.3 @@ -1,5 +1,5 @@ 34.4 /* 34.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 34.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 34.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 34.8 * 34.9 * This code is free software; you can redistribute it and/or modify it 34.10 @@ -56,9 +56,9 @@ 34.11 return null; 34.12 } else { 34.13 tree.accept(this); 34.14 - JCTree result = this.result; 34.15 + JCTree tmpResult = this.result; 34.16 this.result = null; 34.17 - return (T)result; // XXX cast 34.18 + return (T)tmpResult; // XXX cast 34.19 } 34.20 } 34.21
35.1 --- a/src/share/classes/com/sun/tools/javadoc/JavadocTool.java Mon May 19 22:00:11 2014 -0700 35.2 +++ b/src/share/classes/com/sun/tools/javadoc/JavadocTool.java Thu May 29 13:46:36 2014 -0700 35.3 @@ -1,5 +1,5 @@ 35.4 /* 35.5 - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. 35.6 + * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. 35.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 35.8 * 35.9 * This code is free software; you can redistribute it and/or modify it 35.10 @@ -30,6 +30,7 @@ 35.11 import java.util.Collection; 35.12 import java.util.EnumSet; 35.13 import java.util.HashMap; 35.14 +import java.util.HashSet; 35.15 import java.util.Map; 35.16 import java.util.Set; 35.17 import javax.tools.JavaFileManager.Location; 35.18 @@ -67,6 +68,7 @@ 35.19 final Messager messager; 35.20 final JavadocClassReader javadocReader; 35.21 final JavadocEnter javadocEnter; 35.22 + final Set<JavaFileObject> uniquefiles; 35.23 35.24 /** 35.25 * Construct a new JavaCompiler processor, using appropriately 35.26 @@ -77,6 +79,7 @@ 35.27 messager = Messager.instance0(context); 35.28 javadocReader = JavadocClassReader.instance0(context); 35.29 javadocEnter = JavadocEnter.instance0(context); 35.30 + uniquefiles = new HashSet<>(); 35.31 } 35.32 35.33 /** 35.34 @@ -147,9 +150,7 @@ 35.35 String name = it.head; 35.36 if (!docClasses && fm != null && name.endsWith(".java") && new File(name).exists()) { 35.37 JavaFileObject fo = fm.getJavaFileObjects(name).iterator().next(); 35.38 - docenv.notice("main.Loading_source_file", name); 35.39 - JCCompilationUnit tree = parse(fo); 35.40 - classTrees.append(tree); 35.41 + parse(fo, classTrees, true); 35.42 } else if (isValidPackageName(name)) { 35.43 names = names.append(name); 35.44 } else if (name.endsWith(".java")) { 35.45 @@ -162,9 +163,7 @@ 35.46 } 35.47 } 35.48 for (JavaFileObject fo: fileObjects) { 35.49 - docenv.notice("main.Loading_source_file", fo.getName()); 35.50 - JCCompilationUnit tree = parse(fo); 35.51 - classTrees.append(tree); 35.52 + parse(fo, classTrees, true); 35.53 } 35.54 35.55 if (!docClasses) { 35.56 @@ -212,7 +211,7 @@ 35.57 * .java files found in such a directory to args. 35.58 */ 35.59 private void parsePackageClasses(String name, 35.60 - Iterable<JavaFileObject> files, 35.61 + List<JavaFileObject> files, 35.62 ListBuffer<JCCompilationUnit> trees, 35.63 List<String> excludedPackages) 35.64 throws IOException { 35.65 @@ -220,7 +219,6 @@ 35.66 return; 35.67 } 35.68 35.69 - boolean hasFiles = false; 35.70 docenv.notice("main.Loading_source_files_for_package", name); 35.71 35.72 if (files == null) { 35.73 @@ -237,16 +235,22 @@ 35.74 } 35.75 files = lb.toList(); 35.76 } 35.77 + if (files.nonEmpty()) { 35.78 + for (JavaFileObject fo : files) { 35.79 + parse(fo, trees, false); 35.80 + } 35.81 + } else { 35.82 + messager.warning(Messager.NOPOS, "main.no_source_files_for_package", 35.83 + name.replace(File.separatorChar, '.')); 35.84 + } 35.85 + } 35.86 35.87 - for (JavaFileObject fo : files) { 35.88 - // messager.notice("main.Loading_source_file", fn); 35.89 + private void parse(JavaFileObject fo, ListBuffer<JCCompilationUnit> trees, 35.90 + boolean trace) { 35.91 + if (uniquefiles.add(fo)) { // ignore duplicates 35.92 + if (trace) 35.93 + docenv.notice("main.Loading_source_file", fo.getName()); 35.94 trees.append(parse(fo)); 35.95 - hasFiles = true; 35.96 - } 35.97 - 35.98 - if (!hasFiles) { 35.99 - messager.warning(Messager.NOPOS, "main.no_source_files_for_package", 35.100 - name.replace(File.separatorChar, '.')); 35.101 } 35.102 } 35.103
36.1 --- a/src/share/classes/com/sun/tools/javap/AttributeWriter.java Mon May 19 22:00:11 2014 -0700 36.2 +++ b/src/share/classes/com/sun/tools/javap/AttributeWriter.java Thu May 29 13:46:36 2014 -0700 36.3 @@ -226,10 +226,7 @@ 36.4 } 36.5 36.6 public Void visitConstantValue(ConstantValue_attribute attr, Void ignore) { 36.7 - if (options.compat) // BUG 6622216 javap names some attributes incorrectly 36.8 - print("Constant value: "); 36.9 - else 36.10 - print("ConstantValue: "); 36.11 + print("ConstantValue: "); 36.12 constantWriter.write(attr.constantvalue_index); 36.13 println(); 36.14 return null; 36.15 @@ -290,20 +287,10 @@ 36.16 36.17 public Void visitInnerClasses(InnerClasses_attribute attr, Void ignore) { 36.18 boolean first = true; 36.19 - if (options.compat) { 36.20 - writeInnerClassHeader(); 36.21 - first = false; 36.22 - } 36.23 for (int i = 0 ; i < attr.classes.length; i++) { 36.24 InnerClasses_attribute.Info info = attr.classes[i]; 36.25 //access 36.26 AccessFlags access_flags = info.inner_class_access_flags; 36.27 - if (options.compat) { 36.28 - // BUG 6622215: javap ignores certain relevant access flags 36.29 - access_flags = access_flags.ignore(ACC_STATIC | ACC_PROTECTED | ACC_PRIVATE | ACC_INTERFACE | ACC_SYNTHETIC | ACC_ENUM); 36.30 - // BUG 6622232: javap gets whitespace confused 36.31 - print(" "); 36.32 - } 36.33 if (options.checkAccess(access_flags)) { 36.34 if (first) { 36.35 writeInnerClassHeader(); 36.36 @@ -345,11 +332,7 @@ 36.37 } 36.38 36.39 private void writeInnerClassHeader() { 36.40 - if (options.compat) // BUG 6622216: javap names some attributes incorrectly 36.41 - print("InnerClass"); 36.42 - else 36.43 - print("InnerClasses"); 36.44 - println(":"); 36.45 + println("InnerClasses:"); 36.46 indent(+1); 36.47 } 36.48 36.49 @@ -547,7 +530,6 @@ 36.50 for (StackMapTable_attribute.stack_map_frame entry : attr.entries) { 36.51 w.write(entry); 36.52 } 36.53 - println(); 36.54 indent(-1); 36.55 return null; 36.56 } 36.57 @@ -559,7 +541,6 @@ 36.58 for (StackMapTable_attribute.stack_map_frame entry : attr.entries) { 36.59 w.write(entry); 36.60 } 36.61 - println(); 36.62 indent(-1); 36.63 return null; 36.64 } 36.65 @@ -571,14 +552,12 @@ 36.66 } 36.67 36.68 public Void visit_same_frame(StackMapTable_attribute.same_frame frame, Void p) { 36.69 - printHeader(frame); 36.70 - println(" /* same */"); 36.71 + printHeader(frame, "/* same */"); 36.72 return null; 36.73 } 36.74 36.75 public Void visit_same_locals_1_stack_item_frame(StackMapTable_attribute.same_locals_1_stack_item_frame frame, Void p) { 36.76 - printHeader(frame); 36.77 - println(" /* same_locals_1_stack_item */"); 36.78 + printHeader(frame, "/* same_locals_1_stack_item */"); 36.79 indent(+1); 36.80 printMap("stack", frame.stack); 36.81 indent(-1); 36.82 @@ -586,8 +565,7 @@ 36.83 } 36.84 36.85 public Void visit_same_locals_1_stack_item_frame_extended(StackMapTable_attribute.same_locals_1_stack_item_frame_extended frame, Void p) { 36.86 - printHeader(frame); 36.87 - println(" /* same_locals_1_stack_item_frame_extended */"); 36.88 + printHeader(frame, "/* same_locals_1_stack_item_frame_extended */"); 36.89 indent(+1); 36.90 println("offset_delta = " + frame.offset_delta); 36.91 printMap("stack", frame.stack); 36.92 @@ -596,8 +574,7 @@ 36.93 } 36.94 36.95 public Void visit_chop_frame(StackMapTable_attribute.chop_frame frame, Void p) { 36.96 - printHeader(frame); 36.97 - println(" /* chop */"); 36.98 + printHeader(frame, "/* chop */"); 36.99 indent(+1); 36.100 println("offset_delta = " + frame.offset_delta); 36.101 indent(-1); 36.102 @@ -605,8 +582,7 @@ 36.103 } 36.104 36.105 public Void visit_same_frame_extended(StackMapTable_attribute.same_frame_extended frame, Void p) { 36.106 - printHeader(frame); 36.107 - println(" /* same_frame_extended */"); 36.108 + printHeader(frame, "/* same_frame_extended */"); 36.109 indent(+1); 36.110 println("offset_delta = " + frame.offset_delta); 36.111 indent(-1); 36.112 @@ -614,21 +590,20 @@ 36.113 } 36.114 36.115 public Void visit_append_frame(StackMapTable_attribute.append_frame frame, Void p) { 36.116 - printHeader(frame); 36.117 - println(" /* append */"); 36.118 + printHeader(frame, "/* append */"); 36.119 indent(+1); 36.120 println("offset_delta = " + frame.offset_delta); 36.121 printMap("locals", frame.locals); 36.122 + indent(-1); 36.123 return null; 36.124 } 36.125 36.126 public Void visit_full_frame(StackMapTable_attribute.full_frame frame, Void p) { 36.127 - printHeader(frame); 36.128 if (frame instanceof StackMap_attribute.stack_map_frame) { 36.129 + printHeader(frame, "offset = " + frame.offset_delta); 36.130 indent(+1); 36.131 - println(" offset = " + frame.offset_delta); 36.132 } else { 36.133 - println(" /* full_frame */"); 36.134 + printHeader(frame, "/* full_frame */"); 36.135 indent(+1); 36.136 println("offset_delta = " + frame.offset_delta); 36.137 } 36.138 @@ -638,8 +613,9 @@ 36.139 return null; 36.140 } 36.141 36.142 - void printHeader(StackMapTable_attribute.stack_map_frame frame) { 36.143 - print(" frame_type = " + frame.frame_type); 36.144 + void printHeader(StackMapTable_attribute.stack_map_frame frame, String extra) { 36.145 + print("frame_type = " + frame.frame_type + " "); 36.146 + println(extra); 36.147 } 36.148 36.149 void printMap(String name, StackMapTable_attribute.verification_type_info[] map) { 36.150 @@ -710,10 +686,7 @@ 36.151 } 36.152 36.153 String toHex(byte b, int w) { 36.154 - if (options.compat) // BUG 6622260: javap prints negative bytes incorrectly in hex 36.155 - return toHex((int) b, w); 36.156 - else 36.157 - return toHex(b & 0xff, w); 36.158 + return toHex(b & 0xff, w); 36.159 } 36.160 36.161 static String toHex(int i) {
37.1 --- a/src/share/classes/com/sun/tools/javap/BasicWriter.java Mon May 19 22:00:11 2014 -0700 37.2 +++ b/src/share/classes/com/sun/tools/javap/BasicWriter.java Thu May 29 13:46:36 2014 -0700 37.3 @@ -151,12 +151,22 @@ 37.4 for (int i = 0; i < s.length(); i++) { 37.5 char c = s.charAt(i); 37.6 switch (c) { 37.7 + case ' ': 37.8 + pendingSpaces++; 37.9 + break; 37.10 + 37.11 case '\n': 37.12 println(); 37.13 break; 37.14 + 37.15 default: 37.16 if (buffer.length() == 0) 37.17 indent(); 37.18 + if (pendingSpaces > 0) { 37.19 + for (int sp = 0; sp < pendingSpaces; sp++) 37.20 + buffer.append(' '); 37.21 + pendingSpaces = 0; 37.22 + } 37.23 buffer.append(c); 37.24 } 37.25 } 37.26 @@ -164,6 +174,8 @@ 37.27 } 37.28 37.29 protected void println() { 37.30 + // ignore/discard pending spaces 37.31 + pendingSpaces = 0; 37.32 out.println(buffer); 37.33 buffer.setLength(0); 37.34 } 37.35 @@ -173,26 +185,21 @@ 37.36 } 37.37 37.38 protected void tab() { 37.39 - if (buffer.length() == 0) 37.40 - indent(); 37.41 - space(indentCount * indentWidth + tabColumn - buffer.length()); 37.42 + int col = indentCount * indentWidth + tabColumn; 37.43 + pendingSpaces += (col <= buffer.length() ? 1 : col - buffer.length()); 37.44 } 37.45 37.46 private void indent() { 37.47 - space(indentCount * indentWidth); 37.48 + pendingSpaces += (indentCount * indentWidth); 37.49 } 37.50 37.51 - private void space(int n) { 37.52 - for (int i = 0; i < n; i++) 37.53 - buffer.append(' '); 37.54 - } 37.55 - 37.56 - private PrintWriter out; 37.57 - private StringBuilder buffer; 37.58 + private final PrintWriter out; 37.59 + private final StringBuilder buffer; 37.60 private int indentCount; 37.61 - private int indentWidth; 37.62 - private int tabColumn; 37.63 + private final int indentWidth; 37.64 + private final int tabColumn; 37.65 private boolean pendingNewline; 37.66 + private int pendingSpaces; 37.67 } 37.68 } 37.69
38.1 --- a/src/share/classes/com/sun/tools/javap/ClassWriter.java Mon May 19 22:00:11 2014 -0700 38.2 +++ b/src/share/classes/com/sun/tools/javap/ClassWriter.java Thu May 29 13:46:36 2014 -0700 38.3 @@ -1,5 +1,5 @@ 38.4 /* 38.5 - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. 38.6 + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. 38.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 38.8 * 38.9 * This code is free software; you can redistribute it and/or modify it 38.10 @@ -120,7 +120,7 @@ 38.11 public void write(ClassFile cf) { 38.12 setClassFile(cf); 38.13 38.14 - if ((options.sysInfo || options.verbose) && !options.compat) { 38.15 + if (options.sysInfo || options.verbose) { 38.16 if (uri != null) { 38.17 if (uri.getScheme().equals("file")) 38.18 println("Classfile " + uri.getPath()); 38.19 @@ -152,7 +152,7 @@ 38.20 println("Compiled from \"" + getSourceFile((SourceFile_attribute) sfa) + "\""); 38.21 } 38.22 38.23 - if ((options.sysInfo || options.verbose) && !options.compat) { 38.24 + if (options.sysInfo || options.verbose) { 38.25 indent(-1); 38.26 } 38.27 38.28 @@ -202,11 +202,9 @@ 38.29 if (options.verbose) { 38.30 println(); 38.31 indent(+1); 38.32 - attrWriter.write(cf, cf.attributes, constant_pool); 38.33 println("minor version: " + cf.minor_version); 38.34 println("major version: " + cf.major_version); 38.35 - if (!options.compat) 38.36 - writeList("flags: ", flags.getClassFlags(), "\n"); 38.37 + writeList("flags: ", flags.getClassFlags(), "\n"); 38.38 indent(-1); 38.39 constantWriter.writeConstantPool(); 38.40 } else { 38.41 @@ -219,6 +217,10 @@ 38.42 writeMethods(); 38.43 indent(-1); 38.44 println("}"); 38.45 + 38.46 + if (options.verbose) { 38.47 + attrWriter.write(cf, cf.attributes, constant_pool); 38.48 + } 38.49 } 38.50 // where 38.51 class JavaTypePrinter implements Type.Visitor<StringBuilder,StringBuilder> { 38.52 @@ -372,7 +374,7 @@ 38.53 } 38.54 print(" "); 38.55 print(getFieldName(f)); 38.56 - if (options.showConstants && !options.compat) { // BUG 4111861 print static final field contents 38.57 + if (options.showConstants) { 38.58 Attribute a = f.attributes.get(Attribute.ConstantValue); 38.59 if (a instanceof ConstantValue_attribute) { 38.60 print(" = "); 38.61 @@ -385,21 +387,23 @@ 38.62 38.63 indent(+1); 38.64 38.65 + boolean showBlank = false; 38.66 + 38.67 if (options.showDescriptors) 38.68 println("descriptor: " + getValue(f.descriptor)); 38.69 38.70 - if (options.verbose && !options.compat) 38.71 + if (options.verbose) 38.72 writeList("flags: ", flags.getFieldFlags(), "\n"); 38.73 38.74 if (options.showAllAttrs) { 38.75 for (Attribute attr: f.attributes) 38.76 attrWriter.write(f, attr, constant_pool); 38.77 - println(); 38.78 + showBlank = true; 38.79 } 38.80 38.81 indent(-1); 38.82 38.83 - if (options.showDisassembled || options.showLineAndLocalVariableTables) 38.84 + if (showBlank || options.showDisassembled || options.showLineAndLocalVariableTables) 38.85 println(); 38.86 } 38.87 38.88 @@ -485,7 +489,7 @@ 38.89 println("descriptor: " + getValue(m.descriptor)); 38.90 } 38.91 38.92 - if (options.verbose && !options.compat) { 38.93 + if (options.verbose) { 38.94 writeList("flags: ", flags.getMethodFlags(), "\n"); 38.95 } 38.96 38.97 @@ -498,27 +502,23 @@ 38.98 report("Unexpected or invalid value for Code attribute"); 38.99 } 38.100 38.101 - if (options.showDisassembled && !options.showAllAttrs) { 38.102 - if (code != null) { 38.103 + if (options.showAllAttrs) { 38.104 + Attribute[] attrs = m.attributes.attrs; 38.105 + for (Attribute attr: attrs) 38.106 + attrWriter.write(m, attr, constant_pool); 38.107 + } else if (code != null) { 38.108 + if (options.showDisassembled) { 38.109 println("Code:"); 38.110 codeWriter.writeInstrs(code); 38.111 codeWriter.writeExceptionTable(code); 38.112 } 38.113 - } 38.114 38.115 - if (options.showLineAndLocalVariableTables) { 38.116 - if (code != null) { 38.117 + if (options.showLineAndLocalVariableTables) { 38.118 attrWriter.write(code, code.attributes.get(Attribute.LineNumberTable), constant_pool); 38.119 attrWriter.write(code, code.attributes.get(Attribute.LocalVariableTable), constant_pool); 38.120 } 38.121 } 38.122 38.123 - if (options.showAllAttrs) { 38.124 - Attribute[] attrs = m.attributes.attrs; 38.125 - for (Attribute attr: attrs) 38.126 - attrWriter.write(m, attr, constant_pool); 38.127 - } 38.128 - 38.129 indent(-1); 38.130 38.131 // set pendingNewline to write a newline before the next method (if any) 38.132 @@ -555,13 +555,11 @@ 38.133 } 38.134 38.135 Signature_attribute getSignature(Attributes attributes) { 38.136 - if (options.compat) // javap does not recognize recent attributes 38.137 - return null; 38.138 return (Signature_attribute) attributes.get(Attribute.Signature); 38.139 } 38.140 38.141 String adjustVarargs(AccessFlags flags, String params) { 38.142 - if (flags.is(ACC_VARARGS) && !options.compat) { 38.143 + if (flags.is(ACC_VARARGS)) { 38.144 int i = params.lastIndexOf("[]"); 38.145 if (i > 0) 38.146 return params.substring(0, i) + "..." + params.substring(i+2);
39.1 --- a/src/share/classes/com/sun/tools/javap/ConstantWriter.java Mon May 19 22:00:11 2014 -0700 39.2 +++ b/src/share/classes/com/sun/tools/javap/ConstantWriter.java Thu May 29 13:46:36 2014 -0700 39.3 @@ -64,7 +64,7 @@ 39.4 public Integer visitClass(CONSTANT_Class_info info, Void p) { 39.5 print("#" + info.name_index); 39.6 tab(); 39.7 - println("// " + stringValue(info)); 39.8 + println("// " + stringValue(info)); 39.9 return 1; 39.10 } 39.11 39.12 @@ -76,7 +76,7 @@ 39.13 public Integer visitFieldref(CONSTANT_Fieldref_info info, Void p) { 39.14 print("#" + info.class_index + ".#" + info.name_and_type_index); 39.15 tab(); 39.16 - println("// " + stringValue(info)); 39.17 + println("// " + stringValue(info)); 39.18 return 1; 39.19 } 39.20 39.21 @@ -93,14 +93,14 @@ 39.22 public Integer visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, Void p) { 39.23 print("#" + info.class_index + ".#" + info.name_and_type_index); 39.24 tab(); 39.25 - println("// " + stringValue(info)); 39.26 + println("// " + stringValue(info)); 39.27 return 1; 39.28 } 39.29 39.30 public Integer visitInvokeDynamic(CONSTANT_InvokeDynamic_info info, Void p) { 39.31 print("#" + info.bootstrap_method_attr_index + ":#" + info.name_and_type_index); 39.32 tab(); 39.33 - println("// " + stringValue(info)); 39.34 + println("// " + stringValue(info)); 39.35 return 1; 39.36 } 39.37 39.38 @@ -112,21 +112,21 @@ 39.39 public Integer visitNameAndType(CONSTANT_NameAndType_info info, Void p) { 39.40 print("#" + info.name_index + ":#" + info.type_index); 39.41 tab(); 39.42 - println("// " + stringValue(info)); 39.43 + println("// " + stringValue(info)); 39.44 return 1; 39.45 } 39.46 39.47 public Integer visitMethodref(CONSTANT_Methodref_info info, Void p) { 39.48 print("#" + info.class_index + ".#" + info.name_and_type_index); 39.49 tab(); 39.50 - println("// " + stringValue(info)); 39.51 + println("// " + stringValue(info)); 39.52 return 1; 39.53 } 39.54 39.55 public Integer visitMethodHandle(CONSTANT_MethodHandle_info info, Void p) { 39.56 print("#" + info.reference_kind.tag + ":#" + info.reference_index); 39.57 tab(); 39.58 - println("// " + stringValue(info)); 39.59 + println("// " + stringValue(info)); 39.60 return 1; 39.61 } 39.62 39.63 @@ -140,7 +140,7 @@ 39.64 public Integer visitString(CONSTANT_String_info info, Void p) { 39.65 print("#" + info.string_index); 39.66 tab(); 39.67 - println("// " + stringValue(info)); 39.68 + println("// " + stringValue(info)); 39.69 return 1; 39.70 } 39.71
40.1 --- a/src/share/classes/com/sun/tools/javap/JavapTask.java Mon May 19 22:00:11 2014 -0700 40.2 +++ b/src/share/classes/com/sun/tools/javap/JavapTask.java Thu May 29 13:46:36 2014 -0700 40.3 @@ -195,48 +195,12 @@ 40.4 } 40.5 }, 40.6 40.7 -// new Option(false, "-all") { 40.8 -// void process(JavapTask task, String opt, String arg) { 40.9 -// task.options.showAllAttrs = true; 40.10 -// } 40.11 -// }, 40.12 - 40.13 - new Option(false, "-h") { 40.14 - void process(JavapTask task, String opt, String arg) throws BadArgs { 40.15 - throw task.new BadArgs("err.h.not.supported"); 40.16 - } 40.17 - }, 40.18 - 40.19 - new Option(false, "-verify", "-verify-verbose") { 40.20 - void process(JavapTask task, String opt, String arg) throws BadArgs { 40.21 - throw task.new BadArgs("err.verify.not.supported"); 40.22 - } 40.23 - }, 40.24 - 40.25 new Option(false, "-sysinfo") { 40.26 void process(JavapTask task, String opt, String arg) { 40.27 task.options.sysInfo = true; 40.28 } 40.29 }, 40.30 40.31 - new Option(false, "-Xold") { 40.32 - void process(JavapTask task, String opt, String arg) throws BadArgs { 40.33 - task.log.println(task.getMessage("warn.Xold.not.supported")); 40.34 - } 40.35 - }, 40.36 - 40.37 - new Option(false, "-Xnew") { 40.38 - void process(JavapTask task, String opt, String arg) throws BadArgs { 40.39 - // ignore: this _is_ the new version 40.40 - } 40.41 - }, 40.42 - 40.43 - new Option(false, "-XDcompat") { 40.44 - void process(JavapTask task, String opt, String arg) { 40.45 - task.options.compat = true; 40.46 - } 40.47 - }, 40.48 - 40.49 new Option(false, "-XDdetails") { 40.50 void process(JavapTask task, String opt, String arg) { 40.51 task.options.details = EnumSet.allOf(InstructionDetailWriter.Kind.class); 40.52 @@ -309,7 +273,9 @@ 40.53 void process(JavapTask task, String opt, String arg) throws BadArgs { 40.54 int sep = opt.indexOf(":"); 40.55 try { 40.56 - task.options.indentWidth = Integer.valueOf(opt.substring(sep + 1)); 40.57 + int i = Integer.valueOf(opt.substring(sep + 1)); 40.58 + if (i > 0) // silently ignore invalid values 40.59 + task.options.indentWidth = i; 40.60 } catch (NumberFormatException e) { 40.61 } 40.62 } 40.63 @@ -325,7 +291,9 @@ 40.64 void process(JavapTask task, String opt, String arg) throws BadArgs { 40.65 int sep = opt.indexOf(":"); 40.66 try { 40.67 - task.options.tabColumn = Integer.valueOf(opt.substring(sep + 1)); 40.68 + int i = Integer.valueOf(opt.substring(sep + 1)); 40.69 + if (i > 0) // silently ignore invalid values 40.70 + task.options.tabColumn = i; 40.71 } catch (NumberFormatException e) { 40.72 } 40.73 } 40.74 @@ -466,7 +434,7 @@ 40.75 } catch (BadArgs e) { 40.76 reportError(e.key, e.args); 40.77 if (e.showUsage) { 40.78 - log.println(getMessage("main.usage.summary", progname)); 40.79 + printLines(getMessage("main.usage.summary", progname)); 40.80 } 40.81 return EXIT_CMDERR; 40.82 } catch (InternalError e) { 40.83 @@ -520,7 +488,7 @@ 40.84 throw new BadArgs("err.unknown.option", arg).showUsage(true); 40.85 } 40.86 40.87 - if (!options.compat && options.accessOptions.size() > 1) { 40.88 + if (options.accessOptions.size() > 1) { 40.89 StringBuilder sb = new StringBuilder(); 40.90 for (String opt: options.accessOptions) { 40.91 if (sb.length() > 0) 40.92 @@ -561,8 +529,12 @@ 40.93 } 40.94 } 40.95 40.96 - if (fileManager.handleOption(name, rest)) 40.97 - return; 40.98 + try { 40.99 + if (fileManager.handleOption(name, rest)) 40.100 + return; 40.101 + } catch (IllegalArgumentException e) { 40.102 + throw new BadArgs("err.invalid.use.of.option", name).showUsage(true); 40.103 + } 40.104 40.105 throw new BadArgs("err.unknown.option", name).showUsage(true); 40.106 } 40.107 @@ -581,8 +553,6 @@ 40.108 SourceWriter sourceWriter = SourceWriter.instance(context); 40.109 sourceWriter.setFileManager(fileManager); 40.110 40.111 - attributeFactory.setCompat(options.compat); 40.112 - 40.113 int result = EXIT_OK; 40.114 40.115 for (String className: classes) { 40.116 @@ -878,27 +848,33 @@ 40.117 } 40.118 40.119 private void showHelp() { 40.120 - log.println(getMessage("main.usage", progname)); 40.121 + printLines(getMessage("main.usage", progname)); 40.122 for (Option o: recognizedOptions) { 40.123 String name = o.aliases[0].substring(1); // there must always be at least one name 40.124 if (name.startsWith("X") || name.equals("fullversion") || name.equals("h") || name.equals("verify")) 40.125 continue; 40.126 - log.println(getMessage("main.opt." + name)); 40.127 + printLines(getMessage("main.opt." + name)); 40.128 } 40.129 String[] fmOptions = { "-classpath", "-cp", "-bootclasspath" }; 40.130 for (String o: fmOptions) { 40.131 if (fileManager.isSupportedOption(o) == -1) 40.132 continue; 40.133 String name = o.substring(1); 40.134 - log.println(getMessage("main.opt." + name)); 40.135 + printLines(getMessage("main.opt." + name)); 40.136 } 40.137 40.138 } 40.139 40.140 private void showVersion(boolean full) { 40.141 - log.println(version(full ? "full" : "release")); 40.142 + printLines(version(full ? "full" : "release")); 40.143 } 40.144 40.145 + private void printLines(String msg) { 40.146 + log.println(msg.replace("\n", nl)); 40.147 + } 40.148 + 40.149 + private static final String nl = System.getProperty("line.separator"); 40.150 + 40.151 private static final String versionRBName = "com.sun.tools.javap.resources.version"; 40.152 private static ResourceBundle versionRB; 40.153
41.1 --- a/src/share/classes/com/sun/tools/javap/Options.java Mon May 19 22:00:11 2014 -0700 41.2 +++ b/src/share/classes/com/sun/tools/javap/Options.java Thu May 29 13:46:36 2014 -0700 41.3 @@ -86,8 +86,6 @@ 41.4 public boolean showConstants; 41.5 public boolean sysInfo; 41.6 public boolean showInnerClasses; 41.7 - public int indentWidth = 2; // #spaces per indentWidth level 41.8 - public int tabColumn = 40; // column number for comments 41.9 - 41.10 - public boolean compat; // bug-for-bug compatibility mode with old javap 41.11 + public int indentWidth = 2; // #spaces per indentWidth level; must be > 0 41.12 + public int tabColumn = 40; // column number for comments; must be > 0 41.13 }
42.1 --- a/src/share/classes/com/sun/tools/javap/resources/javap.properties Mon May 19 22:00:11 2014 -0700 42.2 +++ b/src/share/classes/com/sun/tools/javap/resources/javap.properties Thu May 29 13:46:36 2014 -0700 42.3 @@ -6,7 +6,6 @@ 42.4 err.crash=A serious internal error has occurred: {0}\nPlease file a bug report, and include the following information:\n{1} 42.5 err.end.of.file=unexpected end of file while reading {0} 42.6 err.file.not.found=file not found: {0} 42.7 -err.h.not.supported=-h is no longer available - use the 'javah' program 42.8 err.incompatible.options=bad combination of options: {0} 42.9 err.internal.error=internal error: {0} {1} {2} 42.10 err.invalid.arg.for.option=invalid argument for option: {0} 42.11 @@ -14,12 +13,11 @@ 42.12 err.missing.arg=no value given for {0} 42.13 err.no.classes.specified=no classes specified 42.14 err.not.standard.file.manager=can only specify class files when using a standard file manager 42.15 +err.invalid.use.of.option=invalid use of option: {0} 42.16 err.unknown.option=unknown option: {0} 42.17 -err.verify.not.supported=-verify not supported 42.18 err.no.SourceFile.attribute=no SourceFile attribute 42.19 err.source.file.not.found=source file not found 42.20 err.bad.innerclasses.attribute=bad InnerClasses attribute for {0} 42.21 -warn.Xold.not.supported=-Xold is no longer available 42.22 42.23 main.usage.summary=\ 42.24 Usage: {0} <options> <classes>\n\ 42.25 @@ -80,7 +78,7 @@ 42.26 \ -bootclasspath <path> Override location of bootstrap class files 42.27 42.28 main.opt.constants=\ 42.29 -\ -constants Show static final constants 42.30 +\ -constants Show final constants 42.31 42.32 42.33 main.opt.sysinfo=\
43.1 --- a/src/share/classes/com/sun/tools/javap/resources/javap_ja.properties Mon May 19 22:00:11 2014 -0700 43.2 +++ b/src/share/classes/com/sun/tools/javap/resources/javap_ja.properties Thu May 29 13:46:36 2014 -0700 43.3 @@ -3,10 +3,9 @@ 43.4 43.5 err.bad.constant.pool={0}\u306E\u5B9A\u6570\u30D7\u30FC\u30EB\u306E\u8AAD\u53D6\u308A\u4E2D\u306B\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F: {1} 43.6 err.class.not.found=\u30AF\u30E9\u30B9\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: {0} 43.7 -err.crash=\u91CD\u5927\u306A\u5185\u90E8\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F: {0}\n\u6B21\u306E\u60C5\u5831\u3092\u542B\u3080\u30D0\u30B0\u30FB\u30EC\u30DD\u30FC\u30C8\u3092\u30D5\u30A1\u30A4\u30EB\u3057\u3066\u304F\u3060\u3055\u3044:\n{1} 43.8 +err.crash=\u91CD\u5927\u306A\u5185\u90E8\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F: {0}\n\u6B21\u306E\u60C5\u5831\u3092\u542B\u3080bug\u30EC\u30DD\u30FC\u30C8\u3092\u30D5\u30A1\u30A4\u30EB\u3057\u3066\u304F\u3060\u3055\u3044:\n{1} 43.9 err.end.of.file={0}\u306E\u8AAD\u53D6\u308A\u4E2D\u306B\u4E88\u671F\u3057\u306A\u3044\u30D5\u30A1\u30A4\u30EB\u306E\u7D42\u308F\u308A\u304C\u691C\u51FA\u3055\u308C\u307E\u3057\u305F 43.10 err.file.not.found=\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: {0} 43.11 -err.h.not.supported=-h\u306F\u4F7F\u7528\u53EF\u80FD\u3067\u306A\u304F\u306A\u308A\u307E\u3057\u305F - 'javah'\u30D7\u30ED\u30B0\u30E9\u30E0\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044 43.12 err.incompatible.options=\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u7D44\u5408\u305B\u304C\u4E0D\u6B63\u3067\u3059: {0} 43.13 err.internal.error=\u5185\u90E8\u30A8\u30E9\u30FC: {0} {1} {2} 43.14 err.invalid.arg.for.option=\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u5F15\u6570\u304C\u7121\u52B9\u3067\u3059: {0} 43.15 @@ -14,12 +13,11 @@ 43.16 err.missing.arg={0}\u306B\u5024\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093 43.17 err.no.classes.specified=\u30AF\u30E9\u30B9\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093 43.18 err.not.standard.file.manager=\u6A19\u6E96\u30D5\u30A1\u30A4\u30EB\u30FB\u30DE\u30CD\u30FC\u30B8\u30E3\u3092\u4F7F\u7528\u3057\u3066\u3044\u308B\u5834\u5408\u306F\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u307F\u6307\u5B9A\u3067\u304D\u307E\u3059 43.19 +err.invalid.use.of.option=\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u4F7F\u7528\u304C\u7121\u52B9\u3067\u3059: {0} 43.20 err.unknown.option=\u4E0D\u660E\u306A\u30AA\u30D7\u30B7\u30E7\u30F3: {0} 43.21 -err.verify.not.supported=-verify\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093 43.22 err.no.SourceFile.attribute=SourceFile\u5C5E\u6027\u304C\u3042\u308A\u307E\u305B\u3093 43.23 err.source.file.not.found=\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093 43.24 err.bad.innerclasses.attribute={0}\u306EInnerClasses\u5C5E\u6027\u304C\u4E0D\u6B63\u3067\u3059 43.25 -warn.Xold.not.supported=-Xold\u306F\u4F7F\u7528\u3067\u304D\u306A\u304F\u306A\u308A\u307E\u3057\u305F 43.26 43.27 main.usage.summary=\u4F7F\u7528\u65B9\u6CD5: {0} <options> <classes>\n\u4F7F\u7528\u53EF\u80FD\u306A\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u30EA\u30B9\u30C8\u306B\u3064\u3044\u3066\u306F\u3001-help\u3092\u4F7F\u7528\u3057\u307E\u3059 43.28 43.29 @@ -57,9 +55,9 @@ 43.30 43.31 main.opt.cp=\ -cp <path> \u30E6\u30FC\u30B6\u30FC\u30FB\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u691C\u7D22\u3059\u308B\u5834\u6240\u3092\u6307\u5B9A\u3059\u308B 43.32 43.33 -main.opt.bootclasspath=\ -bootclasspath <path> \u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u4F4D\u7F6E\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B 43.34 +main.opt.bootclasspath=\ -bootclasspath <path> \u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u5834\u6240\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B 43.35 43.36 -main.opt.constants=\ -constants \u9759\u7684final\u5B9A\u6570\u3092\u8868\u793A\u3059\u308B 43.37 +main.opt.constants=\ -constants final\u5B9A\u6570\u3092\u8868\u793A\u3059\u308B 43.38 43.39 43.40 main.opt.sysinfo=\ -sysinfo \u51E6\u7406\u3057\u3066\u3044\u308B\u30AF\u30E9\u30B9\u306E\u30B7\u30B9\u30C6\u30E0\u60C5\u5831(\u30D1\u30B9\u3001\u30B5\u30A4\u30BA\u3001\u65E5\u4ED8\u3001MD5\u30CF\u30C3\u30B7\u30E5)\n \u3092\u8868\u793A\u3059\u308B
44.1 --- a/src/share/classes/com/sun/tools/javap/resources/javap_zh_CN.properties Mon May 19 22:00:11 2014 -0700 44.2 +++ b/src/share/classes/com/sun/tools/javap/resources/javap_zh_CN.properties Thu May 29 13:46:36 2014 -0700 44.3 @@ -6,7 +6,6 @@ 44.4 err.crash=\u51FA\u73B0\u4E25\u91CD\u7684\u5185\u90E8\u9519\u8BEF: {0}\n\u8BF7\u5EFA\u7ACB Bug \u62A5\u544A, \u5E76\u5305\u62EC\u4EE5\u4E0B\u4FE1\u606F:\n{1} 44.5 err.end.of.file=\u8BFB\u53D6{0}\u65F6\u51FA\u73B0\u610F\u5916\u7684\u6587\u4EF6\u7ED3\u5C3E 44.6 err.file.not.found=\u627E\u4E0D\u5230\u6587\u4EF6: {0} 44.7 -err.h.not.supported=-h \u4E0D\u518D\u53EF\u7528 - \u8BF7\u4F7F\u7528 'javah' \u7A0B\u5E8F 44.8 err.incompatible.options=\u9009\u9879\u7EC4\u5408\u9519\u8BEF: {0} 44.9 err.internal.error=\u5185\u90E8\u9519\u8BEF: {0} {1} {2} 44.10 err.invalid.arg.for.option=\u9009\u9879\u7684\u53C2\u6570\u65E0\u6548: {0} 44.11 @@ -14,12 +13,11 @@ 44.12 err.missing.arg=\u6CA1\u6709\u4E3A{0}\u6307\u5B9A\u503C 44.13 err.no.classes.specified=\u672A\u6307\u5B9A\u7C7B 44.14 err.not.standard.file.manager=\u4F7F\u7528\u6807\u51C6\u6587\u4EF6\u7BA1\u7406\u5668\u65F6\u53EA\u80FD\u6307\u5B9A\u7C7B\u6587\u4EF6 44.15 +err.invalid.use.of.option=\u9009\u9879\u7684\u4F7F\u7528\u65E0\u6548: {0} 44.16 err.unknown.option=\u672A\u77E5\u9009\u9879: {0} 44.17 -err.verify.not.supported=\u4E0D\u652F\u6301 -verify 44.18 err.no.SourceFile.attribute=\u6CA1\u6709 SourceFile \u5C5E\u6027 44.19 err.source.file.not.found=\u627E\u4E0D\u5230\u6E90\u6587\u4EF6 44.20 err.bad.innerclasses.attribute={0}\u7684 InnerClasses \u5C5E\u6027\u9519\u8BEF 44.21 -warn.Xold.not.supported=-Xold \u4E0D\u518D\u53EF\u7528 44.22 44.23 main.usage.summary=\u7528\u6CD5: {0} <options> <classes>\n\u4F7F\u7528 -help \u5217\u51FA\u53EF\u80FD\u7684\u9009\u9879 44.24 44.25 @@ -59,7 +57,7 @@ 44.26 44.27 main.opt.bootclasspath=\ -bootclasspath <path> \u8986\u76D6\u5F15\u5BFC\u7C7B\u6587\u4EF6\u7684\u4F4D\u7F6E 44.28 44.29 -main.opt.constants=\ -constants \u663E\u793A\u9759\u6001\u6700\u7EC8\u5E38\u91CF 44.30 +main.opt.constants=\ -constants \u663E\u793A\u6700\u7EC8\u5E38\u91CF 44.31 44.32 44.33 main.opt.sysinfo=\ -sysinfo \u663E\u793A\u6B63\u5728\u5904\u7406\u7684\u7C7B\u7684\n \u7CFB\u7EDF\u4FE1\u606F (\u8DEF\u5F84, \u5927\u5C0F, \u65E5\u671F, MD5 \u6563\u5217)
45.1 --- a/test/Makefile Mon May 19 22:00:11 2014 -0700 45.2 +++ b/test/Makefile Thu May 29 13:46:36 2014 -0700 45.3 @@ -186,6 +186,12 @@ 45.4 JTREG_OPTIONS += -timeoutFactor:$(JTREG_TIMEOUT_FACTOR) 45.5 endif 45.6 45.7 +# Default verbosity setting for jtreg 45.8 +JTREG_VERBOSE = fail,error,nopass 45.9 + 45.10 +# Default verbosity setting for jck 45.11 +JCK_VERBOSE = non-pass 45.12 + 45.13 # Assertions: some tests show failures when assertions are enabled. 45.14 # Since javac is typically loaded via the bootclassloader (either via TESTJAVA 45.15 # or TESTBOOTCLASSPATH), you may need -esa to enable assertions in javac. 45.16 @@ -256,6 +262,8 @@ 45.17 # Version of java used to run jtreg. Should normally be the same as TESTJAVA 45.18 # TESTJAVA 45.19 # Version of java to be tested. 45.20 +# JTREG_VERBOSE 45.21 +# Verbosity setting for jtreg 45.22 # JTREG_OPTIONS 45.23 # Additional options for jtreg 45.24 # JTREG_TESTDIRS 45.25 @@ -273,7 +281,7 @@ 45.26 JT_JAVA=$(JT_JAVA) $(JTREG) \ 45.27 -J-Xmx512m \ 45.28 -vmoption:-Xmx768m \ 45.29 - -a -ignore:quiet -v:fail,error,nopass \ 45.30 + -a -ignore:quiet $(if $(JTREG_VERBOSE),-v:$(JTREG_VERBOSE)) \ 45.31 -r:$(JTREG_OUTPUT_DIR)/JTreport \ 45.32 -w:$(JTREG_OUTPUT_DIR)/JTwork \ 45.33 -jdk:$(TESTJAVA) \ 45.34 @@ -312,6 +320,8 @@ 45.35 # Default is JDK 7 45.36 # TESTJAVA 45.37 # Version of java to be tested. 45.38 +# JCK_VERBOSE 45.39 +# Verbosity setting for jtjck 45.40 # JCK_COMPILER_OPTIONS 45.41 # Additional options for JCK-compiler 45.42 # JCK_COMPILER_TESTDIRS 45.43 @@ -325,9 +335,9 @@ 45.44 @rm -f -r $(JCK_COMPILER_OUTPUT_DIR)/work $(JCK_COMPILER_OUTPUT_DIR)/report \ 45.45 $(JCK_COMPILER_OUTPUT_DIR)/diff.html $(JCK_COMPILER_OUTPUT_DIR)/status.txt 45.46 @mkdir -p $(JCK_COMPILER_OUTPUT_DIR) 45.47 - $(JT_JAVA)/bin/java -XX:MaxPermSize=256m -Xmx512m \ 45.48 + $(JT_JAVA)/bin/java -Xmx512m \ 45.49 -jar $(JCK_HOME)/JCK-compiler-8/lib/jtjck.jar \ 45.50 - -v:non-pass \ 45.51 + $(if $(JCK_VERBOSE),-v:$(JCK_VERBOSE)) \ 45.52 -r:$(JCK_COMPILER_OUTPUT_DIR)/report \ 45.53 -w:$(JCK_COMPILER_OUTPUT_DIR)/work \ 45.54 -jdk:$(TESTJAVA) \ 45.55 @@ -361,6 +371,8 @@ 45.56 # Version of java used to run JCK. Should normally be the same as TESTJAVA 45.57 # TESTJAVA 45.58 # Version of java to be tested. 45.59 +# JCK_VERBOSE 45.60 +# Verbosity setting for jtjck 45.61 # JCK_RUNTIME_OPTIONS 45.62 # Additional options for JCK-runtime 45.63 # JCK_RUNTIME_TESTDIRS 45.64 @@ -374,9 +386,9 @@ 45.65 @rm -f -r $(JCK_RUNTIME_OUTPUT_DIR)/work $(JCK_RUNTIME_OUTPUT_DIR)/report \ 45.66 $(JCK_RUNTIME_OUTPUT_DIR)/diff.html $(JCK_RUNTIME_OUTPUT_DIR)/status.txt 45.67 @mkdir -p $(JCK_RUNTIME_OUTPUT_DIR) 45.68 - $(JT_JAVA)/bin/java -XX:MaxPermSize=256m -Xmx512m \ 45.69 + $(JT_JAVA)/bin/java -Xmx512m \ 45.70 -jar $(JCK_HOME)/JCK-runtime-8/lib/jtjck.jar \ 45.71 - -v:non-pass \ 45.72 + $(if $(JCK_VERBOSE),-v:$(JCK_VERBOSE)) \ 45.73 -r:$(JCK_RUNTIME_OUTPUT_DIR)/report \ 45.74 -w:$(JCK_RUNTIME_OUTPUT_DIR)/work \ 45.75 -jdk:$(TESTJAVA) \
46.1 --- a/test/com/sun/javadoc/testLinkOption/TestLinkOption.java Mon May 19 22:00:11 2014 -0700 46.2 +++ b/test/com/sun/javadoc/testLinkOption/TestLinkOption.java Thu May 29 13:46:36 2014 -0700 46.3 @@ -23,18 +23,20 @@ 46.4 46.5 /* 46.6 * @test 46.7 - * @bug 4720957 5020118 8026567 46.8 + * @bug 4720957 5020118 8026567 8038976 46.9 * @summary Test to make sure that -link and -linkoffline link to 46.10 - * right files. 46.11 + * right files, and URLs with and without trailing slash are accepted. 46.12 * @author jamieh 46.13 * @library ../lib/ 46.14 * @build JavadocTester TestLinkOption 46.15 * @run main TestLinkOption 46.16 */ 46.17 46.18 +import java.io.File; 46.19 + 46.20 public class TestLinkOption extends JavadocTester { 46.21 46.22 - private static final String BUG_ID = "4720957-5020118"; 46.23 + private static final String BUG_ID = "4720957-5020118-8038976"; 46.24 46.25 //Generate the documentation using -linkoffline and a URL as the first parameter. 46.26 private static final String[] ARGS1 = new String[] { 46.27 @@ -83,7 +85,34 @@ 46.28 } 46.29 }; 46.30 private static final String[][] NEGATED_TEST2 = NO_TEST; 46.31 - 46.32 + /* 46.33 + * Create the documentation using the -link option, vary the behavior with 46.34 + * both trailing and no trailing slash. We are only interested in ensuring 46.35 + * that the command executes with no errors or related warnings. 46.36 + */ 46.37 + static String[] createArguments(boolean withTrailingSlash) { 46.38 + String packagePath = new File(BUG_ID + "-1").getAbsolutePath(); 46.39 + String outputDirName = BUG_ID; 46.40 + if (withTrailingSlash) { 46.41 + // add the trailing slash, if it is not present! 46.42 + if (!packagePath.endsWith(FS)) { 46.43 + packagePath = packagePath + FS; 46.44 + } 46.45 + outputDirName = outputDirName + "-3"; 46.46 + } else { 46.47 + // remove the trailing slash, if it is present! 46.48 + if (packagePath.endsWith(FS)) { 46.49 + packagePath = packagePath.substring(0, packagePath.length() - 1); 46.50 + } 46.51 + outputDirName = outputDirName + "-4"; 46.52 + } 46.53 + String args[] = { 46.54 + "-d", outputDirName, "-sourcepath", SRC_DIR, 46.55 + "-link", "file:///" + packagePath, "-package", "pkg2" 46.56 + }; 46.57 + System.out.println("packagePath: " + packagePath); 46.58 + return args; 46.59 + } 46.60 /** 46.61 * The entry point of the test. 46.62 * @param args the array of command line arguments. 46.63 @@ -92,6 +121,12 @@ 46.64 TestLinkOption tester = new TestLinkOption(); 46.65 run(tester, ARGS1, TEST1, NEGATED_TEST1); 46.66 run(tester, ARGS2, TEST2, NEGATED_TEST2); 46.67 + tester.runJavadoc(createArguments(true)); // with trailing slash 46.68 + tester.runJavadoc(createArguments(false)); // without trailing slash 46.69 + tester.printSummary(); 46.70 + if (tester.getWarningOutput().contains("warning - Error fetching URL")) { 46.71 + throw new Error("URL rejected ?"); 46.72 + } 46.73 tester.printSummary(); 46.74 } 46.75
47.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 47.2 +++ b/test/tools/javac/AnonymousSubclassTest.java Thu May 29 13:46:36 2014 -0700 47.3 @@ -0,0 +1,91 @@ 47.4 +/* 47.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 47.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 47.7 + * 47.8 + * This code is free software; you can redistribute it and/or modify it 47.9 + * under the terms of the GNU General Public License version 2 only, as 47.10 + * published by the Free Software Foundation. 47.11 + * 47.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 47.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 47.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 47.15 + * version 2 for more details (a copy is included in the LICENSE file that 47.16 + * accompanied this code). 47.17 + * 47.18 + * You should have received a copy of the GNU General Public License version 47.19 + * 2 along with this work; if not, write to the Free Software Foundation, 47.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 47.21 + * 47.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 47.23 + * or visit www.oracle.com if you need additional information or have any 47.24 + * questions. 47.25 + */ 47.26 + 47.27 +/* 47.28 + * @test 47.29 + * @bug 8023945 47.30 + * @summary javac wrongly allows a subclass of an anonymous class 47.31 + * @library /tools/javac/lib 47.32 + * @build ToolBox 47.33 + * @run main AnonymousSubclassTest 47.34 + */ 47.35 + 47.36 +import java.util.ArrayList; 47.37 +import java.io.IOException; 47.38 + 47.39 +public class AnonymousSubclassTest { 47.40 + public static void main(String... args) throws Exception { 47.41 + new AnonymousSubclassTest().run(); 47.42 + } 47.43 + 47.44 + // To trigger the error we want, first we need to compile 47.45 + // a class with an anonymous inner class: Foo$1. 47.46 + final String foo = 47.47 + "public class Foo {" + 47.48 + " void m() { Foo f = new Foo() {}; }" + 47.49 + "}"; 47.50 + 47.51 + // Then, we try to subclass the anonymous class 47.52 + // Note: we must do this in two classes because a different 47.53 + // error will be generated if we don't load Foo$1 through the 47.54 + // class reader. 47.55 + final String test1 = 47.56 + "public class Test1 {" + 47.57 + " void m() {"+ 47.58 + " Foo f1 = new Foo();"+ 47.59 + " Foo f2 = new Foo$1(f1) {};"+ 47.60 + " }" + 47.61 + "}"; 47.62 + 47.63 + final String test2 = 47.64 + "public class Test2 {" + 47.65 + " class T extends Foo$1 {" + 47.66 + " public T(Foo f) { super(f); }" + 47.67 + " }"+ 47.68 + "}"; 47.69 + 47.70 + void compOk(String code) throws Exception { 47.71 + ToolBox.javac(new ToolBox.JavaToolArgs().setSources(code)); 47.72 + } 47.73 + 47.74 + void compFail(String code) throws Exception { 47.75 + ArrayList<String> errors = new ArrayList<>(); 47.76 + ToolBox.JavaToolArgs args = new ToolBox.JavaToolArgs(); 47.77 + args.setSources(code) 47.78 + .appendArgs("-cp", ".", "-XDrawDiagnostics") 47.79 + .set(ToolBox.Expect.FAIL) 47.80 + .setErrOutput(errors); 47.81 + ToolBox.javac(args); 47.82 + 47.83 + if (!errors.get(0).contains("cant.inherit.from.anon")) { 47.84 + System.out.println(errors.get(0)); 47.85 + throw new Exception("test failed"); 47.86 + } 47.87 + } 47.88 + 47.89 + void run() throws Exception { 47.90 + compOk(foo); 47.91 + compFail(test1); 47.92 + compFail(test2); 47.93 + } 47.94 +}
48.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 48.2 +++ b/test/tools/javac/DefiniteAssignment/T8039026.java Thu May 29 13:46:36 2014 -0700 48.3 @@ -0,0 +1,21 @@ 48.4 +/* 48.5 + * @test /nodynamiccopyright/ 48.6 + * @bug 8039026 48.7 + * @summary Definitely unassigned field can be accessed 48.8 + * @compile/fail/ref=T8039026.out -XDrawDiagnostics T8039026.java 48.9 + */ 48.10 + 48.11 +public class T8039026 { 48.12 + final int x,y,z; 48.13 + final int a = this.y; // <- error 48.14 + { 48.15 + int b = true ? this.x : 0; // <- error 48.16 + System.out.println(this.x); // <- error 48.17 + this.y = 1; 48.18 + } 48.19 + T8039026() { 48.20 + this.x = 1; // <- no error! 48.21 + this.y = 1; // <- error 48.22 + this.z = this.x; // <- no error 48.23 + } 48.24 +}
49.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 49.2 +++ b/test/tools/javac/DefiniteAssignment/T8039026.out Thu May 29 13:46:36 2014 -0700 49.3 @@ -0,0 +1,4 @@ 49.4 +T8039026.java:10:23: compiler.err.var.might.not.have.been.initialized: y 49.5 +T8039026.java:12:28: compiler.err.var.might.not.have.been.initialized: x 49.6 +T8039026.java:18:13: compiler.err.var.might.already.be.assigned: y 49.7 +3 errors
50.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 50.2 +++ b/test/tools/javac/IncorrectInheritance/IncorrectInheritanceTest.java Thu May 29 13:46:36 2014 -0700 50.3 @@ -0,0 +1,68 @@ 50.4 +/* 50.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 50.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 50.7 + * 50.8 + * This code is free software; you can redistribute it and/or modify it 50.9 + * under the terms of the GNU General Public License version 2 only, as 50.10 + * published by the Free Software Foundation. 50.11 + * 50.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 50.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 50.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 50.15 + * version 2 for more details (a copy is included in the LICENSE file that 50.16 + * accompanied this code). 50.17 + * 50.18 + * You should have received a copy of the GNU General Public License version 50.19 + * 2 along with this work; if not, write to the Free Software Foundation, 50.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 50.21 + * 50.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 50.23 + * or visit www.oracle.com if you need additional information or have any 50.24 + * questions. 50.25 + */ 50.26 + 50.27 +/* 50.28 + * @test 50.29 + * @bug 8034924 50.30 + * @summary Incorrect inheritance of inaccessible static method 50.31 + * @library /tools/javac/lib 50.32 + * @build ToolBox 50.33 + * @run main IncorrectInheritanceTest 50.34 + */ 50.35 + 50.36 +public class IncorrectInheritanceTest { 50.37 + private static final String ASrc = 50.38 + "package pkg;\n" + 50.39 + "\n" + 50.40 + "public class A {\n" + 50.41 + " static void foo(Object o) {}\n" + 50.42 + " private static void bar(Object o) {}\n" + 50.43 + "}"; 50.44 + 50.45 + private static final String BSrc = 50.46 + "import pkg.A;\n" + 50.47 + "class B extends A {\n" + 50.48 + " public void foo(Object o) {}\n" + 50.49 + " public void bar(Object o) {}\n" + 50.50 + "}"; 50.51 + 50.52 + private static final String CSrc = 50.53 + "class C extends B {\n" + 50.54 + " public void m(Object o) {\n" + 50.55 + " foo(o);\n" + 50.56 + " bar(o);\n" + 50.57 + " }\n" + 50.58 + "}"; 50.59 + 50.60 + public static void main(String[] args) throws Exception { 50.61 + new IncorrectInheritanceTest().test(); 50.62 + } 50.63 + 50.64 + public void test() throws Exception { 50.65 + ToolBox.JavaToolArgs javacParams = 50.66 + new ToolBox.JavaToolArgs() 50.67 + .setSources(ASrc, BSrc, CSrc); 50.68 + ToolBox.javac(javacParams); 50.69 + } 50.70 + 50.71 +}
51.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 51.2 +++ b/test/tools/javac/T8029002/MultipleUpperBoundsIncorporationTest.java Thu May 29 13:46:36 2014 -0700 51.3 @@ -0,0 +1,72 @@ 51.4 +/* 51.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 51.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 51.7 + * 51.8 + * This code is free software; you can redistribute it and/or modify it 51.9 + * under the terms of the GNU General Public License version 2 only, as 51.10 + * published by the Free Software Foundation. 51.11 + * 51.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 51.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 51.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 51.15 + * version 2 for more details (a copy is included in the LICENSE file that 51.16 + * accompanied this code). 51.17 + * 51.18 + * You should have received a copy of the GNU General Public License version 51.19 + * 2 along with this work; if not, write to the Free Software Foundation, 51.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 51.21 + * 51.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 51.23 + * or visit www.oracle.com if you need additional information or have any 51.24 + * questions. 51.25 + */ 51.26 + 51.27 +/* 51.28 + * @test 51.29 + * @bug 8029002 51.30 + * @summary javac should take multiple upper bounds into account in incorporation 51.31 + * @compile MultipleUpperBoundsIncorporationTest.java 51.32 + */ 51.33 + 51.34 +import java.util.ArrayList; 51.35 +import java.util.List; 51.36 + 51.37 +public class MultipleUpperBoundsIncorporationTest { 51.38 + 51.39 + static class TestCase1 { 51.40 + interface Task<E extends Exception> {} 51.41 + 51.42 + class Comparator<T> {} 51.43 + 51.44 + class CustomException extends Exception {} 51.45 + 51.46 + class TaskQueue<E extends Exception, T extends Task<E>> {} 51.47 + 51.48 + abstract class Test { 51.49 + abstract <E extends Exception, T extends Task<E>> TaskQueue<E, T> create(Comparator<? super T> comparator); 51.50 + 51.51 + void f(Comparator<Task<CustomException>> comp) { 51.52 + TaskQueue<CustomException, Task<CustomException>> queue = create(comp); 51.53 + queue.getClass(); 51.54 + } 51.55 + } 51.56 + } 51.57 + 51.58 + static class TestCase2 { 51.59 + public <T, E extends List<T>> E typedNull() { 51.60 + return null; 51.61 + } 51.62 + 51.63 + public void call() { 51.64 + ArrayList<String> list = typedNull(); 51.65 + } 51.66 + } 51.67 + 51.68 + static class TestCase3 { 51.69 + interface I extends Iterable<String> {} 51.70 + 51.71 + <T, Exp extends Iterable<T>> Exp typedNull() { return null; } 51.72 + I i = typedNull(); 51.73 + } 51.74 + 51.75 +}
52.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 52.2 +++ b/test/tools/javac/T8029102/WarnSerializableLambdaTest.java Thu May 29 13:46:36 2014 -0700 52.3 @@ -0,0 +1,241 @@ 52.4 +/* 52.5 + * @test /nodynamiccopyright/ 52.6 + * @bug 8029102 52.7 + * @summary Enhance compiler warnings for Lambda 52.8 + * Checks that the warning for accessing non public members of a class is 52.9 + * fired correctly. 52.10 + * @compile/fail/ref=WarnSerializableLambdaTest.out -XDrawDiagnostics -Werror -XDwarnOnAccessToSensitiveMembers WarnSerializableLambdaTest.java 52.11 + */ 52.12 + 52.13 +import java.io.Serializable; 52.14 + 52.15 +public class WarnSerializableLambdaTest { 52.16 + 52.17 + void warnLambda() throws Exception { 52.18 + SAM t3 = (SAM & Serializable)WarnSerializableLambdaTest::packageClassMethod; 52.19 + SAM t4 = (SAM & Serializable)WarnSerializableLambdaTest::protectedClassMethod; 52.20 + SAM t5 = (SAM & Serializable)WarnSerializableLambdaTest::privateClassMethod; 52.21 + 52.22 + WarnSerializableLambdaTest test = new WarnSerializableLambdaTest(); 52.23 + SAM t6 = (SAM & Serializable)test::packageInstanceMethod; 52.24 + SAM t7 = (SAM & Serializable)test::protectedInstanceMethod; 52.25 + SAM t8 = (SAM & Serializable)test::privateInstanceMethod; 52.26 + 52.27 + SAM t9 = (SAM & Serializable) c -> { 52.28 + 52.29 + WarnSerializableLambdaTest.staticPackageField = ""; 52.30 + WarnSerializableLambdaTest.staticProtectedField = ""; 52.31 + WarnSerializableLambdaTest.staticPrivateField = ""; 52.32 + 52.33 + packageField = ""; 52.34 + protectedField = ""; 52.35 + privateField = ""; 52.36 + 52.37 + WarnSerializableLambdaTest.packageClassMethod(null); 52.38 + WarnSerializableLambdaTest.protectedClassMethod(null); 52.39 + WarnSerializableLambdaTest.privateClassMethod(null); 52.40 + 52.41 + packageInstanceMethod(null); 52.42 + protectedInstanceMethod(null); 52.43 + privateInstanceMethod(null); 52.44 + 52.45 + PrivateClass.effectivelyNonPublicStaticField = ""; 52.46 + PrivateClass.effectivelyNonPublicClassMethod(); 52.47 + 52.48 + PrivateClass p = new PrivateClass(); 52.49 + p.effectivelyNonPublicInstanceField = ""; 52.50 + p.effectivelyNonPublicInstanceMethod(); 52.51 + 52.52 + return null; 52.53 + }; 52.54 + } 52.55 + 52.56 + private void warnAnoInnerClass() throws Exception { 52.57 + new SerializableDesc() { 52.58 + public void m(Object param) throws Exception { 52.59 + WarnSerializableLambdaTest.staticPackageField = ""; 52.60 + WarnSerializableLambdaTest.staticProtectedField = ""; 52.61 + WarnSerializableLambdaTest.staticPrivateField = ""; 52.62 + 52.63 + packageField = ""; 52.64 + protectedField = ""; 52.65 + privateField = ""; 52.66 + 52.67 + WarnSerializableLambdaTest.packageClassMethod(null); 52.68 + WarnSerializableLambdaTest.protectedClassMethod(null); 52.69 + WarnSerializableLambdaTest.privateClassMethod(null); 52.70 + 52.71 + packageInstanceMethod(null); 52.72 + protectedInstanceMethod(null); 52.73 + privateInstanceMethod(null); 52.74 + 52.75 + PrivateClass.effectivelyNonPublicStaticField = ""; 52.76 + PrivateClass.effectivelyNonPublicClassMethod(); 52.77 + 52.78 + PrivateClass p = new PrivateClass(); 52.79 + p.effectivelyNonPublicInstanceField = ""; 52.80 + p.effectivelyNonPublicInstanceMethod(); 52.81 + } 52.82 + }; 52.83 + } 52.84 + 52.85 + void dontWarnLambda() throws Exception { 52.86 + SAM t1 = (SAM & Serializable)WarnSerializableLambdaTest::publicClassMethod; 52.87 + 52.88 + WarnSerializableLambdaTest test = new WarnSerializableLambdaTest(); 52.89 + SAM t2 = (SAM & Serializable)test::publicInstanceMethod; 52.90 + 52.91 + int[] buffer = {0}; 52.92 + 52.93 + SAM t3 = (SAM & Serializable) param -> { 52.94 + Object localVar; 52.95 + localVar = null; 52.96 + param = null; 52.97 + 52.98 + WarnSerializableLambdaTest.staticPublicField = ""; 52.99 + publicField = ""; 52.100 + WarnSerializableLambdaTest.publicClassMethod(null); 52.101 + publicInstanceMethod(null); 52.102 + 52.103 + PublicClass.effectivelyPublicStaticField = ""; 52.104 + PublicClass.effectivelyPublicClassMethod(); 52.105 + 52.106 + PublicClass p = new PublicClass(); 52.107 + p.effectivelyPublicInstanceField = ""; 52.108 + p.effectivelyPublicInstanceMethod(); 52.109 + 52.110 + int l = buffer.length; 52.111 + 52.112 + return null; 52.113 + }; 52.114 + } 52.115 + 52.116 + private void dontWarnAnoInnerClass() throws Exception { 52.117 + final int[] buffer = {0}; 52.118 + new SerializableDesc() { 52.119 + public void m(Object param) throws Exception { 52.120 + Object localVar; 52.121 + localVar = null; 52.122 + param = null; 52.123 + 52.124 + WarnSerializableLambdaTest.staticPublicField = ""; 52.125 + publicField = ""; 52.126 + WarnSerializableLambdaTest.publicClassMethod(null); 52.127 + publicInstanceMethod(null); 52.128 + 52.129 + PublicClass.effectivelyPublicStaticField = ""; 52.130 + PublicClass.effectivelyPublicClassMethod(); 52.131 + 52.132 + PublicClass p = new PublicClass(); 52.133 + p.effectivelyPublicInstanceField = ""; 52.134 + p.effectivelyPublicInstanceMethod(); 52.135 + 52.136 + int l = buffer.length; 52.137 + } 52.138 + }; 52.139 + } 52.140 + 52.141 + enum WarnEnum { 52.142 + A { 52.143 + public void m() throws Exception { 52.144 + WarnSerializableLambdaTest.staticPackageField = ""; 52.145 + WarnSerializableLambdaTest.staticProtectedField = ""; 52.146 + WarnSerializableLambdaTest.staticPrivateField = ""; 52.147 + 52.148 + WarnSerializableLambdaTest test = 52.149 + new WarnSerializableLambdaTest(); 52.150 + 52.151 + test.packageField = ""; 52.152 + test.protectedField = ""; 52.153 + test.privateField = ""; 52.154 + 52.155 + WarnSerializableLambdaTest.packageClassMethod(null); 52.156 + WarnSerializableLambdaTest.protectedClassMethod(null); 52.157 + WarnSerializableLambdaTest.privateClassMethod(null); 52.158 + 52.159 + test.packageInstanceMethod(null); 52.160 + test.protectedInstanceMethod(null); 52.161 + test.privateInstanceMethod(null); 52.162 + 52.163 + PrivateClass.effectivelyNonPublicStaticField = ""; 52.164 + PrivateClass.effectivelyNonPublicClassMethod(); 52.165 + 52.166 + PrivateClass p = new PrivateClass(); 52.167 + p.effectivelyNonPublicInstanceField = ""; 52.168 + p.effectivelyNonPublicInstanceMethod(); 52.169 + } 52.170 + }; 52.171 + 52.172 + public void m() throws Exception {} 52.173 + } 52.174 + 52.175 + static String staticPackageField; 52.176 + static private String staticPrivateField; 52.177 + static protected String staticProtectedField; 52.178 + static public String staticPublicField; 52.179 + 52.180 + String packageField; 52.181 + private String privateField; 52.182 + protected String protectedField; 52.183 + public String publicField; 52.184 + 52.185 + static Object packageClassMethod(String s) { 52.186 + return null; 52.187 + } 52.188 + 52.189 + static private Object privateClassMethod(String s) { 52.190 + return null; 52.191 + } 52.192 + 52.193 + static protected Object protectedClassMethod(String s) { 52.194 + return null; 52.195 + } 52.196 + 52.197 + static public Object publicClassMethod(String s) { 52.198 + return null; 52.199 + } 52.200 + 52.201 + Object packageInstanceMethod(String s) { 52.202 + return null; 52.203 + } 52.204 + 52.205 + protected Object protectedInstanceMethod(String s) { 52.206 + return null; 52.207 + } 52.208 + 52.209 + private Object privateInstanceMethod(String s) { 52.210 + return null; 52.211 + } 52.212 + 52.213 + public Object publicInstanceMethod(String s) { 52.214 + return null; 52.215 + } 52.216 + 52.217 + interface SAM { 52.218 + Object apply(String s) throws Exception; 52.219 + } 52.220 + 52.221 + interface SAM2 { 52.222 + Object apply(String arg1, String arg2); 52.223 + } 52.224 + 52.225 + class SerializableDesc implements Serializable { 52.226 + public void m(Object param) throws Exception {} 52.227 + } 52.228 + 52.229 + static private class PrivateClass { 52.230 + static public String effectivelyNonPublicStaticField; 52.231 + public String effectivelyNonPublicInstanceField; 52.232 + 52.233 + static public void effectivelyNonPublicClassMethod() {} 52.234 + public void effectivelyNonPublicInstanceMethod() {} 52.235 + } 52.236 + 52.237 + static public class PublicClass { 52.238 + static public String effectivelyPublicStaticField; 52.239 + public String effectivelyPublicInstanceField; 52.240 + 52.241 + static public void effectivelyPublicClassMethod() {} 52.242 + public void effectivelyPublicInstanceMethod() {} 52.243 + } 52.244 +}
53.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 53.2 +++ b/test/tools/javac/T8029102/WarnSerializableLambdaTest.out Thu May 29 13:46:36 2014 -0700 53.3 @@ -0,0 +1,57 @@ 53.4 +WarnSerializableLambdaTest.java:15:38: compiler.warn.access.to.sensitive.member.from.serializable.element: packageClassMethod(java.lang.String) 53.5 +WarnSerializableLambdaTest.java:16:38: compiler.warn.access.to.sensitive.member.from.serializable.element: protectedClassMethod(java.lang.String) 53.6 +WarnSerializableLambdaTest.java:17:38: compiler.warn.access.to.sensitive.member.from.serializable.element: privateClassMethod(java.lang.String) 53.7 +WarnSerializableLambdaTest.java:20:38: compiler.warn.access.to.sensitive.member.from.serializable.element: packageInstanceMethod(java.lang.String) 53.8 +WarnSerializableLambdaTest.java:21:38: compiler.warn.access.to.sensitive.member.from.serializable.element: protectedInstanceMethod(java.lang.String) 53.9 +WarnSerializableLambdaTest.java:22:38: compiler.warn.access.to.sensitive.member.from.serializable.element: privateInstanceMethod(java.lang.String) 53.10 +WarnSerializableLambdaTest.java:26:39: compiler.warn.access.to.sensitive.member.from.serializable.element: staticPackageField 53.11 +WarnSerializableLambdaTest.java:27:39: compiler.warn.access.to.sensitive.member.from.serializable.element: staticProtectedField 53.12 +WarnSerializableLambdaTest.java:28:39: compiler.warn.access.to.sensitive.member.from.serializable.element: staticPrivateField 53.13 +WarnSerializableLambdaTest.java:30:13: compiler.warn.access.to.sensitive.member.from.serializable.element: packageField 53.14 +WarnSerializableLambdaTest.java:31:13: compiler.warn.access.to.sensitive.member.from.serializable.element: protectedField 53.15 +WarnSerializableLambdaTest.java:32:13: compiler.warn.access.to.sensitive.member.from.serializable.element: privateField 53.16 +WarnSerializableLambdaTest.java:34:39: compiler.warn.access.to.sensitive.member.from.serializable.element: packageClassMethod(java.lang.String) 53.17 +WarnSerializableLambdaTest.java:35:39: compiler.warn.access.to.sensitive.member.from.serializable.element: protectedClassMethod(java.lang.String) 53.18 +WarnSerializableLambdaTest.java:36:39: compiler.warn.access.to.sensitive.member.from.serializable.element: privateClassMethod(java.lang.String) 53.19 +WarnSerializableLambdaTest.java:38:13: compiler.warn.access.to.sensitive.member.from.serializable.element: packageInstanceMethod(java.lang.String) 53.20 +WarnSerializableLambdaTest.java:39:13: compiler.warn.access.to.sensitive.member.from.serializable.element: protectedInstanceMethod(java.lang.String) 53.21 +WarnSerializableLambdaTest.java:40:13: compiler.warn.access.to.sensitive.member.from.serializable.element: privateInstanceMethod(java.lang.String) 53.22 +WarnSerializableLambdaTest.java:42:25: compiler.warn.access.to.sensitive.member.from.serializable.element: effectivelyNonPublicStaticField 53.23 +WarnSerializableLambdaTest.java:43:25: compiler.warn.access.to.sensitive.member.from.serializable.element: effectivelyNonPublicClassMethod() 53.24 +WarnSerializableLambdaTest.java:46:14: compiler.warn.access.to.sensitive.member.from.serializable.element: effectivelyNonPublicInstanceField 53.25 +WarnSerializableLambdaTest.java:47:14: compiler.warn.access.to.sensitive.member.from.serializable.element: effectivelyNonPublicInstanceMethod() 53.26 +WarnSerializableLambdaTest.java:56:43: compiler.warn.access.to.sensitive.member.from.serializable.element: staticPackageField 53.27 +WarnSerializableLambdaTest.java:57:43: compiler.warn.access.to.sensitive.member.from.serializable.element: staticProtectedField 53.28 +WarnSerializableLambdaTest.java:58:43: compiler.warn.access.to.sensitive.member.from.serializable.element: staticPrivateField 53.29 +WarnSerializableLambdaTest.java:60:17: compiler.warn.access.to.sensitive.member.from.serializable.element: packageField 53.30 +WarnSerializableLambdaTest.java:61:17: compiler.warn.access.to.sensitive.member.from.serializable.element: protectedField 53.31 +WarnSerializableLambdaTest.java:62:17: compiler.warn.access.to.sensitive.member.from.serializable.element: privateField 53.32 +WarnSerializableLambdaTest.java:64:43: compiler.warn.access.to.sensitive.member.from.serializable.element: packageClassMethod(java.lang.String) 53.33 +WarnSerializableLambdaTest.java:65:43: compiler.warn.access.to.sensitive.member.from.serializable.element: protectedClassMethod(java.lang.String) 53.34 +WarnSerializableLambdaTest.java:66:43: compiler.warn.access.to.sensitive.member.from.serializable.element: privateClassMethod(java.lang.String) 53.35 +WarnSerializableLambdaTest.java:68:17: compiler.warn.access.to.sensitive.member.from.serializable.element: packageInstanceMethod(java.lang.String) 53.36 +WarnSerializableLambdaTest.java:69:17: compiler.warn.access.to.sensitive.member.from.serializable.element: protectedInstanceMethod(java.lang.String) 53.37 +WarnSerializableLambdaTest.java:70:17: compiler.warn.access.to.sensitive.member.from.serializable.element: privateInstanceMethod(java.lang.String) 53.38 +WarnSerializableLambdaTest.java:72:29: compiler.warn.access.to.sensitive.member.from.serializable.element: effectivelyNonPublicStaticField 53.39 +WarnSerializableLambdaTest.java:73:29: compiler.warn.access.to.sensitive.member.from.serializable.element: effectivelyNonPublicClassMethod() 53.40 +WarnSerializableLambdaTest.java:76:18: compiler.warn.access.to.sensitive.member.from.serializable.element: effectivelyNonPublicInstanceField 53.41 +WarnSerializableLambdaTest.java:77:18: compiler.warn.access.to.sensitive.member.from.serializable.element: effectivelyNonPublicInstanceMethod() 53.42 +WarnSerializableLambdaTest.java:141:43: compiler.warn.access.to.sensitive.member.from.serializable.element: staticPackageField 53.43 +WarnSerializableLambdaTest.java:142:43: compiler.warn.access.to.sensitive.member.from.serializable.element: staticProtectedField 53.44 +WarnSerializableLambdaTest.java:143:43: compiler.warn.access.to.sensitive.member.from.serializable.element: staticPrivateField 53.45 +WarnSerializableLambdaTest.java:148:21: compiler.warn.access.to.sensitive.member.from.serializable.element: packageField 53.46 +WarnSerializableLambdaTest.java:149:21: compiler.warn.access.to.sensitive.member.from.serializable.element: protectedField 53.47 +WarnSerializableLambdaTest.java:150:21: compiler.warn.access.to.sensitive.member.from.serializable.element: privateField 53.48 +WarnSerializableLambdaTest.java:152:43: compiler.warn.access.to.sensitive.member.from.serializable.element: packageClassMethod(java.lang.String) 53.49 +WarnSerializableLambdaTest.java:153:43: compiler.warn.access.to.sensitive.member.from.serializable.element: protectedClassMethod(java.lang.String) 53.50 +WarnSerializableLambdaTest.java:154:43: compiler.warn.access.to.sensitive.member.from.serializable.element: privateClassMethod(java.lang.String) 53.51 +WarnSerializableLambdaTest.java:156:21: compiler.warn.access.to.sensitive.member.from.serializable.element: packageInstanceMethod(java.lang.String) 53.52 +WarnSerializableLambdaTest.java:157:21: compiler.warn.access.to.sensitive.member.from.serializable.element: protectedInstanceMethod(java.lang.String) 53.53 +WarnSerializableLambdaTest.java:158:21: compiler.warn.access.to.sensitive.member.from.serializable.element: privateInstanceMethod(java.lang.String) 53.54 +WarnSerializableLambdaTest.java:160:29: compiler.warn.access.to.sensitive.member.from.serializable.element: effectivelyNonPublicStaticField 53.55 +WarnSerializableLambdaTest.java:161:29: compiler.warn.access.to.sensitive.member.from.serializable.element: effectivelyNonPublicClassMethod() 53.56 +WarnSerializableLambdaTest.java:164:18: compiler.warn.access.to.sensitive.member.from.serializable.element: effectivelyNonPublicInstanceField 53.57 +WarnSerializableLambdaTest.java:165:18: compiler.warn.access.to.sensitive.member.from.serializable.element: effectivelyNonPublicInstanceMethod() 53.58 +- compiler.err.warnings.and.werror 53.59 +1 error 53.60 +54 warnings
54.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 54.2 +++ b/test/tools/javac/T8029102/WarnSerializableLambdaTestb.java Thu May 29 13:46:36 2014 -0700 54.3 @@ -0,0 +1,56 @@ 54.4 +/* 54.5 + * @test /nodynamiccopyright/ 54.6 + * @bug 8029102 54.7 + * @summary Enhance compiler warnings for Lambda 54.8 + * Checks that the warning for accessing non public members of a class is 54.9 + * fired correctly. 54.10 + * @compile/fail/ref=WarnSerializableLambdaTestb.out -XDrawDiagnostics -Werror -XDwarnOnAccessToSensitiveMembers WarnSerializableLambdaTestb.java 54.11 + */ 54.12 + 54.13 +import java.io.Serializable; 54.14 + 54.15 +public class WarnSerializableLambdaTestb { 54.16 + public void foo(Secret1 secret) { 54.17 + Object o = (Runnable & java.io.Serializable) () -> { secret.test(); }; 54.18 + } 54.19 + 54.20 + public void bar(Secret2 secret) { 54.21 + Object o = (Runnable & java.io.Serializable) () -> { secret.test(); }; 54.22 + } 54.23 + 54.24 + private class Secret1 { 54.25 + public void test() {} 54.26 + } 54.27 + 54.28 + static private class Secret2 { 54.29 + public void test() {} 54.30 + } 54.31 + 54.32 + class TestInner { 54.33 + private int j = 0; 54.34 + void m() { 54.35 + Serializable s = new Serializable() { 54.36 + int i; 54.37 + void m() { 54.38 + i = 0; // don't warn 54.39 + System.out.println(j); //warn 54.40 + } 54.41 + }; 54.42 + } 54.43 + } 54.44 + 54.45 + class TestInner2 { 54.46 + class W implements Serializable { 54.47 + public int p = 0; 54.48 + class I { 54.49 + public int r = 0; 54.50 + class K implements Serializable { 54.51 + void m() { 54.52 + p = 1; // don't warn owner is serializable 54.53 + r = 2; // warn owner is not serializable 54.54 + } 54.55 + } 54.56 + } 54.57 + } 54.58 + } 54.59 +}
55.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 55.2 +++ b/test/tools/javac/T8029102/WarnSerializableLambdaTestb.out Thu May 29 13:46:36 2014 -0700 55.3 @@ -0,0 +1,7 @@ 55.4 +WarnSerializableLambdaTestb.java:14:69: compiler.warn.access.to.sensitive.member.from.serializable.element: test() 55.5 +WarnSerializableLambdaTestb.java:18:69: compiler.warn.access.to.sensitive.member.from.serializable.element: test() 55.6 +WarnSerializableLambdaTestb.java:36:40: compiler.warn.access.to.sensitive.member.from.serializable.element: j 55.7 +WarnSerializableLambdaTestb.java:50:25: compiler.warn.access.to.sensitive.member.from.serializable.element: r 55.8 +- compiler.err.warnings.and.werror 55.9 +1 error 55.10 +4 warnings
56.1 --- a/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.java Mon May 19 22:00:11 2014 -0700 56.2 +++ b/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.java Thu May 29 13:46:36 2014 -0700 56.3 @@ -1,30 +1,8 @@ 56.4 /* 56.5 - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 56.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 56.7 - * 56.8 - * This code is free software; you can redistribute it and/or modify it 56.9 - * under the terms of the GNU General Public License version 2 only, as 56.10 - * published by the Free Software Foundation. 56.11 - * 56.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 56.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 56.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 56.15 - * version 2 for more details (a copy is included in the LICENSE file that 56.16 - * accompanied this code). 56.17 - * 56.18 - * You should have received a copy of the GNU General Public License version 56.19 - * 2 along with this work; if not, write to the Free Software Foundation, 56.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 56.21 - * 56.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 56.23 - * or visit www.oracle.com if you need additional information or have any 56.24 - * questions. 56.25 - */ 56.26 - 56.27 -/* 56.28 - * @test 56.29 - * @bug 8029569 56.30 + * @test /nodynamiccopyright/ 56.31 + * @bug 8029569 8037379 56.32 * @summary internal javac cast exception when resolving varargs ambiguity 56.33 + * fix for JDK-8029569 doesn't cover all possible cases 56.34 * @compile/fail/ref=VarargsAmbiguityCrashTest.out -XDrawDiagnostics VarargsAmbiguityCrashTest.java 56.35 */ 56.36
57.1 --- a/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.out Mon May 19 22:00:11 2014 -0700 57.2 +++ b/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.out Thu May 29 13:46:36 2014 -0700 57.3 @@ -1,2 +1,2 @@ 57.4 -VarargsAmbiguityCrashTest.java:33:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(java.lang.Exception...), VarargsAmbiguityCrashTest, kindname.method, m2(java.lang.Long,java.lang.Exception...), VarargsAmbiguityCrashTest 57.5 +VarargsAmbiguityCrashTest.java:11:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(java.lang.Exception...), VarargsAmbiguityCrashTest, kindname.method, m2(java.lang.Long,java.lang.Exception...), VarargsAmbiguityCrashTest 57.6 1 error
58.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 58.2 +++ b/test/tools/javac/T8030816/CrashLambdaExpressionWithNonAccessibleIdTest.java Thu May 29 13:46:36 2014 -0700 58.3 @@ -0,0 +1,22 @@ 58.4 +/* 58.5 + * @test /nodynamiccopyright/ 58.6 + * @bug 8030816 58.7 + * @summary javac can't compile program with lambda expression 58.8 + * @compile/fail/ref=CrashLambdaExpressionWithNonAccessibleIdTest.out -XDrawDiagnostics CrashLambdaExpressionWithNonAccessibleIdTest.java 58.9 + */ 58.10 + 58.11 +/* This test must make sure that javac won't crash when compiling lambda 58.12 + * containing an anonymous innerclass based on an unresolvable type. 58.13 + */ 58.14 +public class CrashLambdaExpressionWithNonAccessibleIdTest { 58.15 + void m() { 58.16 + m1(()-> { 58.17 + new A(){ 58.18 + public void m11() {} 58.19 + }; 58.20 + }); 58.21 + 58.22 + } 58.23 + 58.24 + void m1(Runnable r) {} 58.25 +}
59.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 59.2 +++ b/test/tools/javac/T8030816/CrashLambdaExpressionWithNonAccessibleIdTest.out Thu May 29 13:46:36 2014 -0700 59.3 @@ -0,0 +1,3 @@ 59.4 +CrashLambdaExpressionWithNonAccessibleIdTest.java:15:35: compiler.err.missing.ret.stmt 59.5 +CrashLambdaExpressionWithNonAccessibleIdTest.java:14:17: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, CrashLambdaExpressionWithNonAccessibleIdTest, null) 59.6 +2 errors
60.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 60.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/8029017/TypeUseTarget.java Thu May 29 13:46:36 2014 -0700 60.3 @@ -0,0 +1,129 @@ 60.4 +/* 60.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 60.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 60.7 + * 60.8 + * This code is free software; you can redistribute it and/or modify it 60.9 + * under the terms of the GNU General Public License version 2 only, as 60.10 + * published by the Free Software Foundation. 60.11 + * 60.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 60.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 60.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 60.15 + * version 2 for more details (a copy is included in the LICENSE file that 60.16 + * accompanied this code). 60.17 + * 60.18 + * You should have received a copy of the GNU General Public License version 60.19 + * 2 along with this work; if not, write to the Free Software Foundation, 60.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 60.21 + * 60.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 60.23 + * or visit www.oracle.com if you need additional information or have any 60.24 + * questions. 60.25 + */ 60.26 + 60.27 +/** 60.28 + * @test 60.29 + * @bug 8029017 60.30 + * @summary sanity testing of ElementType validation for repeating annotations 60.31 + * @compile TypeUseTarget.java 60.32 + */ 60.33 + 60.34 +import java.lang.annotation.*; 60.35 + 60.36 +public class TypeUseTarget {} 60.37 + 60.38 + 60.39 +// Case 1: 60.40 +@Target({ 60.41 + ElementType.TYPE_USE, 60.42 +}) 60.43 +@Repeatable(Case1Container.class) 60.44 +@interface Case1 {} 60.45 + 60.46 +@Target({ 60.47 + ElementType.ANNOTATION_TYPE, 60.48 + ElementType.TYPE, 60.49 + ElementType.TYPE_USE, 60.50 + ElementType.TYPE_PARAMETER, 60.51 +}) 60.52 +@interface Case1Container { 60.53 + Case1[] value(); 60.54 +} 60.55 + 60.56 + 60.57 +// Case 2: 60.58 +@Target({ 60.59 + ElementType.TYPE_USE, 60.60 +}) 60.61 +@Repeatable(Case2Container.class) 60.62 +@interface Case2 {} 60.63 + 60.64 +@Target({ 60.65 + ElementType.ANNOTATION_TYPE, 60.66 + ElementType.TYPE, 60.67 + ElementType.TYPE_USE, 60.68 +}) 60.69 +@interface Case2Container { 60.70 + Case2[] value(); 60.71 +} 60.72 + 60.73 + 60.74 +// Case 3: 60.75 +@Target({ 60.76 + ElementType.TYPE_USE, 60.77 +}) 60.78 +@Repeatable(Case3Container.class) 60.79 +@interface Case3 {} 60.80 + 60.81 +@Target({ 60.82 + ElementType.ANNOTATION_TYPE, 60.83 + ElementType.TYPE, 60.84 +}) 60.85 +@interface Case3Container { 60.86 + Case3[] value(); 60.87 +} 60.88 + 60.89 + 60.90 +// Case 4: 60.91 +@Target({ 60.92 + ElementType.TYPE_USE, 60.93 +}) 60.94 +@Repeatable(Case4Container.class) 60.95 +@interface Case4 {} 60.96 + 60.97 +@Target({ 60.98 + ElementType.ANNOTATION_TYPE, 60.99 +}) 60.100 +@interface Case4Container { 60.101 + Case4[] value(); 60.102 +} 60.103 + 60.104 + 60.105 +// Case 5: 60.106 +@Target({ 60.107 + ElementType.TYPE_USE, 60.108 +}) 60.109 +@Repeatable(Case5Container.class) 60.110 +@interface Case5 {} 60.111 + 60.112 +@Target({ 60.113 + ElementType.TYPE, 60.114 +}) 60.115 +@interface Case5Container { 60.116 + Case5[] value(); 60.117 +} 60.118 + 60.119 + 60.120 +// Case 6: 60.121 +@Target({ 60.122 + ElementType.TYPE_USE, 60.123 +}) 60.124 +@Repeatable(Case6Container.class) 60.125 +@interface Case6 {} 60.126 + 60.127 +@Target({ 60.128 + ElementType.TYPE_PARAMETER, 60.129 +}) 60.130 +@interface Case6Container { 60.131 + Case6[] value(); 60.132 +}
61.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 61.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/8029017/TypeUseTargetNeg.java Thu May 29 13:46:36 2014 -0700 61.3 @@ -0,0 +1,100 @@ 61.4 +/** 61.5 + * @test /nodynamiccopyright/ 61.6 + * @bug 8029017 61.7 + * @summary sanity testing of ElementType validation for repeating annotations 61.8 + * @compile/fail/ref=TypeUseTargetNeg.out -XDrawDiagnostics TypeUseTargetNeg.java 61.9 + */ 61.10 + 61.11 +import java.lang.annotation.*; 61.12 + 61.13 +public class TypeUseTargetNeg {} 61.14 + 61.15 +// Case 1: 61.16 +@Target({ 61.17 + ElementType.TYPE_USE, 61.18 +}) 61.19 +@Repeatable(FooContainer.class) 61.20 +@interface Foo {} 61.21 + 61.22 +@Target({ 61.23 + ElementType.ANNOTATION_TYPE, 61.24 + ElementType.TYPE, 61.25 + ElementType.TYPE_USE, 61.26 + ElementType.TYPE_PARAMETER, 61.27 + ElementType.FIELD, 61.28 + 61.29 +}) 61.30 +@interface FooContainer { 61.31 + Foo[] value(); 61.32 +} 61.33 + 61.34 + 61.35 +// Case 2: 61.36 +@Target({ 61.37 + ElementType.TYPE_USE, 61.38 +}) 61.39 +@Repeatable(BarContainer.class) 61.40 +@interface Bar {} 61.41 + 61.42 +@Target({ 61.43 + ElementType.ANNOTATION_TYPE, 61.44 + ElementType.TYPE, 61.45 + ElementType.TYPE_USE, 61.46 + ElementType.METHOD, 61.47 +}) 61.48 +@interface BarContainer { 61.49 + Bar[] value(); 61.50 +} 61.51 + 61.52 + 61.53 +// Case 3: 61.54 +@Target({ 61.55 + ElementType.TYPE_USE, 61.56 +}) 61.57 +@Repeatable(BazContainer.class) 61.58 +@interface Baz {} 61.59 + 61.60 +@Target({ 61.61 + ElementType.ANNOTATION_TYPE, 61.62 + ElementType.TYPE, 61.63 + ElementType.PARAMETER, 61.64 +}) 61.65 +@interface BazContainer { 61.66 + Baz[] value(); 61.67 +} 61.68 + 61.69 + 61.70 +// Case 4: 61.71 +@Target({ 61.72 + ElementType.TYPE_USE, 61.73 +}) 61.74 +@Repeatable(QuxContainer.class) 61.75 +@interface Qux {} 61.76 + 61.77 +@interface QuxContainer { 61.78 + Qux[] value(); 61.79 +} 61.80 + 61.81 + 61.82 +// Case 5: 61.83 +@Target({}) 61.84 +@Repeatable(QuuxContainer.class) 61.85 +@interface Quux {} 61.86 + 61.87 +@Target({ 61.88 + ElementType.TYPE_PARAMETER, 61.89 +}) 61.90 +@interface QuuxContainer { 61.91 + Quux[] value(); 61.92 +} 61.93 + 61.94 +// Case 6: 61.95 +@Repeatable(QuuuxContainer.class) 61.96 +@interface Quuux {} 61.97 + 61.98 +@Target({ 61.99 + ElementType.TYPE_USE, 61.100 +}) 61.101 +@interface QuuuxContainer { 61.102 + Quuux[] value(); 61.103 +}
62.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 62.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/8029017/TypeUseTargetNeg.out Thu May 29 13:46:36 2014 -0700 62.3 @@ -0,0 +1,7 @@ 62.4 +TypeUseTargetNeg.java:16:1: compiler.err.invalid.repeatable.annotation.incompatible.target: FooContainer, Foo 62.5 +TypeUseTargetNeg.java:36:1: compiler.err.invalid.repeatable.annotation.incompatible.target: BarContainer, Bar 62.6 +TypeUseTargetNeg.java:54:1: compiler.err.invalid.repeatable.annotation.incompatible.target: BazContainer, Baz 62.7 +TypeUseTargetNeg.java:71:1: compiler.err.invalid.repeatable.annotation.incompatible.target: QuxContainer, Qux 62.8 +TypeUseTargetNeg.java:81:1: compiler.err.invalid.repeatable.annotation.incompatible.target: QuuxContainer, Quux 62.9 +TypeUseTargetNeg.java:92:1: compiler.err.invalid.repeatable.annotation.incompatible.target: QuuuxContainer, Quuux 62.10 +6 errors
63.1 --- a/test/tools/javac/annotations/repeatingAnnotations/combo/ReflectionTest.java Mon May 19 22:00:11 2014 -0700 63.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/combo/ReflectionTest.java Thu May 29 13:46:36 2014 -0700 63.3 @@ -1,5 +1,5 @@ 63.4 /* 63.5 - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 63.6 + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. 63.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 63.8 * 63.9 * This code is free software; you can redistribute it and/or modify it 63.10 @@ -23,7 +23,7 @@ 63.11 63.12 /** 63.13 * @test 63.14 - * @bug 8001457 63.15 + * @bug 8001457 8027477 63.16 * @author sogoel 63.17 * @summary Reflection api tests 63.18 * @build Helper 63.19 @@ -159,7 +159,12 @@ 63.20 "SingleOnSuperContainerAndSingleOnSub_Inherited_Legacy", 63.21 "ContainerAndSingleOnSuperSingleOnSub_Inherited_Legacy", 63.22 "SingleAnnoWithContainer", 63.23 - "SingleOnSuperContainerAndSingleOnSub_Inherited"); 63.24 + "SingleOnSuperContainerAndSingleOnSub_Inherited", 63.25 + "RepeatableOnSuperSingleOnSub_Inherited", 63.26 + "SingleOnSuperRepeatableOnSub_Inherited", 63.27 + "ContainerOnSuperSingleOnSub_Inherited", 63.28 + "SingleOnSuperContainerOnSub_Inherited", 63.29 + "ContainerAndSingleOnSuperSingleOnSub_Inherited"); 63.30 if (orderingTestFailures.contains(testCase.toString())) { 63.31 CHECKORDERING = false; 63.32 } else 63.33 @@ -1612,323 +1617,323 @@ 63.34 return files; 63.35 } 63.36 }, 63.37 -// // Testcase not working as expected, JDK-8004912 63.38 -// RepeatableOnSuperSingleOnSub_Inherited( 63.39 -// "@ExpectedBase(value=Foo.class, " 63.40 -// + "getAnnotationVal = \"Foo\", " 63.41 -// + "getAnnotationsVals = {" 63.42 -// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, " 63.43 -// + //override every annotation on superClass 63.44 -// "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, " 63.45 -// + // ignores inherited annotations 63.46 -// "getDeclAnnoVal = \"Foo\", " // ignores inherited 63.47 -// + "getAnnosArgs = {\"Foo\"}, " 63.48 -// + "getDeclAnnosArgs = { \"Foo\" })", // ignores inherited 63.49 -// "@ExpectedContainer(value=FooContainer.class, " 63.50 -// + "getAnnotationVal = \"FooContainer\", " 63.51 -// + "getAnnotationsVals = {" 63.52 -// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, " 63.53 -// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, " 63.54 -// + // ignores inherited annotations 63.55 -// "getDeclAnnoVal = \"NULL\", " 63.56 -// + "getAnnosArgs = {\"FooContainer\"}, " 63.57 -// + "getDeclAnnosArgs = {}) // ignores inherited ") { 63.58 + // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 63.59 + // fail with ordering issues 63.60 + RepeatableOnSuperSingleOnSub_Inherited( 63.61 + "@ExpectedBase(value=Foo.class, " 63.62 + + "getAnnotationVal = \"@Foo(value=3)\", " 63.63 + + "getAnnotationsVals = {" 63.64 + + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=3)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 63.65 + + //override every annotation on superClass 63.66 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=3)\"}, " 63.67 + + // ignores inherited annotations 63.68 + "getDeclAnnoVal = \"@Foo(value=3)\", " // ignores inherited 63.69 + + "getAnnosArgs = {\"@Foo(value=3)\"}, " 63.70 + + "getDeclAnnosArgs = { \"@Foo(value=3)\" })", // ignores inherited 63.71 + "@ExpectedContainer(value=FooContainer.class, " 63.72 + + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 63.73 + + "getAnnotationsVals = {" 63.74 + + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=3)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 63.75 + + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=3)\"}, " 63.76 + + // ignores inherited annotations 63.77 + "getDeclAnnoVal = \"NULL\", " 63.78 + + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 63.79 + + "getDeclAnnosArgs = {}) // ignores inherited ") { 63.80 63.81 -// @Override 63.82 -// public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 63.83 -// String className) { 63.84 -// String anno = ""; 63.85 -// String replaceVal = ""; 63.86 -// String contents = ""; 63.87 -// JavaFileObject srcFileObj = null; 63.88 -// Iterable<? extends JavaFileObject> files = null; 63.89 + @Override 63.90 + public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 63.91 + String className) { 63.92 + String anno = ""; 63.93 + String replaceVal = ""; 63.94 + String contents = ""; 63.95 + JavaFileObject srcFileObj = null; 63.96 + Iterable<? extends JavaFileObject> files = null; 63.97 63.98 -// String expectedVals = "\n" + getExpectedBase() + "\n" 63.99 -// + getExpectedContainer() + "\n"; 63.100 -// StringBuilder commonStmts = getCommonStmts(true); 63.101 + String expectedVals = "\n" + getExpectedBase() + "\n" 63.102 + + getExpectedContainer() + "\n"; 63.103 + StringBuilder commonStmts = getCommonStmts(true); 63.104 63.105 -// /* 63.106 -// Sample testSrc: 63.107 -// @Retention(RetentionPolicy.RUNTIME) 63.108 -// @Inherited 63.109 -// @Repeatable(FooContainer.class) 63.110 -// @interface Foo {int value() default Integer.MAX_VALUE;} 63.111 + /* 63.112 + Sample testSrc: 63.113 + @Retention(RetentionPolicy.RUNTIME) 63.114 + @Inherited 63.115 + @Repeatable(FooContainer.class) 63.116 + @interface Foo {int value() default Integer.MAX_VALUE;} 63.117 63.118 -// @Retention(RetentionPolicy.RUNTIME) 63.119 -// @Inherited 63.120 -// @interface FooContainer { 63.121 -// Foo[] value(); 63.122 -// } 63.123 + @Retention(RetentionPolicy.RUNTIME) 63.124 + @Inherited 63.125 + @interface FooContainer { 63.126 + Foo[] value(); 63.127 + } 63.128 63.129 -// @Foo() @Foo 63.130 -// class SuperClass { } 63.131 + @Foo(1) @Foo(2) 63.132 + class SuperClass { } 63.133 63.134 -// @ExpectedBase 63.135 -// @ExpectedContainer 63.136 -// @Foo 63.137 -// class SubClass extends SuperClass { } 63.138 -// */ 63.139 -// //@Inherited only works for classes, no switch cases for method, field, package 63.140 + @ExpectedBase 63.141 + @ExpectedContainer 63.142 + @Foo(3) 63.143 + class SubClass extends SuperClass { } 63.144 + */ 63.145 + //@Inherited only works for classes, no switch cases for method, field, package 63.146 + if (srcType == SrcType.CLASS) { 63.147 + //Contents for SuperClass 63.148 + anno = Helper.ContentVars.REPEATABLEANNO.getVal(); 63.149 + replaceVal = commonStmts + "\n" + anno; 63.150 + String superClassContents = srcType.getTemplate() 63.151 + .replace("#CN", SUPERCLASS) 63.152 + .replace("#REPLACE", replaceVal); 63.153 63.154 -// if (srcType == SrcType.CLASS) { 63.155 -// //Contents for SuperClass 63.156 -// anno = Helper.ContentVars.REPEATABLEANNO.getVal(); 63.157 -// replaceVal = commonStmts + "\n" + anno; 63.158 -// String superClassContents = srcType.getTemplate() 63.159 -// .replace("#CN", SUPERCLASS) 63.160 -// .replace("#REPLACE", replaceVal); 63.161 + //Contents for SubClass that extends SuperClass 63.162 + anno = "@Foo(3)"; 63.163 + replaceVal = expectedVals + "\n" + anno; 63.164 + String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 63.165 + .replace("#CN", className) 63.166 + .replace("#SN", SUPERCLASS) 63.167 + .replace("#REPLACE", replaceVal); 63.168 + contents = superClassContents + subClassContents; 63.169 + srcFileObj = Helper.getFile(className, contents); 63.170 + files = Arrays.asList(srcFileObj); 63.171 + } 63.172 + return files; 63.173 + } 63.174 + }, 63.175 + // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 63.176 + // fail with ordering issues 63.177 + SingleOnSuperRepeatableOnSub_Inherited( 63.178 + "@ExpectedBase(value=Foo.class, " 63.179 + + "getAnnotationVal = \"@Foo(value=0)\", " 63.180 + + "getAnnotationsVals = {" 63.181 + + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 63.182 + + //override every annotation on superClass 63.183 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 63.184 + + // ignores inherited annotations 63.185 + "getDeclAnnoVal = \"NULL\","// ignores inherited 63.186 + + "getAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"}, " 63.187 + + "getDeclAnnosArgs = { \"@Foo(value=1)\", \"@Foo(value=2)\"})", 63.188 + "@ExpectedContainer(value=FooContainer.class, " 63.189 + + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 63.190 + + "getAnnotationsVals = {" 63.191 + + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 63.192 + + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 63.193 + + // ignores inherited annotations 63.194 + "getDeclAnnoVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", "// ignores inherited 63.195 + + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 63.196 + + "getDeclAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"})") { 63.197 63.198 -// //Contents for SubClass that extends SuperClass 63.199 -// anno = "@Foo(0)"; 63.200 -// replaceVal = expectedVals + "\n" + anno; 63.201 -// String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 63.202 -// .replace("#CN", className) 63.203 -// .replace("#SN", SUPERCLASS) 63.204 -// .replace("#REPLACE", replaceVal); 63.205 -// contents = superClassContents + subClassContents; 63.206 -// srcFileObj = Helper.getFile(className, contents); 63.207 -// files = Arrays.asList(srcFileObj); 63.208 -// } 63.209 -// return files; 63.210 -// } 63.211 -// }, 63.212 -// //Testcase not working as expected, JDK-8004912 63.213 -// SingleOnSuperRepeatableOnSub_Inherited( 63.214 -// "@ExpectedBase(value=Foo.class, " 63.215 -// + "getAnnotationVal = \"Foo\", " 63.216 -// + "getAnnotationsVals = {" 63.217 -// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, " 63.218 -// + //override every annotation on superClass 63.219 -// "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, " 63.220 -// + // ignores inherited annotations 63.221 -// "getDeclAnnoVal = \"NULL\","// ignores inherited 63.222 -// + "getAnnosArgs = {\"Foo\", \"Foo\"}, " 63.223 -// + "getDeclAnnosArgs = { \"Foo\", \"Foo\"})", 63.224 -// "@ExpectedContainer(value=FooContainer.class, " 63.225 -// + "getAnnotationVal = \"FooContainer\", " 63.226 -// + "getAnnotationsVals = {" 63.227 -// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, " 63.228 -// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, " 63.229 -// + // ignores inherited annotations 63.230 -// "getDeclAnnoVal = \"FooContainer\", "// ignores inherited 63.231 -// + "getAnnosArgs = {\"FooContainer\"}, " 63.232 -// + "getDeclAnnosArgs = {\"FooContainer\"})") { 63.233 + @Override 63.234 + public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 63.235 + String className) { 63.236 + String anno = ""; 63.237 + String replaceVal = ""; 63.238 + String contents = ""; 63.239 + JavaFileObject srcFileObj = null; 63.240 + Iterable<? extends JavaFileObject> files = null; 63.241 63.242 -// @Override 63.243 -// public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 63.244 -// String className) { 63.245 -// String anno = ""; 63.246 -// String replaceVal = ""; 63.247 -// String contents = ""; 63.248 -// JavaFileObject srcFileObj = null; 63.249 -// Iterable<? extends JavaFileObject> files = null; 63.250 + String expectedVals = "\n" + getExpectedBase() + "\n" 63.251 + + getExpectedContainer() + "\n"; 63.252 + StringBuilder commonStmts = getCommonStmts(true); 63.253 63.254 -// String expectedVals = "\n" + getExpectedBase() + "\n" 63.255 -// + getExpectedContainer() + "\n"; 63.256 -// StringBuilder commonStmts = getCommonStmts(true); 63.257 + /* 63.258 + Sample testSrc: 63.259 + @Retention(RetentionPolicy.RUNTIME) 63.260 + @Inherited 63.261 + @Repeatable(FooContainer.class) 63.262 + @interface Foo {int value() default Integer.MAX_VALUE;} 63.263 63.264 -// /* 63.265 -// Sample testSrc: 63.266 -// @Retention(RetentionPolicy.RUNTIME) 63.267 -// @Inherited 63.268 -// @Repeatable(FooContainer.class) 63.269 -// @interface Foo {int value() default Integer.MAX_VALUE;} 63.270 + @Retention(RetentionPolicy.RUNTIME) 63.271 + @Inherited 63.272 + @interface FooContainer { 63.273 + Foo[] value(); 63.274 + } 63.275 63.276 -// @Retention(RetentionPolicy.RUNTIME) 63.277 -// @Inherited 63.278 -// @interface FooContainer { 63.279 -// Foo[] value(); 63.280 -// } 63.281 + @Foo(0) 63.282 + class SuperClass { } 63.283 63.284 -// @Foo() 63.285 -// class SuperClass { } 63.286 + @ExpectedBase 63.287 + @ExpectedContainer 63.288 + @Foo(1) @Foo(2) 63.289 + class SubClass extends SuperClass { } 63.290 + */ 63.291 + //@Inherited only works for classes, no switch cases for method, field, package 63.292 + if (srcType == SrcType.CLASS) { 63.293 + //Contents for SuperClass 63.294 + anno = Helper.ContentVars.BASEANNO.getVal(); 63.295 + replaceVal = commonStmts + "\n" + anno; 63.296 + String superClassContents = srcType.getTemplate() 63.297 + .replace("#CN", SUPERCLASS) 63.298 + .replace("#REPLACE", replaceVal); 63.299 63.300 -// @ExpectedBase 63.301 -// @ExpectedContainer 63.302 -// @Foo @Foo 63.303 -// class SubClass extends SuperClass { } 63.304 -// */ 63.305 + //Contents for SubClass that extends SuperClass 63.306 + anno = Helper.ContentVars.REPEATABLEANNO.getVal(); 63.307 + replaceVal = expectedVals + "\n" + anno; 63.308 + String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 63.309 + .replace("#CN", className) 63.310 + .replace("#SN", SUPERCLASS) 63.311 + .replace("#REPLACE", replaceVal); 63.312 63.313 -// //@Inherited only works for classes, no switch cases for method, field, package 63.314 -// if (srcType == SrcType.CLASS) { 63.315 -// //Contents for SuperClass 63.316 -// anno = "@Foo(0)"; 63.317 -// replaceVal = commonStmts + "\n" + anno; 63.318 -// String superClassContents = srcType.getTemplate() 63.319 -// .replace("#CN", SUPERCLASS) 63.320 -// .replace("#REPLACE", replaceVal); 63.321 + contents = superClassContents + subClassContents; 63.322 + srcFileObj = Helper.getFile(className, contents); 63.323 + files = Arrays.asList(srcFileObj); 63.324 + } 63.325 + return files; 63.326 + } 63.327 + }, 63.328 + // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 63.329 + // fail with ordering issues 63.330 + ContainerOnSuperSingleOnSub_Inherited( 63.331 + "@ExpectedBase(value=Foo.class, " 63.332 + + "getAnnotationVal = \"@Foo(value=0)\", " 63.333 + + "getAnnotationsVals = {" 63.334 + + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 63.335 + + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"}," 63.336 + + "getDeclAnnoVal = \"@Foo(value=0)\"," 63.337 + + "getAnnosArgs = {\"@Foo(value=0)\"}," 63.338 + + "getDeclAnnosArgs = {\"@Foo(value=0)\"})", 63.339 + "@ExpectedContainer(value=FooContainer.class, " 63.340 + + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 63.341 + + "getAnnotationsVals = {" 63.342 + + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 63.343 + + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"}," 63.344 + + "getDeclAnnoVal = \"NULL\"," 63.345 + + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 63.346 + + "getDeclAnnosArgs = {})") { 63.347 63.348 -// //Contents for SubClass that extends SuperClass 63.349 -// anno = Helper.ContentVars.REPEATABLEANNO.getVal(); 63.350 -// replaceVal = expectedVals + "\n" + anno; 63.351 -// String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 63.352 -// .replace("#CN", className) 63.353 -// .replace("#SN", SUPERCLASS) 63.354 -// .replace("#REPLACE", replaceVal); 63.355 + @Override 63.356 + public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 63.357 + String className) { 63.358 + String anno = ""; 63.359 + String replaceVal = ""; 63.360 + String contents = ""; 63.361 + JavaFileObject srcFileObj = null; 63.362 + Iterable<? extends JavaFileObject> files = null; 63.363 63.364 -// contents = superClassContents + subClassContents; 63.365 -// srcFileObj = Helper.getFile(className, contents); 63.366 -// files = Arrays.asList(srcFileObj); 63.367 -// } 63.368 -// return files; 63.369 -// } 63.370 -// }, 63.371 -// //Testcase not working as expected, JDK-8004912 63.372 -// ContainerOnSuperSingleOnSub_Inherited( 63.373 -// "@ExpectedBase(value=Foo.class, " 63.374 -// + "getAnnotationVal = \"Foo\", " 63.375 -// + "getAnnotationsVals = {" 63.376 -// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, " 63.377 -// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}," 63.378 -// + "getDeclAnnoVal = \"Foo\"," 63.379 -// + "getAnnosArgs = {\"Foo\"}," 63.380 -// + "getDeclAnnosArgs = {\"Foo\"})", 63.381 -// "@ExpectedContainer(value=FooContainer.class, " 63.382 -// + "getAnnotationVal = \"FooContainer\", " 63.383 -// + "getAnnotationsVals = {" 63.384 -// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, " 63.385 -// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}," 63.386 -// + "getDeclAnnoVal = \"NULL\"," 63.387 -// + "getAnnosArgs = {\"FooContainer\"}," 63.388 -// + "getDeclAnnosArgs = {})") { 63.389 + String expectedVals = "\n" + getExpectedBase() + "\n" 63.390 + + getExpectedContainer() + "\n"; 63.391 + StringBuilder commonStmts = getCommonStmts(true); 63.392 63.393 -// @Override 63.394 -// public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 63.395 -// String className) { 63.396 -// String anno = ""; 63.397 -// String replaceVal = ""; 63.398 -// String contents = ""; 63.399 -// JavaFileObject srcFileObj = null; 63.400 -// Iterable<? extends JavaFileObject> files = null; 63.401 + /* 63.402 + Sample testSrc: 63.403 + @Retention(RetentionPolicy.RUNTIME) 63.404 + @Inherited 63.405 + @Repeatable(FooContainer.class) 63.406 + @interface Foo {int value() default Integer.MAX_VALUE;} 63.407 63.408 -// String expectedVals = "\n" + getExpectedBase() + "\n" 63.409 -// + getExpectedContainer() + "\n"; 63.410 -// StringBuilder commonStmts = getCommonStmts(true); 63.411 + @Retention(RetentionPolicy.RUNTIME) 63.412 + @Inherited 63.413 + @interface FooContainer { 63.414 + Foo[] value(); 63.415 + } 63.416 63.417 -// /* 63.418 -// Sample testSrc: 63.419 -// @Retention(RetentionPolicy.RUNTIME) 63.420 -// @Inherited 63.421 -// @Repeatable(FooContainer.class) 63.422 -// @interface Foo {int value() default Integer.MAX_VALUE;} 63.423 + @FooContainer(value = {@Foo(1), @Foo(2)}) 63.424 + class SuperClass { } 63.425 63.426 -// @Retention(RetentionPolicy.RUNTIME) 63.427 -// @Inherited 63.428 -// @interface FooContainer { 63.429 -// Foo[] value(); 63.430 -// } 63.431 + @ExpectedBase 63.432 + @ExpectedContainer 63.433 + @Foo(0) 63.434 + class SubClass extends SuperClass { } 63.435 + */ 63.436 + //@Inherited only works for classes, no switch cases for method, field, package 63.437 + if (srcType == SrcType.CLASS) { 63.438 + //Contents for SuperClass 63.439 + anno = Helper.ContentVars.LEGACYCONTAINER.getVal(); 63.440 + replaceVal = commonStmts + "\n" + anno; 63.441 + String superClassContents = srcType.getTemplate() 63.442 + .replace("#CN", SUPERCLASS) 63.443 + .replace("#REPLACE", replaceVal); 63.444 63.445 -// @FooContainer(value = {@Foo, @Foo}) 63.446 -// class SuperClass { } 63.447 + //Contents for SubClass that extends SuperClass 63.448 + anno = Helper.ContentVars.BASEANNO.getVal(); 63.449 + replaceVal = expectedVals + "\n" + anno; 63.450 + String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 63.451 + .replace("#CN", className) 63.452 + .replace("#SN", SUPERCLASS) 63.453 + .replace("#REPLACE", replaceVal); 63.454 63.455 -// @ExpectedBase 63.456 -// @ExpectedContainer 63.457 -// @Foo 63.458 -// class SubClass extends SuperClass { } 63.459 -// */ 63.460 + contents = superClassContents + subClassContents; 63.461 + srcFileObj = Helper.getFile(className, contents); 63.462 + files = Arrays.asList(srcFileObj); 63.463 + } 63.464 + return files; 63.465 + } 63.466 + }, 63.467 + // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 63.468 + // fail with ordering issues 63.469 + SingleOnSuperContainerOnSub_Inherited( 63.470 + "@ExpectedBase(value=Foo.class, " 63.471 + + "getAnnotationVal = \"@Foo(value=0)\", " 63.472 + + "getAnnotationsVals = {" 63.473 + + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 63.474 + + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 63.475 + + "getDeclAnnoVal = \"NULL\"," 63.476 + + "getAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"}," 63.477 + + "getDeclAnnosArgs = {\"@Foo(value=1)\", \"@Foo(value=2)\"})", 63.478 + "@ExpectedContainer(value=FooContainer.class, " 63.479 + + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 63.480 + + "getAnnotationsVals = {" 63.481 + + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 63.482 + + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 63.483 + + "getDeclAnnoVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"," 63.484 + + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 63.485 + + "getDeclAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"})") { 63.486 63.487 -// //@Inherited only works for classes, no switch cases for method, field, package 63.488 -// if (srcType == SrcType.CLASS) { 63.489 -// //Contents for SuperClass 63.490 -// anno = Helper.ContentVars.LEGACYCONTAINER.getVal(); 63.491 -// replaceVal = commonStmts + "\n" + anno; 63.492 -// String superClassContents = srcType.getTemplate() 63.493 -// .replace("#CN", SUPERCLASS) 63.494 -// .replace("#REPLACE", replaceVal); 63.495 + @Override 63.496 + public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 63.497 + String className) { 63.498 + String anno = ""; 63.499 + String replaceVal = ""; 63.500 + String contents = ""; 63.501 + JavaFileObject srcFileObj = null; 63.502 + Iterable<? extends JavaFileObject> files = null; 63.503 63.504 -// //Contents for SubClass that extends SuperClass 63.505 -// anno = "@Foo(0)"; 63.506 -// replaceVal = expectedVals + "\n" + anno; 63.507 -// String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 63.508 -// .replace("#CN", className) 63.509 -// .replace("#SN", SUPERCLASS) 63.510 -// .replace("#REPLACE", replaceVal); 63.511 + String expectedVals = "\n" + getExpectedBase() + "\n" 63.512 + + getExpectedContainer() + "\n"; 63.513 + StringBuilder commonStmts = getCommonStmts(true); 63.514 63.515 -// contents = superClassContents + subClassContents; 63.516 -// srcFileObj = Helper.getFile(className, contents); 63.517 -// files = Arrays.asList(srcFileObj); 63.518 -// } 63.519 -// return files; 63.520 -// } 63.521 -// }, 63.522 -// // TestCase not working as expected, JDK-8004912 63.523 -// SingleOnSuperContainerOnSub_Inherited( 63.524 -// "@ExpectedBase(value=Foo.class, " 63.525 -// + "getAnnotationVal = \"Foo\", " 63.526 -// + "getAnnotationsVals = {" 63.527 -// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, " 63.528 -// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}," 63.529 -// + "getDeclAnnoVal = \"NULL\"," 63.530 -// + "getAnnosArgs = {\"Foo\", \"Foo\"}," 63.531 -// + "getDeclAnnosArgs = {\"Foo\", \"Foo\"})", 63.532 -// "@ExpectedContainer(value=FooContainer.class, " 63.533 -// + "getAnnotationVal = \"FooContainer\", " 63.534 -// + "getAnnotationsVals = {" 63.535 -// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, " 63.536 -// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}," 63.537 -// + "getDeclAnnoVal = \"FooContainer\"," 63.538 -// + "getAnnosArgs = {\"FooContainer\"}," 63.539 -// + "getDeclAnnosArgs = {\"FooContainer\"})") { 63.540 + /* 63.541 + Sample testSrc: 63.542 + @Retention(RetentionPolicy.RUNTIME) 63.543 + @Inherited 63.544 + @Repeatable(FooContainer.class) 63.545 + @interface Foo {int value() default Integer.MAX_VALUE;} 63.546 63.547 -// @Override 63.548 -// public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 63.549 -// String className) { 63.550 -// String anno = ""; 63.551 -// String replaceVal = ""; 63.552 -// String contents = ""; 63.553 -// JavaFileObject srcFileObj = null; 63.554 -// Iterable<? extends JavaFileObject> files = null; 63.555 + @Retention(RetentionPolicy.RUNTIME) 63.556 + @Inherited 63.557 + @interface FooContainer { 63.558 + Foo[] value(); 63.559 + } 63.560 63.561 -// String expectedVals = "\n" + getExpectedBase() + "\n" 63.562 -// + getExpectedContainer() + "\n"; 63.563 -// StringBuilder commonStmts = getCommonStmts(true); 63.564 + @Foo(0) 63.565 + class SuperClass { } 63.566 63.567 -// /* 63.568 -// Sample testSrc: 63.569 -// @Retention(RetentionPolicy.RUNTIME) 63.570 -// @Inherited 63.571 -// @Repeatable(FooContainer.class) 63.572 -// @interface Foo {int value() default Integer.MAX_VALUE;} 63.573 + @ExpectedBase 63.574 + @ExpectedContainer 63.575 + @FooContainer(value = {@Foo(1), @Foo(2)}) 63.576 + class SubClass extends SuperClass { } 63.577 + */ 63.578 + //@Inherited only works for classes, no switch cases for method, field, package 63.579 + if (srcType == SrcType.CLASS) { 63.580 + //Contents for SuperClass 63.581 + anno = Helper.ContentVars.BASEANNO.getVal(); 63.582 + replaceVal = commonStmts + "\n" + anno; 63.583 + String superClassContents = srcType.getTemplate() 63.584 + .replace("#CN", SUPERCLASS) 63.585 + .replace("#REPLACE", replaceVal); 63.586 63.587 -// @Retention(RetentionPolicy.RUNTIME) 63.588 -// @Inherited 63.589 -// @interface FooContainer { 63.590 -// Foo[] value(); 63.591 -// } 63.592 + //Contents for SubClass that extends SuperClass 63.593 + anno = Helper.ContentVars.LEGACYCONTAINER.getVal(); 63.594 + replaceVal = expectedVals + "\n" + anno; 63.595 + String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 63.596 + .replace("#CN", className) 63.597 + .replace("#SN", SUPERCLASS) 63.598 + .replace("#REPLACE", replaceVal); 63.599 63.600 -// @Foo 63.601 -// class SuperClass { } 63.602 - 63.603 -// @ExpectedBase 63.604 -// @ExpectedContainer 63.605 -// @FooContainer(value = {@Foo, @Foo}) 63.606 -// class SubClass extends SuperClass { } 63.607 -// */ 63.608 - 63.609 -// //@Inherited only works for classes, no switch cases for method, field, package 63.610 -// if (srcType == SrcType.CLASS) { 63.611 -// //Contents for SuperClass 63.612 -// anno = "@Foo(0)"; 63.613 -// replaceVal = commonStmts + "\n" + anno; 63.614 -// String superClassContents = srcType.getTemplate() 63.615 -// .replace("#CN", SUPERCLASS) 63.616 -// .replace("#REPLACE", replaceVal); 63.617 - 63.618 -// //Contents for SubClass that extends SuperClass 63.619 -// anno = Helper.ContentVars.LEGACYCONTAINER.getVal(); 63.620 -// replaceVal = expectedVals + "\n" + anno; 63.621 -// String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 63.622 -// .replace("#CN", className) 63.623 -// .replace("#SN", SUPERCLASS) 63.624 -// .replace("#REPLACE", replaceVal); 63.625 - 63.626 -// contents = superClassContents + subClassContents; 63.627 -// srcFileObj = Helper.getFile(className, contents); 63.628 -// files = Arrays.asList(srcFileObj); 63.629 -// } 63.630 -// return files; 63.631 -// } 63.632 -// }, 63.633 + contents = superClassContents + subClassContents; 63.634 + srcFileObj = Helper.getFile(className, contents); 63.635 + files = Arrays.asList(srcFileObj); 63.636 + } 63.637 + return files; 63.638 + } 63.639 + }, 63.640 // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 63.641 // fail with ordering issues 63.642 SingleOnSuperContainerAndSingleOnSub_Inherited( 63.643 @@ -2009,87 +2014,88 @@ 63.644 return files; 63.645 } 63.646 }, 63.647 -// // TestCase not working as expected, JDK-8004912 63.648 -// ContainerAndSingleOnSuperSingleOnSub_Inherited( 63.649 -// "@ExpectedBase(value=Foo.class, " 63.650 -// + "getAnnotationVal = \"Foo\", " 63.651 -// + "getAnnotationsVals = {" 63.652 -// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, " 63.653 -// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}," 63.654 -// + "getDeclAnnoVal = \"Foo\"," 63.655 -// + "getAnnosArgs = {\"Foo\"}," 63.656 -// + "getDeclAnnosArgs = {\"Foo\"})", 63.657 -// "@ExpectedContainer(value=FooContainer.class, " 63.658 -// + "getAnnotationVal = \"FooContainer\", " 63.659 -// + "getAnnotationsVals = {" 63.660 -// + "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, " 63.661 -// + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}," 63.662 -// + "getDeclAnnoVal = \"NULL\"," 63.663 -// + "getAnnosArgs = {\"FooContainer\"}," 63.664 -// + "getDeclAnnosArgs = {})") { 63.665 + // @ignore 8025924: Several test cases in repeatingAnnotations/combo/ReflectionTest 63.666 + // fail with ordering issues 63.667 + ContainerAndSingleOnSuperSingleOnSub_Inherited( 63.668 + "@ExpectedBase(value=Foo.class, " 63.669 + + "getAnnotationVal = \"@Foo(value=0)\", " 63.670 + + "getAnnotationsVals = {" 63.671 + + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 63.672 + + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"}," 63.673 + + "getDeclAnnoVal = \"@Foo(value=0)\"," 63.674 + + "getAnnosArgs = {\"@Foo(value=0)\"}," 63.675 + + "getDeclAnnosArgs = {\"@Foo(value=0)\"})", 63.676 + "@ExpectedContainer(value=FooContainer.class, " 63.677 + + "getAnnotationVal = \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\", " 63.678 + + "getAnnotationsVals = {" 63.679 + + "\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\", \"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}, " 63.680 + + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"@Foo(value=0)\"}," 63.681 + + "getDeclAnnoVal = \"NULL\"," 63.682 + + "getAnnosArgs = {\"@FooContainer(value=[@Foo(value=1), @Foo(value=2)])\"}," 63.683 + + "getDeclAnnosArgs = {})") { 63.684 63.685 -// @Override 63.686 -// public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 63.687 -// String className) { 63.688 -// String anno = ""; 63.689 -// String replaceVal = ""; 63.690 -// String contents = ""; 63.691 -// JavaFileObject srcFileObj = null; 63.692 -// Iterable<? extends JavaFileObject> files = null; 63.693 + @Override 63.694 + public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType, 63.695 + String className) { 63.696 + String anno = ""; 63.697 + String replaceVal = ""; 63.698 + String contents = ""; 63.699 + JavaFileObject srcFileObj = null; 63.700 + Iterable<? extends JavaFileObject> files = null; 63.701 63.702 -// String expectedVals = "\n" + getExpectedBase() + "\n" 63.703 -// + getExpectedContainer() + "\n"; 63.704 -// StringBuilder commonStmts = getCommonStmts(true); 63.705 + String expectedVals = "\n" + getExpectedBase() + "\n" 63.706 + + getExpectedContainer() + "\n"; 63.707 + StringBuilder commonStmts = getCommonStmts(true); 63.708 63.709 -// /* 63.710 -// Sample testSrc: 63.711 -// @Retention(RetentionPolicy.RUNTIME) 63.712 -// @Inherited 63.713 -// @Repeatable(FooContainer.class) 63.714 -// @interface Foo {int value() default Integer.MAX_VALUE;} 63.715 + /* 63.716 + Sample testSrc: 63.717 + @Retention(RetentionPolicy.RUNTIME) 63.718 + @Inherited 63.719 + @Repeatable(FooContainer.class) 63.720 + @interface Foo {int value() default Integer.MAX_VALUE;} 63.721 63.722 -// @Retention(RetentionPolicy.RUNTIME) 63.723 -// @Inherited 63.724 -// @interface FooContainer { 63.725 -// Foo[] value(); 63.726 -// } 63.727 + @Retention(RetentionPolicy.RUNTIME) 63.728 + @Inherited 63.729 + @interface FooContainer { 63.730 + Foo[] value(); 63.731 + } 63.732 63.733 -// @FooContainer(value = {@Foo, @Foo}) 63.734 -// @Foo 63.735 -// class SuperClass { } 63.736 + @FooContainer(value = {@Foo(1), @Foo(2)}) 63.737 + @Foo(3) 63.738 + class SuperClass { } 63.739 63.740 -// @ExpectedBase 63.741 -// @ExpectedContainer 63.742 -// @Foo 63.743 -// class SubClass extends SuperClass { } 63.744 -// */ 63.745 + @ExpectedBase 63.746 + @ExpectedContainer 63.747 + @Foo(0) 63.748 + class SubClass extends SuperClass { } 63.749 + */ 63.750 63.751 -// //@Inherited only works for classes, no switch cases for method, field, package 63.752 -// if (srcType == SrcType.CLASS) { 63.753 -// //Contents for SuperClass 63.754 -// anno = Helper.ContentVars.LEGACYCONTAINER.getVal() 63.755 -// + Helper.ContentVars.BASEANNO.getVal(); 63.756 -// replaceVal = commonStmts + "\n" + anno; 63.757 -// String superClassContents = srcType.getTemplate() 63.758 -// .replace("#CN", SUPERCLASS) 63.759 -// .replace("#REPLACE", replaceVal); 63.760 + //@Inherited only works for classes, no switch cases for method, field, package 63.761 + if (srcType == SrcType.CLASS) { 63.762 + //Contents for SuperClass 63.763 + anno = Helper.ContentVars.LEGACYCONTAINER.getVal() 63.764 + + "@Foo(3)" ; 63.765 + replaceVal = commonStmts + "\n" + anno; 63.766 + String superClassContents = srcType.getTemplate() 63.767 + .replace("#CN", SUPERCLASS) 63.768 + .replace("#REPLACE", replaceVal); 63.769 63.770 -// //Contents for SubClass that extends SuperClass 63.771 -// anno = "@Foo(0)"; 63.772 -// replaceVal = expectedVals + "\n" + anno; 63.773 -// String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 63.774 -// .replace("#CN", className) 63.775 -// .replace("#SN", SUPERCLASS) 63.776 -// .replace("#REPLACE", replaceVal); 63.777 + //Contents for SubClass that extends SuperClass 63.778 + anno = Helper.ContentVars.BASEANNO.getVal(); 63.779 + replaceVal = expectedVals + "\n" + anno; 63.780 + String subClassContents = SrcType.CLASSEXTENDS.getTemplate() 63.781 + .replace("#CN", className) 63.782 + .replace("#SN", SUPERCLASS) 63.783 + .replace("#REPLACE", replaceVal); 63.784 63.785 -// contents = superClassContents + subClassContents; 63.786 -// srcFileObj = Helper.getFile(className, contents); 63.787 -// files = Arrays.asList(srcFileObj); 63.788 -// } 63.789 -// return files; 63.790 -// } 63.791 -// } 63.792 - ; 63.793 + contents = superClassContents + subClassContents; 63.794 + srcFileObj = Helper.getFile(className, contents); 63.795 + files = Arrays.asList(srcFileObj); 63.796 + } 63.797 + return files; 63.798 + } 63.799 + }; 63.800 + 63.801 private String expectedBase, expectedContainer; 63.802 63.803 private TestCase(String expectedBase, String expectedContainer) { 63.804 @@ -2942,7 +2948,7 @@ 63.805 System.out.print("Actual Arr Values: "); 63.806 for (Annotation a : actualAnnos) { 63.807 if (a != null && a.annotationType() != null) { 63.808 - System.out.print("[" + a.annotationType().getSimpleName() + "]"); 63.809 + System.out.print("[" + a.toString() + "]"); 63.810 } else { 63.811 System.out.println("[null]"); 63.812 }
64.1 --- a/test/tools/javac/annotations/repeatingAnnotations/combo/TargetAnnoCombo.java Mon May 19 22:00:11 2014 -0700 64.2 +++ b/test/tools/javac/annotations/repeatingAnnotations/combo/TargetAnnoCombo.java Thu May 29 13:46:36 2014 -0700 64.3 @@ -1,5 +1,5 @@ 64.4 /* 64.5 - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 64.6 + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. 64.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 64.8 * 64.9 * This code is free software; you can redistribute it and/or modify it 64.10 @@ -23,7 +23,7 @@ 64.11 64.12 /* 64.13 * @test 64.14 - * @bug 7151010 8006547 8007766 64.15 + * @bug 7151010 8006547 8007766 8029017 64.16 * @summary Default test cases for running combinations for Target values 64.17 * @build Helper 64.18 * @run main TargetAnnoCombo 64.19 @@ -145,11 +145,19 @@ 64.20 64.21 Set<ElementType> tempBaseSet = EnumSet.noneOf(ElementType.class); 64.22 tempBaseSet.addAll(baseAnnotations); 64.23 + 64.24 // If BaseAnno has TYPE, then ANNOTATION_TYPE is allowed by default. 64.25 if (baseAnnotations.contains(TYPE)) { 64.26 tempBaseSet.add(ANNOTATION_TYPE); 64.27 } 64.28 64.29 + // If BaseAnno has TYPE_USE, then add the extra allowed types 64.30 + if (baseAnnotations.contains(TYPE_USE)) { 64.31 + tempBaseSet.add(ANNOTATION_TYPE); 64.32 + tempBaseSet.add(TYPE); 64.33 + tempBaseSet.add(TYPE_PARAMETER); 64.34 + } 64.35 + 64.36 // If containerAnno has no @Target, only valid case if baseAnnoTarget has 64.37 // all targets defined else invalid set. 64.38 if (containerAnnotations == null) {
65.1 --- a/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateScoping.out Mon May 19 22:00:11 2014 -0700 65.2 +++ b/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateScoping.out Thu May 29 13:46:36 2014 -0700 65.3 @@ -6,6 +6,7 @@ 65.4 CantAnnotateScoping.java:56:37: compiler.err.cant.type.annotate.scoping: @TA,@TA2 65.5 CantAnnotateScoping.java:40:14: compiler.err.cant.type.annotate.scoping.1: @TA 65.6 CantAnnotateScoping.java:42:34: compiler.err.cant.type.annotate.scoping: @TA,@DA,@TA2 65.7 +CantAnnotateScoping.java:42:25: compiler.err.annotation.type.not.applicable 65.8 CantAnnotateScoping.java:44:38: compiler.err.cant.type.annotate.scoping: @TA,@DA 65.9 CantAnnotateScoping.java:44:34: compiler.err.annotation.type.not.applicable 65.10 -10 errors 65.11 \ No newline at end of file 65.12 +11 errors
66.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 66.2 +++ b/test/tools/javac/annotations/typeAnnotations/failures/CheckErrorsForSource7.java Thu May 29 13:46:36 2014 -0700 66.3 @@ -0,0 +1,195 @@ 66.4 +/* 66.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 66.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 66.7 + * 66.8 + * This code is free software; you can redistribute it and/or modify it 66.9 + * under the terms of the GNU General Public License version 2 only, as 66.10 + * published by the Free Software Foundation. 66.11 + * 66.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 66.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 66.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 66.15 + * version 2 for more details (a copy is included in the LICENSE file that 66.16 + * accompanied this code). 66.17 + * 66.18 + * You should have received a copy of the GNU General Public License version 66.19 + * 2 along with this work; if not, write to the Free Software Foundation, 66.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 66.21 + * 66.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 66.23 + * or visit www.oracle.com if you need additional information or have any 66.24 + * questions. 66.25 + */ 66.26 + 66.27 +/**@test 66.28 + * @bug 8035890 66.29 + * @summary Verify that the parser correctly checks for source level 8 on the new places where 66.30 + * annotations can appear in 8. 66.31 + * @run main CheckErrorsForSource7 CheckErrorsForSource7.java 66.32 + */ 66.33 +import java.io.File; 66.34 +import java.io.IOException; 66.35 +import java.lang.annotation.ElementType; 66.36 +import java.lang.annotation.Target; 66.37 +import java.net.URI; 66.38 +import java.net.URISyntaxException; 66.39 +import java.util.ArrayList; 66.40 +import java.util.Arrays; 66.41 +import java.util.Collections; 66.42 +import java.util.Comparator; 66.43 +import java.util.HashSet; 66.44 +import java.util.List; 66.45 +import java.util.Set; 66.46 +import javax.tools.Diagnostic; 66.47 +import javax.tools.DiagnosticCollector; 66.48 +import javax.tools.JavaFileObject; 66.49 +import javax.tools.SimpleJavaFileObject; 66.50 +import com.sun.source.tree.AnnotationTree; 66.51 +import com.sun.source.tree.CompilationUnitTree; 66.52 +import com.sun.source.tree.IdentifierTree; 66.53 +import com.sun.source.tree.Tree.Kind; 66.54 +import com.sun.source.util.JavacTask; 66.55 +import com.sun.source.util.TreePathScanner; 66.56 +import com.sun.source.util.Trees; 66.57 +import com.sun.tools.javac.api.JavacTool; 66.58 +import com.sun.tools.javac.file.JavacFileManager; 66.59 + 66.60 +/**For each place where an annotation can syntactically appear with -source 8, but not with 66.61 + * -source 7, this test verifies that an error is correctly emitted from the parser for 66.62 + * the annotation for -source 7. This test first gathers the occurrences of @TA from 66.63 + * the CheckErrorsForSource7Data class below, and then repeatedly removes all these annotations 66.64 + * except one and checks the parser reports an expected error. This is needed as as the parser 66.65 + * typically produces only one 'insufficient source level' error for each new feature used. 66.66 + */ 66.67 +public class CheckErrorsForSource7 { 66.68 + public static void main(String... args) throws IOException, URISyntaxException { 66.69 + new CheckErrorsForSource7().run(args); 66.70 + } 66.71 + 66.72 + private void run(String... args) throws IOException, URISyntaxException { 66.73 + //the first and only parameter must be the name of the file to be analyzed: 66.74 + if (args.length != 1) throw new IllegalStateException("Must provide source file!"); 66.75 + File testSrc = new File(System.getProperty("test.src")); 66.76 + File testFile = new File(testSrc, args[0]); 66.77 + if (!testFile.canRead()) throw new IllegalStateException("Cannot read the test source"); 66.78 + JavacFileManager fm = JavacTool.create().getStandardFileManager(null, null, null); 66.79 + 66.80 + //gather spans of the @TA annotations into typeAnnotationSpans: 66.81 + JavacTask task = JavacTool.create().getTask(null, 66.82 + fm, 66.83 + null, 66.84 + Collections.<String>emptyList(), 66.85 + null, 66.86 + fm.getJavaFileObjects(testFile)); 66.87 + final Trees trees = Trees.instance(task); 66.88 + final CompilationUnitTree cut = task.parse().iterator().next(); 66.89 + final List<int[]> typeAnnotationSpans = new ArrayList<>(); 66.90 + 66.91 + new TreePathScanner<Void, Void>() { 66.92 + @Override 66.93 + public Void visitAnnotation(AnnotationTree node, Void p) { 66.94 + if (node.getAnnotationType().getKind() == Kind.IDENTIFIER && 66.95 + ((IdentifierTree) node.getAnnotationType()).getName().contentEquals("TA")) { 66.96 + int start = (int) trees.getSourcePositions().getStartPosition(cut, node); 66.97 + int end = (int) trees.getSourcePositions().getEndPosition(cut, node); 66.98 + typeAnnotationSpans.add(new int[] {start, end}); 66.99 + } 66.100 + return null; 66.101 + } 66.102 + }.scan(cut, null); 66.103 + 66.104 + //sort the spans in the reverse order, to simplify removing them from the source: 66.105 + Collections.sort(typeAnnotationSpans, new Comparator<int[]>() { 66.106 + @Override 66.107 + public int compare(int[] o1, int[] o2) { 66.108 + return o2[0] - o1[0]; 66.109 + } 66.110 + }); 66.111 + 66.112 + //verify the errors are produce correctly: 66.113 + String originalSource = cut.getSourceFile().getCharContent(false).toString(); 66.114 + 66.115 + for (int[] toKeep : typeAnnotationSpans) { 66.116 + //prepare updated source code by removing all the annotations except the toKeep one: 66.117 + String updated = originalSource; 66.118 + 66.119 + for (int[] span : typeAnnotationSpans) { 66.120 + if (span == toKeep) continue; 66.121 + 66.122 + updated = updated.substring(0, span[0]) + updated.substring(span[1]); 66.123 + } 66.124 + 66.125 + //parse and verify: 66.126 + JavaFileObject updatedFile = new TestFO(cut.getSourceFile().toUri(), updated); 66.127 + DiagnosticCollector<JavaFileObject> errors = new DiagnosticCollector<>(); 66.128 + JavacTask task2 = JavacTool.create().getTask(null, 66.129 + fm, 66.130 + errors, 66.131 + Arrays.asList("-source", "7"), 66.132 + null, 66.133 + Arrays.asList(updatedFile)); 66.134 + task2.parse(); 66.135 + 66.136 + boolean found = false; 66.137 + 66.138 + for (Diagnostic<? extends JavaFileObject> d : errors.getDiagnostics()) { 66.139 + if (d.getKind() == Diagnostic.Kind.ERROR && EXPECTED_ERRORS.contains(d.getCode())) { 66.140 + if (found) { 66.141 + throw new IllegalStateException("More than one expected error found."); 66.142 + } 66.143 + found = true; 66.144 + } 66.145 + } 66.146 + 66.147 + if (!found) 66.148 + throw new IllegalStateException("Did not produce proper errors for: " + updated); 66.149 + } 66.150 + } 66.151 + 66.152 + static final Set<String> EXPECTED_ERRORS = new HashSet<>(Arrays.asList( 66.153 + "compiler.err.type.annotations.not.supported.in.source", 66.154 + "compiler.err.annotations.after.type.params.not.supported.in.source" 66.155 + )); 66.156 + 66.157 + class TestFO extends SimpleJavaFileObject { 66.158 + private final String content; 66.159 + public TestFO(URI uri, String content) { 66.160 + super(uri, Kind.SOURCE); 66.161 + this.content = content; 66.162 + } 66.163 + 66.164 + @Override public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { 66.165 + return content; 66.166 + } 66.167 + 66.168 + @Override public boolean isNameCompatible(String simpleName, Kind kind) { 66.169 + return true; 66.170 + } 66.171 + } 66.172 +} 66.173 + 66.174 +//data on which the source level check is verified: 66.175 +class CheckErrorsForSource7Data { 66.176 + @Target(ElementType.TYPE_USE) 66.177 + @interface TA { } 66.178 + 66.179 + Object n1 = new @TA ArrayList<@TA String>(); 66.180 + Object n2 = new @TA Object() {}; 66.181 + Object [] @TA [] arr @TA[]; 66.182 + <T> @TA int @TA[] ret(Object obj) @TA[] throws @TA Exception { 66.183 + this.<@TA String>ret(null); 66.184 + Object c1 = new @TA String[1]; 66.185 + 66.186 + int val = obj instanceof @TA String ? ((@TA String) obj).length() : 0; 66.187 + List<@TA ?> l; 66.188 + return null; 66.189 + } 66.190 + void vararg(String @TA ... args) { } 66.191 + 66.192 + abstract class C<@TA T extends @TA Number & @TA Runnable> 66.193 + extends @TA ArrayList<@TA String> 66.194 + implements java.util. @TA Comparator<@TA T> { } 66.195 + 66.196 + interface I extends java.util. @TA Comparator<@TA String> { } 66.197 + 66.198 +}
67.1 --- a/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DeclarationAnnotation.out Mon May 19 22:00:11 2014 -0700 67.2 +++ b/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DeclarationAnnotation.out Thu May 29 13:46:36 2014 -0700 67.3 @@ -1,5 +1,5 @@ 67.4 +DeclarationAnnotation.java:13:21: compiler.err.annotation.type.not.applicable 67.5 DeclarationAnnotation.java:10:21: compiler.err.annotation.type.not.applicable 67.6 DeclarationAnnotation.java:11:21: compiler.err.annotation.type.not.applicable 67.7 DeclarationAnnotation.java:12:21: compiler.err.annotation.type.not.applicable 67.8 -DeclarationAnnotation.java:13:21: compiler.err.annotation.type.not.applicable 67.9 4 errors
68.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 68.2 +++ b/test/tools/javac/annotations/typeAnnotations/newlocations/AfterMethodTypeParams.java Thu May 29 13:46:36 2014 -0700 68.3 @@ -0,0 +1,138 @@ 68.4 +/* 68.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 68.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 68.7 + * 68.8 + * This code is free software; you can redistribute it and/or modify it 68.9 + * under the terms of the GNU General Public License version 2 only, as 68.10 + * published by the Free Software Foundation. 68.11 + * 68.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 68.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 68.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 68.15 + * version 2 for more details (a copy is included in the LICENSE file that 68.16 + * accompanied this code). 68.17 + * 68.18 + * You should have received a copy of the GNU General Public License version 68.19 + * 2 along with this work; if not, write to the Free Software Foundation, 68.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 68.21 + * 68.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 68.23 + * or visit www.oracle.com if you need additional information or have any 68.24 + * questions. 68.25 + */ 68.26 + 68.27 +/** 68.28 + * @test 68.29 + * @bug 8038788 68.30 + * @summary Verify proper handling of annotations after method's type parameters. 68.31 + * @build AfterMethodTypeParams 68.32 + * @run main AfterMethodTypeParams 68.33 + */ 68.34 + 68.35 +import java.io.IOException; 68.36 +import java.io.StringWriter; 68.37 +import java.net.URI; 68.38 +import java.util.*; 68.39 + 68.40 +import javax.lang.model.element.Name; 68.41 +import javax.tools.*; 68.42 + 68.43 +import com.sun.source.tree.*; 68.44 +import com.sun.source.util.*; 68.45 + 68.46 +public class AfterMethodTypeParams { 68.47 + 68.48 + public static void main(String... args) throws IOException { 68.49 + new AfterMethodTypeParams().run(); 68.50 + } 68.51 + 68.52 + void run() throws IOException { 68.53 + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); 68.54 + 68.55 + for (TestCase tc : testCases) { 68.56 + String test = TEMPLATE.replace("CONTENT", tc.snippet); 68.57 + List<JavaFileObject> files = Arrays.asList(new MyFileObject(test)); 68.58 + StringWriter out = new StringWriter(); 68.59 + List<String> options = Arrays.asList("-XDrawDiagnostics", "-XDshouldStopPolicy=FLOW"); 68.60 + JavacTask task = (JavacTask) compiler.getTask(out, null, null, options, null, files); 68.61 + 68.62 + new TreePathScanner<Void, Void>() { 68.63 + boolean seenAnnotation; 68.64 + @Override 68.65 + public Void visitAnnotation(AnnotationTree node, Void p) { 68.66 + Name name = ((IdentifierTree) node.getAnnotationType()).getName(); 68.67 + seenAnnotation |= name.contentEquals("TA") || name.contentEquals("DA"); 68.68 + return null; 68.69 + } 68.70 + @Override 68.71 + public Void visitCompilationUnit(CompilationUnitTree node, Void p) { 68.72 + super.visitCompilationUnit(node, p); 68.73 + if (!seenAnnotation) 68.74 + error(test, "Annotation was missing"); 68.75 + return null; 68.76 + } 68.77 + }.scan(task.parse(), null); 68.78 + 68.79 + task.analyze(); 68.80 + 68.81 + if (!tc.error.equals(out.toString().trim())) { 68.82 + error(test, "Incorrect errors: " + out.toString()); 68.83 + } 68.84 + } 68.85 + 68.86 + if (errors > 0) { 68.87 + throw new IllegalStateException("Errors found"); 68.88 + } 68.89 + } 68.90 + 68.91 + int errors; 68.92 + 68.93 + void error(String code, String error) { 68.94 + System.out.println("Error detected: " + error); 68.95 + System.out.println("Code:"); 68.96 + System.out.println(code); 68.97 + errors++; 68.98 + } 68.99 + 68.100 + static String TEMPLATE = 68.101 + "import java.lang.annotation.*;\n" + 68.102 + "public class Test {\n" + 68.103 + " CONTENT\n" + 68.104 + "}\n" + 68.105 + "@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})\n" + 68.106 + "@interface DA { }\n" + 68.107 + "@Target(ElementType.TYPE_USE)\n" + 68.108 + "@interface TA { }\n"; 68.109 + 68.110 + static class MyFileObject extends SimpleJavaFileObject { 68.111 + final String text; 68.112 + public MyFileObject(String text) { 68.113 + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); 68.114 + this.text = text; 68.115 + } 68.116 + @Override 68.117 + public CharSequence getCharContent(boolean ignoreEncodingErrors) { 68.118 + return text; 68.119 + } 68.120 + } 68.121 + 68.122 + static TestCase[] testCases = new TestCase[] { 68.123 + new TestCase("<T> @DA int foo1() { return 0;}", ""), 68.124 + new TestCase("<T> @DA void foo2() { }", ""), 68.125 + new TestCase("<T> @TA int foo3() { return 0;}", ""), 68.126 + new TestCase("<T> @TA void foo4() { }", 68.127 + "Test.java:3:9: compiler.err.annotation.type.not.applicable"), 68.128 + new TestCase("<T> @DA Test() { }", "Test.java:3:9: compiler.err.illegal.start.of.type"), 68.129 + new TestCase("<T> @TA Test() { }", "Test.java:3:9: compiler.err.illegal.start.of.type"), 68.130 + }; 68.131 + 68.132 + static class TestCase { 68.133 + final String snippet; 68.134 + final String error; 68.135 + public TestCase(String snippet, String error) { 68.136 + this.snippet = snippet; 68.137 + this.error = error; 68.138 + } 68.139 + } 68.140 +} 68.141 +
69.1 --- a/test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java Mon May 19 22:00:11 2014 -0700 69.2 +++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java Thu May 29 13:46:36 2014 -0700 69.3 @@ -1,5 +1,5 @@ 69.4 /* 69.5 - * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. 69.6 + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. 69.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 69.8 * 69.9 * This code is free software; you can redistribute it and/or modify it 69.10 @@ -30,6 +30,7 @@ 69.11 import java.lang.annotation.*; 69.12 import java.lang.reflect.*; 69.13 import java.util.ArrayList; 69.14 +import java.util.Arrays; 69.15 import java.util.Collections; 69.16 import java.util.HashMap; 69.17 import java.util.List; 69.18 @@ -51,6 +52,11 @@ 69.19 new Driver().runDriver(clazz.newInstance()); 69.20 } 69.21 69.22 + String[][] extraParamsCombinations = new String[][] { 69.23 + new String[] { }, 69.24 + new String[] { "-g" }, 69.25 + }; 69.26 + 69.27 protected void runDriver(Object object) throws Exception { 69.28 int passed = 0, failed = 0; 69.29 Class<?> clazz = object.getClass(); 69.30 @@ -65,18 +71,20 @@ 69.31 throw new IllegalArgumentException("Test method needs to return a string: " + method); 69.32 String testClass = testClassOf(method); 69.33 69.34 - try { 69.35 - String compact = (String)method.invoke(object); 69.36 - String fullFile = wrap(compact); 69.37 - ClassFile cf = compileAndReturn(fullFile, testClass); 69.38 - List<TypeAnnotation> actual = ReferenceInfoUtil.extendedAnnotationsOf(cf); 69.39 - ReferenceInfoUtil.compare(expected, actual, cf); 69.40 - out.println("PASSED: " + method.getName()); 69.41 - ++passed; 69.42 - } catch (Throwable e) { 69.43 - out.println("FAILED: " + method.getName()); 69.44 - out.println(" " + e.toString()); 69.45 - ++failed; 69.46 + for (String[] extraParams : extraParamsCombinations) { 69.47 + try { 69.48 + String compact = (String)method.invoke(object); 69.49 + String fullFile = wrap(compact); 69.50 + ClassFile cf = compileAndReturn(fullFile, testClass, extraParams); 69.51 + List<TypeAnnotation> actual = ReferenceInfoUtil.extendedAnnotationsOf(cf); 69.52 + ReferenceInfoUtil.compare(expected, actual, cf); 69.53 + out.println("PASSED: " + method.getName()); 69.54 + ++passed; 69.55 + } catch (Throwable e) { 69.56 + out.println("FAILED: " + method.getName()); 69.57 + out.println(" " + e.toString()); 69.58 + ++failed; 69.59 + } 69.60 } 69.61 } 69.62 69.63 @@ -156,7 +164,7 @@ 69.64 } 69.65 } 69.66 69.67 - private ClassFile compileAndReturn(String fullFile, String testClass) throws Exception { 69.68 + private ClassFile compileAndReturn(String fullFile, String testClass, String... extraParams) throws Exception { 69.69 File source = writeTestFile(fullFile); 69.70 File clazzFile = compileTestFile(source, testClass); 69.71 return ClassFile.read(clazzFile); 69.72 @@ -170,8 +178,12 @@ 69.73 return f; 69.74 } 69.75 69.76 - protected File compileTestFile(File f, String testClass) { 69.77 - int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.8", "-g", f.getPath() }); 69.78 + protected File compileTestFile(File f, String testClass, String... extraParams) { 69.79 + List<String> options = new ArrayList<>(); 69.80 + options.addAll(Arrays.asList("-source", "1.8")); 69.81 + options.addAll(Arrays.asList(extraParams)); 69.82 + options.add(f.getPath()); 69.83 + int rc = com.sun.tools.javac.Main.compile(options.toArray(new String[options.size()])); 69.84 if (rc != 0) 69.85 throw new Error("compilation failed. rc=" + rc); 69.86 String path;
70.1 --- a/test/tools/javac/annotations/typeAnnotations/referenceinfos/ExceptionParameters.java Mon May 19 22:00:11 2014 -0700 70.2 +++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/ExceptionParameters.java Thu May 29 13:46:36 2014 -0700 70.3 @@ -1,5 +1,5 @@ 70.4 /* 70.5 - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 70.6 + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. 70.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 70.8 * 70.9 * This code is free software; you can redistribute it and/or modify it 70.10 @@ -25,6 +25,7 @@ 70.11 70.12 /* 70.13 * @test 70.14 + * @bug 8028576 70.15 * @summary Test population of reference info for exception parameters 70.16 * @author Werner Dietl 70.17 * @compile -g Driver.java ReferenceInfoUtil.java ExceptionParameters.java
71.1 --- a/test/tools/javac/api/TestJavacTaskScanner.java Mon May 19 22:00:11 2014 -0700 71.2 +++ b/test/tools/javac/api/TestJavacTaskScanner.java Thu May 29 13:46:36 2014 -0700 71.3 @@ -1,5 +1,5 @@ 71.4 /* 71.5 - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 71.6 + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. 71.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 71.8 * 71.9 * This code is free software; you can redistribute it and/or modify it 71.10 @@ -23,7 +23,7 @@ 71.11 71.12 /* 71.13 * @test 71.14 - * @bug 4813736 71.15 + * @bug 4813736 8013256 71.16 * @summary Additional functionality test of task and JSR 269 71.17 * @author Peter von der Ah\u00e9 71.18 * @library ./lib
72.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 72.2 +++ b/test/tools/javac/api/taskListeners/EventsBalancedTest.java Thu May 29 13:46:36 2014 -0700 72.3 @@ -0,0 +1,127 @@ 72.4 +/* 72.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 72.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 72.7 + * 72.8 + * This code is free software; you can redistribute it and/or modify it 72.9 + * under the terms of the GNU General Public License version 2 only, as 72.10 + * published by the Free Software Foundation. 72.11 + * 72.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 72.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 72.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 72.15 + * version 2 for more details (a copy is included in the LICENSE file that 72.16 + * accompanied this code). 72.17 + * 72.18 + * You should have received a copy of the GNU General Public License version 72.19 + * 2 along with this work; if not, write to the Free Software Foundation, 72.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 72.21 + * 72.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 72.23 + * or visit www.oracle.com if you need additional information or have any 72.24 + * questions. 72.25 + */ 72.26 + 72.27 +/* 72.28 + * @test 72.29 + * @bug 8040822 72.30 + * @summary Check that all TaskEvents are balanced. 72.31 + */ 72.32 + 72.33 +import java.io.*; 72.34 +import java.net.URI; 72.35 +import java.util.*; 72.36 +import java.util.Map.Entry; 72.37 + 72.38 +import javax.tools.*; 72.39 + 72.40 +import com.sun.source.util.*; 72.41 +import com.sun.source.util.TaskEvent.Kind; 72.42 +import com.sun.tools.javac.api.JavacTool; 72.43 +import com.sun.tools.javac.comp.CompileStates.CompileState; 72.44 + 72.45 +public class EventsBalancedTest { 72.46 + JavacTool tool = (JavacTool) ToolProvider.getSystemJavaCompiler(); 72.47 + StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); 72.48 + 72.49 + public static void main(String... args) throws IOException { 72.50 + new EventsBalancedTest().test(); 72.51 + } 72.52 + 72.53 + void test() throws IOException { 72.54 + TestSource a = new TestSource("B", "class B extends A { }"); 72.55 + TestSource b = new TestSource("A", "abstract class A { }"); 72.56 + 72.57 + test(null, Arrays.asList(a, b)); 72.58 + test(null, Arrays.asList(b, a)); 72.59 + test(Arrays.asList("-XD-relax"), Arrays.asList(a, b)); 72.60 + test(Arrays.asList("-XD-relax"), Arrays.asList(b, a)); 72.61 + 72.62 + for (CompileState stop : CompileState.values()) { 72.63 + test(Arrays.asList("-XDshouldStopPolicyIfNoError=" + stop, 72.64 + "-XDshouldStopPolicyIfError=" + stop), 72.65 + Arrays.asList(a, b)); 72.66 + test(Arrays.asList("-XDshouldStopPolicyIfNoError=" + stop, 72.67 + "-XDshouldStopPolicyIfError=" + stop), 72.68 + Arrays.asList(b, a)); 72.69 + } 72.70 + } 72.71 + 72.72 + void test(Iterable<String> options, Iterable<JavaFileObject> files) throws IOException { 72.73 + StringWriter sw = new StringWriter(); 72.74 + PrintWriter pw = new PrintWriter(sw); 72.75 + TestListener listener = new TestListener(); 72.76 + JavacTask task = tool.getTask(pw, fm, null, options, null, files); 72.77 + 72.78 + task.setTaskListener(listener); 72.79 + 72.80 + task.call(); 72.81 + 72.82 + for (Entry<Kind, Integer> e : listener.kind2Count.entrySet()) { 72.83 + if (e.getValue() != null && e.getValue() != 0) { 72.84 + throw new IllegalStateException("Not balanced event: " + e.getKey()); 72.85 + } 72.86 + } 72.87 + } 72.88 + 72.89 + static class TestListener implements TaskListener { 72.90 + final Map<Kind, Integer> kind2Count = new HashMap<>(); 72.91 + 72.92 + int get(Kind k) { 72.93 + Integer count = kind2Count.get(k); 72.94 + 72.95 + if (count == null) 72.96 + kind2Count.put(k, count = 0); 72.97 + 72.98 + return count; 72.99 + } 72.100 + 72.101 + @Override 72.102 + public void started(TaskEvent e) { 72.103 + kind2Count.put(e.getKind(), get(e.getKind()) + 1); 72.104 + } 72.105 + 72.106 + @Override 72.107 + public void finished(TaskEvent e) { 72.108 + int count = get(e.getKind()); 72.109 + 72.110 + if (count <= 0) 72.111 + throw new IllegalStateException("count<=0 for: " + e.getKind()); 72.112 + 72.113 + kind2Count.put(e.getKind(), count - 1); 72.114 + } 72.115 + 72.116 + } 72.117 + static class TestSource extends SimpleJavaFileObject { 72.118 + final String content; 72.119 + public TestSource(String fileName, String content) { 72.120 + super(URI.create("myfo:/" + fileName + ".java"), JavaFileObject.Kind.SOURCE); 72.121 + this.content = content; 72.122 + } 72.123 + 72.124 + @Override 72.125 + public CharSequence getCharContent(boolean ignoreEncodingErrors) { 72.126 + return content; 72.127 + } 72.128 + } 72.129 + 72.130 +}
73.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 73.2 +++ b/test/tools/javac/classfiles/InnerClasses/SyntheticClasses.java Thu May 29 13:46:36 2014 -0700 73.3 @@ -0,0 +1,97 @@ 73.4 +/* 73.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 73.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 73.7 + * 73.8 + * This code is free software; you can redistribute it and/or modify it 73.9 + * under the terms of the GNU General Public License version 2 only, as 73.10 + * published by the Free Software Foundation. 73.11 + * 73.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 73.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 73.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 73.15 + * version 2 for more details (a copy is included in the LICENSE file that 73.16 + * accompanied this code). 73.17 + * 73.18 + * You should have received a copy of the GNU General Public License version 73.19 + * 2 along with this work; if not, write to the Free Software Foundation, 73.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 73.21 + * 73.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 73.23 + * or visit www.oracle.com if you need additional information or have any 73.24 + * questions. 73.25 + */ 73.26 + 73.27 +/** @test 73.28 + * @bug 8034854 73.29 + * @summary Verify that the InnerClasses attribute has outer_class_info_index zero if it has 73.30 + * inner_name_index zero (for synthetic classes) 73.31 + * @compile SyntheticClasses.java 73.32 + * @run main SyntheticClasses 73.33 + */ 73.34 + 73.35 +import java.io.*; 73.36 +import java.util.*; 73.37 +import com.sun.tools.classfile.*; 73.38 + 73.39 +public class SyntheticClasses { 73.40 + 73.41 + public static void main(String[] args) throws IOException, ConstantPoolException { 73.42 + new SyntheticClasses().run(); 73.43 + } 73.44 + 73.45 + private void run() throws IOException, ConstantPoolException { 73.46 + File testClasses = new File(System.getProperty("test.classes")); 73.47 + for (File classFile : testClasses.listFiles(f -> f.getName().endsWith(".class"))) { 73.48 + ClassFile cf = ClassFile.read(classFile); 73.49 + if (cf.getName().matches(".*\\$[0-9]+")) { 73.50 + EnclosingMethod_attribute encl = 73.51 + (EnclosingMethod_attribute) cf.getAttribute(Attribute.EnclosingMethod); 73.52 + if (encl != null) { 73.53 + if (encl.method_index != 0) 73.54 + throw new IllegalStateException("Invalid EnclosingMethod.method_index: " + 73.55 + encl.method_index + "."); 73.56 + } 73.57 + } 73.58 + InnerClasses_attribute attr = 73.59 + (InnerClasses_attribute) cf.getAttribute(Attribute.InnerClasses); 73.60 + if (attr != null) { 73.61 + for (InnerClasses_attribute.Info info : attr.classes) { 73.62 + if (cf.major_version < 51) 73.63 + throw new IllegalStateException(); 73.64 + if (info.inner_name_index == 0 && info.outer_class_info_index != 0) 73.65 + throw new IllegalStateException("Invalid outer_class_info_index=" + 73.66 + info.outer_class_info_index + 73.67 + "; inner_name_index=" + 73.68 + info.inner_name_index + "."); 73.69 + } 73.70 + } 73.71 + } 73.72 + } 73.73 +} 73.74 + 73.75 +class SyntheticConstructorAccessTag { 73.76 + 73.77 + private static class A { 73.78 + private A(){} 73.79 + } 73.80 + 73.81 + public void test() { 73.82 + new A(); 73.83 + } 73.84 +} 73.85 + 73.86 +class SyntheticEnumMapping { 73.87 + private int convert(E e) { 73.88 + switch (e) { 73.89 + case A: return 0; 73.90 + default: return -1; 73.91 + } 73.92 + } 73.93 + enum E { A } 73.94 +} 73.95 + 73.96 +interface SyntheticAssertionsDisabled { 73.97 + public default void test() { 73.98 + assert false; 73.99 + } 73.100 +}
74.1 --- a/test/tools/javac/defaultMethods/static/hiding/InterfaceMethodHidingTest.java Mon May 19 22:00:11 2014 -0700 74.2 +++ b/test/tools/javac/defaultMethods/static/hiding/InterfaceMethodHidingTest.java Thu May 29 13:46:36 2014 -0700 74.3 @@ -1,5 +1,5 @@ 74.4 /* 74.5 - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 74.6 + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. 74.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 74.8 * 74.9 * This code is free software; you can redistribute it and/or modify it 74.10 @@ -26,6 +26,7 @@ 74.11 * @bug 8005166 74.12 * @summary Add support for static interface methods 74.13 * Smoke test for static interface method hiding 74.14 + * @run main/timeout=600 InterfaceMethodHidingTest 74.15 */ 74.16 74.17 import com.sun.source.util.JavacTask;
75.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 75.2 +++ b/test/tools/javac/defaultMethodsVisibility/DefaultMethodsNotVisibleForSourceLessThan8Test.java Thu May 29 13:46:36 2014 -0700 75.3 @@ -0,0 +1,180 @@ 75.4 +/* 75.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 75.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 75.7 + * 75.8 + * This code is free software; you can redistribute it and/or modify it 75.9 + * under the terms of the GNU General Public License version 2 only, as 75.10 + * published by the Free Software Foundation. 75.11 + * 75.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 75.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 75.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 75.15 + * version 2 for more details (a copy is included in the LICENSE file that 75.16 + * accompanied this code). 75.17 + * 75.18 + * You should have received a copy of the GNU General Public License version 75.19 + * 2 along with this work; if not, write to the Free Software Foundation, 75.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 75.21 + * 75.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 75.23 + * or visit www.oracle.com if you need additional information or have any 75.24 + * questions. 75.25 + */ 75.26 + 75.27 +/* 75.28 + * @test 75.29 + * @bug 8029240 8030855 75.30 + * @summary Default methods not always visible under -source 7 75.31 + * Default methods should be visible under source previous to 8 75.32 + * @library /tools/javac/lib 75.33 + * @build ToolBox 75.34 + * @run main DefaultMethodsNotVisibleForSourceLessThan8Test 75.35 + */ 75.36 + 75.37 +import java.nio.file.Files; 75.38 +import java.nio.file.Paths; 75.39 + 75.40 +public class DefaultMethodsNotVisibleForSourceLessThan8Test { 75.41 + // common definitions 75.42 + 75.43 + // this one should be compiled with source 8, the rest with source < 8 75.44 + static final String ISrc = 75.45 + "interface I {\n" + 75.46 + " default void m() {}\n" + 75.47 + "}"; 75.48 + 75.49 + static final String JSrc = 75.50 + "interface J extends I {}"; 75.51 + 75.52 + static final String ASrc = 75.53 + "abstract class A implements I {}"; 75.54 + 75.55 + static final String BSrc = 75.56 + "class B implements I {}"; 75.57 + 75.58 + // test legacy implementations 75.59 + static final String C1Src = 75.60 + "class C1 implements I {\n" + 75.61 + " public void m() {}\n" + 75.62 + "}"; 75.63 + 75.64 + static final String C2Src = 75.65 + "class C2 implements J {\n" + 75.66 + " public void m() {}\n" + 75.67 + "}"; 75.68 + 75.69 + static final String C3Src = 75.70 + "class C3 extends A {\n" + 75.71 + " public void m() {}\n" + 75.72 + "}"; 75.73 + 75.74 + static final String C4Src = 75.75 + "class C4 extends B {\n" + 75.76 + " public void m() {}\n" + 75.77 + "}"; 75.78 + 75.79 + //test legacy invocations 75.80 + static final String LegacyInvocationSrc = 75.81 + "class LegacyInvocation {\n" + 75.82 + " public static void test(I i, J j, A a, B b) {\n" + 75.83 + " i.m();\n" + 75.84 + " j.m();\n" + 75.85 + " a.m();\n" + 75.86 + " b.m();\n" + 75.87 + " }\n" + 75.88 + "}"; 75.89 + 75.90 + //test case super invocations 75.91 + static final String SubASrc = 75.92 + "class SubA extends A {\n" + 75.93 + " public void test() {\n" + 75.94 + " super.m();\n" + 75.95 + " }\n" + 75.96 + "}"; 75.97 + 75.98 + static final String SubBSrc = 75.99 + "class SubB extends B {\n" + 75.100 + " public void test() {\n" + 75.101 + " super.m();\n" + 75.102 + " }\n" + 75.103 + "}"; 75.104 + 75.105 + public static void main(String[] args) throws Exception { 75.106 + String[] sources = new String[] { 75.107 + "1.2", 75.108 + "1.3", 75.109 + "1.4", 75.110 + "1.5", 75.111 + "1.6", 75.112 + "1.7", 75.113 + }; 75.114 + for (String source : sources) { 75.115 + new DefaultMethodsNotVisibleForSourceLessThan8Test().run(source); 75.116 + } 75.117 + } 75.118 + 75.119 + String outDir; 75.120 + String source; 75.121 + 75.122 + void run(String source) throws Exception { 75.123 + this.source = source; 75.124 + outDir = "out" + source.replace('.', '_'); 75.125 + testsPreparation(); 75.126 + testLegacyImplementations(); 75.127 + testLegacyInvocations(); 75.128 + testSuperInvocations(); 75.129 + } 75.130 + 75.131 + void testsPreparation() throws Exception { 75.132 + Files.createDirectory(Paths.get(outDir)); 75.133 + 75.134 + /* as an extra check let's make sure that interface 'I' can't be compiled 75.135 + * with source < 8 75.136 + */ 75.137 + ToolBox.JavaToolArgs javacArgs = 75.138 + new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL) 75.139 + .setOptions("-d", outDir, "-source", source) 75.140 + .setSources(ISrc); 75.141 + ToolBox.javac(javacArgs); 75.142 + 75.143 + //but it should compile with source >= 8 75.144 + javacArgs = 75.145 + new ToolBox.JavaToolArgs() 75.146 + .setOptions("-d", outDir) 75.147 + .setSources(ISrc); 75.148 + ToolBox.javac(javacArgs); 75.149 + 75.150 + javacArgs = 75.151 + new ToolBox.JavaToolArgs() 75.152 + .setOptions("-cp", outDir, "-d", outDir, "-source", source) 75.153 + .setSources(JSrc, ASrc, BSrc); 75.154 + ToolBox.javac(javacArgs); 75.155 + } 75.156 + 75.157 + void testLegacyImplementations() throws Exception { 75.158 + //compile C1-4 75.159 + ToolBox.JavaToolArgs javacArgs = 75.160 + new ToolBox.JavaToolArgs() 75.161 + .setOptions("-cp", outDir, "-d", outDir, "-source", source) 75.162 + .setSources(C1Src, C2Src, C3Src, C4Src); 75.163 + ToolBox.javac(javacArgs); 75.164 + } 75.165 + 75.166 + void testLegacyInvocations() throws Exception { 75.167 + //compile LegacyInvocation 75.168 + ToolBox.JavaToolArgs javacArgs = 75.169 + new ToolBox.JavaToolArgs() 75.170 + .setOptions("-cp", outDir, "-d", outDir, "-source", source) 75.171 + .setSources(LegacyInvocationSrc); 75.172 + ToolBox.javac(javacArgs); 75.173 + } 75.174 + 75.175 + void testSuperInvocations() throws Exception { 75.176 + //compile SubA, SubB 75.177 + ToolBox.JavaToolArgs javacArgs = 75.178 + new ToolBox.JavaToolArgs() 75.179 + .setOptions("-cp", outDir, "-d", outDir, "-source", source) 75.180 + .setSources(SubASrc, SubBSrc); 75.181 + ToolBox.javac(javacArgs); 75.182 + } 75.183 +}
76.1 --- a/test/tools/javac/diags/examples.not-yet.txt Mon May 19 22:00:11 2014 -0700 76.2 +++ b/test/tools/javac/diags/examples.not-yet.txt Thu May 29 13:46:36 2014 -0700 76.3 @@ -110,4 +110,5 @@ 76.4 compiler.warn.unknown.enum.constant # in bad class file 76.5 compiler.warn.unknown.enum.constant.reason # in bad class file 76.6 compiler.warn.override.equals.but.not.hashcode # when a class overrides equals but not hashCode method from Object 76.7 - 76.8 +compiler.err.cant.inherit.from.anon # error for subclass of anonymous class 76.9 +compiler.misc.bad.const.pool.entry # constant pool entry has wrong type
77.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 77.2 +++ b/test/tools/javac/diags/examples/AnnotationsAfterTypeParamsNotSupportedInSource.java Thu May 29 13:46:36 2014 -0700 77.3 @@ -0,0 +1,34 @@ 77.4 +/* 77.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 77.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 77.7 + * 77.8 + * This code is free software; you can redistribute it and/or modify it 77.9 + * under the terms of the GNU General Public License version 2 only, as 77.10 + * published by the Free Software Foundation. 77.11 + * 77.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 77.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 77.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 77.15 + * version 2 for more details (a copy is included in the LICENSE file that 77.16 + * accompanied this code). 77.17 + * 77.18 + * You should have received a copy of the GNU General Public License version 77.19 + * 2 along with this work; if not, write to the Free Software Foundation, 77.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 77.21 + * 77.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 77.23 + * or visit www.oracle.com if you need additional information or have any 77.24 + * questions. 77.25 + */ 77.26 + 77.27 +// key: compiler.err.annotations.after.type.params.not.supported.in.source 77.28 +// key: compiler.warn.source.no.bootclasspath 77.29 +// options: -source 7 77.30 + 77.31 +@interface Anno { } 77.32 + 77.33 +class AnnotationsAfterTypeParamsNotSupportedInSource { 77.34 + <T> @Anno int m() { 77.35 + return 0; 77.36 + } 77.37 +}
78.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 78.2 +++ b/test/tools/javac/diags/examples/LambdaBodyNeitherValueNorVoidCompatible.java Thu May 29 13:46:36 2014 -0700 78.3 @@ -0,0 +1,46 @@ 78.4 +/* 78.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 78.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 78.7 + * 78.8 + * This code is free software; you can redistribute it and/or modify it 78.9 + * under the terms of the GNU General Public License version 2 only, as 78.10 + * published by the Free Software Foundation. 78.11 + * 78.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 78.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 78.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 78.15 + * version 2 for more details (a copy is included in the LICENSE file that 78.16 + * accompanied this code). 78.17 + * 78.18 + * You should have received a copy of the GNU General Public License version 78.19 + * 2 along with this work; if not, write to the Free Software Foundation, 78.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 78.21 + * 78.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 78.23 + * or visit www.oracle.com if you need additional information or have any 78.24 + * questions. 78.25 + */ 78.26 + 78.27 +// key: compiler.err.lambda.body.neither.value.nor.void.compatible 78.28 +// key: compiler.err.cant.apply.symbol 78.29 +// key: compiler.misc.incompatible.ret.type.in.lambda 78.30 +// key: compiler.misc.missing.ret.val 78.31 +// key: compiler.misc.no.conforming.assignment.exists 78.32 + 78.33 +class LambdaBodyNeitherValueNorVoidCompatible { 78.34 + interface I { 78.35 + String f(String x); 78.36 + } 78.37 + 78.38 + static void foo(I i) {} 78.39 + 78.40 + void m() { 78.41 + foo((x) -> { 78.42 + if (x == null) { 78.43 + return; 78.44 + } else { 78.45 + return x; 78.46 + } 78.47 + }); 78.48 + } 78.49 +}
79.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 79.2 +++ b/test/tools/javac/diags/examples/WarnSerializableLambda.java Thu May 29 13:46:36 2014 -0700 79.3 @@ -0,0 +1,41 @@ 79.4 +/* 79.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 79.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 79.7 + * 79.8 + * This code is free software; you can redistribute it and/or modify it 79.9 + * under the terms of the GNU General Public License version 2 only, as 79.10 + * published by the Free Software Foundation. 79.11 + * 79.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 79.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 79.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 79.15 + * version 2 for more details (a copy is included in the LICENSE file that 79.16 + * accompanied this code). 79.17 + * 79.18 + * You should have received a copy of the GNU General Public License version 79.19 + * 2 along with this work; if not, write to the Free Software Foundation, 79.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 79.21 + * 79.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 79.23 + * or visit www.oracle.com if you need additional information or have any 79.24 + * questions. 79.25 + */ 79.26 + 79.27 +// key: compiler.warn.access.to.sensitive.member.from.serializable.element 79.28 +// options: -XDwarnOnAccessToSensitiveMembers 79.29 + 79.30 +import java.io.Serializable; 79.31 + 79.32 +public class WarnSerializableLambda { 79.33 + interface SAM { 79.34 + void apply(String s); 79.35 + } 79.36 + 79.37 + private void m1() { 79.38 + SAM s = (SAM & Serializable) c -> { 79.39 + packageField = ""; 79.40 + }; 79.41 + } 79.42 + 79.43 + String packageField; 79.44 +}
80.1 --- a/test/tools/javac/doctree/SeeTest.java Mon May 19 22:00:11 2014 -0700 80.2 +++ b/test/tools/javac/doctree/SeeTest.java Thu May 29 13:46:36 2014 -0700 80.3 @@ -1,5 +1,5 @@ 80.4 /* 80.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 80.6 + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. 80.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 80.8 * 80.9 * This code is free software; you can redistribute it and/or modify it 80.10 @@ -23,7 +23,7 @@ 80.11 80.12 /* 80.13 * @test 80.14 - * @bug 7021614 80.15 + * @bug 7021614 8031212 80.16 * @summary extend com.sun.source API to support parsing javadoc comments 80.17 * @build DocCommentTester 80.18 * @run main DocCommentTester SeeTest.java 80.19 @@ -41,9 +41,9 @@ 80.20 Text[TEXT, pos:1, abc.] 80.21 body: empty 80.22 block tags: 1 80.23 - Erroneous[ERRONEOUS, pos:7 80.24 - code: compiler.err.dc.unexpected.content 80.25 - body: @see_"String" 80.26 + See[SEE, pos:7 80.27 + reference: 1 80.28 + Text[TEXT, pos:12, "String"] 80.29 ] 80.30 ] 80.31 */
81.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 81.2 +++ b/test/tools/javac/flow/T8030218/CompileTimeErrorForNonAssignedStaticFieldTest.java Thu May 29 13:46:36 2014 -0700 81.3 @@ -0,0 +1,29 @@ 81.4 +/* 81.5 + * @test /nodynamiccopyright/ 81.6 + * @bug 8030218 81.7 + * @summary javac, compile time error isn't shown when final static field is not assigned, follow-up 81.8 + * @compile/fail/ref=CompileTimeErrorForNonAssignedStaticFieldTest.out -XDrawDiagnostics CompileTimeErrorForNonAssignedStaticFieldTest.java 81.9 + */ 81.10 + 81.11 +public class CompileTimeErrorForNonAssignedStaticFieldTest { 81.12 + private final static int i; 81.13 + 81.14 + public CompileTimeErrorForNonAssignedStaticFieldTest() 81.15 + throws InstantiationException { 81.16 + throw new InstantiationException("Can't instantiate"); 81.17 + } 81.18 + 81.19 + static class Inner { 81.20 + private final int j; 81.21 + public Inner(int x) 81.22 + throws InstantiationException { 81.23 + if (x == 0) { 81.24 + throw new InstantiationException("Can't instantiate"); 81.25 + } else { 81.26 + j = 1; 81.27 + } 81.28 + System.out.println(j); 81.29 + } 81.30 + } 81.31 + 81.32 +}
82.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 82.2 +++ b/test/tools/javac/flow/T8030218/CompileTimeErrorForNonAssignedStaticFieldTest.out Thu May 29 13:46:36 2014 -0700 82.3 @@ -0,0 +1,2 @@ 82.4 +CompileTimeErrorForNonAssignedStaticFieldTest.java:14:5: compiler.err.var.might.not.have.been.initialized: i 82.5 +1 error
83.1 --- a/test/tools/javac/generics/inference/7086586/T7086586.out Mon May 19 22:00:11 2014 -0700 83.2 +++ b/test/tools/javac/generics/inference/7086586/T7086586.out Thu May 29 13:46:36 2014 -0700 83.3 @@ -1,5 +1,5 @@ 83.4 -T7086586.java:14:20: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>)) 83.5 -T7086586.java:15:20: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>)) 83.6 -T7086586.java:16:23: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>)) 83.7 -T7086586.java:17:9: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>)) 83.8 +T7086586.java:14:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.captureof: 1, ?, java.lang.String) 83.9 +T7086586.java:15:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.captureof: 1, ?, java.lang.Number) 83.10 +T7086586.java:16:31: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.captureof: 1, ?, java.lang.Exception) 83.11 +T7086586.java:17:13: compiler.err.cant.resolve.location.args: kindname.method, nonExistentMethod, , , (compiler.misc.location: kindname.interface, java.util.List<compiler.misc.type.captureof: 1, ?>, null) 83.12 4 errors
84.1 --- a/test/tools/javac/generics/inference/7086586/T7086586b.java Mon May 19 22:00:11 2014 -0700 84.2 +++ b/test/tools/javac/generics/inference/7086586/T7086586b.java Thu May 29 13:46:36 2014 -0700 84.3 @@ -23,9 +23,10 @@ 84.4 84.5 /* 84.6 * @test 84.7 - * @bug 7086586 84.8 + * @bug 7086586 8033718 84.9 * 84.10 - * @summary Inference producing null type argument 84.11 + * @summary Inference producing null type argument; inference ignores capture 84.12 + * variable as upper bound 84.13 */ 84.14 import java.util.List; 84.15 84.16 @@ -40,8 +41,8 @@ 84.17 assertionCount++; 84.18 } 84.19 84.20 - <T> void m(List<? super T> dummy) { assertTrue(false); } 84.21 - <T> void m(Object dummy) { assertTrue(true); } 84.22 + <T> void m(List<? super T> dummy) { assertTrue(true); } 84.23 + <T> void m(Object dummy) { assertTrue(false); } 84.24 84.25 void test(List<?> l) { 84.26 m(l);
85.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 85.2 +++ b/test/tools/javac/generics/inference/LowerBoundGLB.java Thu May 29 13:46:36 2014 -0700 85.3 @@ -0,0 +1,47 @@ 85.4 +/* 85.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 85.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 85.7 + * 85.8 + * This code is free software; you can redistribute it and/or modify it 85.9 + * under the terms of the GNU General Public License version 2 only, as 85.10 + * published by the Free Software Foundation. 85.11 + * 85.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 85.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 85.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 85.15 + * version 2 for more details (a copy is included in the LICENSE file that 85.16 + * accompanied this code). 85.17 + * 85.18 + * You should have received a copy of the GNU General Public License version 85.19 + * 2 along with this work; if not, write to the Free Software Foundation, 85.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 85.21 + * 85.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 85.23 + * or visit www.oracle.com if you need additional information or have any 85.24 + * questions. 85.25 + */ 85.26 + 85.27 +/** 85.28 + * @test 85.29 + * @bug 8033718 85.30 + * @author dlsmith 85.31 + * @summary GLB for two capture variables with lower bounds 85.32 + * @compile LowerBoundGLB.java 85.33 + */ 85.34 + 85.35 +public class LowerBoundGLB { 85.36 + 85.37 + interface Box<T> { 85.38 + T get(); 85.39 + void set(T arg); 85.40 + } 85.41 + 85.42 + <T> T doGLB(Box<? super T> b1, Box<? super T> b2) { 85.43 + return null; 85.44 + } 85.45 + 85.46 + void test(Box<? super String> l1, Box<? super CharSequence> l2) { 85.47 + doGLB(l1, l2).substring(3); 85.48 + } 85.49 + 85.50 +}
86.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 86.2 +++ b/test/tools/javac/generics/inference/T8028503/PrimitiveTypeInBoundForMethodRefTest.java Thu May 29 13:46:36 2014 -0700 86.3 @@ -0,0 +1,48 @@ 86.4 +/* 86.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 86.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 86.7 + * 86.8 + * This code is free software; you can redistribute it and/or modify it 86.9 + * under the terms of the GNU General Public License version 2 only, as 86.10 + * published by the Free Software Foundation. 86.11 + * 86.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 86.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 86.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 86.15 + * version 2 for more details (a copy is included in the LICENSE file that 86.16 + * accompanied this code). 86.17 + * 86.18 + * You should have received a copy of the GNU General Public License version 86.19 + * 2 along with this work; if not, write to the Free Software Foundation, 86.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 86.21 + * 86.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 86.23 + * or visit www.oracle.com if you need additional information or have any 86.24 + * questions. 86.25 + */ 86.26 + 86.27 +/** 86.28 + * @test 86.29 + * @bug 8028503 86.30 + * @summary javac, for method references a primitive type can be added as a bound 86.31 + * @compile PrimitiveTypeInBoundForMethodRefTest.java 86.32 + */ 86.33 + 86.34 +class PrimitiveTypeInBoundForMethodRefTest { 86.35 + 86.36 + interface Mapper<T, U> { 86.37 + U map(T t); 86.38 + } 86.39 + 86.40 + static <U> Iterable<U> map(Mapper<String, U> mapper) { 86.41 + return null; 86.42 + } 86.43 + 86.44 + static void test() { 86.45 + Iterable<Integer> map = map(PrimitiveTypeInBoundForMethodRefTest::length); 86.46 + } 86.47 + 86.48 + public static <T> int length(String s) { 86.49 + return 0; 86.50 + } 86.51 +}
87.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 87.2 +++ b/test/tools/javac/generics/typevars/IntersectionSubVar.java Thu May 29 13:46:36 2014 -0700 87.3 @@ -0,0 +1,49 @@ 87.4 +/* 87.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 87.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 87.7 + * 87.8 + * This code is free software; you can redistribute it and/or modify it 87.9 + * under the terms of the GNU General Public License version 2 only, as 87.10 + * published by the Free Software Foundation. 87.11 + * 87.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 87.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 87.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 87.15 + * version 2 for more details (a copy is included in the LICENSE file that 87.16 + * accompanied this code). 87.17 + * 87.18 + * You should have received a copy of the GNU General Public License version 87.19 + * 2 along with this work; if not, write to the Free Software Foundation, 87.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 87.21 + * 87.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 87.23 + * or visit www.oracle.com if you need additional information or have any 87.24 + * questions. 87.25 + */ 87.26 + 87.27 +/* 87.28 + * @test 87.29 + * @bug 8042656 87.30 + * @summary Subtyping for intersection types containing type variables 87.31 + * @compile IntersectionSubVar.java 87.32 + */ 87.33 + 87.34 +class IntersectionSubVar { 87.35 + 87.36 + interface Box<T> { 87.37 + void set(T arg); 87.38 + T get(); 87.39 + } 87.40 + 87.41 + <I> Box<I> glb(Box<? super I> arg1, Box<? super I> arg2) { 87.42 + return null; 87.43 + } 87.44 + 87.45 + <E extends Cloneable> void takeBox(Box<? super E> box) {} 87.46 + 87.47 + <T> void test(Box<T> arg1, Box<Cloneable> arg2, Box<? super T> arg3) { 87.48 + T t = glb(arg1, arg2).get(); // assign T&Cloneable to T 87.49 + takeBox(arg3); // inference tests Box<CAP> <: Box<? super CAP&Cloneable> 87.50 + } 87.51 + 87.52 +}
88.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 88.2 +++ b/test/tools/javac/inference/EagerReturnTypeResolution/EagerReturnTypeResolutionTesta.java Thu May 29 13:46:36 2014 -0700 88.3 @@ -0,0 +1,78 @@ 88.4 +/* 88.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 88.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 88.7 + * 88.8 + * This code is free software; you can redistribute it and/or modify it 88.9 + * under the terms of the GNU General Public License version 2 only, as 88.10 + * published by the Free Software Foundation. Oracle designates this 88.11 + * particular file as subject to the "Classpath" exception as provided 88.12 + * by Oracle in the LICENSE file that accompanied this code. 88.13 + * 88.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 88.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 88.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 88.17 + * version 2 for more details (a copy is included in the LICENSE file that 88.18 + * accompanied this code). 88.19 + * 88.20 + * You should have received a copy of the GNU General Public License version 88.21 + * 2 along with this work; if not, write to the Free Software Foundation, 88.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 88.23 + * 88.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 88.25 + * or visit www.oracle.com if you need additional information or have any 88.26 + * questions. 88.27 + */ 88.28 + 88.29 +/* 88.30 + * @test 88.31 + * @bug 8030741 88.32 + * @summary Inference: implement eager resolution of return types, consistent with JDK-8028800 88.33 + * @compile EagerReturnTypeResolutionTesta.java 88.34 + */ 88.35 + 88.36 +public class EagerReturnTypeResolutionTesta { 88.37 + 88.38 + abstract class Test1<T>{ 88.39 + abstract <S> S foo(S x, S y); 88.40 + <S extends Number & Comparable<? extends Number>> void baz(Test1<S> a){} 88.41 + 88.42 + void bar(Test1<Long> x, Test1<Integer> y){ 88.43 + baz(foo(x, y)); 88.44 + } 88.45 + } 88.46 + 88.47 + abstract class Test2<T>{ 88.48 + abstract <S> S foo(S x, S y); 88.49 + abstract <S1> void baz(Test2<S1> a); 88.50 + 88.51 + void bar(Test2<Integer> y, Test2<Long> x){ 88.52 + baz(foo(x, y)); 88.53 + } 88.54 + } 88.55 + 88.56 + abstract class Test3<T>{ 88.57 + abstract <S> S foo(S x, S y); 88.58 + <T extends Number & Comparable<?>, 88.59 + S extends Number & Comparable<? extends T>> void baz(Test3<S> a){} 88.60 + 88.61 + void bar(Test3<Long> x, Test3<Integer> y){ 88.62 + baz(foo(x, y)); 88.63 + } 88.64 + } 88.65 + 88.66 + abstract class Test4 { 88.67 + abstract class A0<T> {} 88.68 + 88.69 + abstract class A1<T> extends A0<T> {} 88.70 + 88.71 + abstract class A2<T> extends A0<T> {} 88.72 + 88.73 + abstract <S> S foo(S x, S y); 88.74 + abstract <S1> void baz(A0<S1> a); 88.75 + 88.76 + void bar(A2<Integer> y, A1<Long> x){ 88.77 + baz(foo(x, y)); 88.78 + } 88.79 + } 88.80 + 88.81 +}
89.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 89.2 +++ b/test/tools/javac/inference/EagerReturnTypeResolution/EagerReturnTypeResolutionTestb.java Thu May 29 13:46:36 2014 -0700 89.3 @@ -0,0 +1,182 @@ 89.4 +/* 89.5 + * @test /nodynamiccopyright/ 89.6 + * @bug 8030741 89.7 + * @summary Inference: implement eager resolution of return types, consistent with JDK-8028800 89.8 + * @compile/fail/ref=EagerReturnTypeResolutionTestb.out -XDrawDiagnostics EagerReturnTypeResolutionTestb.java 89.9 + * @author Dan Smith 89.10 + */ 89.11 + 89.12 +import java.util.List; 89.13 + 89.14 +public class EagerReturnTypeResolutionTestb { 89.15 + interface I<S> {} 89.16 + interface J<S> extends I<S> {} 89.17 + interface K extends I<String> {} 89.18 + interface L<S> extends I {} 89.19 + 89.20 + <T> T lower(List<? extends T> l) { return null; } 89.21 + <T> T lower2(List<? extends T> l1, List<? extends T> l2) { return null; } 89.22 + 89.23 + <T> T upper(List<? super T> l) { return null; } 89.24 + <T> T upper2(List<? super T> l1, List<? super T> l2) { return null; } 89.25 + 89.26 + <T> T eq(List<T> l) { return null; } 89.27 + <T> T eq2(List<T> l1, List<T> l2) { return null; } 89.28 + 89.29 + <X> void takeI(I<X> i) {} 89.30 + void takeIString(I<String> i) {} 89.31 + I<String> iStringField; 89.32 + 89.33 + void takeLong(long arg) {} 89.34 + long longField; 89.35 + 89.36 + void testSimpleCaptureOK(List<I<?>> i1) { 89.37 + takeI(lower(i1)); // ok* 89.38 + takeI(eq(i1)); // ok* 89.39 + takeI(upper(i1)); // ok, no capture 89.40 + takeIString(upper(i1)); // ok 89.41 + iStringField = upper(i1); // ok 89.42 + } 89.43 + 89.44 + void testSimpleCaptureKO(List<I<?>> i1) { 89.45 + takeIString(lower(i1)); // ERROR 89.46 + takeIString(eq(i1)); // ERROR 89.47 + iStringField = lower(i1); // ERROR 89.48 + iStringField = eq(i1); // ERROR 89.49 + } 89.50 + 89.51 + void testMultiCaptureOK(List<I<String>> i1, List<I<Integer>> i2, List<I<?>> i3, 89.52 + List<J<String>> j1, List<J<Integer>> j2, List<K> k1) { 89.53 + /* Lines marked with JDK-8029002 should be uncommented once this bug is 89.54 + * fixed 89.55 + */ 89.56 + takeI(lower2(i1, i2)); // ok* 89.57 + takeI(lower2(i1, i3)); // ok* 89.58 + takeI(upper2(i1, i3)); // ok, no capture* JDK-8029002 89.59 + 89.60 + takeIString(upper2(i1, i3)); // ok, no capture 89.61 + iStringField = upper2(i1, i3); // ok, no capture 89.62 + 89.63 + takeI(lower2(j1, j2)); // ok* 89.64 + takeI(lower2(j1, k1)); // ok, no capture 89.65 + takeI(upper2(j1, k1)); // ok, no capture* JDK-8029002 89.66 + 89.67 + takeIString(lower2(j1, k1)); // ok, no capture 89.68 + takeIString(upper2(j1, k1)); // ok, no capture 89.69 + 89.70 + iStringField = lower2(j1, k1); // ok, no capture 89.71 + iStringField = upper2(j1, k1); // ok, no capture 89.72 + takeI(lower2(j2, k1)); // ok* 89.73 + } 89.74 + 89.75 + void testMultiCaptureKO(List<I<String>> i1, List<I<Integer>> i2, List<I<?>> i3, 89.76 + List<J<String>> j1, List<J<Integer>> j2, List<K> k1) { 89.77 + takeI(eq2(i1, i2)); // ERROR, bad bounds 89.78 + takeI(upper2(i1, i2)); // ERROR, bad bounds 89.79 + 89.80 + takeIString(lower2(i1, i2)); // ERROR 89.81 + takeIString(eq2(i1, i2)); // ERROR, bad bounds 89.82 + takeIString(upper2(i1, i2)); // ERROR, bad bounds 89.83 + 89.84 + iStringField = lower2(i1, i2); // ERROR 89.85 + iStringField = eq2(i1, i2); // ERROR, bad bounds 89.86 + iStringField = upper2(i1, i2); // ERROR, bad bounds 89.87 + 89.88 + takeI(eq2(i1, i3)); // ERROR, bad bounds 89.89 + takeIString(lower2(i1, i3)); // ERROR 89.90 + takeIString(eq2(i1, i3)); // ERROR, bad bounds 89.91 + 89.92 + iStringField = lower2(i1, i3); // ERROR 89.93 + iStringField = eq2(i1, i3); // ERROR, bad bounds 89.94 + takeI(eq2(j1, j2)); // ERROR, bad bounds 89.95 + takeI(upper2(j1, j2)); // ERROR, bad bounds 89.96 + 89.97 + takeIString(lower2(j1, j2)); // ERROR 89.98 + takeIString(eq2(j1, j2)); // ERROR, bad bounds 89.99 + takeIString(upper2(j1, j2)); // ERROR, bad bounds 89.100 + 89.101 + iStringField = lower2(j1, j2); // ERROR 89.102 + iStringField = eq2(j1, j2); // ERROR, bad bounds 89.103 + iStringField = upper2(j1, j2); // ERROR, bad bounds 89.104 + 89.105 + takeI(eq2(j1, k1)); // ERROR, bad bounds 89.106 + takeIString(eq2(j1, k1)); // ERROR, bad bounds 89.107 + iStringField = eq2(j1, k1); // ERROR, bad bounds 89.108 + takeI(eq2(j2, k1)); // ERROR, bad bounds 89.109 + takeI(upper2(j2, k1)); // ERROR, bad bounds; actual: no error, see JDK-8037474 89.110 + 89.111 + takeIString(lower2(j2, k1)); // ERROR 89.112 + takeIString(eq2(j2, k1)); // ERROR, bad bounds 89.113 + takeIString(upper2(j2, k1)); // ERROR, bad bounds 89.114 + 89.115 + iStringField = lower2(j2, k1); // ERROR 89.116 + iStringField = eq2(j2, k1); // ERROR, bad bounds 89.117 + iStringField = upper2(j2, k1); // ERROR, bad bounds 89.118 + } 89.119 + 89.120 + void testRawOK(List<I> i1, List<J> j1, List<L<String>> l1) { 89.121 + takeI(lower(i1)); // ok, unchecked 89.122 + takeI(eq(i1)); // ok, unchecked 89.123 + takeI(upper(i1)); // ok, no capture, not unchecked 89.124 + 89.125 + takeIString(lower(i1)); // ok, unchecked 89.126 + takeIString(eq(i1)); // ok, unchecked 89.127 + takeIString(upper(i1)); // ok, no capture, not unchecked 89.128 + 89.129 + iStringField = lower(i1); // ok, unchecked 89.130 + iStringField = eq(i1); // ok, unchecked 89.131 + iStringField = upper(i1); // ok, no capture, not unchecked 89.132 + 89.133 + takeI(lower(j1)); // ok, unchecked 89.134 + takeI(eq(j1)); // ok, unchecked 89.135 + takeI(upper(j1)); // bad bounds? -- spec is unclear 89.136 + 89.137 + takeIString(lower(j1)); // ok, unchecked 89.138 + takeIString(eq(j1)); // ok, unchecked 89.139 + takeIString(upper(j1)); // bad bounds? -- spec is unclear 89.140 + 89.141 + iStringField = lower(j1); // ok, unchecked 89.142 + iStringField = eq(j1); // ok, unchecked 89.143 + iStringField = upper(j1); // bad bounds? -- spec is unclear 89.144 + 89.145 + takeI(lower(l1)); // ok, unchecked 89.146 + takeI(eq(l1)); // ok, unchecked 89.147 + takeI(upper(l1)); // bad bounds? -- spec is unclear 89.148 + 89.149 + takeIString(lower(l1)); // ok, unchecked 89.150 + takeIString(eq(l1)); // ok, unchecked 89.151 + takeIString(upper(l1)); // bad bounds? -- spec is unclear 89.152 + 89.153 + iStringField = lower(l1); // ok, unchecked 89.154 + iStringField = eq(l1); // ok, unchecked 89.155 + iStringField = upper(l1); // bad bounds? -- spec is unclear 89.156 + } 89.157 + 89.158 + void testPrimOK(List<Integer> i1, List<Long> l1, List<Double> d1) { 89.159 + takeLong(lower(i1)); // ok 89.160 + takeLong(eq(i1)); // ok 89.161 + takeLong(upper(i1)); // ok* 89.162 + 89.163 + longField = lower(i1); // ok 89.164 + longField = eq(i1); // ok 89.165 + longField = upper(i1); // ok* 89.166 + 89.167 + takeLong(lower(l1)); // ok 89.168 + takeLong(eq(l1)); // ok 89.169 + takeLong(upper(l1)); // ok 89.170 + 89.171 + longField = lower(l1); // ok 89.172 + longField = eq(l1); // ok 89.173 + longField = upper(l1); // ok 89.174 + } 89.175 + 89.176 + void testPrimKO(List<Integer> i1, List<Long> l1, List<Double> d1) { 89.177 + takeLong(lower(d1)); // ERROR 89.178 + takeLong(eq(d1)); // ERROR 89.179 + takeLong(upper(d1)); // ERROR 89.180 + 89.181 + longField = lower(d1); // ERROR 89.182 + longField = eq(d1); // ERROR 89.183 + longField = upper(d1); // ERROR 89.184 + } 89.185 +}
90.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 90.2 +++ b/test/tools/javac/inference/EagerReturnTypeResolution/EagerReturnTypeResolutionTestb.out Thu May 29 13:46:36 2014 -0700 90.3 @@ -0,0 +1,45 @@ 90.4 +EagerReturnTypeResolutionTestb.java:42:9: compiler.err.cant.apply.symbol: kindname.method, takeIString, EagerReturnTypeResolutionTestb.I<java.lang.String>, EagerReturnTypeResolutionTestb.I<compiler.misc.type.captureof: 1, ?>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inferred.do.not.conform.to.upper.bounds: EagerReturnTypeResolutionTestb.I<?>, EagerReturnTypeResolutionTestb.I<java.lang.String>,java.lang.Object)) 90.5 +EagerReturnTypeResolutionTestb.java:43:9: compiler.err.cant.apply.symbol: kindname.method, takeIString, EagerReturnTypeResolutionTestb.I<java.lang.String>, EagerReturnTypeResolutionTestb.I<compiler.misc.type.captureof: 1, ?>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inferred.do.not.conform.to.upper.bounds: EagerReturnTypeResolutionTestb.I<?>, EagerReturnTypeResolutionTestb.I<java.lang.String>,java.lang.Object)) 90.6 +EagerReturnTypeResolutionTestb.java:44:29: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.upper.bounds: EagerReturnTypeResolutionTestb.I<?>, EagerReturnTypeResolutionTestb.I<java.lang.String>,java.lang.Object) 90.7 +EagerReturnTypeResolutionTestb.java:45:26: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.upper.bounds: EagerReturnTypeResolutionTestb.I<?>, EagerReturnTypeResolutionTestb.I<java.lang.String>,java.lang.Object) 90.8 +EagerReturnTypeResolutionTestb.java:74:15: compiler.err.cant.apply.symbol: kindname.method, eq2, java.util.List<T>,java.util.List<T>, java.util.List<EagerReturnTypeResolutionTestb.I<java.lang.String>>,java.util.List<EagerReturnTypeResolutionTestb.I<java.lang.Integer>>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.inferred.do.not.conform.to.eq.bounds: EagerReturnTypeResolutionTestb.I<java.lang.Integer>, EagerReturnTypeResolutionTestb.I<java.lang.Integer>,EagerReturnTypeResolutionTestb.I<java.lang.String>) 90.9 +EagerReturnTypeResolutionTestb.java:75:15: compiler.err.cant.apply.symbol: kindname.method, upper2, java.util.List<? super T>,java.util.List<? super T>, java.util.List<EagerReturnTypeResolutionTestb.I<java.lang.String>>,java.util.List<EagerReturnTypeResolutionTestb.I<java.lang.Integer>>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.inferred.do.not.conform.to.upper.bounds: EagerReturnTypeResolutionTestb.I<java.lang.Integer>, EagerReturnTypeResolutionTestb.I<java.lang.Integer>,EagerReturnTypeResolutionTestb.I<java.lang.String>,java.lang.Object) 90.10 +EagerReturnTypeResolutionTestb.java:77:9: compiler.err.cant.apply.symbol: kindname.method, takeIString, EagerReturnTypeResolutionTestb.I<java.lang.String>, EagerReturnTypeResolutionTestb.I<compiler.misc.type.captureof: 1, ? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<?>>>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inferred.do.not.conform.to.upper.bounds: EagerReturnTypeResolutionTestb.I<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<?>>>, EagerReturnTypeResolutionTestb.I<java.lang.String>,java.lang.Object)) 90.11 +EagerReturnTypeResolutionTestb.java:78:21: compiler.err.cant.apply.symbol: kindname.method, eq2, java.util.List<T>,java.util.List<T>, java.util.List<EagerReturnTypeResolutionTestb.I<java.lang.String>>,java.util.List<EagerReturnTypeResolutionTestb.I<java.lang.Integer>>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.inferred.do.not.conform.to.eq.bounds: EagerReturnTypeResolutionTestb.I<java.lang.Integer>, EagerReturnTypeResolutionTestb.I<java.lang.Integer>,EagerReturnTypeResolutionTestb.I<java.lang.String>) 90.12 +EagerReturnTypeResolutionTestb.java:79:21: compiler.err.cant.apply.symbol: kindname.method, upper2, java.util.List<? super T>,java.util.List<? super T>, java.util.List<EagerReturnTypeResolutionTestb.I<java.lang.String>>,java.util.List<EagerReturnTypeResolutionTestb.I<java.lang.Integer>>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.inferred.do.not.conform.to.upper.bounds: EagerReturnTypeResolutionTestb.I<java.lang.Integer>, EagerReturnTypeResolutionTestb.I<java.lang.Integer>,EagerReturnTypeResolutionTestb.I<java.lang.String>,java.lang.Object) 90.13 +EagerReturnTypeResolutionTestb.java:81:30: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.upper.bounds: EagerReturnTypeResolutionTestb.I<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<?>>>, EagerReturnTypeResolutionTestb.I<java.lang.String>,java.lang.Object) 90.14 +EagerReturnTypeResolutionTestb.java:82:24: compiler.err.cant.apply.symbol: kindname.method, eq2, java.util.List<T>,java.util.List<T>, java.util.List<EagerReturnTypeResolutionTestb.I<java.lang.String>>,java.util.List<EagerReturnTypeResolutionTestb.I<java.lang.Integer>>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.inferred.do.not.conform.to.eq.bounds: EagerReturnTypeResolutionTestb.I<java.lang.Integer>, EagerReturnTypeResolutionTestb.I<java.lang.Integer>,EagerReturnTypeResolutionTestb.I<java.lang.String>) 90.15 +EagerReturnTypeResolutionTestb.java:83:24: compiler.err.cant.apply.symbol: kindname.method, upper2, java.util.List<? super T>,java.util.List<? super T>, java.util.List<EagerReturnTypeResolutionTestb.I<java.lang.String>>,java.util.List<EagerReturnTypeResolutionTestb.I<java.lang.Integer>>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.inferred.do.not.conform.to.upper.bounds: EagerReturnTypeResolutionTestb.I<java.lang.Integer>, EagerReturnTypeResolutionTestb.I<java.lang.Integer>,EagerReturnTypeResolutionTestb.I<java.lang.String>,java.lang.Object) 90.16 +EagerReturnTypeResolutionTestb.java:85:15: compiler.err.cant.apply.symbol: kindname.method, eq2, java.util.List<T>,java.util.List<T>, java.util.List<EagerReturnTypeResolutionTestb.I<java.lang.String>>,java.util.List<EagerReturnTypeResolutionTestb.I<?>>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.inferred.do.not.conform.to.eq.bounds: EagerReturnTypeResolutionTestb.I<?>, EagerReturnTypeResolutionTestb.I<?>,EagerReturnTypeResolutionTestb.I<java.lang.String>) 90.17 +EagerReturnTypeResolutionTestb.java:86:9: compiler.err.cant.apply.symbol: kindname.method, takeIString, EagerReturnTypeResolutionTestb.I<java.lang.String>, EagerReturnTypeResolutionTestb.I<compiler.misc.type.captureof: 1, ?>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inferred.do.not.conform.to.upper.bounds: EagerReturnTypeResolutionTestb.I<?>, EagerReturnTypeResolutionTestb.I<java.lang.String>,java.lang.Object)) 90.18 +EagerReturnTypeResolutionTestb.java:87:21: compiler.err.cant.apply.symbol: kindname.method, eq2, java.util.List<T>,java.util.List<T>, java.util.List<EagerReturnTypeResolutionTestb.I<java.lang.String>>,java.util.List<EagerReturnTypeResolutionTestb.I<?>>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.inferred.do.not.conform.to.eq.bounds: EagerReturnTypeResolutionTestb.I<?>, EagerReturnTypeResolutionTestb.I<?>,EagerReturnTypeResolutionTestb.I<java.lang.String>) 90.19 +EagerReturnTypeResolutionTestb.java:89:30: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.upper.bounds: EagerReturnTypeResolutionTestb.I<?>, EagerReturnTypeResolutionTestb.I<java.lang.String>,java.lang.Object) 90.20 +EagerReturnTypeResolutionTestb.java:90:24: compiler.err.cant.apply.symbol: kindname.method, eq2, java.util.List<T>,java.util.List<T>, java.util.List<EagerReturnTypeResolutionTestb.I<java.lang.String>>,java.util.List<EagerReturnTypeResolutionTestb.I<?>>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.inferred.do.not.conform.to.eq.bounds: EagerReturnTypeResolutionTestb.I<?>, EagerReturnTypeResolutionTestb.I<?>,EagerReturnTypeResolutionTestb.I<java.lang.String>) 90.21 +EagerReturnTypeResolutionTestb.java:91:15: compiler.err.cant.apply.symbol: kindname.method, eq2, java.util.List<T>,java.util.List<T>, java.util.List<EagerReturnTypeResolutionTestb.J<java.lang.String>>,java.util.List<EagerReturnTypeResolutionTestb.J<java.lang.Integer>>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.inferred.do.not.conform.to.eq.bounds: EagerReturnTypeResolutionTestb.J<java.lang.Integer>, EagerReturnTypeResolutionTestb.J<java.lang.Integer>,EagerReturnTypeResolutionTestb.J<java.lang.String>) 90.22 +EagerReturnTypeResolutionTestb.java:92:15: compiler.err.cant.apply.symbol: kindname.method, upper2, java.util.List<? super T>,java.util.List<? super T>, java.util.List<EagerReturnTypeResolutionTestb.J<java.lang.String>>,java.util.List<EagerReturnTypeResolutionTestb.J<java.lang.Integer>>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.inferred.do.not.conform.to.upper.bounds: EagerReturnTypeResolutionTestb.J<java.lang.Integer>, EagerReturnTypeResolutionTestb.J<java.lang.Integer>,EagerReturnTypeResolutionTestb.J<java.lang.String>,java.lang.Object) 90.23 +EagerReturnTypeResolutionTestb.java:94:9: compiler.err.cant.apply.symbol: kindname.method, takeIString, EagerReturnTypeResolutionTestb.I<java.lang.String>, EagerReturnTypeResolutionTestb.J<compiler.misc.type.captureof: 1, ? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<?>>>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inferred.do.not.conform.to.upper.bounds: EagerReturnTypeResolutionTestb.J<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<?>>>, EagerReturnTypeResolutionTestb.I<java.lang.String>,java.lang.Object)) 90.24 +EagerReturnTypeResolutionTestb.java:95:21: compiler.err.cant.apply.symbol: kindname.method, eq2, java.util.List<T>,java.util.List<T>, java.util.List<EagerReturnTypeResolutionTestb.J<java.lang.String>>,java.util.List<EagerReturnTypeResolutionTestb.J<java.lang.Integer>>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.inferred.do.not.conform.to.eq.bounds: EagerReturnTypeResolutionTestb.J<java.lang.Integer>, EagerReturnTypeResolutionTestb.J<java.lang.Integer>,EagerReturnTypeResolutionTestb.J<java.lang.String>) 90.25 +EagerReturnTypeResolutionTestb.java:96:21: compiler.err.cant.apply.symbol: kindname.method, upper2, java.util.List<? super T>,java.util.List<? super T>, java.util.List<EagerReturnTypeResolutionTestb.J<java.lang.String>>,java.util.List<EagerReturnTypeResolutionTestb.J<java.lang.Integer>>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.inferred.do.not.conform.to.upper.bounds: EagerReturnTypeResolutionTestb.J<java.lang.Integer>, EagerReturnTypeResolutionTestb.J<java.lang.Integer>,EagerReturnTypeResolutionTestb.J<java.lang.String>,java.lang.Object) 90.26 +EagerReturnTypeResolutionTestb.java:98:30: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.upper.bounds: EagerReturnTypeResolutionTestb.J<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<?>>>, EagerReturnTypeResolutionTestb.I<java.lang.String>,java.lang.Object) 90.27 +EagerReturnTypeResolutionTestb.java:99:24: compiler.err.cant.apply.symbol: kindname.method, eq2, java.util.List<T>,java.util.List<T>, java.util.List<EagerReturnTypeResolutionTestb.J<java.lang.String>>,java.util.List<EagerReturnTypeResolutionTestb.J<java.lang.Integer>>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.inferred.do.not.conform.to.eq.bounds: EagerReturnTypeResolutionTestb.J<java.lang.Integer>, EagerReturnTypeResolutionTestb.J<java.lang.Integer>,EagerReturnTypeResolutionTestb.J<java.lang.String>) 90.28 +EagerReturnTypeResolutionTestb.java:100:24: compiler.err.cant.apply.symbol: kindname.method, upper2, java.util.List<? super T>,java.util.List<? super T>, java.util.List<EagerReturnTypeResolutionTestb.J<java.lang.String>>,java.util.List<EagerReturnTypeResolutionTestb.J<java.lang.Integer>>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.inferred.do.not.conform.to.upper.bounds: EagerReturnTypeResolutionTestb.J<java.lang.Integer>, EagerReturnTypeResolutionTestb.J<java.lang.Integer>,EagerReturnTypeResolutionTestb.J<java.lang.String>,java.lang.Object) 90.29 +EagerReturnTypeResolutionTestb.java:102:15: compiler.err.cant.apply.symbol: kindname.method, eq2, java.util.List<T>,java.util.List<T>, java.util.List<EagerReturnTypeResolutionTestb.J<java.lang.String>>,java.util.List<EagerReturnTypeResolutionTestb.K>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.inferred.do.not.conform.to.eq.bounds: EagerReturnTypeResolutionTestb.K, EagerReturnTypeResolutionTestb.K,EagerReturnTypeResolutionTestb.J<java.lang.String>) 90.30 +EagerReturnTypeResolutionTestb.java:103:21: compiler.err.cant.apply.symbol: kindname.method, eq2, java.util.List<T>,java.util.List<T>, java.util.List<EagerReturnTypeResolutionTestb.J<java.lang.String>>,java.util.List<EagerReturnTypeResolutionTestb.K>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.inferred.do.not.conform.to.eq.bounds: EagerReturnTypeResolutionTestb.K, EagerReturnTypeResolutionTestb.K,EagerReturnTypeResolutionTestb.J<java.lang.String>) 90.31 +EagerReturnTypeResolutionTestb.java:104:24: compiler.err.cant.apply.symbol: kindname.method, eq2, java.util.List<T>,java.util.List<T>, java.util.List<EagerReturnTypeResolutionTestb.J<java.lang.String>>,java.util.List<EagerReturnTypeResolutionTestb.K>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.inferred.do.not.conform.to.eq.bounds: EagerReturnTypeResolutionTestb.K, EagerReturnTypeResolutionTestb.K,EagerReturnTypeResolutionTestb.J<java.lang.String>) 90.32 +EagerReturnTypeResolutionTestb.java:105:15: compiler.err.cant.apply.symbol: kindname.method, eq2, java.util.List<T>,java.util.List<T>, java.util.List<EagerReturnTypeResolutionTestb.J<java.lang.Integer>>,java.util.List<EagerReturnTypeResolutionTestb.K>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.inferred.do.not.conform.to.eq.bounds: EagerReturnTypeResolutionTestb.K, EagerReturnTypeResolutionTestb.K,EagerReturnTypeResolutionTestb.J<java.lang.Integer>) 90.33 +EagerReturnTypeResolutionTestb.java:106:9: compiler.err.cant.apply.symbol: kindname.method, takeI, EagerReturnTypeResolutionTestb.I<X>, java.lang.Object&EagerReturnTypeResolutionTestb.J<java.lang.Integer>&EagerReturnTypeResolutionTestb.K, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.inferred.do.not.conform.to.eq.bounds: java.lang.Integer, java.lang.Integer,java.lang.String) 90.34 +EagerReturnTypeResolutionTestb.java:108:9: compiler.err.cant.apply.symbol: kindname.method, takeIString, EagerReturnTypeResolutionTestb.I<java.lang.String>, EagerReturnTypeResolutionTestb.I<compiler.misc.type.captureof: 1, ? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<?>>>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inferred.do.not.conform.to.upper.bounds: EagerReturnTypeResolutionTestb.I<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<?>>>, EagerReturnTypeResolutionTestb.I<java.lang.String>,java.lang.Object)) 90.35 +EagerReturnTypeResolutionTestb.java:109:21: compiler.err.cant.apply.symbol: kindname.method, eq2, java.util.List<T>,java.util.List<T>, java.util.List<EagerReturnTypeResolutionTestb.J<java.lang.Integer>>,java.util.List<EagerReturnTypeResolutionTestb.K>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.inferred.do.not.conform.to.eq.bounds: EagerReturnTypeResolutionTestb.K, EagerReturnTypeResolutionTestb.K,EagerReturnTypeResolutionTestb.J<java.lang.Integer>) 90.36 +EagerReturnTypeResolutionTestb.java:110:9: compiler.err.cant.apply.symbol: kindname.method, takeIString, EagerReturnTypeResolutionTestb.I<java.lang.String>, java.lang.Object&EagerReturnTypeResolutionTestb.J<java.lang.Integer>&EagerReturnTypeResolutionTestb.K, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Object&EagerReturnTypeResolutionTestb.J<java.lang.Integer>&EagerReturnTypeResolutionTestb.K, EagerReturnTypeResolutionTestb.I<java.lang.String>,EagerReturnTypeResolutionTestb.K,EagerReturnTypeResolutionTestb.J<java.lang.Integer>,java.lang.Object)) 90.37 +EagerReturnTypeResolutionTestb.java:112:30: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.upper.bounds: EagerReturnTypeResolutionTestb.I<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<?>>>, EagerReturnTypeResolutionTestb.I<java.lang.String>,java.lang.Object) 90.38 +EagerReturnTypeResolutionTestb.java:113:24: compiler.err.cant.apply.symbol: kindname.method, eq2, java.util.List<T>,java.util.List<T>, java.util.List<EagerReturnTypeResolutionTestb.J<java.lang.Integer>>,java.util.List<EagerReturnTypeResolutionTestb.K>, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.inferred.do.not.conform.to.eq.bounds: EagerReturnTypeResolutionTestb.K, EagerReturnTypeResolutionTestb.K,EagerReturnTypeResolutionTestb.J<java.lang.Integer>) 90.39 +EagerReturnTypeResolutionTestb.java:114:30: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Object&EagerReturnTypeResolutionTestb.J<java.lang.Integer>&EagerReturnTypeResolutionTestb.K, EagerReturnTypeResolutionTestb.I<java.lang.String>,EagerReturnTypeResolutionTestb.K,EagerReturnTypeResolutionTestb.J<java.lang.Integer>,java.lang.Object) 90.40 +EagerReturnTypeResolutionTestb.java:174:9: compiler.err.cant.apply.symbol: kindname.method, takeLong, long, java.lang.Double, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.no.conforming.instance.exists: , T, long)) 90.41 +EagerReturnTypeResolutionTestb.java:175:9: compiler.err.cant.apply.symbol: kindname.method, takeLong, long, java.lang.Double, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.no.conforming.instance.exists: , T, long)) 90.42 +EagerReturnTypeResolutionTestb.java:176:9: compiler.err.cant.apply.symbol: kindname.method, takeLong, long, java.lang.Double, kindname.class, EagerReturnTypeResolutionTestb, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.no.conforming.instance.exists: , T, long)) 90.43 +EagerReturnTypeResolutionTestb.java:178:26: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.instance.exists: , T, long) 90.44 +EagerReturnTypeResolutionTestb.java:179:23: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.instance.exists: , T, long) 90.45 +EagerReturnTypeResolutionTestb.java:180:26: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.instance.exists: , T, long) 90.46 +- compiler.note.unchecked.filename: EagerReturnTypeResolutionTestb.java 90.47 +- compiler.note.unchecked.recompile 90.48 +42 errors
91.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 91.2 +++ b/test/tools/javac/inference/EagerReturnTypeResolution/PrimitiveTypeBoxingTest.java Thu May 29 13:46:36 2014 -0700 91.3 @@ -0,0 +1,25 @@ 91.4 +/* 91.5 + * @test /nodynamiccopyright/ 91.6 + * @bug 8030741 91.7 + * @summary Inference: implement eager resolution of return types, consistent with JDK-8028800 91.8 + * @compile/fail/ref=PrimitiveTypeBoxingTest.out -XDrawDiagnostics PrimitiveTypeBoxingTest.java 91.9 + */ 91.10 + 91.11 +public class PrimitiveTypeBoxingTest { 91.12 + 91.13 + static void foo(long arg) {} 91.14 + static void bar(int arg) {} 91.15 + 91.16 + interface F<X> { void get(X arg); } 91.17 + 91.18 + <Z> void m1(F<Z> f, Z arg) {} 91.19 + <Z> void m2(Z arg, F<Z> f) {} 91.20 + 91.21 + void test() { 91.22 + m1(PrimitiveTypeBoxingTest::foo, 23); // expected: error 91.23 + m2(23, PrimitiveTypeBoxingTest::foo); // expected: error 91.24 + 91.25 + m1(PrimitiveTypeBoxingTest::bar, 23); // expected: success 91.26 + m2(23, PrimitiveTypeBoxingTest::bar); // expected: success 91.27 + } 91.28 +}
92.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 92.2 +++ b/test/tools/javac/inference/EagerReturnTypeResolution/PrimitiveTypeBoxingTest.out Thu May 29 13:46:36 2014 -0700 92.3 @@ -0,0 +1,3 @@ 92.4 +PrimitiveTypeBoxingTest.java:19:9: compiler.err.cant.apply.symbol: kindname.method, m1, PrimitiveTypeBoxingTest.F<Z>,Z, @490,int, kindname.class, PrimitiveTypeBoxingTest, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, java.lang.Long,java.lang.Object) 92.5 +PrimitiveTypeBoxingTest.java:20:9: compiler.err.cant.apply.symbol: kindname.method, m2, Z,PrimitiveTypeBoxingTest.F<Z>, int,@559, kindname.class, PrimitiveTypeBoxingTest, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, java.lang.Long,java.lang.Object) 92.6 +2 errors
93.1 --- a/test/tools/javac/lambda/ErroneousLambdaExpr.java Mon May 19 22:00:11 2014 -0700 93.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 93.3 @@ -1,66 +0,0 @@ 93.4 -/* 93.5 - * Copyright (c) 2012, 2013 Oracle and/or its affiliates. All rights reserved. 93.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 93.7 - * 93.8 - * This code is free software; you can redistribute it and/or modify it 93.9 - * under the terms of the GNU General Public License version 2 only, as 93.10 - * published by the Free Software Foundation. 93.11 - * 93.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 93.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 93.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 93.15 - * version 2 for more details (a copy is included in the LICENSE file that 93.16 - * accompanied this code). 93.17 - * 93.18 - * You should have received a copy of the GNU General Public License version 93.19 - * 2 along with this work; if not, write to the Free Software Foundation, 93.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 93.21 - * 93.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 93.23 - * or visit www.oracle.com if you need additional information or have any 93.24 - * questions. 93.25 - */ 93.26 - 93.27 -/* 93.28 - * @test 93.29 - * @bug 8003280 93.30 - * @summary Add lambda tests 93.31 - * stale state after speculative attribution round leads to missing classfiles 93.32 - * @compile/fail/ref=ErroneousLambdaExpr.out -XDrawDiagnostics ErroneousLambdaExpr.java 93.33 - */ 93.34 -public class ErroneousLambdaExpr<T> { 93.35 - 93.36 - static int assertionCount = 0; 93.37 - 93.38 - static void assertTrue(boolean cond) { 93.39 - assertionCount++; 93.40 - if (!cond) 93.41 - throw new AssertionError(); 93.42 - } 93.43 - 93.44 - interface SAM1<X> { 93.45 - X m(X t, String s); 93.46 - } 93.47 - 93.48 - interface SAM2 { 93.49 - void m(String s, int i); 93.50 - } 93.51 - 93.52 - interface SAM3<X> { 93.53 - X m(X t, String s, int i); 93.54 - } 93.55 - 93.56 - void call(SAM1<T> s1) { assertTrue(true); } 93.57 - 93.58 - void call(SAM2 s2) { assertTrue(false); } 93.59 - 93.60 - void call(SAM3<T> s3) { assertTrue(false); } 93.61 - 93.62 - public static void main(String[] args) { 93.63 - ErroneousLambdaExpr<StringBuilder> test = 93.64 - new ErroneousLambdaExpr<>(); 93.65 - 93.66 - test.call((builder, string) -> { builder.append(string); return builder; }); 93.67 - assertTrue(assertionCount == 1); 93.68 - } 93.69 -}
94.1 --- a/test/tools/javac/lambda/ErroneousLambdaExpr.out Mon May 19 22:00:11 2014 -0700 94.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 94.3 @@ -1,2 +0,0 @@ 94.4 -ErroneousLambdaExpr.java:63:13: compiler.err.ref.ambiguous: call, kindname.method, call(ErroneousLambdaExpr.SAM1<T>), ErroneousLambdaExpr, kindname.method, call(ErroneousLambdaExpr.SAM2), ErroneousLambdaExpr 94.5 -1 error
95.1 --- a/test/tools/javac/lambda/FunctionalInterfaceConversionTest.java Mon May 19 22:00:11 2014 -0700 95.2 +++ b/test/tools/javac/lambda/FunctionalInterfaceConversionTest.java Thu May 29 13:46:36 2014 -0700 95.3 @@ -1,5 +1,5 @@ 95.4 /* 95.5 - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 95.6 + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. 95.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 95.8 * 95.9 * This code is free software; you can redistribute it and/or modify it 95.10 @@ -30,7 +30,7 @@ 95.11 * @author Maurizio Cimadamore 95.12 * @library ../lib 95.13 * @build JavacTestingAbstractThreadedTest 95.14 - * @run main/othervm FunctionalInterfaceConversionTest 95.15 + * @run main/timeout=600/othervm FunctionalInterfaceConversionTest 95.16 */ 95.17 95.18 // use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
96.1 --- a/test/tools/javac/lambda/InnerConstructor.java Mon May 19 22:00:11 2014 -0700 96.2 +++ b/test/tools/javac/lambda/InnerConstructor.java Thu May 29 13:46:36 2014 -0700 96.3 @@ -1,5 +1,5 @@ 96.4 /* 96.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 96.6 + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. 96.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 96.8 * 96.9 * This code is free software; you can redistribute it and/or modify it 96.10 @@ -23,7 +23,7 @@ 96.11 96.12 /* 96.13 * @test 96.14 - * @bug 8003280 96.15 + * @bug 8003280 8003306 96.16 * @summary Add lambda tests 96.17 * Regression test JDK-8003306 inner class constructor in lambda 96.18 * @author Robert Field
97.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 97.2 +++ b/test/tools/javac/lambda/LambdaExprLeadsToMissingClassFilesTest.java Thu May 29 13:46:36 2014 -0700 97.3 @@ -0,0 +1,66 @@ 97.4 +/* 97.5 + * Copyright (c) 2012, 2014 Oracle and/or its affiliates. All rights reserved. 97.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 97.7 + * 97.8 + * This code is free software; you can redistribute it and/or modify it 97.9 + * under the terms of the GNU General Public License version 2 only, as 97.10 + * published by the Free Software Foundation. 97.11 + * 97.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 97.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 97.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 97.15 + * version 2 for more details (a copy is included in the LICENSE file that 97.16 + * accompanied this code). 97.17 + * 97.18 + * You should have received a copy of the GNU General Public License version 97.19 + * 2 along with this work; if not, write to the Free Software Foundation, 97.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 97.21 + * 97.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 97.23 + * or visit www.oracle.com if you need additional information or have any 97.24 + * questions. 97.25 + */ 97.26 + 97.27 +/* 97.28 + * @test 97.29 + * @bug 8003280 97.30 + * @summary Add lambda tests 97.31 + * stale state after speculative attribution round leads to missing classfiles 97.32 + */ 97.33 +public class LambdaExprLeadsToMissingClassFilesTest<T> { 97.34 + 97.35 + static int assertionCount = 0; 97.36 + 97.37 + static void assertTrue(boolean cond) { 97.38 + assertionCount++; 97.39 + if (!cond) { 97.40 + throw new AssertionError(); 97.41 + } 97.42 + } 97.43 + 97.44 + interface SAM1<X> { 97.45 + X m(X t, String s); 97.46 + } 97.47 + 97.48 + interface SAM2 { 97.49 + void m(String s, int i); 97.50 + } 97.51 + 97.52 + interface SAM3<X> { 97.53 + X m(X t, String s, int i); 97.54 + } 97.55 + 97.56 + void call(SAM1<T> s1) { assertTrue(true); } 97.57 + 97.58 + void call(SAM2 s2) { assertTrue(false); } 97.59 + 97.60 + void call(SAM3<T> s3) { assertTrue(false); } 97.61 + 97.62 + public static void main(String[] args) { 97.63 + LambdaExprLeadsToMissingClassFilesTest<StringBuilder> test = 97.64 + new LambdaExprLeadsToMissingClassFilesTest<>(); 97.65 + 97.66 + test.call((builder, string) -> { builder.append(string); return builder; }); 97.67 + assertTrue(assertionCount == 1); 97.68 + } 97.69 +}
98.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 98.2 +++ b/test/tools/javac/lambda/LambdaLocalTest.java Thu May 29 13:46:36 2014 -0700 98.3 @@ -0,0 +1,55 @@ 98.4 +/* 98.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 98.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 98.7 + * 98.8 + * This code is free software; you can redistribute it and/or modify it 98.9 + * under the terms of the GNU General Public License version 2 only, as 98.10 + * published by the Free Software Foundation. 98.11 + * 98.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 98.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 98.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 98.15 + * version 2 for more details (a copy is included in the LICENSE file that 98.16 + * accompanied this code). 98.17 + * 98.18 + * You should have received a copy of the GNU General Public License version 98.19 + * 2 along with this work; if not, write to the Free Software Foundation, 98.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 98.21 + * 98.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 98.23 + * or visit www.oracle.com if you need additional information or have any 98.24 + * questions. 98.25 + */ 98.26 + 98.27 +/* 98.28 + * @test 98.29 + * @bug 8029725 98.30 + * @summary Lambda reference to containing local class causes javac infinite recursion 98.31 + * @author Robert Field 98.32 + * @run main LambdaLocalTest 98.33 + */ 98.34 + 98.35 +public class LambdaLocalTest { 98.36 + interface F {void f();} 98.37 + 98.38 + static F f; 98.39 + static StringBuffer sb = new StringBuffer(); 98.40 + 98.41 + static void assertEquals(Object val, Object expected) { 98.42 + if (!val.equals(expected)) { 98.43 + throw new AssertionError("expected '" + expected + "' got '" + val + "'"); 98.44 + } 98.45 + } 98.46 + 98.47 + public static void main(String[] args) { 98.48 + class Local { 98.49 + public Local() { 98.50 + f = () -> new Local(); 98.51 + sb.append("+"); 98.52 + } 98.53 + } 98.54 + new Local(); 98.55 + f.f(); 98.56 + assertEquals(sb.toString(), "++"); 98.57 + } 98.58 +}
99.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 99.2 +++ b/test/tools/javac/lambda/LambdaMultiCatchTest.java Thu May 29 13:46:36 2014 -0700 99.3 @@ -0,0 +1,58 @@ 99.4 +/* 99.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 99.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 99.7 + * 99.8 + * This code is free software; you can redistribute it and/or modify it 99.9 + * under the terms of the GNU General Public License version 2 only, as 99.10 + * published by the Free Software Foundation. Oracle designates this 99.11 + * particular file as subject to the "Classpath" exception as provided 99.12 + * by Oracle in the LICENSE file that accompanied this code. 99.13 + * 99.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 99.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 99.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 99.17 + * version 2 for more details (a copy is included in the LICENSE file that 99.18 + * accompanied this code). 99.19 + * 99.20 + * You should have received a copy of the GNU General Public License version 99.21 + * 2 along with this work; if not, write to the Free Software Foundation, 99.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 99.23 + * 99.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 99.25 + * or visit www.oracle.com if you need additional information or have any 99.26 + * questions. 99.27 + */ 99.28 + 99.29 +/** 99.30 + * @test 99.31 + * @bug 8036942 99.32 + * @summary javac generates incorrect exception table for multi-catch statements inside a lambda 99.33 + * @run main LambdaMultiCatchTest 99.34 + */ 99.35 + 99.36 +import java.io.IOException; 99.37 +import java.util.function.Function; 99.38 + 99.39 +public class LambdaMultiCatchTest { 99.40 + public static void main(String[] args) { 99.41 + Function<String,String> fi = x -> { 99.42 + String result = "nada"; 99.43 + try { 99.44 + switch (x) { 99.45 + case "IO": throw new IOException(); 99.46 + case "Illegal": throw new IllegalArgumentException(); 99.47 + case "Run": throw new RuntimeException(); 99.48 + } 99.49 + } catch (IOException|IllegalArgumentException ex) { 99.50 + result = "IO/Illegal"; 99.51 + } catch (Exception ex) { 99.52 + result = "Any"; 99.53 + }; 99.54 + return result; 99.55 + }; 99.56 + String val = fi.apply("Run"); 99.57 + if (!val.equals("Any")) { 99.58 + throw new AssertionError("Fail: Expected 'Any' but got '" + val + "'"); 99.59 + } 99.60 + } 99.61 +}
100.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 100.2 +++ b/test/tools/javac/lambda/LambdaOuterLocalTest.java Thu May 29 13:46:36 2014 -0700 100.3 @@ -0,0 +1,61 @@ 100.4 +/* 100.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 100.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 100.7 + * 100.8 + * This code is free software; you can redistribute it and/or modify it 100.9 + * under the terms of the GNU General Public License version 2 only, as 100.10 + * published by the Free Software Foundation. 100.11 + * 100.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 100.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 100.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 100.15 + * version 2 for more details (a copy is included in the LICENSE file that 100.16 + * accompanied this code). 100.17 + * 100.18 + * You should have received a copy of the GNU General Public License version 100.19 + * 2 along with this work; if not, write to the Free Software Foundation, 100.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 100.21 + * 100.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 100.23 + * or visit www.oracle.com if you need additional information or have any 100.24 + * questions. 100.25 + */ 100.26 + 100.27 +/* 100.28 + * @test 100.29 + * @bug 8029725 100.30 + * @summary Lambda reference to containing local class causes javac infinite recursion 100.31 + * @author Robert Field 100.32 + * @run main LambdaOuterLocalTest 100.33 + */ 100.34 + 100.35 +public class LambdaOuterLocalTest { 100.36 + interface F {void f();} 100.37 + 100.38 + static F f; 100.39 + static StringBuffer sb = new StringBuffer(); 100.40 + 100.41 + static void assertEquals(Object val, Object expected) { 100.42 + if (!val.equals(expected)) { 100.43 + throw new AssertionError("expected '" + expected + "' got '" + val + "'"); 100.44 + } 100.45 + } 100.46 + 100.47 + public static void main(String[] args) { 100.48 + class Local1 { 100.49 + public Local1() { 100.50 + class Local2 { 100.51 + public Local2() { 100.52 + f = () -> new Local1(); 100.53 + sb.append("2"); 100.54 + } 100.55 + } 100.56 + sb.append("1"); 100.57 + new Local2(); 100.58 + } 100.59 + } 100.60 + new Local1(); 100.61 + f.f(); 100.62 + assertEquals(sb.toString(), "1212"); 100.63 + } 100.64 +}
101.1 --- a/test/tools/javac/lambda/MethodReference42.out Mon May 19 22:00:11 2014 -0700 101.2 +++ b/test/tools/javac/lambda/MethodReference42.out Thu May 29 13:46:36 2014 -0700 101.3 @@ -1,4 +1,4 @@ 101.4 -MethodReference42.java:38:11: compiler.err.cant.apply.symbol: kindname.method, m1, MethodReference42.SAM1, @811, kindname.class, MethodReference42, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number)) 101.5 -MethodReference42.java:40:11: compiler.err.cant.apply.symbol: kindname.method, m3, MethodReference42.SAM3, @855, kindname.class, MethodReference42, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.Object, java.lang.Number)) 101.6 +MethodReference42.java:38:11: compiler.err.cant.apply.symbol: kindname.method, m1, MethodReference42.SAM1, @811, kindname.class, MethodReference42, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number))) 101.7 +MethodReference42.java:40:11: compiler.err.cant.apply.symbol: kindname.method, m3, MethodReference42.SAM3, @855, kindname.class, MethodReference42, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.Object, java.lang.Number))) 101.8 MethodReference42.java:41:9: compiler.err.ref.ambiguous: m4, kindname.method, m4(MethodReference42.SAM2), MethodReference42, kindname.method, m4(MethodReference42.SAM3), MethodReference42 101.9 3 errors
102.1 --- a/test/tools/javac/lambda/MethodReference44.out Mon May 19 22:00:11 2014 -0700 102.2 +++ b/test/tools/javac/lambda/MethodReference44.out Thu May 29 13:46:36 2014 -0700 102.3 @@ -1,4 +1,4 @@ 102.4 -MethodReference44.java:40:11: compiler.err.cant.apply.symbol: kindname.method, g1, MethodReference44.SAM1, @864, kindname.class, MethodReference44, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number)) 102.5 -MethodReference44.java:42:11: compiler.err.cant.apply.symbol: kindname.method, g3, MethodReference44.SAM3, @932, kindname.class, MethodReference44, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.Object, java.lang.Number)) 102.6 +MethodReference44.java:40:11: compiler.err.cant.apply.symbol: kindname.method, g1, MethodReference44.SAM1, @864, kindname.class, MethodReference44, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number))) 102.7 +MethodReference44.java:42:11: compiler.err.cant.apply.symbol: kindname.method, g3, MethodReference44.SAM3, @932, kindname.class, MethodReference44, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.Object, java.lang.Number))) 102.8 MethodReference44.java:43:9: compiler.err.ref.ambiguous: g4, kindname.method, g4(MethodReference44.SAM2), MethodReference44, kindname.method, g4(MethodReference44.SAM3), MethodReference44 102.9 3 errors
103.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 103.2 +++ b/test/tools/javac/lambda/MostSpecific09.java Thu May 29 13:46:36 2014 -0700 103.3 @@ -0,0 +1,81 @@ 103.4 +/* 103.5 + * @test /nodynamiccopyright/ 103.6 + * @bug 8029718 103.7 + * @summary Should always use lambda body structure to disambiguate overload resolution 103.8 + * @compile/fail/ref=MostSpecific09.out -XDrawDiagnostics -XDshouldStopPolicy=ATTR -XDverboseResolution=applicable,success MostSpecific09.java 103.9 + */ 103.10 + 103.11 +class MostSpecific09 { 103.12 + 103.13 + interface I { 103.14 + String xoo(String x); 103.15 + } 103.16 + 103.17 + interface J { 103.18 + void xoo(int x); 103.19 + } 103.20 + 103.21 + static void foo(I i) {} 103.22 + static void foo(J j) {} 103.23 + 103.24 + static void moo(I i) {} 103.25 + static void moo(J j) {} 103.26 + 103.27 + void m() { 103.28 + foo((x) -> { return x += 1; }); 103.29 + foo((x) -> { return ""; }); 103.30 + foo((x) -> { System.out.println(""); }); 103.31 + foo((x) -> { return ""; System.out.println(""); }); 103.32 + foo((x) -> { throw new RuntimeException(); }); 103.33 + foo((x) -> { while (true); }); 103.34 + 103.35 + foo((x) -> x += 1); 103.36 + foo((x) -> ""); 103.37 + } 103.38 + 103.39 + /* any return statement that is not in the body of the lambda but in an 103.40 + * inner class or another lambda should be ignored for value void compatibility 103.41 + * determination. 103.42 + */ 103.43 + void m1() { 103.44 + boolean cond = true; 103.45 + foo((x) -> { 103.46 + if (cond) { 103.47 + return ""; 103.48 + } 103.49 + System.out.println(""); 103.50 + }); 103.51 + 103.52 + foo((x)->{ 103.53 + class Bar { 103.54 + String m() { 103.55 + return "from Bar.m()"; 103.56 + } 103.57 + } 103.58 + class Boo { 103.59 + Bar b = new Bar (){ 103.60 + String m() { 103.61 + return "from Bar$1.m()"; 103.62 + } 103.63 + }; 103.64 + } 103.65 + moo((y) -> { return ""; }); 103.66 + return; 103.67 + }); 103.68 + 103.69 + foo((x)->{ 103.70 + class Bar { 103.71 + void m() {} 103.72 + } 103.73 + class Boo { 103.74 + Bar b = new Bar (){ 103.75 + void m() { 103.76 + return; 103.77 + } 103.78 + }; 103.79 + } 103.80 + moo((y) -> { System.out.println(""); }); 103.81 + return ""; 103.82 + }); 103.83 + } 103.84 +}
104.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 104.2 +++ b/test/tools/javac/lambda/MostSpecific09.out Thu May 29 13:46:36 2014 -0700 104.3 @@ -0,0 +1,27 @@ 104.4 +MostSpecific09.java:25:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.I), null)} 104.5 +MostSpecific09.java:26:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.I), null)} 104.6 +MostSpecific09.java:27:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.J), null)} 104.7 +MostSpecific09.java:27:32: compiler.note.verbose.resolve.multi: println, java.io.PrintStream, 1, BASIC, java.lang.String, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, println(java.lang.Object), null),(compiler.misc.applicable.method.found: 1, println(java.lang.String), null)} 104.8 +MostSpecific09.java:28:13: compiler.err.lambda.body.neither.value.nor.void.compatible 104.9 +MostSpecific09.java:28:9: compiler.err.cant.apply.symbols: kindname.method, foo, @680,{(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.I), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.J), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.unexpected.ret.val)))} 104.10 +MostSpecific09.java:28:43: compiler.note.verbose.resolve.multi: println, java.io.PrintStream, 1, BASIC, java.lang.String, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, println(java.lang.Object), null),(compiler.misc.applicable.method.found: 1, println(java.lang.String), null)} 104.11 +MostSpecific09.java:29:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(MostSpecific09.I), MostSpecific09, kindname.method, foo(MostSpecific09.J), MostSpecific09 104.12 +MostSpecific09.java:29:28: compiler.note.verbose.resolve.multi: <init>, java.lang.RuntimeException, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, java.lang.RuntimeException(), null)} 104.13 +MostSpecific09.java:30:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(MostSpecific09.I), MostSpecific09, kindname.method, foo(MostSpecific09.J), MostSpecific09 104.14 +MostSpecific09.java:32:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(MostSpecific09.I), MostSpecific09, kindname.method, foo(MostSpecific09.J), MostSpecific09 104.15 +MostSpecific09.java:33:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.I), null)} 104.16 +MostSpecific09.java:42:13: compiler.err.lambda.body.neither.value.nor.void.compatible 104.17 +MostSpecific09.java:42:9: compiler.err.cant.apply.symbols: kindname.method, foo, @1129,{(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.I), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.J), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.unexpected.ret.val)))} 104.18 +MostSpecific09.java:46:23: compiler.note.verbose.resolve.multi: println, java.io.PrintStream, 1, BASIC, java.lang.String, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, println(java.lang.Object), null),(compiler.misc.applicable.method.found: 1, println(java.lang.String), null)} 104.19 +MostSpecific09.java:49:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.J), null)} 104.20 +MostSpecific09.java:56:25: compiler.note.verbose.resolve.multi: <init>, Bar, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, Bar(), null)} 104.21 +MostSpecific09.java:56:35: compiler.note.verbose.resolve.multi: <init>, Bar, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, Bar(), null)} 104.22 +MostSpecific09.java:56:25: compiler.note.verbose.resolve.multi: <init>, compiler.misc.anonymous.class: MostSpecific09$1Boo$1, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, compiler.misc.anonymous.class: MostSpecific09$1Boo$1(), null)} 104.23 +MostSpecific09.java:62:13: compiler.note.verbose.resolve.multi: moo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, moo(MostSpecific09.I), null)} 104.24 +MostSpecific09.java:66:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.I), null)} 104.25 +MostSpecific09.java:71:25: compiler.note.verbose.resolve.multi: <init>, Bar, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, Bar(), null)} 104.26 +MostSpecific09.java:71:35: compiler.note.verbose.resolve.multi: <init>, Bar, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, Bar(), null)} 104.27 +MostSpecific09.java:71:25: compiler.note.verbose.resolve.multi: <init>, compiler.misc.anonymous.class: MostSpecific09$2Boo$1, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, compiler.misc.anonymous.class: MostSpecific09$2Boo$1(), null)} 104.28 +MostSpecific09.java:77:13: compiler.note.verbose.resolve.multi: moo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, moo(MostSpecific09.J), null)} 104.29 +MostSpecific09.java:77:36: compiler.note.verbose.resolve.multi: println, java.io.PrintStream, 1, BASIC, java.lang.String, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, println(java.lang.Object), null),(compiler.misc.applicable.method.found: 1, println(java.lang.String), null)} 104.30 +7 errors
105.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 105.2 +++ b/test/tools/javac/lambda/MostSpecific10.java Thu May 29 13:46:36 2014 -0700 105.3 @@ -0,0 +1,54 @@ 105.4 +/* 105.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 105.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 105.7 + * 105.8 + * This code is free software; you can redistribute it and/or modify it 105.9 + * under the terms of the GNU General Public License version 2 only, as 105.10 + * published by the Free Software Foundation. 105.11 + * 105.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 105.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 105.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 105.15 + * version 2 for more details (a copy is included in the LICENSE file that 105.16 + * accompanied this code). 105.17 + * 105.18 + * You should have received a copy of the GNU General Public License version 105.19 + * 2 along with this work; if not, write to the Free Software Foundation, 105.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 105.21 + * 105.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 105.23 + * or visit www.oracle.com if you need additional information or have any 105.24 + * questions. 105.25 + */ 105.26 + 105.27 +/* 105.28 + * @test 105.29 + * @bug 8034223 105.30 + * @summary Structural most-specific logic for lambdas, method refs, parens, and conditionals 105.31 + * @compile MostSpecific10.java 105.32 + */ 105.33 +class MostSpecific10 { 105.34 + 105.35 + interface GetInt { 105.36 + int get(); 105.37 + } 105.38 + 105.39 + interface GetInteger { 105.40 + Integer get(); 105.41 + } 105.42 + 105.43 + void m(GetInt getter) {} 105.44 + void m(GetInteger getter) {} 105.45 + 105.46 + void test(boolean cond) { 105.47 + m(() -> 23); 105.48 + m("abc"::length); 105.49 + m(( () -> 23 )); 105.50 + m(( "abc"::length )); 105.51 + m(cond ? () -> 23 : "abc"::length); 105.52 + m(( cond ? () -> 23 : "abc"::length )); 105.53 + m(cond ? (() -> 23) : ("abc"::length) ); 105.54 + m(( cond ? () -> 23 : cond ? ("abc"::length) : (() -> 23) )); 105.55 + } 105.56 + 105.57 +}
106.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 106.2 +++ b/test/tools/javac/lambda/MostSpecific11.java Thu May 29 13:46:36 2014 -0700 106.3 @@ -0,0 +1,42 @@ 106.4 +/* 106.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 106.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 106.7 + * 106.8 + * This code is free software; you can redistribute it and/or modify it 106.9 + * under the terms of the GNU General Public License version 2 only, as 106.10 + * published by the Free Software Foundation. 106.11 + * 106.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 106.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 106.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 106.15 + * version 2 for more details (a copy is included in the LICENSE file that 106.16 + * accompanied this code). 106.17 + * 106.18 + * You should have received a copy of the GNU General Public License version 106.19 + * 2 along with this work; if not, write to the Free Software Foundation, 106.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 106.21 + * 106.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 106.23 + * or visit www.oracle.com if you need additional information or have any 106.24 + * questions. 106.25 + */ 106.26 + 106.27 +/* 106.28 + * @test 106.29 + * @bug 8034223 106.30 + * @summary Return type Object is not more specific than return type String 106.31 + * @compile MostSpecific11.java 106.32 + */ 106.33 +class MostSpecific11 { 106.34 + 106.35 + interface I { Object run(); } 106.36 + interface J { String run(); } 106.37 + 106.38 + void m(I arg) {} 106.39 + void m(J arg) {} 106.40 + 106.41 + void test() { 106.42 + m(() -> { throw new RuntimeException(); }); 106.43 + } 106.44 + 106.45 +}
107.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 107.2 +++ b/test/tools/javac/lambda/MostSpecific12.java Thu May 29 13:46:36 2014 -0700 107.3 @@ -0,0 +1,38 @@ 107.4 +/* 107.5 + * @test /nodynamiccopyright/ 107.6 + * @bug 8034223 107.7 + * @summary Most-specific testing with inference variables in function parameter types 107.8 + * @compile/fail/ref=MostSpecific12.out -XDrawDiagnostics MostSpecific12.java 107.9 + */ 107.10 +class MostSpecific12 { 107.11 + 107.12 + interface I<T> { void take(T arg1, String arg2); } 107.13 + interface J<T> { void take(String arg1, T arg2); } 107.14 + interface K { void take(String arg1, String arg2); } 107.15 + 107.16 + <T> void m1(I<T> arg) {} 107.17 + void m1(K arg) {} 107.18 + 107.19 + <T> void m2(J<T> arg) {} 107.20 + <T> void m2(K arg) {} 107.21 + 107.22 + <T> void m3(I<T> arg) {} 107.23 + <T> void m3(J<T> arg) {} 107.24 + 107.25 + void test() { 107.26 + m1((String s1, String s2) -> {}); // ok 107.27 + m2((String s1, String s2) -> {}); // ok 107.28 + m3((String s1, String s2) -> {}); // error 107.29 + 107.30 + m1(this::referencedMethod); // ok 107.31 + m2(this::referencedMethod); // ok 107.32 + m3(this::referencedMethod); // error 107.33 + 107.34 + m1(String::compareTo); // ok 107.35 + m2(String::compareTo); // ok 107.36 + m3(String::compareTo); // error 107.37 + } 107.38 + 107.39 + void referencedMethod(String s1, String s2) {} 107.40 + 107.41 +}
108.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 108.2 +++ b/test/tools/javac/lambda/MostSpecific12.out Thu May 29 13:46:36 2014 -0700 108.3 @@ -0,0 +1,4 @@ 108.4 +MostSpecific12.java:25:9: compiler.err.ref.ambiguous: m3, kindname.method, <T>m3(MostSpecific12.I<T>), MostSpecific12, kindname.method, <T>m3(MostSpecific12.J<T>), MostSpecific12 108.5 +MostSpecific12.java:29:9: compiler.err.ref.ambiguous: m3, kindname.method, <T>m3(MostSpecific12.I<T>), MostSpecific12, kindname.method, <T>m3(MostSpecific12.J<T>), MostSpecific12 108.6 +MostSpecific12.java:33:9: compiler.err.ref.ambiguous: m3, kindname.method, <T>m3(MostSpecific12.I<T>), MostSpecific12, kindname.method, <T>m3(MostSpecific12.J<T>), MostSpecific12 108.7 +3 errors
109.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 109.2 +++ b/test/tools/javac/lambda/MostSpecific13.java Thu May 29 13:46:36 2014 -0700 109.3 @@ -0,0 +1,21 @@ 109.4 +/* 109.5 + * @test /nodynamiccopyright/ 109.6 + * @bug 8034223 109.7 + * @summary Most-specific testing with inference variables in function parameter types 109.8 + * @compile/fail/ref=MostSpecific13.out -XDrawDiagnostics MostSpecific13.java 109.9 + */ 109.10 +class MostSpecific13 { 109.11 + 109.12 + interface UnaryOp<T> { T apply(T arg); } 109.13 + interface IntegerToNumber { Number apply(Integer arg); } 109.14 + 109.15 + <T> void m(UnaryOp<T> f) {} 109.16 + void m(IntegerToNumber f) {} 109.17 + 109.18 + void test() { 109.19 + m((Integer i) -> i); // error 109.20 + m(this::id); // error 109.21 + } 109.22 + 109.23 + Integer id(Integer arg) { return arg; } 109.24 +} 109.25 \ No newline at end of file
110.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 110.2 +++ b/test/tools/javac/lambda/MostSpecific13.out Thu May 29 13:46:36 2014 -0700 110.3 @@ -0,0 +1,3 @@ 110.4 +MostSpecific13.java:16:9: compiler.err.ref.ambiguous: m, kindname.method, <T>m(MostSpecific13.UnaryOp<T>), MostSpecific13, kindname.method, m(MostSpecific13.IntegerToNumber), MostSpecific13 110.5 +MostSpecific13.java:17:9: compiler.err.ref.ambiguous: m, kindname.method, <T>m(MostSpecific13.UnaryOp<T>), MostSpecific13, kindname.method, m(MostSpecific13.IntegerToNumber), MostSpecific13 110.6 +2 errors
111.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 111.2 +++ b/test/tools/javac/lambda/MostSpecific14.java Thu May 29 13:46:36 2014 -0700 111.3 @@ -0,0 +1,33 @@ 111.4 +/* 111.5 + * @test /nodynamiccopyright/ 111.6 + * @bug 8034223 111.7 + * @summary Most-specific testing for nested functional interface types 111.8 + * @compile/fail/ref=MostSpecific14.out -XDrawDiagnostics MostSpecific14.java 111.9 + */ 111.10 +class MostSpecific14 { 111.11 + interface ToNumber { Number get(); } 111.12 + interface ToToNumber { ToNumber get(); } 111.13 + interface Factory<T> { T get(); } 111.14 + 111.15 + void m1(Factory<Factory<Object>> f) {} 111.16 + void m1(ToToNumber f) {} 111.17 + 111.18 + void m2(Factory<Factory<Number>> f) {} 111.19 + void m2(ToToNumber f) {} 111.20 + 111.21 + void m3(Factory<Factory<Integer>> f) {} 111.22 + void m3(ToToNumber f) {} 111.23 + 111.24 + 111.25 + void test() { 111.26 + m1(() -> () -> 23); // ok: choose ToToNumber 111.27 + m2(() -> () -> 23); // error: ambiguous 111.28 + m3(() -> () -> 23); // ok: choose Factory<Factory<Integer>> 111.29 + 111.30 + m1(() -> this::getInteger); // ok: choose ToToNumber 111.31 + m2(() -> this::getInteger); // error: ambiguous 111.32 + m3(() -> this::getInteger); // ok: choose Factory<Factory<Integer>> 111.33 + } 111.34 + 111.35 + Integer getInteger() { return 23; } 111.36 +} 111.37 \ No newline at end of file
112.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 112.2 +++ b/test/tools/javac/lambda/MostSpecific14.out Thu May 29 13:46:36 2014 -0700 112.3 @@ -0,0 +1,3 @@ 112.4 +MostSpecific14.java:24:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(MostSpecific14.Factory<MostSpecific14.Factory<java.lang.Number>>), MostSpecific14, kindname.method, m2(MostSpecific14.ToToNumber), MostSpecific14 112.5 +MostSpecific14.java:28:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(MostSpecific14.Factory<MostSpecific14.Factory<java.lang.Number>>), MostSpecific14, kindname.method, m2(MostSpecific14.ToToNumber), MostSpecific14 112.6 +2 errors
113.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 113.2 +++ b/test/tools/javac/lambda/SingleLocalTest.java Thu May 29 13:46:36 2014 -0700 113.3 @@ -0,0 +1,50 @@ 113.4 +/* 113.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 113.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 113.7 + * 113.8 + * This code is free software; you can redistribute it and/or modify it 113.9 + * under the terms of the GNU General Public License version 2 only, as 113.10 + * published by the Free Software Foundation. 113.11 + * 113.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 113.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 113.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 113.15 + * version 2 for more details (a copy is included in the LICENSE file that 113.16 + * accompanied this code). 113.17 + * 113.18 + * You should have received a copy of the GNU General Public License version 113.19 + * 2 along with this work; if not, write to the Free Software Foundation, 113.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 113.21 + * 113.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 113.23 + * or visit www.oracle.com if you need additional information or have any 113.24 + * questions. 113.25 + */ 113.26 + 113.27 +/* 113.28 + * @test 113.29 + * @bug 8029852 113.30 + * @summary Bad code generated (VerifyError) when lambda instantiates 113.31 + * enclosing local class and has captured variables 113.32 + */ 113.33 +public class SingleLocalTest { 113.34 + interface F {void f();} 113.35 + 113.36 + static F f; 113.37 + 113.38 + public static void main(String[] args) { 113.39 + StringBuffer sb = new StringBuffer(); 113.40 + class Local1 { 113.41 + public Local1() { 113.42 + f = () -> new Local1(); 113.43 + sb.append("1"); 113.44 + } 113.45 + } 113.46 + new Local1(); 113.47 + f.f(); 113.48 + String s = sb.toString(); 113.49 + if (!s.equals("11")) { 113.50 + throw new AssertionError("Expected '11' got '" + s + "'"); 113.51 + } 113.52 + } 113.53 +}
114.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 114.2 +++ b/test/tools/javac/lambda/T8037935/LambdaWithBinOpConstRefToConstString.java Thu May 29 13:46:36 2014 -0700 114.3 @@ -0,0 +1,43 @@ 114.4 +/* 114.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 114.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 114.7 + * 114.8 + * This code is free software; you can redistribute it and/or modify it 114.9 + * under the terms of the GNU General Public License version 2 only, as 114.10 + * published by the Free Software Foundation. 114.11 + * 114.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 114.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 114.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 114.15 + * version 2 for more details (a copy is included in the LICENSE file that 114.16 + * accompanied this code). 114.17 + * 114.18 + * You should have received a copy of the GNU General Public License version 114.19 + * 2 along with this work; if not, write to the Free Software Foundation, 114.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 114.21 + * 114.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 114.23 + * or visit www.oracle.com if you need additional information or have any 114.24 + * questions. 114.25 + */ 114.26 + 114.27 +/* 114.28 + * @test 114.29 + * @bug 8037935 114.30 + * @summary Javac: final local String var referenced in binary/unary op in lambda produces code that does not verify 114.31 + * @run main LambdaWithBinOpConstRefToConstString 114.32 + */ 114.33 + 114.34 +interface MyFI { 114.35 + void accept(); 114.36 +} 114.37 + 114.38 +public class LambdaWithBinOpConstRefToConstString { 114.39 + public static void main(String[] args) { 114.40 + final String CONSTANT_STRING_VALUE = "mwmwm"; 114.41 + 114.42 + MyFI consumeStrings = () -> { 114.43 + System.out.println(" local constant: " + CONSTANT_STRING_VALUE); 114.44 + }; 114.45 + } 114.46 +}
115.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 115.2 +++ b/test/tools/javac/lambda/T8038420/LambdaIncrement.java Thu May 29 13:46:36 2014 -0700 115.3 @@ -0,0 +1,52 @@ 115.4 +/* 115.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 115.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 115.7 + * 115.8 + * This code is free software; you can redistribute it and/or modify it 115.9 + * under the terms of the GNU General Public License version 2 only, as 115.10 + * published by the Free Software Foundation. Oracle designates this 115.11 + * particular file as subject to the "Classpath" exception as provided 115.12 + * by Oracle in the LICENSE file that accompanied this code. 115.13 + * 115.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 115.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 115.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 115.17 + * version 2 for more details (a copy is included in the LICENSE file that 115.18 + * accompanied this code). 115.19 + * 115.20 + * You should have received a copy of the GNU General Public License version 115.21 + * 2 along with this work; if not, write to the Free Software Foundation, 115.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 115.23 + * 115.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 115.25 + * or visit www.oracle.com if you need additional information or have any 115.26 + * questions. 115.27 + */ 115.28 + 115.29 +/** 115.30 + * @test 115.31 + * @bug 8038420 115.32 + * @summary Lambda returning post-increment generates wrong code 115.33 + * @run main LambdaIncrement 115.34 + */ 115.35 + 115.36 +public class LambdaIncrement { 115.37 + 115.38 + interface IntegerOp { Integer apply(Integer arg); } 115.39 + 115.40 + private static void assertNotIncremented(IntegerOp lmb, String label) { 115.41 + int result = lmb.apply(3); 115.42 + if (result != 3) { 115.43 + throw new AssertionError("Post-increment failure. Expected 3, got: " + 115.44 + result + " " + label); 115.45 + } 115.46 + } 115.47 + 115.48 + public static void main(String... args) throws Exception { 115.49 + assertNotIncremented(x -> x++, "PostIncExpr"); 115.50 + assertNotIncremented(x -> { return x++; }, "PostIncReturn"); 115.51 + assertNotIncremented(x -> { int y = x; return y++; }, "PostIncLocal"); 115.52 + assertNotIncremented(x -> { Integer y = x; return y++; }, "PostIncLocalBox"); 115.53 + assertNotIncremented(x -> { int y = x; return y; }, "HASINIT"); 115.54 + } 115.55 +}
116.1 --- a/test/tools/javac/lambda/TargetType01.java Mon May 19 22:00:11 2014 -0700 116.2 +++ b/test/tools/javac/lambda/TargetType01.java Thu May 29 13:46:36 2014 -0700 116.3 @@ -1,5 +1,5 @@ 116.4 /* 116.5 - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 116.6 + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. 116.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 116.8 * 116.9 * This code is free software; you can redistribute it and/or modify it 116.10 @@ -42,6 +42,10 @@ 116.11 static String M(F_S_S f){ return null; } 116.12 116.13 static { 116.14 - M(x1 -> { return M( x2 -> { return x1 + x2; });}); //ambiguous 116.15 + M(x1 -> { 116.16 + return M( x2 -> { 116.17 + return x1 + x2; 116.18 + }); 116.19 + }); //ambiguous 116.20 } 116.21 }
117.1 --- a/test/tools/javac/lambda/TargetType01.out Mon May 19 22:00:11 2014 -0700 117.2 +++ b/test/tools/javac/lambda/TargetType01.out Thu May 29 13:46:36 2014 -0700 117.3 @@ -1,3 +1,3 @@ 117.4 TargetType01.java:45:9: compiler.err.ref.ambiguous: M, kindname.method, M(TargetType01.F_I_I), TargetType01, kindname.method, M(TargetType01.F_S_S), TargetType01 117.5 -TargetType01.java:45:26: compiler.err.ref.ambiguous: M, kindname.method, M(TargetType01.F_I_I), TargetType01, kindname.method, M(TargetType01.F_S_S), TargetType01 117.6 +TargetType01.java:46:20: compiler.err.ref.ambiguous: M, kindname.method, M(TargetType01.F_I_I), TargetType01, kindname.method, M(TargetType01.F_S_S), TargetType01 117.7 2 errors
118.1 --- a/test/tools/javac/lambda/TargetType02.java Mon May 19 22:00:11 2014 -0700 118.2 +++ b/test/tools/javac/lambda/TargetType02.java Thu May 29 13:46:36 2014 -0700 118.3 @@ -1,31 +1,9 @@ 118.4 /* 118.5 - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 118.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 118.7 - * 118.8 - * This code is free software; you can redistribute it and/or modify it 118.9 - * under the terms of the GNU General Public License version 2 only, as 118.10 - * published by the Free Software Foundation. 118.11 - * 118.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 118.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 118.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 118.15 - * version 2 for more details (a copy is included in the LICENSE file that 118.16 - * accompanied this code). 118.17 - * 118.18 - * You should have received a copy of the GNU General Public License version 118.19 - * 2 along with this work; if not, write to the Free Software Foundation, 118.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 118.21 - * 118.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 118.23 - * or visit www.oracle.com if you need additional information or have any 118.24 - * questions. 118.25 - */ 118.26 - 118.27 -/* 118.28 - * @test 118.29 - * @bug 8003280 118.30 + * @test /nodynamiccopyright/ 118.31 + * @bug 8003280 8029718 118.32 * @summary Add lambda tests 118.33 * check overload resolution and target type inference w.r.t. generic methods 118.34 + * Should always use lambda body structure to disambiguate overload resolution 118.35 * @author Maurizio Cimadamore 118.36 * @compile/fail/ref=TargetType02.out -XDrawDiagnostics TargetType02.java 118.37 */ 118.38 @@ -47,9 +25,18 @@ 118.39 static <Z extends Number> void call3(S1<Z> s) { } 118.40 static <Z extends String> void call3(S2<Z> s) { } 118.41 118.42 + static <Z extends Number> Z call4(S1<Z> s) { return null; } 118.43 + static <Z extends String> Z call4(S2<Z> s) { return null; } 118.44 + 118.45 void test() { 118.46 call1(i -> { toString(); return i; }); 118.47 call2(i -> { toString(); return i; }); 118.48 call3(i -> { toString(); return i; }); 118.49 + call3(i -> { 118.50 + toString(); 118.51 + return call4(j -> { 118.52 + return j; 118.53 + }); 118.54 + }); 118.55 } 118.56 }
119.1 --- a/test/tools/javac/lambda/TargetType02.out Mon May 19 22:00:11 2014 -0700 119.2 +++ b/test/tools/javac/lambda/TargetType02.out Thu May 29 13:46:36 2014 -0700 119.3 @@ -1,3 +1,5 @@ 119.4 -TargetType02.java:52:14: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, java.lang.String) 119.5 -TargetType02.java:53:9: compiler.err.ref.ambiguous: call3, kindname.method, <Z>call3(TargetType02.S1<Z>), TargetType02, kindname.method, <Z>call3(TargetType02.S2<Z>), TargetType02 119.6 -2 errors 119.7 +TargetType02.java:33:14: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, java.lang.String) 119.8 +TargetType02.java:34:9: compiler.err.ref.ambiguous: call3, kindname.method, <Z>call3(TargetType02.S1<Z>), TargetType02, kindname.method, <Z>call3(TargetType02.S2<Z>), TargetType02 119.9 +TargetType02.java:35:9: compiler.err.ref.ambiguous: call3, kindname.method, <Z>call3(TargetType02.S1<Z>), TargetType02, kindname.method, <Z>call3(TargetType02.S2<Z>), TargetType02 119.10 +TargetType02.java:37:20: compiler.err.ref.ambiguous: call4, kindname.method, <Z>call4(TargetType02.S1<Z>), TargetType02, kindname.method, <Z>call4(TargetType02.S2<Z>), TargetType02 119.11 +4 errors
120.1 --- a/test/tools/javac/lambda/TargetType16.java Mon May 19 22:00:11 2014 -0700 120.2 +++ b/test/tools/javac/lambda/TargetType16.java Thu May 29 13:46:36 2014 -0700 120.3 @@ -1,9 +1,9 @@ 120.4 /* 120.5 * @test /nodynamiccopyright/ 120.6 - * @bug 8003280 120.7 + * @bug 8003280 8034223 120.8 * @summary Add lambda tests 120.9 * Check void-compatibility in strict vs. loose conversion contexts 120.10 - * @compile/fail/ref=TargetType16.out -XDrawDiagnostics TargetType16.java 120.11 + * @compile TargetType16.java 120.12 */ 120.13 120.14 class TargetType16 { 120.15 @@ -20,6 +20,6 @@ 120.16 static <T> void m(SAM2<T> s2) { } 120.17 120.18 public static void main(String[] args) { 120.19 - m(() -> { throw new AssertionError(); }); //ambiguous 120.20 + m(() -> { throw new AssertionError(); }); // prefer SAM2 120.21 } 120.22 }
121.1 --- a/test/tools/javac/lambda/TargetType16.out Mon May 19 22:00:11 2014 -0700 121.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 121.3 @@ -1,2 +0,0 @@ 121.4 -TargetType16.java:23:9: compiler.err.ref.ambiguous: m, kindname.method, m(TargetType16.SAM1), TargetType16, kindname.method, <T>m(TargetType16.SAM2<T>), TargetType16 121.5 -1 error
122.1 --- a/test/tools/javac/lambda/TargetType21.out Mon May 19 22:00:11 2014 -0700 122.2 +++ b/test/tools/javac/lambda/TargetType21.out Thu May 29 13:46:36 2014 -0700 122.3 @@ -1,7 +1,5 @@ 122.4 TargetType21.java:28:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM2), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21 122.5 -TargetType21.java:31:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM2), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21 122.6 -TargetType21.java:32:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM2), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21 122.7 -TargetType21.java:32:13: compiler.err.cant.apply.symbol: kindname.method, call, TargetType21.SAM2, @888, kindname.class, TargetType21, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.unexpected.ret.val))) 122.8 -TargetType21.java:33:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM2), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21 122.9 -TargetType21.java:33:13: compiler.err.cant.apply.symbol: kindname.method, call, TargetType21.SAM2, @946, kindname.class, TargetType21, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.unexpected.ret.val))) 122.10 -6 errors 122.11 +TargetType21.java:32:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM1), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21 122.12 +TargetType21.java:32:13: compiler.err.cant.apply.symbol: kindname.method, call, TargetType21.SAM1, @888, kindname.class, TargetType21, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, java.lang.String))) 122.13 +TargetType21.java:33:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM1), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21 122.14 +4 errors
123.1 --- a/test/tools/javac/lambda/TargetType23.java Mon May 19 22:00:11 2014 -0700 123.2 +++ b/test/tools/javac/lambda/TargetType23.java Thu May 29 13:46:36 2014 -0700 123.3 @@ -31,7 +31,12 @@ 123.4 void call(Sam2 s) { } 123.5 <Z> void call(Sam3<Z> s) { } 123.6 123.7 + void call2(Sam0 s) { } 123.8 + void call2(Sam2 s) { } 123.9 + <Z> void call2(Sam3<Z> s) { } 123.10 + 123.11 void test() { 123.12 - call(()-> { throw new RuntimeException(); }); //ambiguous - both call(Sam0), call(Sam2), call(Sam3) match 123.13 + call(()-> { throw new RuntimeException(); }); // ambiguous - call(Sam1) vs. call(Sam2) 123.14 + call2(()-> { throw new RuntimeException(); }); // ok 123.15 } 123.16 }
124.1 --- a/test/tools/javac/lambda/TargetType23.out Mon May 19 22:00:11 2014 -0700 124.2 +++ b/test/tools/javac/lambda/TargetType23.out Thu May 29 13:46:36 2014 -0700 124.3 @@ -1,2 +1,2 @@ 124.4 -TargetType23.java:35:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType23.Sam2), TargetType23, kindname.method, <Z>call(TargetType23.Sam3<Z>), TargetType23 124.5 +TargetType23.java:39:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType23.Sam1), TargetType23, kindname.method, call(TargetType23.Sam2), TargetType23 124.6 1 error
125.1 --- a/test/tools/javac/lambda/TargetType42.java Mon May 19 22:00:11 2014 -0700 125.2 +++ b/test/tools/javac/lambda/TargetType42.java Thu May 29 13:46:36 2014 -0700 125.3 @@ -1,5 +1,5 @@ 125.4 /* 125.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 125.6 + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. 125.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 125.8 * 125.9 * This code is free software; you can redistribute it and/or modify it 125.10 @@ -31,12 +31,18 @@ 125.11 class TargetType42 { 125.12 125.13 interface SAM<X, Y> { 125.14 - Y f(X x); 125.15 + Y f(X x); 125.16 } 125.17 125.18 <Z> void m(SAM<String, SAM<Z, Object>> s, Z z) { } 125.19 125.20 void test(Object obj) { 125.21 - m((x)->{ class Foo { }; return (x2)-> { new Foo(); return null; }; }, obj); 125.22 + m((x)->{ 125.23 + class Foo { } 125.24 + return (x2)-> { 125.25 + new Foo(); 125.26 + return null; 125.27 + }; 125.28 + }, obj); 125.29 } 125.30 }
126.1 --- a/test/tools/javac/lambda/intersection/IntersectionTargetTypeTest.java Mon May 19 22:00:11 2014 -0700 126.2 +++ b/test/tools/javac/lambda/intersection/IntersectionTargetTypeTest.java Thu May 29 13:46:36 2014 -0700 126.3 @@ -1,5 +1,5 @@ 126.4 /* 126.5 - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 126.6 + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. 126.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 126.8 * 126.9 * This code is free software; you can redistribute it and/or modify it 126.10 @@ -23,7 +23,7 @@ 126.11 126.12 /* 126.13 * @test 126.14 - * @bug 8002099 126.15 + * @bug 8002099 8010822 126.16 * @summary Add support for intersection types in cast expression 126.17 */ 126.18
127.1 --- a/test/tools/javac/lambda/lambdaExpression/LambdaTest1.java Mon May 19 22:00:11 2014 -0700 127.2 +++ b/test/tools/javac/lambda/lambdaExpression/LambdaTest1.java Thu May 29 13:46:36 2014 -0700 127.3 @@ -1,5 +1,5 @@ 127.4 /* 127.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 127.6 + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. 127.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 127.8 * 127.9 * This code is free software; you can redistribute it and/or modify it 127.10 @@ -33,7 +33,6 @@ 127.11 import java.util.Collections; 127.12 import java.util.List; 127.13 import java.util.ArrayList; 127.14 -import java.util.Date; 127.15 127.16 public class LambdaTest1 { 127.17
128.1 --- a/test/tools/javac/lambda/lambdaExpression/SamConversionComboTest.java Mon May 19 22:00:11 2014 -0700 128.2 +++ b/test/tools/javac/lambda/lambdaExpression/SamConversionComboTest.java Thu May 29 13:46:36 2014 -0700 128.3 @@ -1,5 +1,5 @@ 128.4 /* 128.5 - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 128.6 + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. 128.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 128.8 * 128.9 * This code is free software; you can redistribute it and/or modify it 128.10 @@ -209,7 +209,11 @@ 128.11 final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); 128.12 DiagnosticChecker dc = new DiagnosticChecker(); 128.13 JavacTask ct = (JavacTask)tool.getTask(null, null, dc, null, null, Arrays.asList(samSourceFile, clientSourceFile)); 128.14 - ct.analyze(); 128.15 + try { 128.16 + ct.analyze(); 128.17 + } catch (Exception e) { 128.18 + throw new AssertionError("failing SAM source file \n" + samSourceFile + "\n\n" + "failing client source file \n"+ clientSourceFile); 128.19 + } 128.20 if (dc.errorFound == checkSamConversion()) { 128.21 throw new AssertionError(samSourceFile + "\n\n" + clientSourceFile); 128.22 }
129.1 --- a/test/tools/javac/lambda/separate/Test.java Mon May 19 22:00:11 2014 -0700 129.2 +++ b/test/tools/javac/lambda/separate/Test.java Thu May 29 13:46:36 2014 -0700 129.3 @@ -1,5 +1,5 @@ 129.4 /* 129.5 - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 129.6 + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. 129.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 129.8 * 129.9 * This code is free software; you can redistribute it and/or modify it 129.10 @@ -23,6 +23,7 @@ 129.11 129.12 /* 129.13 * @test 129.14 + * @bug 8008708 129.15 * @compile Foo.java 129.16 * @compile Test.java 129.17 */
130.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 130.2 +++ b/test/tools/javac/processing/environment/ProcessingEnvAnnoDiscovery.java Thu May 29 13:46:36 2014 -0700 130.3 @@ -0,0 +1,78 @@ 130.4 +/* 130.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 130.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 130.7 + * 130.8 + * This code is free software; you can redistribute it and/or modify it 130.9 + * under the terms of the GNU General Public License version 2 only, as 130.10 + * published by the Free Software Foundation. 130.11 + * 130.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 130.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 130.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 130.15 + * version 2 for more details (a copy is included in the LICENSE file that 130.16 + * accompanied this code). 130.17 + * 130.18 + * You should have received a copy of the GNU General Public License version 130.19 + * 2 along with this work; if not, write to the Free Software Foundation, 130.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 130.21 + * 130.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 130.23 + * or visit www.oracle.com if you need additional information or have any 130.24 + * questions. 130.25 + */ 130.26 + 130.27 +/* 130.28 + * @test 130.29 + * @bug 8038080 130.30 + * @summary make sure that all declaration annotations are discovered 130.31 + * by the processing environment 130.32 + * @library /tools/javac/lib 130.33 + * @build JavacTestingAbstractProcessor ProcessingEnvAnnoDiscovery 130.34 + * @compile/process -processor ProcessingEnvAnnoDiscovery ProcessingEnvAnnoDiscovery.java 130.35 + */ 130.36 + 130.37 +import java.lang.annotation.*; 130.38 +import java.util.Set; 130.39 +import javax.annotation.processing.*; 130.40 +import javax.lang.model.element.*; 130.41 + 130.42 +import com.sun.tools.javac.util.*; 130.43 + 130.44 +@ProcessingEnvAnnoDiscovery.Anno1 130.45 +public class ProcessingEnvAnnoDiscovery<@ProcessingEnvAnnoDiscovery.Anno4 T> 130.46 + extends JavacTestingAbstractProcessor { 130.47 + private int round = 0; 130.48 + 130.49 + public boolean process(Set<? extends TypeElement> annos, RoundEnvironment rEnv) { 130.50 + if (round++ == 0) { 130.51 + System.out.println(annos); 130.52 + Assert.check(annos.contains(eltUtils.getTypeElement("java.lang.annotation.Target"))); 130.53 + Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno1"))); 130.54 + Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno2"))); 130.55 + Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno3"))); 130.56 + Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno4"))); 130.57 + Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno5"))); 130.58 + Assert.check(annos.size() == 6, "Found extra annotations"); //Anno1-5 + @Target 130.59 + } 130.60 + 130.61 + return true; 130.62 + } 130.63 + 130.64 + @Anno2 130.65 + public <@Anno5 K> K m(@Anno3 long foo) { 130.66 + return null; 130.67 + } 130.68 + 130.69 + @interface Anno1 {} 130.70 + 130.71 + @interface Anno2 {} 130.72 + 130.73 + @interface Anno3 {} 130.74 + 130.75 + @Target(ElementType.TYPE_PARAMETER) 130.76 + @interface Anno4 {} 130.77 + 130.78 + @Target(ElementType.TYPE_PARAMETER) 130.79 + @interface Anno5 {} 130.80 + 130.81 +}
131.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 131.2 +++ b/test/tools/javac/processing/environment/round/Anno.java Thu May 29 13:46:36 2014 -0700 131.3 @@ -0,0 +1,28 @@ 131.4 +/* 131.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 131.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 131.7 + * 131.8 + * This code is free software; you can redistribute it and/or modify it 131.9 + * under the terms of the GNU General Public License version 2 only, as 131.10 + * published by the Free Software Foundation. 131.11 + * 131.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 131.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 131.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 131.15 + * version 2 for more details (a copy is included in the LICENSE file that 131.16 + * accompanied this code). 131.17 + * 131.18 + * You should have received a copy of the GNU General Public License version 131.19 + * 2 along with this work; if not, write to the Free Software Foundation, 131.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 131.21 + * 131.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 131.23 + * or visit www.oracle.com if you need additional information or have any 131.24 + * questions. 131.25 + */ 131.26 + 131.27 +import java.lang.annotation.*; 131.28 +import static java.lang.annotation.RetentionPolicy.*; 131.29 + 131.30 +@Retention(RUNTIME) 131.31 +public @interface Anno {}
132.1 --- a/test/tools/javac/processing/environment/round/BuriedAnnotations.java Mon May 19 22:00:11 2014 -0700 132.2 +++ b/test/tools/javac/processing/environment/round/BuriedAnnotations.java Thu May 29 13:46:36 2014 -0700 132.3 @@ -1,5 +1,5 @@ 132.4 /* 132.5 - * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved. 132.6 + * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. 132.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 132.8 * 132.9 * This code is free software; you can redistribute it and/or modify it 132.10 @@ -22,7 +22,7 @@ 132.11 */ 132.12 132.13 /** 132.14 - * Class to hold annotations for ElementsAnnotatedWithTest. 132.15 + * Class to hold annotations for TestElementsAnnotatedWith. 132.16 */ 132.17 132.18 @AnnotatedElementInfo(annotationName="java.lang.SuppressWarnings",
133.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 133.2 +++ b/test/tools/javac/processing/environment/round/ErroneousAnnotations.java Thu May 29 13:46:36 2014 -0700 133.3 @@ -0,0 +1,12 @@ 133.4 +/** /nodynamiccopyright/ 133.5 + * Class to hold annotations for TestElementsAnnotatedWith. 133.6 + */ 133.7 + 133.8 +@AnnotatedElementInfo(annotationName="java.lang.SuppressWarnings", 133.9 + expectedSize=0, 133.10 + names={}) 133.11 +@Undefined 133.12 +public class ErroneousAnnotations { 133.13 + @Undefined 133.14 + private void foo() {return;} 133.15 +}
134.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 134.2 +++ b/test/tools/javac/processing/environment/round/ErroneousAnnotations.out Thu May 29 13:46:36 2014 -0700 134.3 @@ -0,0 +1,3 @@ 134.4 +ErroneousAnnotations.java:8:2: compiler.err.cant.resolve: kindname.class, Undefined, , 134.5 +ErroneousAnnotations.java:10:6: compiler.err.cant.resolve.location: kindname.class, Undefined, , , (compiler.misc.location: kindname.class, ErroneousAnnotations, null) 134.6 +2 errors
135.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 135.2 +++ b/test/tools/javac/processing/environment/round/ParameterAnnotations.java Thu May 29 13:46:36 2014 -0700 135.3 @@ -0,0 +1,33 @@ 135.4 +/* 135.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 135.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 135.7 + * 135.8 + * This code is free software; you can redistribute it and/or modify it 135.9 + * under the terms of the GNU General Public License version 2 only, as 135.10 + * published by the Free Software Foundation. 135.11 + * 135.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 135.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 135.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 135.15 + * version 2 for more details (a copy is included in the LICENSE file that 135.16 + * accompanied this code). 135.17 + * 135.18 + * You should have received a copy of the GNU General Public License version 135.19 + * 2 along with this work; if not, write to the Free Software Foundation, 135.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 135.21 + * 135.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 135.23 + * or visit www.oracle.com if you need additional information or have any 135.24 + * questions. 135.25 + */ 135.26 + 135.27 +/** 135.28 + * Class to hold annotations for ElementsAnnotatedWithTest. 135.29 + */ 135.30 + 135.31 +@AnnotatedElementInfo(annotationName="Anno", 135.32 + expectedSize=1, 135.33 + names={"annotatedParameter"}) 135.34 +public class ParameterAnnotations { 135.35 + private void foo(@Anno Object annotatedParameter) {} 135.36 +}
136.1 --- a/test/tools/javac/processing/environment/round/Part1.java Mon May 19 22:00:11 2014 -0700 136.2 +++ b/test/tools/javac/processing/environment/round/Part1.java Thu May 29 13:46:36 2014 -0700 136.3 @@ -1,5 +1,5 @@ 136.4 /* 136.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 136.6 + * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. 136.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 136.8 * 136.9 * This code is free software; you can redistribute it and/or modify it 136.10 @@ -22,7 +22,7 @@ 136.11 */ 136.12 136.13 /** 136.14 - * Class to hold annotations for ElementsAnnotatedWithTest. 136.15 + * Class to hold annotations for TestElementsAnnotatedWith. 136.16 */ 136.17 136.18 @AnnotatedElementInfo(annotationName="java.lang.SuppressWarnings",
137.1 --- a/test/tools/javac/processing/environment/round/Part2.java Mon May 19 22:00:11 2014 -0700 137.2 +++ b/test/tools/javac/processing/environment/round/Part2.java Thu May 29 13:46:36 2014 -0700 137.3 @@ -1,5 +1,5 @@ 137.4 /* 137.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 137.6 + * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. 137.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 137.8 * 137.9 * This code is free software; you can redistribute it and/or modify it 137.10 @@ -22,7 +22,7 @@ 137.11 */ 137.12 137.13 /** 137.14 - * Class to hold annotations for ElementsAnnotatedWithTest. 137.15 + * Class to hold annotations for TestElementsAnnotatedWith. 137.16 */ 137.17 @SuppressWarnings("") 137.18 public class Part2 {
138.1 --- a/test/tools/javac/processing/environment/round/SurfaceAnnotations.java Mon May 19 22:00:11 2014 -0700 138.2 +++ b/test/tools/javac/processing/environment/round/SurfaceAnnotations.java Thu May 29 13:46:36 2014 -0700 138.3 @@ -1,5 +1,5 @@ 138.4 /* 138.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 138.6 + * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. 138.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 138.8 * 138.9 * This code is free software; you can redistribute it and/or modify it 138.10 @@ -22,7 +22,7 @@ 138.11 */ 138.12 138.13 /** 138.14 - * Class to hold annotations for ElementsAnnotatedWithTest. 138.15 + * Class to hold annotations for TestElementsAnnotatedWith. 138.16 */ 138.17 138.18 @AnnotatedElementInfo(annotationName="java.lang.SuppressWarnings",
139.1 --- a/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java Mon May 19 22:00:11 2014 -0700 139.2 +++ b/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java Thu May 29 13:46:36 2014 -0700 139.3 @@ -1,5 +1,5 @@ 139.4 /* 139.5 - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. 139.6 + * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. 139.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 139.8 * 139.9 * This code is free software; you can redistribute it and/or modify it 139.10 @@ -23,7 +23,7 @@ 139.11 139.12 /* 139.13 * @test 139.14 - * @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854 139.15 + * @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854 8030049 8038080 139.16 * @summary Tests that getElementsAnnotatedWith works properly. 139.17 * @author Joseph D. Darcy 139.18 * @library /tools/javac/lib 139.19 @@ -31,29 +31,26 @@ 139.20 * @compile TestElementsAnnotatedWith.java 139.21 * @compile InheritedAnnotation.java 139.22 * @compile TpAnno.java 139.23 + * @compile Anno.java 139.24 * @compile -processor TestElementsAnnotatedWith -proc:only SurfaceAnnotations.java 139.25 * @compile -processor TestElementsAnnotatedWith -proc:only BuriedAnnotations.java 139.26 * @compile -processor TestElementsAnnotatedWith -proc:only Part1.java Part2.java 139.27 * @compile -processor TestElementsAnnotatedWith -proc:only C2.java 139.28 * @compile -processor TestElementsAnnotatedWith -proc:only Foo.java 139.29 * @compile -processor TestElementsAnnotatedWith -proc:only TypeParameterAnnotations.java 139.30 + * @compile -processor TestElementsAnnotatedWith -proc:only ParameterAnnotations.java 139.31 + * @compile/fail/ref=ErroneousAnnotations.out -processor TestElementsAnnotatedWith -proc:only -XDrawDiagnostics ErroneousAnnotations.java 139.32 * @compile Foo.java 139.33 * @compile/process -processor TestElementsAnnotatedWith -proc:only Foo 139.34 */ 139.35 139.36 import java.lang.annotation.Annotation; 139.37 -import java.io.*; 139.38 import java.util.Collections; 139.39 import java.util.Set; 139.40 import java.util.HashSet; 139.41 -import java.util.List; 139.42 -import java.util.ArrayList; 139.43 import java.util.Arrays; 139.44 import javax.annotation.processing.*; 139.45 -import javax.tools.*; 139.46 -import javax.lang.model.SourceVersion; 139.47 import javax.lang.model.element.*; 139.48 -import javax.lang.model.util.*; 139.49 import static javax.lang.model.util.ElementFilter.*; 139.50 139.51 /** 139.52 @@ -96,7 +93,8 @@ 139.53 roundEnvironment. 139.54 getElementsAnnotatedWith(elements.getTypeElement(annotatedElementInfo.annotationName())); 139.55 139.56 - System.err.println("Results: " + resultsMeta); 139.57 + if (!resultsMeta.isEmpty()) 139.58 + System.err.println("Results: " + resultsMeta); 139.59 139.60 if (resultsMeta.size() != annotatedElementInfo.expectedSize()) { 139.61 failed = true;
140.1 --- a/test/tools/javac/processing/environment/round/TypeParameterAnnotations.java Mon May 19 22:00:11 2014 -0700 140.2 +++ b/test/tools/javac/processing/environment/round/TypeParameterAnnotations.java Thu May 29 13:46:36 2014 -0700 140.3 @@ -1,5 +1,5 @@ 140.4 /* 140.5 - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 140.6 + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. 140.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 140.8 * 140.9 * This code is free software; you can redistribute it and/or modify it 140.10 @@ -22,7 +22,7 @@ 140.11 */ 140.12 140.13 /** 140.14 - * Class to hold annotations for ElementsAnnotatedWithTest. 140.15 + * Class to hold annotations for TestElementsAnnotatedWith. 140.16 */ 140.17 140.18 @AnnotatedElementInfo(annotationName="TpAnno",
141.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 141.2 +++ b/test/tools/javac/resolve/AmbiguityErrorTest.java Thu May 29 13:46:36 2014 -0700 141.3 @@ -0,0 +1,75 @@ 141.4 +/* 141.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 141.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 141.7 + * 141.8 + * This code is free software; you can redistribute it and/or modify it 141.9 + * under the terms of the GNU General Public License version 2 only, as 141.10 + * published by the Free Software Foundation. 141.11 + * 141.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 141.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 141.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 141.15 + * version 2 for more details (a copy is included in the LICENSE file that 141.16 + * accompanied this code). 141.17 + * 141.18 + * You should have received a copy of the GNU General Public License version 141.19 + * 2 along with this work; if not, write to the Free Software Foundation, 141.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 141.21 + * 141.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 141.23 + * or visit www.oracle.com if you need additional information or have any 141.24 + * questions. 141.25 + */ 141.26 + 141.27 +/** 141.28 + * @test 141.29 + * @bug 8041663 141.30 + */ 141.31 + 141.32 +public class AmbiguityErrorTest { 141.33 + 141.34 + public interface A { } 141.35 + 141.36 + public interface B extends A { } 141.37 + 141.38 + public interface C { 141.39 + A m(B strategy); 141.40 + } 141.41 + 141.42 + public interface D { 141.43 + A m(A strategy); 141.44 + A m(B strategy); 141.45 + } 141.46 + 141.47 + public interface T1 extends C, D { } 141.48 + public interface T2 extends D, C { } 141.49 + 141.50 + int count; 141.51 + 141.52 + class T1Impl implements T1, T2 { 141.53 + public A m(B strategy) { 141.54 + count++; 141.55 + return null; 141.56 + } 141.57 + public A m(A strategy) { 141.58 + throw new AssertionError("Should not get here."); 141.59 + } 141.60 + } 141.61 + 141.62 + public static void main(String... args) { 141.63 + new AmbiguityErrorTest().test(); 141.64 + } 141.65 + 141.66 + void test() { 141.67 + T1 t1 = new T1Impl(); 141.68 + T2 t2 = new T1Impl(); 141.69 + final B b = new B() { }; 141.70 + t1.m(b); 141.71 + t2.m(b); 141.72 + 141.73 + if (count != 2) { 141.74 + throw new IllegalStateException("Did not call the methods properly"); 141.75 + } 141.76 + } 141.77 + 141.78 +}
142.1 --- a/test/tools/javac/resolve/ResolveHarness.java Mon May 19 22:00:11 2014 -0700 142.2 +++ b/test/tools/javac/resolve/ResolveHarness.java Thu May 29 13:46:36 2014 -0700 142.3 @@ -1,5 +1,5 @@ 142.4 /* 142.5 - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 142.6 + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. 142.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 142.8 * 142.9 * This code is free software; you can redistribute it and/or modify it 142.10 @@ -23,8 +23,8 @@ 142.11 142.12 /* 142.13 * @test 142.14 - * @bug 7098660 142.15 - * @summary Write better overload resolution/inference tests 142.16 + * @bug 7098660 8014649 8034223 142.17 + * @summary Test harness for overload resolution/inference tests 142.18 * @library /tools/javac/lib 142.19 * @build JavacTestingAbstractProcessor ResolveHarness 142.20 * @run main ResolveHarness
143.1 --- a/test/tools/javac/resolve/tests/PrimitiveOverReferenceVarargsAmbiguous.java Mon May 19 22:00:11 2014 -0700 143.2 +++ b/test/tools/javac/resolve/tests/PrimitiveOverReferenceVarargsAmbiguous.java Thu May 29 13:46:36 2014 -0700 143.3 @@ -23,44 +23,44 @@ 143.4 143.5 @TraceResolve(keys={"compiler.err.ref.ambiguous"}) 143.6 class PrimitiveOverReferenceVarargsAmbiguous { 143.7 - @Candidate(applicable=Phase.VARARGS, mostSpecific=true) 143.8 + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) 143.9 static void m_byte(byte... b) {} 143.10 - @Candidate(applicable=Phase.VARARGS) 143.11 + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) 143.12 static void m_byte(Byte... b) {} 143.13 143.14 - @Candidate(applicable=Phase.VARARGS, mostSpecific=true) 143.15 + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) 143.16 static void m_short(short... s) {} 143.17 - @Candidate(applicable=Phase.VARARGS) 143.18 + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) 143.19 static void m_short(Short... s) {} 143.20 143.21 - @Candidate(applicable=Phase.VARARGS, mostSpecific=true) 143.22 + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) 143.23 static void m_int(int... i) {} 143.24 - @Candidate(applicable=Phase.VARARGS) 143.25 + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) 143.26 static void m_int(Integer... i) {} 143.27 143.28 - @Candidate(applicable=Phase.VARARGS, mostSpecific=true) 143.29 + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) 143.30 static void m_long(long... l) {} 143.31 - @Candidate(applicable=Phase.VARARGS) 143.32 + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) 143.33 static void m_long(Long... l) {} 143.34 143.35 - @Candidate(applicable=Phase.VARARGS, mostSpecific=true) 143.36 + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) 143.37 static void m_float(float... f) {} 143.38 - @Candidate(applicable=Phase.VARARGS) 143.39 + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) 143.40 static void m_float(Float... f) {} 143.41 143.42 - @Candidate(applicable=Phase.VARARGS, mostSpecific=true) 143.43 + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) 143.44 static void m_double(double... d) {} 143.45 - @Candidate(applicable=Phase.VARARGS) 143.46 + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) 143.47 static void m_double(Double... d) {} 143.48 143.49 - @Candidate(applicable=Phase.VARARGS, mostSpecific=true) 143.50 + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) 143.51 static void m_char(char... c) {} 143.52 - @Candidate(applicable=Phase.VARARGS) 143.53 + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) 143.54 static void m_char(Character... c) {} 143.55 143.56 - @Candidate(applicable=Phase.VARARGS, mostSpecific=true) 143.57 + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) 143.58 static void m_bool(boolean... z) {} 143.59 - @Candidate(applicable=Phase.VARARGS) 143.60 + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) 143.61 static void m_bool(Boolean... z) {} 143.62 143.63 {
144.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 144.2 +++ b/test/tools/javac/resolve/tests/PrimitiveVsReferenceSamePhase.java Thu May 29 13:46:36 2014 -0700 144.3 @@ -0,0 +1,76 @@ 144.4 +/* 144.5 + * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. 144.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 144.7 + * 144.8 + * This code is free software; you can redistribute it and/or modify it 144.9 + * under the terms of the GNU General Public License version 2 only, as 144.10 + * published by the Free Software Foundation. 144.11 + * 144.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 144.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 144.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 144.15 + * version 2 for more details (a copy is included in the LICENSE file that 144.16 + * accompanied this code). 144.17 + * 144.18 + * You should have received a copy of the GNU General Public License version 144.19 + * 2 along with this work; if not, write to the Free Software Foundation, 144.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 144.21 + * 144.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 144.23 + * or visit www.oracle.com if you need additional information or have any 144.24 + * questions. 144.25 + */ 144.26 + 144.27 +@TraceResolve(keys={"compiler.err.ref.ambiguous"}) 144.28 +class PrimitiveVsReferenceSamePhase { 144.29 + @Candidate(applicable=Phase.BOX, mostSpecific=false) 144.30 + static void m_byte(Byte b1, byte b2) {} 144.31 + @Candidate(applicable=Phase.BOX, mostSpecific=false) 144.32 + static void m_byte(Byte b1, Byte b2) {} 144.33 + 144.34 + @Candidate(applicable=Phase.BOX, mostSpecific=false) 144.35 + static void m_short(Short s1, short s2) {} 144.36 + @Candidate(applicable=Phase.BOX, mostSpecific=false) 144.37 + static void m_short(Short s1, Short s2) {} 144.38 + 144.39 + @Candidate(applicable=Phase.BOX, mostSpecific=false) 144.40 + static void m_int(Integer i1, int i2) {} 144.41 + @Candidate(applicable=Phase.BOX, mostSpecific=false) 144.42 + static void m_int(Integer i1, Integer i2) {} 144.43 + 144.44 + @Candidate(applicable=Phase.BOX, mostSpecific=false) 144.45 + static void m_long(Long l1, long l2) {} 144.46 + @Candidate(applicable=Phase.BOX, mostSpecific=false) 144.47 + static void m_long(Long l1, Long l2) {} 144.48 + 144.49 + @Candidate(applicable=Phase.BOX, mostSpecific=false) 144.50 + static void m_float(Float f1, float f2) {} 144.51 + @Candidate(applicable=Phase.BOX, mostSpecific=false) 144.52 + static void m_float(Float f1, Float f2) {} 144.53 + 144.54 + @Candidate(applicable=Phase.BOX, mostSpecific=false) 144.55 + static void m_double(Double d1, double d2) {} 144.56 + @Candidate(applicable=Phase.BOX, mostSpecific=false) 144.57 + static void m_double(Double d1, Double d2) {} 144.58 + 144.59 + @Candidate(applicable=Phase.BOX, mostSpecific=false) 144.60 + static void m_char(Character c1, char c2) {} 144.61 + @Candidate(applicable=Phase.BOX, mostSpecific=false) 144.62 + static void m_char(Character c1, Character c2) {} 144.63 + 144.64 + @Candidate(applicable=Phase.BOX, mostSpecific=false) 144.65 + static void m_bool(Boolean z1, boolean z2) {} 144.66 + @Candidate(applicable=Phase.BOX, mostSpecific=false) 144.67 + static void m_bool(Boolean z1, Boolean z2) {} 144.68 + 144.69 + { 144.70 + m_byte((byte)0, (byte)0); 144.71 + m_short((short)0, (short)0); 144.72 + m_int(0, 0); 144.73 + m_long(0L, 0L); 144.74 + m_float(0.0f, 0.0f); 144.75 + m_double(0.0, 0.0); 144.76 + m_char('?', '?'); 144.77 + m_bool(false, false); 144.78 + } 144.79 +}
145.1 --- a/test/tools/javac/scope/7046348/EagerInterfaceCompletionTest.java Mon May 19 22:00:11 2014 -0700 145.2 +++ b/test/tools/javac/scope/7046348/EagerInterfaceCompletionTest.java Thu May 29 13:46:36 2014 -0700 145.3 @@ -1,5 +1,5 @@ 145.4 /* 145.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 145.6 + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. 145.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 145.8 * 145.9 * This code is free software; you can redistribute it and/or modify it 145.10 @@ -181,7 +181,7 @@ 145.11 case FIELD: 145.12 case SUPER: return true; 145.13 case METHOD: return hk != HierarchyKind.INTERFACE || ak == ActionKind.REMOVE_B || 145.14 - (hk == HierarchyKind.INTERFACE && ak == ActionKind.REMOVE_A && vk == VersionKind.LAMBDA); 145.15 + (hk == HierarchyKind.INTERFACE && ak == ActionKind.REMOVE_A); 145.16 default: throw new AssertionError("Unexpected test kind " + this); 145.17 } 145.18 }
146.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 146.2 +++ b/test/tools/javac/varargs/MethodHandleCrash.java Thu May 29 13:46:36 2014 -0700 146.3 @@ -0,0 +1,36 @@ 146.4 +/* 146.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 146.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 146.7 + * 146.8 + * This code is free software; you can redistribute it and/or modify it 146.9 + * under the terms of the GNU General Public License version 2 only, as 146.10 + * published by the Free Software Foundation. 146.11 + * 146.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 146.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 146.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 146.15 + * version 2 for more details (a copy is included in the LICENSE file that 146.16 + * accompanied this code). 146.17 + * 146.18 + * You should have received a copy of the GNU General Public License version 146.19 + * 2 along with this work; if not, write to the Free Software Foundation, 146.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 146.21 + * 146.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 146.23 + * or visit www.oracle.com if you need additional information or have any 146.24 + * questions. 146.25 + */ 146.26 + 146.27 +/* 146.28 + * @test 146.29 + * @bug 8034048 146.30 + * @summary javac crash with method references plus lambda plus var args 146.31 + * @author govereau 146.32 + * 146.33 + * @compile MethodHandleCrash.java 146.34 + */ 146.35 +public interface MethodHandleCrash { 146.36 + static<T> void functional(T... input) { 146.37 + java.util.function.Consumer<T> c = MethodHandleCrash::functional; 146.38 + } 146.39 +}
147.1 --- a/test/tools/javadoc/parser/7091528/T7091528.java Mon May 19 22:00:11 2014 -0700 147.2 +++ b/test/tools/javadoc/parser/7091528/T7091528.java Thu May 29 13:46:36 2014 -0700 147.3 @@ -1,5 +1,5 @@ 147.4 /* 147.5 - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. 147.6 + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. 147.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 147.8 * 147.9 * This code is free software; you can redistribute it and/or modify it 147.10 @@ -23,8 +23,8 @@ 147.11 147.12 /** 147.13 * @test 147.14 - * @bug 7091528 147.15 - * @summary javadoc attempts to parse .class files 147.16 + * @bug 7091528 8029145 8037484 147.17 + * @summary ensures javadoc parses unique source files and ignores all class files 147.18 * @compile p/C1.java p/q/C2.java 147.19 * @run main T7091528 147.20 */ 147.21 @@ -37,17 +37,32 @@ 147.22 public static void main(String... args) { 147.23 new T7091528().run(); 147.24 } 147.25 - 147.26 void run() { 147.27 File testSrc = new File(System.getProperty("test.src")); 147.28 File testClasses = new File(System.getProperty("test.classes")); 147.29 - String[] args = { 147.30 - "-d", ".", 147.31 + // 7091528, tests if class files are being ignored 147.32 + runTest("-d", ".", 147.33 "-sourcepath", testClasses + File.pathSeparator + testSrc, 147.34 "-subpackages", 147.35 - "p" 147.36 - }; 147.37 + "p"); 147.38 + // 8029145, tests if unique source files are parsed 147.39 + runTest("-d", ".", 147.40 + "-sourcepath", testSrc.getAbsolutePath(), 147.41 + "-subpackages", 147.42 + "p:p.q"); 147.43 + File testPkgDir = new File(testSrc, "p"); 147.44 + File testFile = new File(testPkgDir, "C3.java"); 147.45 + runTest("-d", ".", 147.46 + "-sourcepath", testSrc.getAbsolutePath(), 147.47 + testFile.getAbsolutePath(), 147.48 + "p"); 147.49 + runTest("-d", ".", 147.50 + "-classpath", testSrc.getAbsolutePath(), 147.51 + testFile.getAbsolutePath(), 147.52 + "p"); 147.53 147.54 + } 147.55 + void runTest(String... args) { 147.56 StringWriter sw = new StringWriter(); 147.57 PrintWriter pw = new PrintWriter(sw); 147.58 String doclet = com.sun.tools.doclets.standard.Standard.class.getName(); 147.59 @@ -60,7 +75,7 @@ 147.60 } 147.61 147.62 if (rc != 0) 147.63 - System.err.println("javadoc failed: exit code = " + rc); 147.64 + throw new Error("javadoc failed: exit code = " + rc); 147.65 147.66 if (out.matches("(?s).*p/[^ ]+\\.class.*")) 147.67 throw new Error("reading .class files");
148.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 148.2 +++ b/test/tools/javadoc/parser/7091528/p/C3.java Thu May 29 13:46:36 2014 -0700 148.3 @@ -0,0 +1,27 @@ 148.4 +/* 148.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 148.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 148.7 + * 148.8 + * This code is free software; you can redistribute it and/or modify it 148.9 + * under the terms of the GNU General Public License version 2 only, as 148.10 + * published by the Free Software Foundation. 148.11 + * 148.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 148.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 148.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 148.15 + * version 2 for more details (a copy is included in the LICENSE file that 148.16 + * accompanied this code). 148.17 + * 148.18 + * You should have received a copy of the GNU General Public License version 148.19 + * 2 along with this work; if not, write to the Free Software Foundation, 148.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 148.21 + * 148.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 148.23 + * or visit www.oracle.com if you need additional information or have any 148.24 + * questions. 148.25 + */ 148.26 + 148.27 + 148.28 +/** This is class C3, and no package for me please */ 148.29 +public class C3 {} 148.30 +
149.1 --- a/test/tools/javap/InvalidOptions.java Mon May 19 22:00:11 2014 -0700 149.2 +++ b/test/tools/javap/InvalidOptions.java Thu May 29 13:46:36 2014 -0700 149.3 @@ -24,7 +24,7 @@ 149.4 /* 149.5 * @test 149.6 * @bug 8027411 149.7 - * @summary test invalid options -h and -b 149.8 + * @summary test an invalid option 149.9 */ 149.10 149.11 import java.io.*; 149.12 @@ -39,7 +39,6 @@ 149.13 } 149.14 149.15 void run() throws Exception { 149.16 - test(2, "-h", "Error: -h is no longer available - use the javah program"); 149.17 test(2, "-b", "Error: unknown option: -b", 149.18 "Usage: javap <options> <classes>", 149.19 "use -help for a list of possible options");
150.1 --- a/test/tools/javap/MethodParameters.java Mon May 19 22:00:11 2014 -0700 150.2 +++ b/test/tools/javap/MethodParameters.java Thu May 29 13:46:36 2014 -0700 150.3 @@ -1,5 +1,5 @@ 150.4 /* 150.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 150.6 + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. 150.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 150.8 * 150.9 * This code is free software; you can redistribute it and/or modify it 150.10 @@ -44,24 +44,24 @@ 150.11 static final String Init0_expected = 150.12 (" Foo();\n" + 150.13 " descriptor: ()V\n" + 150.14 - " flags: \n" + 150.15 + " flags:\n" + 150.16 " Code:\n" + 150.17 " stack=1, locals=1, args_size=1\n" + 150.18 - " 0: aload_0 \n" + 150.19 + " 0: aload_0\n" + 150.20 " 1: invokespecial #1 // Method java/lang/Object.\"<init>\":()V\n" + 150.21 - " 4: return \n" + 150.22 + " 4: return\n" + 150.23 " LineNumberTable:\n" + 150.24 " line 2: 0").replaceAll(" +", " "); 150.25 150.26 static final String Init1_expected = 150.27 (" Foo(int);\n" + 150.28 " descriptor: (I)V\n" + 150.29 - " flags: \n" + 150.30 + " flags:\n" + 150.31 " Code:\n" + 150.32 " stack=1, locals=2, args_size=2\n" + 150.33 - " 0: aload_0 \n" + 150.34 + " 0: aload_0\n" + 150.35 " 1: invokespecial #1 // Method java/lang/Object.\"<init>\":()V\n" + 150.36 - " 4: return \n" + 150.37 + " 4: return\n" + 150.38 " LineNumberTable:\n" + 150.39 " line 3: 0\n" + 150.40 " MethodParameters:\n" + 150.41 @@ -71,25 +71,25 @@ 150.42 static final String foo0_expected = 150.43 (" void foo0();\n" + 150.44 " descriptor: ()V\n" + 150.45 - " flags: \n" + 150.46 + " flags:\n" + 150.47 " Code:\n" + 150.48 " stack=0, locals=1, args_size=1\n" + 150.49 - " 0: return \n" + 150.50 + " 0: return\n" + 150.51 " LineNumberTable:\n" + 150.52 " line 4: 0").replaceAll(" +", " "); 150.53 150.54 static final String foo2_expected = 150.55 (" void foo2(int, int);\n" + 150.56 " descriptor: (II)V\n" + 150.57 - " flags: \n" + 150.58 + " flags:\n" + 150.59 " Code:\n" + 150.60 " stack=0, locals=3, args_size=3\n" + 150.61 - " 0: return \n" + 150.62 + " 0: return\n" + 150.63 " LineNumberTable:\n" + 150.64 " line 5: 0\n" + 150.65 " MethodParameters:\n" + 150.66 " Name Flags\n" + 150.67 - " j \n" + 150.68 + " j\n" + 150.69 " k").replaceAll(" +", " "); 150.70 150.71 static final File classesdir = new File("methodparameters");
151.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 151.2 +++ b/test/tools/javap/StackMapTableTest.java Thu May 29 13:46:36 2014 -0700 151.3 @@ -0,0 +1,92 @@ 151.4 +/* 151.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 151.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 151.7 + * 151.8 + * This code is free software; you can redistribute it and/or modify it 151.9 + * under the terms of the GNU General Public License version 2 only, as 151.10 + * published by the Free Software Foundation. 151.11 + * 151.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 151.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 151.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 151.15 + * version 2 for more details (a copy is included in the LICENSE file that 151.16 + * accompanied this code). 151.17 + * 151.18 + * You should have received a copy of the GNU General Public License version 151.19 + * 2 along with this work; if not, write to the Free Software Foundation, 151.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 151.21 + * 151.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 151.23 + * or visit www.oracle.com if you need additional information or have any 151.24 + * questions. 151.25 + */ 151.26 + 151.27 +/* 151.28 + * @test 151.29 + * @bug 8033930 8033913 151.30 + * @summary bad formatting of StackMapTable entries 151.31 + */ 151.32 + 151.33 +import java.io.*; 151.34 +import java.util.*; 151.35 + 151.36 +public class StackMapTableTest { 151.37 + public static void main(String... args) throws Exception { 151.38 + new StackMapTableTest().run(); 151.39 + } 151.40 + 151.41 + void run() throws Exception { 151.42 + String testClasses = System.getProperty("test.classes"); 151.43 + String out = javap("-v", "-classpath", testClasses, A.class.getName()); 151.44 + 151.45 + String nl = System.getProperty("line.separator"); 151.46 + out = out.replaceAll(nl, "\n"); 151.47 + 151.48 + if (out.contains("\n\n\n")) 151.49 + error("double blank line found"); 151.50 + 151.51 + String expect = 151.52 + " StackMapTable: number_of_entries = 2\n" + 151.53 + " frame_type = 252 /* append */\n" + 151.54 + " offset_delta = 2\n" + 151.55 + " locals = [ int ]\n" + 151.56 + " frame_type = 250 /* chop */\n" + 151.57 + " offset_delta = 18\n"; 151.58 + if (!out.contains(expect)) 151.59 + error("expected text not found"); 151.60 + 151.61 + if (errors > 0) 151.62 + throw new Exception(errors + " errors found"); 151.63 + } 151.64 + 151.65 + String javap(String... args) throws Exception { 151.66 + StringWriter sw = new StringWriter(); 151.67 + PrintWriter out = new PrintWriter(sw); 151.68 + int rc = com.sun.tools.javap.Main.run(args, out); 151.69 + out.close(); 151.70 + System.out.println(sw.toString()); 151.71 + if (rc < 0) 151.72 + throw new Exception("javap exited, rc=" + rc); 151.73 + return sw.toString(); 151.74 + } 151.75 + 151.76 + void error(String msg) { 151.77 + System.out.println("Error: " + msg); 151.78 + errors++; 151.79 + } 151.80 + 151.81 + int errors; 151.82 + 151.83 + /** Simple test class to run through javap. */ 151.84 + public class A { 151.85 + public void a() { 151.86 + for (int i = 0; i < 10; i++) { 151.87 + System.out.println(i); 151.88 + } 151.89 + } 151.90 + public void b() { 151.91 + } 151.92 + public void c() { 151.93 + } 151.94 + } 151.95 +}
152.1 --- a/test/tools/javap/T4975569.java Mon May 19 22:00:11 2014 -0700 152.2 +++ b/test/tools/javap/T4975569.java Thu May 29 13:46:36 2014 -0700 152.3 @@ -40,10 +40,10 @@ 152.4 verify("T4975569$Anno", "flags: ACC_INTERFACE, ACC_ABSTRACT, ACC_ANNOTATION"); 152.5 verify("T4975569$E", "flags: ACC_FINAL, ACC_SUPER, ACC_ENUM"); 152.6 verify("T4975569$S", "flags: ACC_BRIDGE, ACC_SYNTHETIC", 152.7 - "InnerClasses:\n static"); 152.8 + "InnerClasses:\n static"); 152.9 verify("T4975569$V", "void m(java.lang.String...)", 152.10 "flags: ACC_VARARGS"); 152.11 - verify("T4975569$Prot", "InnerClasses:\n protected"); 152.12 + verify("T4975569$Prot", "InnerClasses:\n protected"); 152.13 //verify("T4975569$Priv", "InnerClasses"); 152.14 if (errors > 0) 152.15 throw new Error(errors + " found.");
153.1 --- a/test/tools/javap/T6868539.java Mon May 19 22:00:11 2014 -0700 153.2 +++ b/test/tools/javap/T6868539.java Thu May 29 13:46:36 2014 -0700 153.3 @@ -23,7 +23,7 @@ 153.4 153.5 /* 153.6 * @test 153.7 - * @bug 6868539 6868548 153.8 + * @bug 6868539 6868548 8035364 153.9 * @summary javap should use current names for constant pool entries, 153.10 * remove spurious ';' from constant pool entries 153.11 */ 153.12 @@ -41,17 +41,17 @@ 153.13 void run() { 153.14 String output = javap("T6868539"); 153.15 verify(output, "Utf8 +java/lang/String"); // 1: Utf8 153.16 - // 2: currently unused 153.17 + // 2: currently unused 153.18 verify(output, "Integer +123456"); // 3: Integer 153.19 verify(output, "Float +123456.0f"); // 4: Float 153.20 verify(output, "Long +123456l"); // 5: Long 153.21 verify(output, "Double +123456.0d"); // 6: Double 153.22 - verify(output, "Class +#[0-9]+ +// + T6868539"); // 7: Class 153.23 - verify(output, "String +#[0-9]+ +// + not found"); // 8: String 153.24 + verify(output, "Class +#[0-9]+ +// +T6868539"); // 7: Class 153.25 + verify(output, "String +#[0-9]+ +// +not found"); // 8: String 153.26 verify(output, "Fieldref +#[0-9]+\\.#[0-9]+ +// +T6868539.errors:I"); // 9: Fieldref 153.27 verify(output, "Methodref +#[0-9]+\\.#[0-9]+ +// +T6868539.run:\\(\\)V"); // 10: Methodref 153.28 verify(output, "InterfaceMethodref +#[0-9]+\\.#[0-9]+ +// +java/lang/Runnable\\.run:\\(\\)V"); 153.29 - // 11: InterfaceMethodref 153.30 + // 11: InterfaceMethodref 153.31 verify(output, "NameAndType +#[0-9]+:#[0-9]+ +// +run:\\(\\)V"); // 12: NameAndType 153.32 if (errors > 0) 153.33 throw new Error(errors + " found.");
154.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 154.2 +++ b/test/tools/javap/T8032814.java Thu May 29 13:46:36 2014 -0700 154.3 @@ -0,0 +1,93 @@ 154.4 +/* 154.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 154.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 154.7 + * 154.8 + * This code is free software; you can redistribute it and/or modify it 154.9 + * under the terms of the GNU General Public License version 2 only, as 154.10 + * published by the Free Software Foundation. 154.11 + * 154.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 154.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 154.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 154.15 + * version 2 for more details (a copy is included in the LICENSE file that 154.16 + * accompanied this code). 154.17 + * 154.18 + * You should have received a copy of the GNU General Public License version 154.19 + * 2 along with this work; if not, write to the Free Software Foundation, 154.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 154.21 + * 154.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 154.23 + * or visit www.oracle.com if you need additional information or have any 154.24 + * questions. 154.25 + */ 154.26 + 154.27 +/* 154.28 + * @test 154.29 + * @bug 8032814 154.30 + * @summary LineNumberTable/LocalVariableTable tables duplication for the 154.31 + * "-v -l" combination of options 154.32 + * @compile -g T8032814.java 154.33 + * @run main T8032814 154.34 + */ 154.35 + 154.36 +import java.io.*; 154.37 +import java.util.*; 154.38 + 154.39 +public class T8032814 { 154.40 + public static void main(String... args) throws Exception { 154.41 + new T8032814().run(); 154.42 + } 154.43 + 154.44 + void run() throws Exception { 154.45 + Class<?> clazz = T8032814.class; 154.46 + int count = clazz.getDeclaredConstructors().length 154.47 + + clazz.getDeclaredMethods().length; 154.48 + test(clazz, 0); 154.49 + test(clazz, count, "-v"); 154.50 + test(clazz, count, "-l"); 154.51 + test(clazz, count, "-v", "-l"); 154.52 + 154.53 + if (errors > 0) 154.54 + throw new Exception(errors + " errors occurred"); 154.55 + } 154.56 + 154.57 + void test(Class<?> clazz, int expectedCount, String... opts) throws Exception { 154.58 + System.err.println("test class " + clazz.getName() + " " + Arrays.asList(opts) + ": expect: " + expectedCount); 154.59 + List<String> args = new ArrayList<String>(); 154.60 + args.addAll(Arrays.asList(opts)); 154.61 + args.addAll(Arrays.asList("-classpath", System.getProperty("test.classes"))); 154.62 + args.add(clazz.getName()); 154.63 + StringWriter sw = new StringWriter(); 154.64 + PrintWriter pw = new PrintWriter(sw); 154.65 + int rc = com.sun.tools.javap.Main.run(args.toArray(new String[args.size()]), pw); 154.66 + pw.close(); 154.67 + String out = sw.toString(); 154.68 + if (rc != 0) 154.69 + throw new Exception("javap failed unexpectedly: rc=" + rc); 154.70 + 154.71 + int lntCount = 0, lvtCount = 0; 154.72 + for (String line: out.split("[\r\n]+")) { 154.73 + if (line.matches("^ *LineNumberTable:$")) 154.74 + lntCount++; 154.75 + if (line.matches("^ *LocalVariableTable:$")) 154.76 + lvtCount++; 154.77 + } 154.78 + checkEqual("LineNumberTable", lntCount, expectedCount); 154.79 + checkEqual("LocalVariableTable", lvtCount, expectedCount); 154.80 + } 154.81 + 154.82 + void checkEqual(String attr, int found, int expect) { 154.83 + if (found != expect) { 154.84 + error("Unexpected number of occurrences of " + attr + "\n" + 154.85 + "found: " + found + ", expected: " + expect); 154.86 + } 154.87 + } 154.88 + 154.89 + void error(String msg) { 154.90 + System.err.println("Error: " + msg); 154.91 + errors++; 154.92 + } 154.93 + 154.94 + int errors = 0; 154.95 +} 154.96 +
155.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 155.2 +++ b/test/tools/javap/T8032819.java Thu May 29 13:46:36 2014 -0700 155.3 @@ -0,0 +1,95 @@ 155.4 +/* 155.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 155.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 155.7 + * 155.8 + * This code is free software; you can redistribute it and/or modify it 155.9 + * under the terms of the GNU General Public License version 2 only, as 155.10 + * published by the Free Software Foundation. 155.11 + * 155.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 155.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 155.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 155.15 + * version 2 for more details (a copy is included in the LICENSE file that 155.16 + * accompanied this code). 155.17 + * 155.18 + * You should have received a copy of the GNU General Public License version 155.19 + * 2 along with this work; if not, write to the Free Software Foundation, 155.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 155.21 + * 155.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 155.23 + * or visit www.oracle.com if you need additional information or have any 155.24 + * questions. 155.25 + */ 155.26 + 155.27 +/* 155.28 + * @test 155.29 + * @bug 8032819 155.30 + * @summary Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options 155.31 + * @compile -g T8032819.java 155.32 + * @run main T8032819 155.33 + */ 155.34 + 155.35 +import java.io.*; 155.36 +import java.util.*; 155.37 + 155.38 +public class T8032819 { 155.39 + static class Fields { 155.40 + int f1; 155.41 + int f2; 155.42 + } 155.43 + 155.44 + public static void main(String... args) throws Exception { 155.45 + new T8032819().run(); 155.46 + } 155.47 + 155.48 + void run() throws Exception { 155.49 + Class<?> clazz = Fields.class; 155.50 + test(clazz); 155.51 + test(clazz, "-c"); 155.52 + test(clazz, "-l"); 155.53 + test(clazz, "-l", "-c"); 155.54 + test(clazz, "-v"); 155.55 + test(clazz, "-v", "-c"); 155.56 + test(clazz, "-v", "-l"); 155.57 + test(clazz, "-v", "-l", "-c"); 155.58 + 155.59 + if (errors > 0) 155.60 + throw new Exception(errors + " errors occurred"); 155.61 + } 155.62 + 155.63 + static final String sep = System.getProperty("line.separator"); 155.64 + static final String doubleBlankLine = sep + sep + sep; 155.65 + 155.66 + void test(Class<?> clazz, String... opts) throws Exception { 155.67 + System.err.println("test " + Arrays.asList(opts)); 155.68 + List<String> args = new ArrayList<String>(); 155.69 + args.addAll(Arrays.asList(opts)); 155.70 + args.addAll(Arrays.asList("-classpath", System.getProperty("test.classes"))); 155.71 + args.add(clazz.getName()); 155.72 + StringWriter sw = new StringWriter(); 155.73 + PrintWriter pw = new PrintWriter(sw); 155.74 + int rc = com.sun.tools.javap.Main.run(args.toArray(new String[args.size()]), pw); 155.75 + pw.close(); 155.76 + String out = sw.toString(); 155.77 + if (rc != 0) 155.78 + throw new Exception("javap failed unexpectedly: rc=" + rc); 155.79 + 155.80 + int count = 0; 155.81 + int i = out.indexOf(doubleBlankLine, 0); 155.82 + while (i != -1) { 155.83 + count++; 155.84 + i = out.indexOf(doubleBlankLine, i + doubleBlankLine.length()); 155.85 + } 155.86 + 155.87 + if (count > 0) 155.88 + error(count + " double blank lines found"); 155.89 + } 155.90 + 155.91 + void error(String msg) { 155.92 + System.err.println("Error: " + msg); 155.93 + errors++; 155.94 + } 155.95 + 155.96 + int errors = 0; 155.97 +} 155.98 +
156.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 156.2 +++ b/test/tools/javap/T8033180.java Thu May 29 13:46:36 2014 -0700 156.3 @@ -0,0 +1,88 @@ 156.4 +/* 156.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 156.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 156.7 + * 156.8 + * This code is free software; you can redistribute it and/or modify it 156.9 + * under the terms of the GNU General Public License version 2 only, as 156.10 + * published by the Free Software Foundation. 156.11 + * 156.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 156.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 156.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 156.15 + * version 2 for more details (a copy is included in the LICENSE file that 156.16 + * accompanied this code). 156.17 + * 156.18 + * You should have received a copy of the GNU General Public License version 156.19 + * 2 along with this work; if not, write to the Free Software Foundation, 156.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 156.21 + * 156.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 156.23 + * or visit www.oracle.com if you need additional information or have any 156.24 + * questions. 156.25 + */ 156.26 + 156.27 +/* 156.28 + * @test 156.29 + * @bug 8033180 156.30 + * @summary Bad newline characters 156.31 + */ 156.32 + 156.33 +import java.io.*; 156.34 +import java.util.*; 156.35 + 156.36 +public class T8033180 { 156.37 + 156.38 + public static void main(String... args) throws Exception { 156.39 + new T8033180().run(); 156.40 + } 156.41 + 156.42 + void run() throws Exception { 156.43 + // fast-track this case, because test cannot fail in this case 156.44 + if (lineSep.equals(nl)) 156.45 + return; 156.46 + 156.47 + test("-help"); 156.48 + test("-version"); 156.49 + 156.50 + if (errors > 0) 156.51 + throw new Exception(errors + " errors occurred"); 156.52 + } 156.53 + 156.54 + static final String lineSep = System.getProperty("line.separator"); 156.55 + static final String nl = "\n"; 156.56 + 156.57 + void test(String... opts) throws Exception { 156.58 + System.err.println("test " + Arrays.asList(opts)); 156.59 + List<String> args = new ArrayList<String>(); 156.60 + args.addAll(Arrays.asList(opts)); 156.61 + StringWriter sw = new StringWriter(); 156.62 + PrintWriter pw = new PrintWriter(sw); 156.63 + int rc = com.sun.tools.javap.Main.run(args.toArray(new String[args.size()]), pw); 156.64 + pw.close(); 156.65 + String out = sw.toString(); 156.66 + if (rc != 0) 156.67 + throw new Exception("javap failed unexpectedly: rc=" + rc); 156.68 + 156.69 + // remove all valid platform newline sequences 156.70 + String out2 = out.replace(lineSep, ""); 156.71 + 156.72 + // count the remaining simple newline characters 156.73 + int count = 0; 156.74 + int i = out2.indexOf(nl, 0); 156.75 + while (i != -1) { 156.76 + count++; 156.77 + i = out2.indexOf(nl, i + nl.length()); 156.78 + } 156.79 + 156.80 + if (count > 0) 156.81 + error(count + " newline characters found"); 156.82 + } 156.83 + 156.84 + void error(String msg) { 156.85 + System.err.println("Error: " + msg); 156.86 + errors++; 156.87 + } 156.88 + 156.89 + int errors = 0; 156.90 +} 156.91 +
157.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 157.2 +++ b/test/tools/javap/T8033711.java Thu May 29 13:46:36 2014 -0700 157.3 @@ -0,0 +1,55 @@ 157.4 +/* 157.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 157.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 157.7 + * 157.8 + * This code is free software; you can redistribute it and/or modify it 157.9 + * under the terms of the GNU General Public License version 2 only, as 157.10 + * published by the Free Software Foundation. 157.11 + * 157.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 157.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 157.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 157.15 + * version 2 for more details (a copy is included in the LICENSE file that 157.16 + * accompanied this code). 157.17 + * 157.18 + * You should have received a copy of the GNU General Public License version 157.19 + * 2 along with this work; if not, write to the Free Software Foundation, 157.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 157.21 + * 157.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 157.23 + * or visit www.oracle.com if you need additional information or have any 157.24 + * questions. 157.25 + */ 157.26 + 157.27 +/* 157.28 + * @test 157.29 + * @bug 8033711 157.30 + * @summary An exception is thrown if using the "-classpath" option with no arguments 157.31 + */ 157.32 + 157.33 + 157.34 +import java.io.*; 157.35 + 157.36 +public class T8033711 { 157.37 + public static void main(String[] args) throws Exception { 157.38 + new T8033711().run(); 157.39 + } 157.40 + 157.41 + public void run() throws Exception { 157.42 + String out = javap("-classpath"); 157.43 + if (out.contains("IllegalArgumentException")) 157.44 + throw new Exception("exception found in javap output"); 157.45 + if (!out.contains("Error: invalid use of option")) 157.46 + throw new Exception("expected error message not found in javap output"); 157.47 + } 157.48 + 157.49 + String javap(String... args) { 157.50 + StringWriter sw = new StringWriter(); 157.51 + PrintWriter out = new PrintWriter(sw); 157.52 + int rc = com.sun.tools.javap.Main.run(args, out); 157.53 + out.close(); 157.54 + System.out.println(sw.toString()); 157.55 + System.out.println("javap exited, rc=" + rc); 157.56 + return sw.toString(); 157.57 + } 157.58 +}
158.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 158.2 +++ b/test/tools/javap/T8035104.java Thu May 29 13:46:36 2014 -0700 158.3 @@ -0,0 +1,67 @@ 158.4 +/* 158.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 158.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 158.7 + * 158.8 + * This code is free software; you can redistribute it and/or modify it 158.9 + * under the terms of the GNU General Public License version 2 only, as 158.10 + * published by the Free Software Foundation. 158.11 + * 158.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 158.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 158.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 158.15 + * version 2 for more details (a copy is included in the LICENSE file that 158.16 + * accompanied this code). 158.17 + * 158.18 + * You should have received a copy of the GNU General Public License version 158.19 + * 2 along with this work; if not, write to the Free Software Foundation, 158.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 158.21 + * 158.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 158.23 + * or visit www.oracle.com if you need additional information or have any 158.24 + * questions. 158.25 + */ 158.26 + 158.27 +/* 158.28 + * @test 158.29 + * @bug 8035104 158.30 + * @summary reorder class file attributes in javap listing 158.31 + */ 158.32 + 158.33 +import java.io.*; 158.34 + 158.35 +public class T8035104 { 158.36 + public static void main(String[] args) throws Exception { 158.37 + new T8035104().run(); 158.38 + } 158.39 + 158.40 + public void run() throws Exception { 158.41 + String[] lines = javap("-v", T8035104.class.getName()).split("[\r\n]+"); 158.42 + int minor = -1; 158.43 + int SourceFile = -1; 158.44 + for (int i = 0; i < lines.length; i++) { 158.45 + String line = lines[i]; 158.46 + if (line.matches(" *minor version: [0-9.]+")) 158.47 + minor = i; 158.48 + if (line.matches(" *SourceFile: .+")) 158.49 + SourceFile = i; 158.50 + } 158.51 + if (minor == -1) 158.52 + throw new Exception("minor version not found"); 158.53 + if (SourceFile == -1) 158.54 + throw new Exception("SourceFile not found"); 158.55 + if (SourceFile < minor) 158.56 + throw new Exception("unexpected order of output"); 158.57 + 158.58 + System.out.println("output OK"); 158.59 + } 158.60 + 158.61 + String javap(String... args) { 158.62 + StringWriter sw = new StringWriter(); 158.63 + PrintWriter out = new PrintWriter(sw); 158.64 + int rc = com.sun.tools.javap.Main.run(args, out); 158.65 + out.close(); 158.66 + System.out.println(sw.toString()); 158.67 + System.out.println("javap exited, rc=" + rc); 158.68 + return sw.toString(); 158.69 + } 158.70 +}
159.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 159.2 +++ b/test/tools/javap/WhitespaceTest.java Thu May 29 13:46:36 2014 -0700 159.3 @@ -0,0 +1,91 @@ 159.4 +/* 159.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 159.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 159.7 + * 159.8 + * This code is free software; you can redistribute it and/or modify it 159.9 + * under the terms of the GNU General Public License version 2 only, as 159.10 + * published by the Free Software Foundation. 159.11 + * 159.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 159.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 159.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 159.15 + * version 2 for more details (a copy is included in the LICENSE file that 159.16 + * accompanied this code). 159.17 + * 159.18 + * You should have received a copy of the GNU General Public License version 159.19 + * 2 along with this work; if not, write to the Free Software Foundation, 159.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 159.21 + * 159.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 159.23 + * or visit www.oracle.com if you need additional information or have any 159.24 + * questions. 159.25 + */ 159.26 + 159.27 +/* 159.28 + * @test 159.29 + * @bug 8033581 8033798 8033726 159.30 + * @summary Check whitespace in generated output 159.31 + */ 159.32 + 159.33 +import java.io.*; 159.34 +import java.util.*; 159.35 + 159.36 +public class WhitespaceTest { 159.37 + public static void main(String... args) throws Exception { 159.38 + new WhitespaceTest().run(); 159.39 + } 159.40 + 159.41 + void run() throws Exception { 159.42 + test("-v", "java.lang.String"); 159.43 + test("-XDtab:1", "-v", "java.lang.String"); 159.44 + 159.45 + String testClasses = System.getProperty("test.classes"); 159.46 + for (int i = 10; i < 40; i++) 159.47 + test("-XDtab:" + i, "-v", "-classpath", testClasses, "WhitespaceTest$HelloWorld"); 159.48 + 159.49 + if (errors > 0) 159.50 + throw new Exception(errors + " errors found"); 159.51 + } 159.52 + 159.53 + void test(String... args) throws Exception { 159.54 + // need to avoid "//" appearing as a constant in the constant pool 159.55 + String slash = "/"; 159.56 + String doubleSlash = slash + slash; 159.57 + System.out.println("test: " + Arrays.asList(args)); 159.58 + String out = javap(args); 159.59 + for (String line: out.split("[\r\n]+")) { 159.60 + if (line.endsWith(" ")) 159.61 + error("line has trailing whitespace: " + line); 159.62 + int comment = line.indexOf(doubleSlash); 159.63 + if (comment > 0 && line.charAt(comment - 1) != ' ') 159.64 + error("no space before comment: " + line); 159.65 + if (line.matches(" +}")) 159.66 + error("bad indentation: " + line); 159.67 + } 159.68 + } 159.69 + 159.70 + String javap(String... args) throws Exception { 159.71 + StringWriter sw = new StringWriter(); 159.72 + PrintWriter out = new PrintWriter(sw); 159.73 + int rc = com.sun.tools.javap.Main.run(args, out); 159.74 + out.close(); 159.75 + System.out.println(sw.toString()); 159.76 + if (rc < 0) 159.77 + throw new Exception("javap exited, rc=" + rc); 159.78 + return sw.toString(); 159.79 + } 159.80 + 159.81 + void error(String msg) { 159.82 + System.out.println("Error: " + msg); 159.83 + errors++; 159.84 + } 159.85 + 159.86 + int errors; 159.87 + 159.88 + // small class to test repeatedly with different tab values 159.89 + static class HelloWorld { 159.90 + public static void main(String... args) { 159.91 + System.out.println("Hello World!"); 159.92 + } 159.93 + } 159.94 +}