OpenJDK / bsd-port / jdk8 / langtools
changeset 2418:89cefe38ecaf
Merge
author | lana |
---|---|
date | Wed, 14 May 2014 11:01:08 -0700 |
parents | ce94cefa660b 5e9879dfadde |
children | 9c577131ffa6 |
files | |
diffstat | 44 files changed, 1886 insertions(+), 264 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_ja.properties Tue May 13 23:18:48 2014 -0700 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_ja.properties Wed May 14 11:01:08 2014 -0700 @@ -29,7 +29,7 @@ doclet.Href_Enum_Title={0}\u5185\u306E\u5217\u6319\u578B doclet.Href_Type_Param_Title={0}\u5185\u306E\u578B\u30D1\u30E9\u30E1\u30FC\u30BF doclet.Href_Class_Or_Interface_Title={0}\u5185\u306E\u30AF\u30E9\u30B9\u307E\u305F\u306F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9 -doclet.Summary=\u6982\u8981: +doclet.Summary=\u30B5\u30DE\u30EA\u30FC: doclet.Detail=\u8A73\u7D30: doclet.navNested=\u30CD\u30B9\u30C8 doclet.navAnnotationTypeOptionalMember=\u30AA\u30D7\u30B7\u30E7\u30F3 @@ -117,18 +117,18 @@ doclet.Window_Source_title=\u30BD\u30FC\u30B9\u30FB\u30B3\u30FC\u30C9 doclet.Window_Help_title=API\u30D8\u30EB\u30D7 doclet.Help_line_1=API\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u69CB\u6210 -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 -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 -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 +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 +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 +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 doclet.Help_line_5=\u30AF\u30E9\u30B9\u307E\u305F\u306F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9 -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 +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 doclet.Help_line_7=\u30AF\u30E9\u30B9\u968E\u5C64\u8868\u793A doclet.Help_line_8=\u76F4\u7CFB\u306E\u30B5\u30D6\u30AF\u30E9\u30B9 doclet.Help_line_9=\u65E2\u77E5\u306E\u30B5\u30D6\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306E\u30EA\u30B9\u30C8 doclet.Help_line_10=\u65E2\u77E5\u306E\u5B9F\u88C5\u30AF\u30E9\u30B9\u306E\u30EA\u30B9\u30C8 doclet.Help_line_11=\u30AF\u30E9\u30B9\u307E\u305F\u306F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306E\u5BA3\u8A00 doclet.Help_line_12=\u30AF\u30E9\u30B9\u307E\u305F\u306F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306E\u8AAC\u660E -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 +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 doclet.Help_line_14=\u4F7F\u7528 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 doclet.Help_line_16=\u968E\u5C64\u30C4\u30EA\u30FC(\u30AF\u30E9\u30B9\u968E\u5C64)
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_ja.properties Tue May 13 23:18:48 2014 -0700 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_ja.properties Wed May 14 11:01:08 2014 -0700 @@ -66,22 +66,22 @@ doclet.malformed_html_link_tag=<a> \u30BF\u30B0\u306E\u5F62\u5F0F\u304C\u4E0D\u6B63:\n"{0}" 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 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 -doclet.Package_Summary=\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u6982\u8981 +doclet.Package_Summary=\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u30B5\u30DE\u30EA\u30FC doclet.Profile_Summary=\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u30FB\u30B5\u30DE\u30EA\u30FC -doclet.Interface_Summary=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306E\u6982\u8981 -doclet.Annotation_Types_Summary=\u6CE8\u91C8\u578B\u306E\u6982\u8981 -doclet.Enum_Summary=\u5217\u6319\u578B\u306E\u6982\u8981 -doclet.Exception_Summary=\u4F8B\u5916\u306E\u6982\u8981 -doclet.Error_Summary=\u30A8\u30E9\u30FC\u306E\u6982\u8981 -doclet.Class_Summary=\u30AF\u30E9\u30B9\u306E\u6982\u8981 -doclet.Nested_Class_Summary=\u30CD\u30B9\u30C8\u3055\u308C\u305F\u30AF\u30E9\u30B9\u306E\u6982\u8981 -doclet.Annotation_Type_Optional_Member_Summary=\u4EFB\u610F\u8981\u7D20\u306E\u6982\u8981 -doclet.Annotation_Type_Required_Member_Summary=\u5FC5\u9808\u8981\u7D20\u306E\u6982\u8981 -doclet.Field_Summary=\u30D5\u30A3\u30FC\u30EB\u30C9\u306E\u6982\u8981 -doclet.Property_Summary=\u30D7\u30ED\u30D1\u30C6\u30A3\u306E\u6982\u8981 -doclet.Enum_Constant_Summary=\u5217\u6319\u578B\u5B9A\u6570\u306E\u6982\u8981 -doclet.Constructor_Summary=\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u306E\u6982\u8981 -doclet.Method_Summary=\u30E1\u30BD\u30C3\u30C9\u306E\u6982\u8981 +doclet.Interface_Summary=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306E\u30B5\u30DE\u30EA\u30FC +doclet.Annotation_Types_Summary=\u6CE8\u91C8\u578B\u306E\u30B5\u30DE\u30EA\u30FC +doclet.Enum_Summary=\u5217\u6319\u578B\u306E\u30B5\u30DE\u30EA\u30FC +doclet.Exception_Summary=\u4F8B\u5916\u306E\u30B5\u30DE\u30EA\u30FC +doclet.Error_Summary=\u30A8\u30E9\u30FC\u306E\u30B5\u30DE\u30EA\u30FC +doclet.Class_Summary=\u30AF\u30E9\u30B9\u306E\u30B5\u30DE\u30EA\u30FC +doclet.Nested_Class_Summary=\u30CD\u30B9\u30C8\u3055\u308C\u305F\u30AF\u30E9\u30B9\u306E\u30B5\u30DE\u30EA\u30FC +doclet.Annotation_Type_Optional_Member_Summary=\u4EFB\u610F\u8981\u7D20\u306E\u30B5\u30DE\u30EA\u30FC +doclet.Annotation_Type_Required_Member_Summary=\u5FC5\u9808\u8981\u7D20\u306E\u30B5\u30DE\u30EA\u30FC +doclet.Field_Summary=\u30D5\u30A3\u30FC\u30EB\u30C9\u306E\u30B5\u30DE\u30EA\u30FC +doclet.Property_Summary=\u30D7\u30ED\u30D1\u30C6\u30A3\u306E\u30B5\u30DE\u30EA\u30FC +doclet.Enum_Constant_Summary=\u5217\u6319\u578B\u5B9A\u6570\u306E\u30B5\u30DE\u30EA\u30FC +doclet.Constructor_Summary=\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u306E\u30B5\u30DE\u30EA\u30FC +doclet.Method_Summary=\u30E1\u30BD\u30C3\u30C9\u306E\u30B5\u30DE\u30EA\u30FC doclet.Interfaces=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9 doclet.Enums=\u5217\u6319\u578B doclet.AnnotationTypes=\u6CE8\u91C8\u578B
--- a/src/share/classes/com/sun/tools/javac/code/Symbol.java Tue May 13 23:18:48 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java Wed May 14 11:01:08 2014 -0700 @@ -392,7 +392,7 @@ /** A class is an inner class if it it has an enclosing instance class. */ public boolean isInner() { - return type.getEnclosingType().hasTag(CLASS); + return kind == TYP && type.getEnclosingType().hasTag(CLASS); } /** An inner class has an outer instance if it is not an interface @@ -703,10 +703,10 @@ } /** - * A total ordering between type symbols that refines the + * A partial ordering between type symbols that refines the * class inheritance graph. * - * Typevariables always precede other kinds of symbols. + * Type variables always precede other kinds of symbols. */ public final boolean precedes(TypeSymbol that, Types types) { if (this == that)
--- a/src/share/classes/com/sun/tools/javac/code/Type.java Tue May 13 23:18:48 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java Wed May 14 11:01:08 2014 -0700 @@ -1445,12 +1445,19 @@ * Inference variable bound kinds */ public enum InferenceBound { - /** upper bounds */ - UPPER, - /** lower bounds */ - LOWER, - /** equality constraints */ - EQ; + UPPER { + public InferenceBound complement() { return LOWER; } + }, + /** lower bounds */ + LOWER { + public InferenceBound complement() { return UPPER; } + }, + /** equality constraints */ + EQ { + public InferenceBound complement() { return EQ; } + }; + + public abstract InferenceBound complement(); } /** inference variable bounds */ @@ -1636,6 +1643,9 @@ //only change bounds if request comes from substBounds super.addBound(ib, bound, types, update); } + else if (bound.hasTag(UNDETVAR) && !((UndetVar) bound).isCaptured()) { + ((UndetVar) bound).addBound(ib.complement(), this, types, false); + } } @Override
--- a/src/share/classes/com/sun/tools/javac/code/Types.java Tue May 13 23:18:48 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Wed May 14 11:01:08 2014 -0700 @@ -43,6 +43,7 @@ import com.sun.tools.javac.comp.Enter; import com.sun.tools.javac.comp.Env; import com.sun.tools.javac.jvm.ClassReader; +import com.sun.tools.javac.tree.JCTree; import com.sun.tools.javac.util.*; import static com.sun.tools.javac.code.BoundKind.*; import static com.sun.tools.javac.code.Flags.*; @@ -151,31 +152,31 @@ }; // </editor-fold> - // <editor-fold defaultstate="collapsed" desc="lowerBound"> + // <editor-fold defaultstate="collapsed" desc="wildLowerBound"> /** - * The "lvalue conversion".<br> - * The lower bound of most types is the type - * itself. Wildcards, on the other hand have upper - * and lower bounds. - * @param t a type - * @return the lower bound of the given type + * Get a wildcard's lower bound, returning non-wildcards unchanged. + * @param t a type argument, either a wildcard or a type */ - public Type lowerBound(Type t) { - return lowerBound.visit(t); + public Type wildLowerBound(Type t) { + if (t.hasTag(WILDCARD)) { + WildcardType w = (WildcardType) t; + return w.isExtendsBound() ? syms.botType : wildLowerBound(w.type); + } + else return t; } - // where - private final MapVisitor<Void> lowerBound = new MapVisitor<Void>() { - - @Override - public Type visitWildcardType(WildcardType t, Void ignored) { - return t.isExtendsBound() ? syms.botType : visit(t.type); - } - - @Override - public Type visitCapturedType(CapturedType t, Void ignored) { - return visit(t.getLowerBound()); - } - }; + // </editor-fold> + + // <editor-fold defaultstate="collapsed" desc="cvarLowerBound"> + /** + * Get a capture variable's lower bound, returning other types unchanged. + * @param t a type + */ + public Type cvarLowerBound(Type t) { + if (t.hasTag(TYPEVAR) && ((TypeVar) t).isCaptured()) { + return cvarLowerBound(t.getLowerBound()); + } + else return t; + } // </editor-fold> // <editor-fold defaultstate="collapsed" desc="isUnbounded"> @@ -305,8 +306,8 @@ } /** - * Is t a subtype of or convertiable via boxing/unboxing - * convertions to s? + * Is t a subtype of or convertible via boxing/unboxing + * conversions to s? */ public boolean isConvertible(Type t, Type s) { return isConvertible(t, s, noWarnings); @@ -827,9 +828,15 @@ return true; } - Type lower = lowerBound(s); - if (s != lower) - return isSubtype(capture ? capture(t) : t, lower, false); + // Generally, if 's' is a type variable, recur on lower bound; but + // for inference variables and intersections, we need to keep 's' + // (see JLS 4.10.2 for intersections and 18.2.3 for inference vars) + if (!t.hasTag(UNDETVAR) && !t.isCompound()) { + // TODO: JDK-8039198, bounds checking sometimes passes in a wildcard as s + Type lower = cvarLowerBound(wildLowerBound(s)); + if (s != lower) + return isSubtype(capture ? capture(t) : t, lower, false); + } return isSubtype.visit(capture ? capture(t) : t, s); } @@ -913,14 +920,11 @@ @Override public Boolean visitClassType(ClassType t, Type s) { Type sup = asSuper(t, s.tsym); - return sup != null - && sup.tsym == s.tsym - // You're not allowed to write - // Vector<Object> vec = new Vector<String>(); - // But with wildcards you can write - // Vector<? extends Object> vec = new Vector<String>(); - // which means that subtype checking must be done - // here instead of same-type checking (via containsType). + if (sup == null) return false; + // If t is an intersection, sup might not be a class type + if (!sup.hasTag(CLASS)) return isSubtypeNoCapture(sup, s); + return sup.tsym == s.tsym + // Check type variable containment && (!s.isParameterized() || containsTypeRecursive(s, sup)) && isSubtypeNoCapture(sup.getEnclosingType(), s.getEnclosingType()); @@ -1136,7 +1140,7 @@ return visit(s, t); if (s.isSuperBound() && !s.isExtendsBound()) - return visit(t, upperBound(s)) && visit(t, lowerBound(s)); + return visit(t, upperBound(s)) && visit(t, wildLowerBound(s)); if (t.isCompound() && s.isCompound()) { if (!visit(supertype(t), supertype(s))) @@ -1291,7 +1295,7 @@ break; } case SUPER: { - Type bound = lowerBound(s); + Type bound = wildLowerBound(s); undetvar.addBound(InferenceBound.LOWER, bound, this); break; } @@ -1384,9 +1388,9 @@ // t.isSuperBound() // || isSubtypeNoCapture(upperBound(s), U(t))); // System.err.format(" %s L(%s) <: L(%s) %s = %s%n", -// L(t), t, s, lowerBound(s), +// L(t), t, s, wildLowerBound(s), // t.isExtendsBound() -// || isSubtypeNoCapture(L(t), lowerBound(s))); +// || isSubtypeNoCapture(L(t), wildLowerBound(s))); // System.err.println(); // } @@ -1398,7 +1402,7 @@ // debugContainsType(t, s); return isSameWildcard(t, s) || isCaptureOf(s, t) - || ((t.isExtendsBound() || isSubtypeNoCapture(L(t), lowerBound(s))) && + || ((t.isExtendsBound() || isSubtypeNoCapture(L(t), wildLowerBound(s))) && (t.isSuperBound() || isSubtypeNoCapture(upperBound(s), U(t)))); } } @@ -1760,7 +1764,7 @@ if (s.isExtendsBound()) return !isCastableRecursive(t.type, upperBound(s)); else if (s.isSuperBound()) - return notSoftSubtypeRecursive(lowerBound(s), t.type); + return notSoftSubtypeRecursive(wildLowerBound(s), t.type); } else if (t.isSuperBound()) { if (s.isExtendsBound()) return notSoftSubtypeRecursive(t.type, upperBound(s)); @@ -1770,19 +1774,13 @@ }; // </editor-fold> - // <editor-fold defaultstate="collapsed" desc="lowerBoundArgtypes"> - /** - * Returns the lower bounds of the formals of a method. - */ - public List<Type> lowerBoundArgtypes(Type t) { - return lowerBounds(t.getParameterTypes()); + // <editor-fold defaultstate="collapsed" desc="cvarLowerBounds"> + public List<Type> cvarLowerBounds(List<Type> ts) { + return map(ts, cvarLowerBoundMapping); } - public List<Type> lowerBounds(List<Type> ts) { - return map(ts, lowerBoundMapping); - } - private final Mapping lowerBoundMapping = new Mapping("lowerBound") { + private final Mapping cvarLowerBoundMapping = new Mapping("cvarLowerBound") { public Type apply(Type t) { - return lowerBound(t); + return cvarLowerBound(t); } }; // </editor-fold> @@ -1934,6 +1932,17 @@ * @param sym a symbol */ public Type asSuper(Type t, Symbol sym) { + /* Some examples: + * + * (Enum<E>, Comparable) => Comparable<E> + * (c.s.s.d.AttributeTree.ValueKind, Enum) => Enum<c.s.s.d.AttributeTree.ValueKind> + * (c.s.s.t.ExpressionTree, c.s.s.t.Tree) => c.s.s.t.Tree + * (j.u.List<capture#160 of ? extends c.s.s.d.DocTree>, Iterable) => + * Iterable<capture#160 of ? extends c.s.s.d.DocTree> + */ + if (sym.type == syms.objectType) { //optimization + return syms.objectType; + } return asSuper.visit(t, sym); } // where @@ -1949,16 +1958,18 @@ return t; Type st = supertype(t); - if (st.hasTag(CLASS) || st.hasTag(TYPEVAR) || st.hasTag(ERROR)) { + if (st.hasTag(CLASS) || st.hasTag(TYPEVAR)) { Type x = asSuper(st, sym); if (x != null) return x; } if ((sym.flags() & INTERFACE) != 0) { for (List<Type> l = interfaces(t); l.nonEmpty(); l = l.tail) { - Type x = asSuper(l.head, sym); - if (x != null) - return x; + if (!l.head.hasTag(ERROR)) { + Type x = asSuper(l.head, sym); + if (x != null) + return x; + } } } return null; @@ -2240,7 +2251,8 @@ // <editor-fold defaultstate="collapsed" desc="makeCompoundType"> /** - * Make a compound type from non-empty list of types + * Make a compound type from non-empty list of types. The list should be + * ordered according to {@link Symbol#precedes(TypeSymbol,Types)}. * * @param bounds the types from which the compound type is formed * @param supertype is objectType if all bounds are interfaces, @@ -3330,12 +3342,15 @@ * Insert a type in a closure */ public List<Type> insert(List<Type> cl, Type t) { - if (cl.isEmpty() || t.tsym.precedes(cl.head.tsym, this)) { + if (cl.isEmpty()) { return cl.prepend(t); - } else if (cl.head.tsym.precedes(t.tsym, this)) { + } else if (t.tsym == cl.head.tsym) { + return cl; + } else if (t.tsym.precedes(cl.head.tsym, this)) { + return cl.prepend(t); + } else { + // t comes after head, or the two are unrelated return insert(cl.tail, t).prepend(cl.head); - } else { - return cl; } } @@ -3347,12 +3362,15 @@ return cl2; } else if (cl2.isEmpty()) { return cl1; + } else if (cl1.head.tsym == cl2.head.tsym) { + return union(cl1.tail, cl2.tail).prepend(cl1.head); } else if (cl1.head.tsym.precedes(cl2.head.tsym, this)) { return union(cl1.tail, cl2).prepend(cl1.head); } else if (cl2.head.tsym.precedes(cl1.head.tsym, this)) { return union(cl1, cl2.tail).prepend(cl2.head); } else { - return union(cl1.tail, cl2.tail).prepend(cl1.head); + // unrelated types + return union(cl1.tail, cl2).prepend(cl1.head); } } @@ -3462,18 +3480,31 @@ private List<Type> closureMin(List<Type> cl) { ListBuffer<Type> classes = new ListBuffer<>(); ListBuffer<Type> interfaces = new ListBuffer<>(); + Set<Type> toSkip = new HashSet<>(); while (!cl.isEmpty()) { Type current = cl.head; - if (current.isInterface()) - interfaces.append(current); - else - classes.append(current); - ListBuffer<Type> candidates = new ListBuffer<>(); - for (Type t : cl.tail) { - if (!isSubtypeNoCapture(current, t)) - candidates.append(t); + boolean keep = !toSkip.contains(current); + if (keep && current.hasTag(TYPEVAR)) { + // skip lower-bounded variables with a subtype in cl.tail + for (Type t : cl.tail) { + if (isSubtypeNoCapture(t, current)) { + keep = false; + break; + } + } } - cl = candidates.toList(); + if (keep) { + if (current.isInterface()) + interfaces.append(current); + else + classes.append(current); + for (Type t : cl.tail) { + // skip supertypes of 'current' in cl.tail + if (isSubtypeNoCapture(current, t)) + toSkip.add(t); + } + } + cl = cl.tail; } return classes.appendList(interfaces).toList(); } @@ -3633,7 +3664,19 @@ return s; List<Type> closure = union(closure(t), closure(s)); - List<Type> bounds = closureMin(closure); + return glbFlattened(closure, t); + } + //where + /** + * Perform glb for a list of non-primitive, non-error, non-compound types; + * redundant elements are removed. Bounds should be ordered according to + * {@link Symbol#precedes(TypeSymbol,Types)}. + * + * @param flatBounds List of type to glb + * @param errT Original type to use if the result is an error type + */ + private Type glbFlattened(List<Type> flatBounds, Type errT) { + List<Type> bounds = closureMin(flatBounds); if (bounds.isEmpty()) { // length == 0 return syms.objectType; @@ -3641,11 +3684,21 @@ return bounds.head; } else { // length > 1 int classCount = 0; - for (Type bound : bounds) - if (!bound.isInterface()) + List<Type> lowers = List.nil(); + for (Type bound : bounds) { + if (!bound.isInterface()) { classCount++; - if (classCount > 1) - return createErrorType(t); + Type lower = cvarLowerBound(bound); + if (bound != lower && !lower.hasTag(BOT)) + lowers = insert(lowers, lower); + } + } + if (classCount > 1) { + if (lowers.isEmpty()) + return createErrorType(errT); + else + return glbFlattened(union(bounds, lowers), errT); + } } return makeCompoundType(bounds); } @@ -3869,9 +3922,11 @@ } return buf.reverse(); } + public Type capture(Type t) { - if (!t.hasTag(CLASS)) + if (!t.hasTag(CLASS)) { return t; + } if (t.getEnclosingType() != Type.noType) { Type capturedEncl = capture(t.getEnclosingType()); if (capturedEncl != t.getEnclosingType()) { @@ -4123,7 +4178,7 @@ if (source.isExtendsBound()) adaptRecursive(upperBound(source), upperBound(target)); else if (source.isSuperBound()) - adaptRecursive(lowerBound(source), lowerBound(target)); + adaptRecursive(wildLowerBound(source), wildLowerBound(target)); return null; } @@ -4135,7 +4190,7 @@ Type val = mapping.get(source.tsym); if (val != null) { if (val.isSuperBound() && target.isSuperBound()) { - val = isSubtype(lowerBound(val), lowerBound(target)) + val = isSubtype(wildLowerBound(val), wildLowerBound(target)) ? target : val; } else if (val.isExtendsBound() && target.isExtendsBound()) { val = isSubtype(upperBound(val), upperBound(target)) @@ -4249,7 +4304,7 @@ } public Type visitType(Type t, Void s) { - return high ? upperBound(t) : lowerBound(t); + return high ? upperBound(t) : t; } @Override
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue May 13 23:18:48 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Wed May 14 11:01:08 2014 -0700 @@ -518,6 +518,10 @@ return new ResultInfo(pkind, pt, newContext); } + protected ResultInfo dup(Type newPt, CheckContext newContext) { + return new ResultInfo(pkind, newPt, newContext); + } + @Override public String toString() { if (pt != null) { @@ -2143,6 +2147,11 @@ cdef.extending = clazz; } + if (resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK && + isSerializable(clazztype)) { + localEnv.info.isSerializable = true; + } + attribStat(cdef, localEnv); checkLambdaCandidate(tree, cdef.sym, clazztype); @@ -2298,6 +2307,9 @@ resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK; try { Type currentTarget = pt(); + if (needsRecovery && isSerializable(currentTarget)) { + localEnv.info.isSerializable = true; + } List<Type> explicitParamTypes = null; if (that.paramKind == JCLambda.ParameterKind.EXPLICIT) { //attribute lambda parameters @@ -2702,17 +2714,20 @@ typeargtypes = attribTypes(that.typeargs, localEnv); } - Type target; Type desc; - if (pt() != Type.recoveryType) { - target = targetChecker.visit(pt(), that); - desc = types.findDescriptorType(target); + Type currentTarget = pt(); + boolean isTargetSerializable = + resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK && + isSerializable(currentTarget); + if (currentTarget != Type.recoveryType) { + currentTarget = targetChecker.visit(currentTarget, that); + desc = types.findDescriptorType(currentTarget); } else { - target = Type.recoveryType; + currentTarget = Type.recoveryType; desc = fallbackDescriptorType(that); } - setFunctionalInfo(localEnv, that, pt(), desc, target, resultInfo.checkContext); + setFunctionalInfo(localEnv, that, pt(), desc, currentTarget, resultInfo.checkContext); List<Type> argtypes = desc.getParameterTypes(); Resolve.MethodCheck referenceCheck = rs.resolveMethodCheck; @@ -2754,7 +2769,7 @@ targetError = false; } - JCDiagnostic detailsDiag = ((Resolve.ResolveError)refSym).getDiagnostic(JCDiagnostic.DiagnosticType.FRAGMENT, + JCDiagnostic detailsDiag = ((Resolve.ResolveError)refSym.baseSymbol()).getDiagnostic(JCDiagnostic.DiagnosticType.FRAGMENT, that, exprType.tsym, exprType, that.name, argtypes, typeargtypes); JCDiagnostic.DiagnosticType diagKind = targetError ? @@ -2763,10 +2778,10 @@ JCDiagnostic diag = diags.create(diagKind, log.currentSource(), that, "invalid.mref", Kinds.kindName(that.getMode()), detailsDiag); - if (targetError && target == Type.recoveryType) { + if (targetError && currentTarget == Type.recoveryType) { //a target error doesn't make sense during recovery stage //as we don't know what actual parameter types are - result = that.type = target; + result = that.type = currentTarget; return; } else { if (targetError) { @@ -2774,7 +2789,7 @@ } else { log.report(diag); } - result = that.type = types.createErrorType(target); + result = that.type = types.createErrorType(currentTarget); return; } } @@ -2785,7 +2800,7 @@ if (desc.getReturnType() == Type.recoveryType) { // stop here - result = that.type = target; + result = that.type = currentTarget; return; } @@ -2803,7 +2818,7 @@ //static ref with class type-args log.error(that.expr.pos(), "invalid.mref", Kinds.kindName(that.getMode()), diags.fragment("static.mref.with.targs")); - result = that.type = types.createErrorType(target); + result = that.type = types.createErrorType(currentTarget); return; } @@ -2812,7 +2827,7 @@ //no static bound mrefs log.error(that.expr.pos(), "invalid.mref", Kinds.kindName(that.getMode()), diags.fragment("static.bound.mref")); - result = that.type = types.createErrorType(target); + result = that.type = types.createErrorType(currentTarget); return; } @@ -2820,12 +2835,17 @@ // Check that super-qualified symbols are not abstract (JLS) rs.checkNonAbstract(that.pos(), that.sym); } + + if (isTargetSerializable) { + chk.checkElemAccessFromSerializableLambda(that); + } } ResultInfo checkInfo = resultInfo.dup(newMethodTemplate( desc.getReturnType().hasTag(VOID) ? Type.noType : desc.getReturnType(), - that.kind.isUnbound() ? argtypes.tail : argtypes, typeargtypes)); + that.kind.isUnbound() ? argtypes.tail : argtypes, typeargtypes), + new FunctionalReturnContext(resultInfo.checkContext)); Type refType = checkId(that, lookupHelper.site, refSym, localEnv, checkInfo); @@ -2851,9 +2871,9 @@ resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.SPECULATIVE; checkReferenceCompatible(that, desc, refType, resultInfo.checkContext, isSpeculativeRound); if (!isSpeculativeRound) { - checkAccessibleTypes(that, localEnv, resultInfo.checkContext.inferenceContext(), desc, target); + checkAccessibleTypes(that, localEnv, resultInfo.checkContext.inferenceContext(), desc, currentTarget); } - result = check(that, target, VAL, resultInfo); + result = check(that, currentTarget, VAL, resultInfo); } catch (Types.FunctionDescriptorLookupError ex) { JCDiagnostic cause = ex.getDiagnostic(); resultInfo.checkContext.report(that, cause); @@ -3193,6 +3213,11 @@ while (env1.outer != null && !rs.isAccessible(env, env1.enclClass.sym.type, sym)) env1 = env1.outer; } + + if (env.info.isSerializable) { + chk.checkElemAccessFromSerializableLambda(tree); + } + result = checkId(tree, env1.enclClass.sym.type, sym, env, resultInfo); } @@ -3317,6 +3342,10 @@ } } + if (env.info.isSerializable) { + chk.checkElemAccessFromSerializableLambda(tree); + } + env.info.selectSuper = selectSuperPrev; result = checkId(tree, site, sym, env, resultInfo); } @@ -4195,6 +4224,11 @@ ((c.flags_field & (Flags.ENUM | Flags.COMPOUND)) == 0)) { log.error(env.tree.pos(), "enum.types.not.extensible"); } + + if (isSerializable(c.type)) { + env.info.isSerializable = true; + } + attribClassBody(env, c); chk.checkDeprecatedAnnotation(env.tree.pos(), c); @@ -4308,7 +4342,7 @@ // Check for proper use of serialVersionUID if (env.info.lint.isEnabled(LintCategory.SERIAL) && - isSerializable(c) && + isSerializable(c.type) && (c.flags() & Flags.ENUM) == 0 && checkForSerial(c)) { checkSerialVersionUID(tree, c); @@ -4348,15 +4382,15 @@ return null; } - /** check if a class is a subtype of Serializable, if that is available. */ - private boolean isSerializable(ClassSymbol c) { + /** check if a type is a subtype of Serializable, if that is available. */ + boolean isSerializable(Type t) { try { syms.serializableType.complete(); } catch (CompletionFailure e) { return false; } - return types.isSubtype(c.type, syms.serializableType); + return types.isSubtype(t, syms.serializableType); } /** Check that an appropriate serialVersionUID member is defined. */
--- a/src/share/classes/com/sun/tools/javac/comp/AttrContext.java Tue May 13 23:18:48 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/AttrContext.java Wed May 14 11:01:08 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,6 +54,10 @@ */ boolean selectSuper = false; + /** Is the current target of lambda expression or method reference serializable? + */ + boolean isSerializable = false; + /** Are arguments to current function applications boxed into an array for varargs? */ Resolve.MethodResolutionPhase pendingResolutionPhase = null; @@ -89,6 +93,7 @@ info.enclVar = enclVar; info.returnResult = returnResult; info.defaultSuperCallSite = defaultSuperCallSite; + info.isSerializable = isSerializable; return info; }
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java Tue May 13 23:18:48 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Wed May 14 11:01:08 2014 -0700 @@ -82,6 +82,7 @@ private final TreeInfo treeinfo; private final JavaFileManager fileManager; private final Profile profile; + private final boolean warnOnAccessToSensitiveMembers; // The set of lint options currently in effect. It is initialized // from the context, and then is set/reset as needed by Attr as it @@ -131,6 +132,7 @@ warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts"); suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile"); enableSunApiLintControl = options.isSet("enableSunApiLintControl"); + warnOnAccessToSensitiveMembers = options.isSet("warnOnAccessToSensitiveMembers"); Target target = Target.instance(context); syntheticNameChar = target.syntheticNameChar(); @@ -510,6 +512,11 @@ public DeferredAttrContext deferredAttrContext() { return deferredAttr.emptyDeferredAttrContext; } + + @Override + public String toString() { + return "CheckContext: basicHandler"; + } }; /** Check that a given type is assignable to a given proto-type. @@ -616,7 +623,7 @@ } else if (a.isExtendsBound()) { return types.isCastable(bound, types.upperBound(a), types.noWarnings); } else if (a.isSuperBound()) { - return !types.notSoftSubtype(types.lowerBound(a), bound); + return !types.notSoftSubtype(types.wildLowerBound(a), bound); } return true; } @@ -2583,6 +2590,44 @@ } } + void checkElemAccessFromSerializableLambda(final JCTree tree) { + if (warnOnAccessToSensitiveMembers) { + Symbol sym = TreeInfo.symbol(tree); + if ((sym.kind & (VAR | MTH)) == 0) { + return; + } + + if (sym.kind == VAR) { + if ((sym.flags() & PARAMETER) != 0 || + sym.isLocal() || + sym.name == names._this || + sym.name == names._super) { + return; + } + } + + if (!types.isSubtype(sym.owner.type, syms.serializableType) && + isEffectivelyNonPublic(sym)) { + log.warning(tree.pos(), + "access.to.sensitive.member.from.serializable.element", sym); + } + } + } + + private boolean isEffectivelyNonPublic(Symbol sym) { + if (sym.packge() == syms.rootPackage) { + return false; + } + + while (sym.kind != Kinds.PCK) { + if ((sym.flags() & PUBLIC) == 0) { + return true; + } + sym = sym.owner; + } + return false; + } + /** Report a conflict between a user symbol and a synthetic symbol. */ private void syntheticError(DiagnosticPosition pos, Symbol sym) { @@ -2680,7 +2725,7 @@ if (types.isSameType(type, syms.stringType)) return; if ((type.tsym.flags() & Flags.ENUM) != 0) return; if ((type.tsym.flags() & Flags.ANNOTATION) != 0) return; - if (types.lowerBound(type).tsym == syms.classType.tsym) return; + if (types.cvarLowerBound(type).tsym == syms.classType.tsym) return; if (types.isArray(type) && !types.isArray(types.elemtype(type))) { validateAnnotationType(pos, types.elemtype(type)); return;
--- a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Tue May 13 23:18:48 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Wed May 14 11:01:08 2014 -0700 @@ -110,6 +110,11 @@ void complete() { Assert.error("Empty deferred context!"); } + + @Override + public String toString() { + return "Empty deferred context!"; + } }; }
--- a/src/share/classes/com/sun/tools/javac/comp/Infer.java Tue May 13 23:18:48 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Wed May 14 11:01:08 2014 -0700 @@ -142,24 +142,24 @@ * Main inference entry point - instantiate a generic method type * using given argument types and (possibly) an expected target-type. */ - public Type instantiateMethod(Env<AttrContext> env, - List<Type> tvars, - MethodType mt, - Attr.ResultInfo resultInfo, - Symbol msym, - List<Type> argtypes, - boolean allowBoxing, - boolean useVarargs, - Resolve.MethodResolutionContext resolveContext, - Warner warn) throws InferenceException { + Type instantiateMethod( Env<AttrContext> env, + List<Type> tvars, + MethodType mt, + Attr.ResultInfo resultInfo, + MethodSymbol msym, + List<Type> argtypes, + boolean allowBoxing, + boolean useVarargs, + Resolve.MethodResolutionContext resolveContext, + Warner warn) throws InferenceException { //-System.err.println("instantiateMethod(" + tvars + ", " + mt + ", " + argtypes + ")"); //DEBUG - final InferenceContext inferenceContext = new InferenceContext(tvars); + final InferenceContext inferenceContext = new InferenceContext(tvars); //B0 inferenceException.clear(); try { DeferredAttr.DeferredAttrContext deferredAttrContext = resolveContext.deferredAttrContext(msym, inferenceContext, resultInfo, warn); - resolveContext.methodCheck.argumentsAcceptable(env, deferredAttrContext, + resolveContext.methodCheck.argumentsAcceptable(env, deferredAttrContext, //B2 argtypes, mt.getParameterTypes(), warn); if (allowGraphInference && @@ -167,7 +167,8 @@ !warn.hasNonSilentLint(Lint.LintCategory.UNCHECKED)) { //inject return constraints earlier checkWithinBounds(inferenceContext, warn); //propagation - Type newRestype = generateReturnConstraints(resultInfo, mt, inferenceContext); + Type newRestype = generateReturnConstraints(env.tree, resultInfo, //B3 + mt, inferenceContext); mt = (MethodType)types.createMethodTypeWithReturn(mt, newRestype); //propagate outwards if needed if (resultInfo.checkContext.inferenceContext().free(resultInfo.pt)) { @@ -193,7 +194,7 @@ inferenceContext.restvars().nonEmpty() && resultInfo != null && !warn.hasNonSilentLint(Lint.LintCategory.UNCHECKED)) { - generateReturnConstraints(resultInfo, mt, inferenceContext); + generateReturnConstraints(env.tree, resultInfo, mt, inferenceContext); inferenceContext.solveLegacy(false, warn, LegacyInferenceSteps.EQ_UPPER.steps); //maximizeInst mt = (MethodType)inferenceContext.asInstType(mt); } @@ -210,6 +211,12 @@ } else { inferenceContext.notifyChange(inferenceContext.boundedVars()); } + if (resultInfo == null) { + /* if the is no result info then we can clear the capture types + * cache without affecting any result info check + */ + inferenceContext.captureTypeCache.clear(); + } } } @@ -218,7 +225,7 @@ * call occurs in a context where a type T is expected, use the expected * type to derive more constraints on the generic method inference variables. */ - Type generateReturnConstraints(Attr.ResultInfo resultInfo, + Type generateReturnConstraints(JCTree tree, Attr.ResultInfo resultInfo, MethodType mt, InferenceContext inferenceContext) { InferenceContext rsInfoInfContext = resultInfo.checkContext.inferenceContext(); Type from = mt.getReturnType(); @@ -232,13 +239,29 @@ } } } - Type qtype1 = inferenceContext.asUndetVar(from); - Type to = returnConstraintTarget(qtype1, resultInfo.pt); + Type qtype = inferenceContext.asUndetVar(from); + Type to = resultInfo.pt; + + if (qtype.hasTag(VOID)) { + to = syms.voidType; + } else if (to.hasTag(NONE)) { + to = from.isPrimitive() ? from : syms.objectType; + } else if (qtype.hasTag(UNDETVAR)) { + if (resultInfo.pt.isReference()) { + to = generateReturnConstraintsUndetVarToReference( + tree, (UndetVar)qtype, to, resultInfo, inferenceContext); + } else { + if (to.isPrimitive()) { + to = generateReturnConstraintsPrimitive(tree, (UndetVar)qtype, to, + resultInfo, inferenceContext); + } + } + } Assert.check(allowGraphInference || !rsInfoInfContext.free(to), "legacy inference engine cannot handle constraints on both sides of a subtyping assertion"); //we need to skip capture? Warner retWarn = new Warner(); - if (!resultInfo.checkContext.compatible(qtype1, rsInfoInfContext.asUndetVar(to), retWarn) || + if (!resultInfo.checkContext.compatible(qtype, rsInfoInfContext.asUndetVar(to), retWarn) || //unchecked conversion is not allowed in source 7 mode (!allowGraphInference && retWarn.hasLint(Lint.LintCategory.UNCHECKED))) { throw inferenceException @@ -248,30 +271,96 @@ return from; } - Type returnConstraintTarget(Type from, Type to) { - if (from.hasTag(VOID)) { - return syms.voidType; - } else if (to.hasTag(NONE)) { - return from.isPrimitive() ? from : syms.objectType; - } else if (from.hasTag(UNDETVAR) && to.isPrimitive()) { - if (!allowGraphInference) { - //if legacy, just return boxed type - return types.boxedClass(to).type; + private Type generateReturnConstraintsPrimitive(JCTree tree, UndetVar from, + Type to, Attr.ResultInfo resultInfo, InferenceContext inferenceContext) { + if (!allowGraphInference) { + //if legacy, just return boxed type + return types.boxedClass(to).type; + } + //if graph inference we need to skip conflicting boxed bounds... + for (Type t : from.getBounds(InferenceBound.EQ, InferenceBound.UPPER, + InferenceBound.LOWER)) { + Type boundAsPrimitive = types.unboxedType(t); + if (boundAsPrimitive == null || boundAsPrimitive.hasTag(NONE)) { + continue; } - //if graph inference we need to skip conflicting boxed bounds... - UndetVar uv = (UndetVar)from; - for (Type t : uv.getBounds(InferenceBound.EQ, InferenceBound.LOWER)) { - Type boundAsPrimitive = types.unboxedType(t); - if (boundAsPrimitive == null) continue; - if (types.isConvertible(boundAsPrimitive, to)) { - //effectively skip return-type constraint generation (compatibility) - return syms.objectType; + return generateReferenceToTargetConstraint(tree, from, to, + resultInfo, inferenceContext); + } + return types.boxedClass(to).type; + } + + private Type generateReturnConstraintsUndetVarToReference(JCTree tree, + UndetVar from, Type to, Attr.ResultInfo resultInfo, + InferenceContext inferenceContext) { + Type captureOfTo = types.capture(to); + /* T is a reference type, but is not a wildcard-parameterized type, and either + */ + if (captureOfTo == to) { //not a wildcard parameterized type + /* i) B2 contains a bound of one of the forms alpha = S or S <: alpha, + * where S is a wildcard-parameterized type, or + */ + for (Type t : from.getBounds(InferenceBound.EQ, InferenceBound.LOWER)) { + Type captureOfBound = types.capture(t); + if (captureOfBound != t) { + return generateReferenceToTargetConstraint(tree, from, to, + resultInfo, inferenceContext); } } - return types.boxedClass(to).type; - } else { - return to; + + /* ii) B2 contains two bounds of the forms S1 <: alpha and S2 <: alpha, + * where S1 and S2 have supertypes that are two different + * parameterizations of the same generic class or interface. + */ + for (Type aLowerBound : from.getBounds(InferenceBound.LOWER)) { + for (Type anotherLowerBound : from.getBounds(InferenceBound.LOWER)) { + if (aLowerBound != anotherLowerBound && + commonSuperWithDiffParameterization(aLowerBound, anotherLowerBound)) { + /* self comment check if any lower bound may be and undetVar, + * in that case the result of this call may be a false positive. + * Should this be restricted to non free types? + */ + return generateReferenceToTargetConstraint(tree, from, to, + resultInfo, inferenceContext); + } + } + } } + + /* T is a parameterization of a generic class or interface, G, + * and B2 contains a bound of one of the forms alpha = S or S <: alpha, + * where there exists no type of the form G<...> that is a + * supertype of S, but the raw type G is a supertype of S + */ + if (to.isParameterized()) { + for (Type t : from.getBounds(InferenceBound.EQ, InferenceBound.LOWER)) { + Type sup = types.asSuper(t, to.tsym); + if (sup != null && sup.isRaw()) { + return generateReferenceToTargetConstraint(tree, from, to, + resultInfo, inferenceContext); + } + } + } + return to; + } + + private boolean commonSuperWithDiffParameterization(Type t, Type s) { + Pair<Type, Type> supers = getParameterizedSupers(t, s); + return (supers != null && !types.isSameType(supers.fst, supers.snd)); + } + + private Type generateReferenceToTargetConstraint(JCTree tree, UndetVar from, + Type to, Attr.ResultInfo resultInfo, + InferenceContext inferenceContext) { + inferenceContext.solve(List.of(from.qtype), new Warner()); + Type capturedType = resultInfo.checkContext.inferenceContext() + .cachedCapture(tree, from.inst, false); + if (types.isConvertible(capturedType, + resultInfo.checkContext.inferenceContext().asUndetVar(to))) { + //effectively skip additional return-type constraint generation (compatibility) + return syms.objectType; + } + return to; } /** @@ -1318,7 +1407,7 @@ Type solve(UndetVar uv, InferenceContext inferenceContext) { Infer infer = inferenceContext.infer(); List<Type> hibounds = filterBounds(uv, inferenceContext); - //note: lobounds should have at least one element + //note: hibounds should have at least one element Type owntype = hibounds.tail.tail == null ? hibounds.head : infer.types.glb(hibounds); if (owntype.isPrimitive() || owntype.hasTag(ERROR)) { throw infer.inferenceException @@ -2082,8 +2171,10 @@ * Copy variable in this inference context to the given context */ void dupTo(final InferenceContext that) { - that.inferencevars = that.inferencevars.appendList(inferencevars); - that.undetvars = that.undetvars.appendList(undetvars); + that.inferencevars = that.inferencevars.appendList( + inferencevars.diff(that.inferencevars)); + that.undetvars = that.undetvars.appendList( + undetvars.diff(that.undetvars)); //set up listeners to notify original inference contexts as //propagated vars are inferred in new context for (Type t : inferencevars) { @@ -2202,6 +2293,30 @@ return "Inference vars: " + inferencevars + '\n' + "Undet vars: " + undetvars; } + + /* Method Types.capture() generates a new type every time it's applied + * to a wildcard parameterized type. This is intended functionality but + * there are some cases when what you need is not to generate a new + * captured type but to check that a previously generated captured type + * is correct. There are cases when caching a captured type for later + * reuse is sound. In general two captures from the same AST are equal. + * This is why the tree is used as the key of the map below. This map + * stores a Type per AST. + */ + Map<JCTree, Type> captureTypeCache = new HashMap<>(); + + Type cachedCapture(JCTree tree, Type t, boolean readOnly) { + Type captured = captureTypeCache.get(tree); + if (captured != null) { + return captured; + } + + Type result = types.capture(t); + if (result != t && !readOnly) { // then t is a wildcard parameterized type + captureTypeCache.put(tree, result); + } + return result; + } } final InferenceContext emptyContext = new InferenceContext(List.<Type>nil());
--- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Tue May 13 23:18:48 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Wed May 14 11:01:08 2014 -0700 @@ -36,6 +36,7 @@ import com.sun.tools.javac.code.Symbol.ClassSymbol; import com.sun.tools.javac.code.Symbol.DynamicMethodSymbol; import com.sun.tools.javac.code.Symbol.MethodSymbol; +import com.sun.tools.javac.code.Symbol.TypeSymbol; import com.sun.tools.javac.code.Symbol.VarSymbol; import com.sun.tools.javac.code.Symtab; import com.sun.tools.javac.code.Type; @@ -50,8 +51,10 @@ import java.util.EnumMap; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.Map; +import java.util.Set; import static com.sun.tools.javac.comp.LambdaToMethod.LambdaSymbolKind.*; import static com.sun.tools.javac.code.Flags.*; @@ -438,13 +441,9 @@ public void visitVarDef(JCVariableDecl tree) { LambdaTranslationContext lambdaContext = (LambdaTranslationContext)context; if (context != null && lambdaContext.getSymbolMap(LOCAL_VAR).containsKey(tree.sym)) { - JCExpression init = translate(tree.init); - int prevPos = make.pos; - try { - result = make.at(tree).VarDef((VarSymbol)lambdaContext.getSymbolMap(LOCAL_VAR).get(tree.sym), init); - } finally { - make.at(prevPos); - } + tree.init = translate(tree.init); + tree.sym = (VarSymbol) lambdaContext.getSymbolMap(LOCAL_VAR).get(tree.sym); + result = tree; } else if (context != null && lambdaContext.getSymbolMap(TYPE_VAR).containsKey(tree.sym)) { JCExpression init = translate(tree.init); VarSymbol xsym = (VarSymbol)lambdaContext.getSymbolMap(TYPE_VAR).get(tree.sym); @@ -1286,7 +1285,10 @@ @Override public void visitNewClass(JCNewClass tree) { - if (lambdaNewClassFilter(context(), tree)) { + TypeSymbol def = tree.type.tsym; + boolean inReferencedClass = currentlyInClass(def); + boolean isLocal = def.isLocal(); + if ((inReferencedClass && isLocal || lambdaNewClassFilter(context(), tree))) { TranslationContext<?> localContext = context(); while (localContext != null) { if (localContext.tree.getTag() == LAMBDA) { @@ -1296,16 +1298,16 @@ localContext = localContext.prev; } } - if (context() != null && tree.type.tsym.owner.kind == MTH) { + if (context() != null && !inReferencedClass && isLocal) { LambdaTranslationContext lambdaContext = (LambdaTranslationContext)context(); - captureLocalClassDefs(tree.type.tsym, lambdaContext); + captureLocalClassDefs(def, lambdaContext); } super.visitNewClass(tree); } //where void captureLocalClassDefs(Symbol csym, final LambdaTranslationContext lambdaContext) { JCClassDecl localCDef = localClassDefs.get(csym); - if (localCDef != null && localCDef.pos < lambdaContext.tree.pos) { + if (localCDef != null && lambdaContext.freeVarProcessedLocalClasses.add(csym)) { BasicFreeVarCollector fvc = lower.new BasicFreeVarCollector() { @Override void addFreeVars(ClassSymbol c) { @@ -1331,6 +1333,18 @@ fvc.scan(localCDef); } } + //where + boolean currentlyInClass(Symbol csym) { + for (Frame frame : frameStack) { + if (frame.tree.hasTag(JCTree.Tag.CLASSDEF)) { + JCClassDecl cdef = (JCClassDecl) frame.tree; + if (cdef.sym == csym) { + return true; + } + } + } + return false; + } /** * Method references to local class constructors, may, if the local @@ -1756,6 +1770,11 @@ List<JCVariableDecl> syntheticParams; + /** + * to prevent recursion, track local classes processed + */ + final Set<Symbol> freeVarProcessedLocalClasses; + LambdaTranslationContext(JCLambda tree) { super(tree); Frame frame = frameStack.head; @@ -1785,6 +1804,8 @@ translatedSymbols.put(CAPTURED_VAR, new LinkedHashMap<Symbol, Symbol>()); translatedSymbols.put(CAPTURED_THIS, new LinkedHashMap<Symbol, Symbol>()); translatedSymbols.put(TYPE_VAR, new LinkedHashMap<Symbol, Symbol>()); + + freeVarProcessedLocalClasses = new HashSet<>(); } /** @@ -1895,7 +1916,7 @@ }; break; case LOCAL_VAR: - ret = new VarSymbol(sym.flags() & FINAL, name, types.erasure(sym.type), translatedSym); + ret = new VarSymbol(sym.flags() & FINAL, name, sym.type, translatedSym); ((VarSymbol) ret).pos = ((VarSymbol) sym).pos; break; case PARAM:
--- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Tue May 13 23:18:48 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Wed May 14 11:01:08 2014 -0700 @@ -565,7 +565,7 @@ tvars, (MethodType)mt, resultInfo, - m, + (MethodSymbol)m, argtypes, allowBoxing, useVarargs, @@ -773,6 +773,7 @@ public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) { return nilMethodCheck; } + } /** @@ -784,6 +785,11 @@ void checkArg(DiagnosticPosition pos, boolean varargs, Type actual, Type formal, DeferredAttrContext deferredAttrContext, Warner warn) { //do nothing - actual always compatible to formals } + + @Override + public String toString() { + return "arityMethodCheck"; + } }; List<Type> dummyArgs(int length) { @@ -869,6 +875,11 @@ public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) { return new MostSpecificCheck(strict, actuals); } + + @Override + public String toString() { + return "resolveMethodCheck"; + } }; /** @@ -900,7 +911,9 @@ @Override public boolean compatible(Type found, Type req, Warner warn) { found = pendingInferenceContext.asUndetVar(found); - req = infer.returnConstraintTarget(found, req); + if (found.hasTag(UNDETVAR) && req.isPrimitive()) { + req = types.boxedClass(req).type; + } return super.compatible(found, req, warn); } @@ -955,6 +968,12 @@ public DeferredAttrContext deferredAttrContext() { return deferredAttrContext; } + + @Override + public String toString() { + return "MethodReferenceCheck"; + } + } /** @@ -973,7 +992,12 @@ DeferredType dt = (DeferredType)found; return dt.check(this); } else { - return super.check(pos, chk.checkNonVoid(pos, types.capture(U(found.baseType())))); + Type uResult = U(found.baseType()); + Type capturedType = pos == null || pos.getTree() == null ? + types.capture(uResult) : + checkContext.inferenceContext() + .cachedCapture(pos.getTree(), uResult, true); + return super.check(pos, chk.checkNonVoid(pos, capturedType)); } } @@ -1408,7 +1432,7 @@ return bestSoFar; } else if (useVarargs && (sym.flags() & VARARGS) == 0) { return bestSoFar.kind >= ERRONEOUS ? - new BadVarargsMethod((ResolveError)bestSoFar) : + new BadVarargsMethod((ResolveError)bestSoFar.baseSymbol()) : bestSoFar; } Assert.check(sym.kind < AMBIGUOUS); @@ -1500,14 +1524,22 @@ if (m2SignatureMoreSpecific) return m2; return ambiguityError(m1, m2); case AMBIGUOUS: - //check if m1 is more specific than all ambiguous methods in m2 + //compare m1 to ambiguous methods in m2 AmbiguityError e = (AmbiguityError)m2.baseSymbol(); + boolean m1MoreSpecificThanAnyAmbiguous = true; + boolean allAmbiguousMoreSpecificThanM1 = true; for (Symbol s : e.ambiguousSyms) { - if (mostSpecific(argtypes, m1, s, env, site, allowBoxing, useVarargs) != m1) { - return e.addAmbiguousSymbol(m1); - } + Symbol moreSpecific = mostSpecific(argtypes, m1, s, env, site, allowBoxing, useVarargs); + m1MoreSpecificThanAnyAmbiguous &= moreSpecific == m1; + allAmbiguousMoreSpecificThanM1 &= moreSpecific == s; } - return m1; + if (m1MoreSpecificThanAnyAmbiguous) + return m1; + //if m1 is more specific than some ambiguous methods, but other ambiguous methods are + //more specific than m1, add it as a new ambiguous method: + if (!allAmbiguousMoreSpecificThanM1) + e.addAmbiguousSymbol(m1); + return e; default: throw new AssertionError(); } @@ -1525,7 +1557,7 @@ currentResolutionContext.methodCheck = prevResolutionContext.methodCheck.mostSpecificCheck(actuals, !allowBoxing); Type mst = instantiate(env, site, m2, null, - adjustArgs(types.lowerBounds(types.memberType(site, m1).getParameterTypes()), m1, maxLength, useVarargs), null, + adjustArgs(types.cvarLowerBounds(types.memberType(site, m1).getParameterTypes()), m1, maxLength, useVarargs), null, allowBoxing, useVarargs, noteWarner); return mst != null && !noteWarner.hasLint(Lint.LintCategory.UNCHECKED); @@ -2168,7 +2200,7 @@ List<Type> typeargtypes, LogResolveHelper logResolveHelper) { if (sym.kind >= AMBIGUOUS) { - ResolveError errSym = (ResolveError)sym; + ResolveError errSym = (ResolveError)sym.baseSymbol(); sym = errSym.access(name, qualified ? site.tsym : syms.noSymbol); argtypes = logResolveHelper.getArgumentTypes(errSym, sym, name, argtypes); if (logResolveHelper.resolveDiagnosticNeeded(site, argtypes, typeargtypes)) { @@ -2557,7 +2589,7 @@ sym = super.access(env, pos, location, sym); } else { final JCDiagnostic details = sym.kind == WRONG_MTH ? - ((InapplicableSymbolError)sym).errCandidate().snd : + ((InapplicableSymbolError)sym.baseSymbol()).errCandidate().snd : null; sym = new InapplicableSymbolError(sym.kind, "diamondError", currentResolutionContext) { @Override @@ -2965,12 +2997,12 @@ return true; case WRONG_MTH: InapplicableSymbolError errSym = - (InapplicableSymbolError)s; + (InapplicableSymbolError)s.baseSymbol(); return new Template(MethodCheckDiag.ARITY_MISMATCH.regex()) .matches(errSym.errCandidate().snd); case WRONG_MTHS: InapplicableSymbolsError errSyms = - (InapplicableSymbolsError)s; + (InapplicableSymbolsError)s.baseSymbol(); return errSyms.filterCandidates(errSyms.mapCandidates()).isEmpty(); case WRONG_STATICNESS: return false;
--- a/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Tue May 13 23:18:48 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Wed May 14 11:01:08 2014 -0700 @@ -35,9 +35,6 @@ import java.util.Queue; import java.util.ResourceBundle; import java.util.Set; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.annotation.processing.Processor; import javax.lang.model.SourceVersion; @@ -1304,11 +1301,16 @@ * Perform dataflow checks on an attributed parse tree. */ protected void flow(Env<AttrContext> env, Queue<Env<AttrContext>> results) { + if (compileStates.isDone(env, CompileState.FLOW)) { + results.add(env); + return; + } + try { if (shouldStop(CompileState.FLOW)) return; - if (relax || compileStates.isDone(env, CompileState.FLOW)) { + if (relax) { results.add(env); return; }
--- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Tue May 13 23:18:48 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Wed May 14 11:01:08 2014 -0700 @@ -1617,6 +1617,10 @@ compiler.warn.varargs.redundant.trustme.anno=\ Redundant {0} annotation. {1} +# 0: symbol +compiler.warn.access.to.sensitive.member.from.serializable.element=\ + access to sensitive member {0} from serializable element can be publicly accessible to untrusted code + ##### ## The following are tokens which are non-terminals in the language. They should
--- a/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties Tue May 13 23:18:48 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties Wed May 14 11:01:08 2014 -0700 @@ -1,5 +1,5 @@ # -# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -30,14 +30,14 @@ javac.opt.g.lines.vars.source=\u3044\u304F\u3064\u304B\u306E\u30C7\u30D0\u30C3\u30B0\u60C5\u5831\u306E\u307F\u3092\u751F\u6210\u3059\u308B javac.opt.nowarn=\u8B66\u544A\u3092\u767A\u751F\u3055\u305B\u306A\u3044 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 -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 +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 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 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 -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 +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 javac.opt.Xbootclasspath.p=\u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u30AF\u30E9\u30B9\u30FB\u30D1\u30B9\u306B\u4ED8\u52A0\u3059\u308B javac.opt.Xbootclasspath.a=\u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u30AF\u30E9\u30B9\u30FB\u30D1\u30B9\u306B\u8FFD\u52A0\u3059\u308B -javac.opt.endorseddirs=\u63A8\u5968\u898F\u683C\u30D1\u30B9\u306E\u4F4D\u7F6E\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B -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 +javac.opt.endorseddirs=\u63A8\u5968\u898F\u683C\u30D1\u30B9\u306E\u5834\u6240\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B +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 javac.opt.processorpath=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u3092\u691C\u7D22\u3059\u308B\u4F4D\u7F6E\u3092\u6307\u5B9A\u3059\u308B 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 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 @@ -133,7 +133,7 @@ javac.msg.usage.nonstandard.footer=\u3053\u308C\u3089\u306F\u975E\u6A19\u6E96\u30AA\u30D7\u30B7\u30E7\u30F3\u3067\u3042\u308A\u4E88\u544A\u306A\u3057\u306B\u5909\u66F4\u3055\u308C\u308B\u3053\u3068\u304C\u3042\u308A\u307E\u3059\u3002 -javac.msg.bug=\u30B3\u30F3\u30D1\u30A4\u30E9\u3067\u4F8B\u5916\u304C\u767A\u751F\u3057\u307E\u3057\u305F({0})\u3002Bug Parade\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 +javac.msg.bug=\u30B3\u30F3\u30D1\u30A4\u30E9\u3067\u4F8B\u5916\u304C\u767A\u751F\u3057\u307E\u3057\u305F({0})\u3002Bug Parade\u3067\u91CD\u8907\u304C\u306A\u3044\u304B\u3092\u3054\u78BA\u8A8D\u306E\u3046\u3048\u3001Java Developer Connection (http://java.sun.com/webapps/bugreport)\u3067bug\u306E\u767B\u9332\u3092\u304A\u9858\u3044\u3044\u305F\u3057\u307E\u3059\u3002\u30EC\u30DD\u30FC\u30C8\u306B\u306F\u3001\u305D\u306E\u30D7\u30ED\u30B0\u30E9\u30E0\u3068\u4E0B\u8A18\u306E\u8A3A\u65AD\u5185\u5BB9\u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u3054\u5354\u529B\u3042\u308A\u304C\u3068\u3046\u3054\u3056\u3044\u307E\u3059\u3002 javac.msg.io=\n\n\u5165\u51FA\u529B\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\n\u8A73\u7D30\u306F\u6B21\u306E\u30B9\u30BF\u30C3\u30AF\u30FB\u30C8\u30EC\u30FC\u30B9\u3067\u8ABF\u67FB\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n
--- a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Tue May 13 23:18:48 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Wed May 14 11:01:08 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -831,6 +831,8 @@ return symbol(((JCTypeApply) tree).clazz); case ANNOTATED_TYPE: return symbol(((JCAnnotatedType) tree).underlyingType); + case REFERENCE: + return ((JCMemberReference) tree).sym; default: return null; }
--- a/src/share/classes/com/sun/tools/javap/resources/javap_ja.properties Tue May 13 23:18:48 2014 -0700 +++ b/src/share/classes/com/sun/tools/javap/resources/javap_ja.properties Wed May 14 11:01:08 2014 -0700 @@ -3,10 +3,9 @@ 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} err.class.not.found=\u30AF\u30E9\u30B9\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: {0} -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} +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} 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 err.file.not.found=\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: {0} -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 err.incompatible.options=\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u7D44\u5408\u305B\u304C\u4E0D\u6B63\u3067\u3059: {0} err.internal.error=\u5185\u90E8\u30A8\u30E9\u30FC: {0} {1} {2} err.invalid.arg.for.option=\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u5F15\u6570\u304C\u7121\u52B9\u3067\u3059: {0} @@ -14,12 +13,11 @@ err.missing.arg={0}\u306B\u5024\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093 err.no.classes.specified=\u30AF\u30E9\u30B9\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093 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 +err.invalid.use.of.option=\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u4F7F\u7528\u304C\u7121\u52B9\u3067\u3059: {0} err.unknown.option=\u4E0D\u660E\u306A\u30AA\u30D7\u30B7\u30E7\u30F3: {0} -err.verify.not.supported=-verify\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093 err.no.SourceFile.attribute=SourceFile\u5C5E\u6027\u304C\u3042\u308A\u307E\u305B\u3093 err.source.file.not.found=\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093 err.bad.innerclasses.attribute={0}\u306EInnerClasses\u5C5E\u6027\u304C\u4E0D\u6B63\u3067\u3059 -warn.Xold.not.supported=-Xold\u306F\u4F7F\u7528\u3067\u304D\u306A\u304F\u306A\u308A\u307E\u3057\u305F 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 @@ -57,9 +55,9 @@ 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 -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 +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 -main.opt.constants=\ -constants \u9759\u7684final\u5B9A\u6570\u3092\u8868\u793A\u3059\u308B +main.opt.constants=\ -constants final\u5B9A\u6570\u3092\u8868\u793A\u3059\u308B 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
--- a/src/share/classes/com/sun/tools/javap/resources/javap_zh_CN.properties Tue May 13 23:18:48 2014 -0700 +++ b/src/share/classes/com/sun/tools/javap/resources/javap_zh_CN.properties Wed May 14 11:01:08 2014 -0700 @@ -6,7 +6,6 @@ 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} err.end.of.file=\u8BFB\u53D6{0}\u65F6\u51FA\u73B0\u610F\u5916\u7684\u6587\u4EF6\u7ED3\u5C3E err.file.not.found=\u627E\u4E0D\u5230\u6587\u4EF6: {0} -err.h.not.supported=-h \u4E0D\u518D\u53EF\u7528 - \u8BF7\u4F7F\u7528 'javah' \u7A0B\u5E8F err.incompatible.options=\u9009\u9879\u7EC4\u5408\u9519\u8BEF: {0} err.internal.error=\u5185\u90E8\u9519\u8BEF: {0} {1} {2} err.invalid.arg.for.option=\u9009\u9879\u7684\u53C2\u6570\u65E0\u6548: {0} @@ -14,12 +13,11 @@ err.missing.arg=\u6CA1\u6709\u4E3A{0}\u6307\u5B9A\u503C err.no.classes.specified=\u672A\u6307\u5B9A\u7C7B err.not.standard.file.manager=\u4F7F\u7528\u6807\u51C6\u6587\u4EF6\u7BA1\u7406\u5668\u65F6\u53EA\u80FD\u6307\u5B9A\u7C7B\u6587\u4EF6 +err.invalid.use.of.option=\u9009\u9879\u7684\u4F7F\u7528\u65E0\u6548: {0} err.unknown.option=\u672A\u77E5\u9009\u9879: {0} -err.verify.not.supported=\u4E0D\u652F\u6301 -verify err.no.SourceFile.attribute=\u6CA1\u6709 SourceFile \u5C5E\u6027 err.source.file.not.found=\u627E\u4E0D\u5230\u6E90\u6587\u4EF6 err.bad.innerclasses.attribute={0}\u7684 InnerClasses \u5C5E\u6027\u9519\u8BEF -warn.Xold.not.supported=-Xold \u4E0D\u518D\u53EF\u7528 main.usage.summary=\u7528\u6CD5: {0} <options> <classes>\n\u4F7F\u7528 -help \u5217\u51FA\u53EF\u80FD\u7684\u9009\u9879 @@ -59,7 +57,7 @@ main.opt.bootclasspath=\ -bootclasspath <path> \u8986\u76D6\u5F15\u5BFC\u7C7B\u6587\u4EF6\u7684\u4F4D\u7F6E -main.opt.constants=\ -constants \u663E\u793A\u9759\u6001\u6700\u7EC8\u5E38\u91CF +main.opt.constants=\ -constants \u663E\u793A\u6700\u7EC8\u5E38\u91CF 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)
--- a/test/Makefile Tue May 13 23:18:48 2014 -0700 +++ b/test/Makefile Wed May 14 11:01:08 2014 -0700 @@ -186,6 +186,12 @@ JTREG_OPTIONS += -timeoutFactor:$(JTREG_TIMEOUT_FACTOR) endif +# Default verbosity setting for jtreg +JTREG_VERBOSE = fail,error,nopass + +# Default verbosity setting for jck +JCK_VERBOSE = non-pass + # Assertions: some tests show failures when assertions are enabled. # Since javac is typically loaded via the bootclassloader (either via TESTJAVA # or TESTBOOTCLASSPATH), you may need -esa to enable assertions in javac. @@ -256,6 +262,8 @@ # Version of java used to run jtreg. Should normally be the same as TESTJAVA # TESTJAVA # Version of java to be tested. +# JTREG_VERBOSE +# Verbosity setting for jtreg # JTREG_OPTIONS # Additional options for jtreg # JTREG_TESTDIRS @@ -273,7 +281,7 @@ JT_JAVA=$(JT_JAVA) $(JTREG) \ -J-Xmx512m \ -vmoption:-Xmx768m \ - -a -ignore:quiet -v:fail,error,nopass \ + -a -ignore:quiet $(if $(JTREG_VERBOSE),-v:$(JTREG_VERBOSE)) \ -r:$(JTREG_OUTPUT_DIR)/JTreport \ -w:$(JTREG_OUTPUT_DIR)/JTwork \ -jdk:$(TESTJAVA) \ @@ -312,6 +320,8 @@ # Default is JDK 7 # TESTJAVA # Version of java to be tested. +# JCK_VERBOSE +# Verbosity setting for jtjck # JCK_COMPILER_OPTIONS # Additional options for JCK-compiler # JCK_COMPILER_TESTDIRS @@ -325,9 +335,9 @@ @rm -f -r $(JCK_COMPILER_OUTPUT_DIR)/work $(JCK_COMPILER_OUTPUT_DIR)/report \ $(JCK_COMPILER_OUTPUT_DIR)/diff.html $(JCK_COMPILER_OUTPUT_DIR)/status.txt @mkdir -p $(JCK_COMPILER_OUTPUT_DIR) - $(JT_JAVA)/bin/java -XX:MaxPermSize=256m -Xmx512m \ + $(JT_JAVA)/bin/java -Xmx512m \ -jar $(JCK_HOME)/JCK-compiler-8/lib/jtjck.jar \ - -v:non-pass \ + $(if $(JCK_VERBOSE),-v:$(JCK_VERBOSE)) \ -r:$(JCK_COMPILER_OUTPUT_DIR)/report \ -w:$(JCK_COMPILER_OUTPUT_DIR)/work \ -jdk:$(TESTJAVA) \ @@ -361,6 +371,8 @@ # Version of java used to run JCK. Should normally be the same as TESTJAVA # TESTJAVA # Version of java to be tested. +# JCK_VERBOSE +# Verbosity setting for jtjck # JCK_RUNTIME_OPTIONS # Additional options for JCK-runtime # JCK_RUNTIME_TESTDIRS @@ -374,9 +386,9 @@ @rm -f -r $(JCK_RUNTIME_OUTPUT_DIR)/work $(JCK_RUNTIME_OUTPUT_DIR)/report \ $(JCK_RUNTIME_OUTPUT_DIR)/diff.html $(JCK_RUNTIME_OUTPUT_DIR)/status.txt @mkdir -p $(JCK_RUNTIME_OUTPUT_DIR) - $(JT_JAVA)/bin/java -XX:MaxPermSize=256m -Xmx512m \ + $(JT_JAVA)/bin/java -Xmx512m \ -jar $(JCK_HOME)/JCK-runtime-8/lib/jtjck.jar \ - -v:non-pass \ + $(if $(JCK_VERBOSE),-v:$(JCK_VERBOSE)) \ -r:$(JCK_RUNTIME_OUTPUT_DIR)/report \ -w:$(JCK_RUNTIME_OUTPUT_DIR)/work \ -jdk:$(TESTJAVA) \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T8029102/WarnSerializableLambdaTest.java Wed May 14 11:01:08 2014 -0700 @@ -0,0 +1,241 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8029102 + * @summary Enhance compiler warnings for Lambda + * Checks that the warning for accessing non public members of a class is + * fired correctly. + * @compile/fail/ref=WarnSerializableLambdaTest.out -XDrawDiagnostics -Werror -XDwarnOnAccessToSensitiveMembers WarnSerializableLambdaTest.java + */ + +import java.io.Serializable; + +public class WarnSerializableLambdaTest { + + void warnLambda() throws Exception { + SAM t3 = (SAM & Serializable)WarnSerializableLambdaTest::packageClassMethod; + SAM t4 = (SAM & Serializable)WarnSerializableLambdaTest::protectedClassMethod; + SAM t5 = (SAM & Serializable)WarnSerializableLambdaTest::privateClassMethod; + + WarnSerializableLambdaTest test = new WarnSerializableLambdaTest(); + SAM t6 = (SAM & Serializable)test::packageInstanceMethod; + SAM t7 = (SAM & Serializable)test::protectedInstanceMethod; + SAM t8 = (SAM & Serializable)test::privateInstanceMethod; + + SAM t9 = (SAM & Serializable) c -> { + + WarnSerializableLambdaTest.staticPackageField = ""; + WarnSerializableLambdaTest.staticProtectedField = ""; + WarnSerializableLambdaTest.staticPrivateField = ""; + + packageField = ""; + protectedField = ""; + privateField = ""; + + WarnSerializableLambdaTest.packageClassMethod(null); + WarnSerializableLambdaTest.protectedClassMethod(null); + WarnSerializableLambdaTest.privateClassMethod(null); + + packageInstanceMethod(null); + protectedInstanceMethod(null); + privateInstanceMethod(null); + + PrivateClass.effectivelyNonPublicStaticField = ""; + PrivateClass.effectivelyNonPublicClassMethod(); + + PrivateClass p = new PrivateClass(); + p.effectivelyNonPublicInstanceField = ""; + p.effectivelyNonPublicInstanceMethod(); + + return null; + }; + } + + private void warnAnoInnerClass() throws Exception { + new SerializableDesc() { + public void m(Object param) throws Exception { + WarnSerializableLambdaTest.staticPackageField = ""; + WarnSerializableLambdaTest.staticProtectedField = ""; + WarnSerializableLambdaTest.staticPrivateField = ""; + + packageField = ""; + protectedField = ""; + privateField = ""; + + WarnSerializableLambdaTest.packageClassMethod(null); + WarnSerializableLambdaTest.protectedClassMethod(null); + WarnSerializableLambdaTest.privateClassMethod(null); + + packageInstanceMethod(null); + protectedInstanceMethod(null); + privateInstanceMethod(null); + + PrivateClass.effectivelyNonPublicStaticField = ""; + PrivateClass.effectivelyNonPublicClassMethod(); + + PrivateClass p = new PrivateClass(); + p.effectivelyNonPublicInstanceField = ""; + p.effectivelyNonPublicInstanceMethod(); + } + }; + } + + void dontWarnLambda() throws Exception { + SAM t1 = (SAM & Serializable)WarnSerializableLambdaTest::publicClassMethod; + + WarnSerializableLambdaTest test = new WarnSerializableLambdaTest(); + SAM t2 = (SAM & Serializable)test::publicInstanceMethod; + + int[] buffer = {0}; + + SAM t3 = (SAM & Serializable) param -> { + Object localVar; + localVar = null; + param = null; + + WarnSerializableLambdaTest.staticPublicField = ""; + publicField = ""; + WarnSerializableLambdaTest.publicClassMethod(null); + publicInstanceMethod(null); + + PublicClass.effectivelyPublicStaticField = ""; + PublicClass.effectivelyPublicClassMethod(); + + PublicClass p = new PublicClass(); + p.effectivelyPublicInstanceField = ""; + p.effectivelyPublicInstanceMethod(); + + int l = buffer.length; + + return null; + }; + } + + private void dontWarnAnoInnerClass() throws Exception { + final int[] buffer = {0}; + new SerializableDesc() { + public void m(Object param) throws Exception { + Object localVar; + localVar = null; + param = null; + + WarnSerializableLambdaTest.staticPublicField = ""; + publicField = ""; + WarnSerializableLambdaTest.publicClassMethod(null); + publicInstanceMethod(null); + + PublicClass.effectivelyPublicStaticField = ""; + PublicClass.effectivelyPublicClassMethod(); + + PublicClass p = new PublicClass(); + p.effectivelyPublicInstanceField = ""; + p.effectivelyPublicInstanceMethod(); + + int l = buffer.length; + } + }; + } + + enum WarnEnum { + A { + public void m() throws Exception { + WarnSerializableLambdaTest.staticPackageField = ""; + WarnSerializableLambdaTest.staticProtectedField = ""; + WarnSerializableLambdaTest.staticPrivateField = ""; + + WarnSerializableLambdaTest test = + new WarnSerializableLambdaTest(); + + test.packageField = ""; + test.protectedField = ""; + test.privateField = ""; + + WarnSerializableLambdaTest.packageClassMethod(null); + WarnSerializableLambdaTest.protectedClassMethod(null); + WarnSerializableLambdaTest.privateClassMethod(null); + + test.packageInstanceMethod(null); + test.protectedInstanceMethod(null); + test.privateInstanceMethod(null); + + PrivateClass.effectivelyNonPublicStaticField = ""; + PrivateClass.effectivelyNonPublicClassMethod(); + + PrivateClass p = new PrivateClass(); + p.effectivelyNonPublicInstanceField = ""; + p.effectivelyNonPublicInstanceMethod(); + } + }; + + public void m() throws Exception {} + } + + static String staticPackageField; + static private String staticPrivateField; + static protected String staticProtectedField; + static public String staticPublicField; + + String packageField; + private String privateField; + protected String protectedField; + public String publicField; + + static Object packageClassMethod(String s) { + return null; + } + + static private Object privateClassMethod(String s) { + return null; + } + + static protected Object protectedClassMethod(String s) { + return null; + } + + static public Object publicClassMethod(String s) { + return null; + } + + Object packageInstanceMethod(String s) { + return null; + } + + protected Object protectedInstanceMethod(String s) { + return null; + } + + private Object privateInstanceMethod(String s) { + return null; + } + + public Object publicInstanceMethod(String s) { + return null; + } + + interface SAM { + Object apply(String s) throws Exception; + } + + interface SAM2 { + Object apply(String arg1, String arg2); + } + + class SerializableDesc implements Serializable { + public void m(Object param) throws Exception {} + } + + static private class PrivateClass { + static public String effectivelyNonPublicStaticField; + public String effectivelyNonPublicInstanceField; + + static public void effectivelyNonPublicClassMethod() {} + public void effectivelyNonPublicInstanceMethod() {} + } + + static public class PublicClass { + static public String effectivelyPublicStaticField; + public String effectivelyPublicInstanceField; + + static public void effectivelyPublicClassMethod() {} + public void effectivelyPublicInstanceMethod() {} + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T8029102/WarnSerializableLambdaTest.out Wed May 14 11:01:08 2014 -0700 @@ -0,0 +1,57 @@ +WarnSerializableLambdaTest.java:15:38: compiler.warn.access.to.sensitive.member.from.serializable.element: packageClassMethod(java.lang.String) +WarnSerializableLambdaTest.java:16:38: compiler.warn.access.to.sensitive.member.from.serializable.element: protectedClassMethod(java.lang.String) +WarnSerializableLambdaTest.java:17:38: compiler.warn.access.to.sensitive.member.from.serializable.element: privateClassMethod(java.lang.String) +WarnSerializableLambdaTest.java:20:38: compiler.warn.access.to.sensitive.member.from.serializable.element: packageInstanceMethod(java.lang.String) +WarnSerializableLambdaTest.java:21:38: compiler.warn.access.to.sensitive.member.from.serializable.element: protectedInstanceMethod(java.lang.String) +WarnSerializableLambdaTest.java:22:38: compiler.warn.access.to.sensitive.member.from.serializable.element: privateInstanceMethod(java.lang.String) +WarnSerializableLambdaTest.java:26:39: compiler.warn.access.to.sensitive.member.from.serializable.element: staticPackageField +WarnSerializableLambdaTest.java:27:39: compiler.warn.access.to.sensitive.member.from.serializable.element: staticProtectedField +WarnSerializableLambdaTest.java:28:39: compiler.warn.access.to.sensitive.member.from.serializable.element: staticPrivateField +WarnSerializableLambdaTest.java:30:13: compiler.warn.access.to.sensitive.member.from.serializable.element: packageField +WarnSerializableLambdaTest.java:31:13: compiler.warn.access.to.sensitive.member.from.serializable.element: protectedField +WarnSerializableLambdaTest.java:32:13: compiler.warn.access.to.sensitive.member.from.serializable.element: privateField +WarnSerializableLambdaTest.java:34:39: compiler.warn.access.to.sensitive.member.from.serializable.element: packageClassMethod(java.lang.String) +WarnSerializableLambdaTest.java:35:39: compiler.warn.access.to.sensitive.member.from.serializable.element: protectedClassMethod(java.lang.String) +WarnSerializableLambdaTest.java:36:39: compiler.warn.access.to.sensitive.member.from.serializable.element: privateClassMethod(java.lang.String) +WarnSerializableLambdaTest.java:38:13: compiler.warn.access.to.sensitive.member.from.serializable.element: packageInstanceMethod(java.lang.String) +WarnSerializableLambdaTest.java:39:13: compiler.warn.access.to.sensitive.member.from.serializable.element: protectedInstanceMethod(java.lang.String) +WarnSerializableLambdaTest.java:40:13: compiler.warn.access.to.sensitive.member.from.serializable.element: privateInstanceMethod(java.lang.String) +WarnSerializableLambdaTest.java:42:25: compiler.warn.access.to.sensitive.member.from.serializable.element: effectivelyNonPublicStaticField +WarnSerializableLambdaTest.java:43:25: compiler.warn.access.to.sensitive.member.from.serializable.element: effectivelyNonPublicClassMethod() +WarnSerializableLambdaTest.java:46:14: compiler.warn.access.to.sensitive.member.from.serializable.element: effectivelyNonPublicInstanceField +WarnSerializableLambdaTest.java:47:14: compiler.warn.access.to.sensitive.member.from.serializable.element: effectivelyNonPublicInstanceMethod() +WarnSerializableLambdaTest.java:56:43: compiler.warn.access.to.sensitive.member.from.serializable.element: staticPackageField +WarnSerializableLambdaTest.java:57:43: compiler.warn.access.to.sensitive.member.from.serializable.element: staticProtectedField +WarnSerializableLambdaTest.java:58:43: compiler.warn.access.to.sensitive.member.from.serializable.element: staticPrivateField +WarnSerializableLambdaTest.java:60:17: compiler.warn.access.to.sensitive.member.from.serializable.element: packageField +WarnSerializableLambdaTest.java:61:17: compiler.warn.access.to.sensitive.member.from.serializable.element: protectedField +WarnSerializableLambdaTest.java:62:17: compiler.warn.access.to.sensitive.member.from.serializable.element: privateField +WarnSerializableLambdaTest.java:64:43: compiler.warn.access.to.sensitive.member.from.serializable.element: packageClassMethod(java.lang.String) +WarnSerializableLambdaTest.java:65:43: compiler.warn.access.to.sensitive.member.from.serializable.element: protectedClassMethod(java.lang.String) +WarnSerializableLambdaTest.java:66:43: compiler.warn.access.to.sensitive.member.from.serializable.element: privateClassMethod(java.lang.String) +WarnSerializableLambdaTest.java:68:17: compiler.warn.access.to.sensitive.member.from.serializable.element: packageInstanceMethod(java.lang.String) +WarnSerializableLambdaTest.java:69:17: compiler.warn.access.to.sensitive.member.from.serializable.element: protectedInstanceMethod(java.lang.String) +WarnSerializableLambdaTest.java:70:17: compiler.warn.access.to.sensitive.member.from.serializable.element: privateInstanceMethod(java.lang.String) +WarnSerializableLambdaTest.java:72:29: compiler.warn.access.to.sensitive.member.from.serializable.element: effectivelyNonPublicStaticField +WarnSerializableLambdaTest.java:73:29: compiler.warn.access.to.sensitive.member.from.serializable.element: effectivelyNonPublicClassMethod() +WarnSerializableLambdaTest.java:76:18: compiler.warn.access.to.sensitive.member.from.serializable.element: effectivelyNonPublicInstanceField +WarnSerializableLambdaTest.java:77:18: compiler.warn.access.to.sensitive.member.from.serializable.element: effectivelyNonPublicInstanceMethod() +WarnSerializableLambdaTest.java:141:43: compiler.warn.access.to.sensitive.member.from.serializable.element: staticPackageField +WarnSerializableLambdaTest.java:142:43: compiler.warn.access.to.sensitive.member.from.serializable.element: staticProtectedField +WarnSerializableLambdaTest.java:143:43: compiler.warn.access.to.sensitive.member.from.serializable.element: staticPrivateField +WarnSerializableLambdaTest.java:148:21: compiler.warn.access.to.sensitive.member.from.serializable.element: packageField +WarnSerializableLambdaTest.java:149:21: compiler.warn.access.to.sensitive.member.from.serializable.element: protectedField +WarnSerializableLambdaTest.java:150:21: compiler.warn.access.to.sensitive.member.from.serializable.element: privateField +WarnSerializableLambdaTest.java:152:43: compiler.warn.access.to.sensitive.member.from.serializable.element: packageClassMethod(java.lang.String) +WarnSerializableLambdaTest.java:153:43: compiler.warn.access.to.sensitive.member.from.serializable.element: protectedClassMethod(java.lang.String) +WarnSerializableLambdaTest.java:154:43: compiler.warn.access.to.sensitive.member.from.serializable.element: privateClassMethod(java.lang.String) +WarnSerializableLambdaTest.java:156:21: compiler.warn.access.to.sensitive.member.from.serializable.element: packageInstanceMethod(java.lang.String) +WarnSerializableLambdaTest.java:157:21: compiler.warn.access.to.sensitive.member.from.serializable.element: protectedInstanceMethod(java.lang.String) +WarnSerializableLambdaTest.java:158:21: compiler.warn.access.to.sensitive.member.from.serializable.element: privateInstanceMethod(java.lang.String) +WarnSerializableLambdaTest.java:160:29: compiler.warn.access.to.sensitive.member.from.serializable.element: effectivelyNonPublicStaticField +WarnSerializableLambdaTest.java:161:29: compiler.warn.access.to.sensitive.member.from.serializable.element: effectivelyNonPublicClassMethod() +WarnSerializableLambdaTest.java:164:18: compiler.warn.access.to.sensitive.member.from.serializable.element: effectivelyNonPublicInstanceField +WarnSerializableLambdaTest.java:165:18: compiler.warn.access.to.sensitive.member.from.serializable.element: effectivelyNonPublicInstanceMethod() +- compiler.err.warnings.and.werror +1 error +54 warnings
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T8029102/WarnSerializableLambdaTestb.java Wed May 14 11:01:08 2014 -0700 @@ -0,0 +1,56 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8029102 + * @summary Enhance compiler warnings for Lambda + * Checks that the warning for accessing non public members of a class is + * fired correctly. + * @compile/fail/ref=WarnSerializableLambdaTestb.out -XDrawDiagnostics -Werror -XDwarnOnAccessToSensitiveMembers WarnSerializableLambdaTestb.java + */ + +import java.io.Serializable; + +public class WarnSerializableLambdaTestb { + public void foo(Secret1 secret) { + Object o = (Runnable & java.io.Serializable) () -> { secret.test(); }; + } + + public void bar(Secret2 secret) { + Object o = (Runnable & java.io.Serializable) () -> { secret.test(); }; + } + + private class Secret1 { + public void test() {} + } + + static private class Secret2 { + public void test() {} + } + + class TestInner { + private int j = 0; + void m() { + Serializable s = new Serializable() { + int i; + void m() { + i = 0; // don't warn + System.out.println(j); //warn + } + }; + } + } + + class TestInner2 { + class W implements Serializable { + public int p = 0; + class I { + public int r = 0; + class K implements Serializable { + void m() { + p = 1; // don't warn owner is serializable + r = 2; // warn owner is not serializable + } + } + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T8029102/WarnSerializableLambdaTestb.out Wed May 14 11:01:08 2014 -0700 @@ -0,0 +1,7 @@ +WarnSerializableLambdaTestb.java:14:69: compiler.warn.access.to.sensitive.member.from.serializable.element: test() +WarnSerializableLambdaTestb.java:18:69: compiler.warn.access.to.sensitive.member.from.serializable.element: test() +WarnSerializableLambdaTestb.java:36:40: compiler.warn.access.to.sensitive.member.from.serializable.element: j +WarnSerializableLambdaTestb.java:50:25: compiler.warn.access.to.sensitive.member.from.serializable.element: r +- compiler.err.warnings.and.werror +1 error +4 warnings
--- a/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.java Tue May 13 23:18:48 2014 -0700 +++ b/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.java Wed May 14 11:01:08 2014 -0700 @@ -1,30 +1,8 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8029569 + * @test /nodynamiccopyright/ + * @bug 8029569 8037379 * @summary internal javac cast exception when resolving varargs ambiguity + * fix for JDK-8029569 doesn't cover all possible cases * @compile/fail/ref=VarargsAmbiguityCrashTest.out -XDrawDiagnostics VarargsAmbiguityCrashTest.java */
--- a/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.out Tue May 13 23:18:48 2014 -0700 +++ b/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.out Wed May 14 11:01:08 2014 -0700 @@ -1,2 +1,2 @@ -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 +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 1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/api/taskListeners/EventsBalancedTest.java Wed May 14 11:01:08 2014 -0700 @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8040822 + * @summary Check that all TaskEvents are balanced. + */ + +import java.io.*; +import java.net.URI; +import java.util.*; +import java.util.Map.Entry; + +import javax.tools.*; + +import com.sun.source.util.*; +import com.sun.source.util.TaskEvent.Kind; +import com.sun.tools.javac.api.JavacTool; +import com.sun.tools.javac.comp.CompileStates.CompileState; + +public class EventsBalancedTest { + JavacTool tool = (JavacTool) ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); + + public static void main(String... args) throws IOException { + new EventsBalancedTest().test(); + } + + void test() throws IOException { + TestSource a = new TestSource("B", "class B extends A { }"); + TestSource b = new TestSource("A", "abstract class A { }"); + + test(null, Arrays.asList(a, b)); + test(null, Arrays.asList(b, a)); + test(Arrays.asList("-XD-relax"), Arrays.asList(a, b)); + test(Arrays.asList("-XD-relax"), Arrays.asList(b, a)); + + for (CompileState stop : CompileState.values()) { + test(Arrays.asList("-XDshouldStopPolicyIfNoError=" + stop, + "-XDshouldStopPolicyIfError=" + stop), + Arrays.asList(a, b)); + test(Arrays.asList("-XDshouldStopPolicyIfNoError=" + stop, + "-XDshouldStopPolicyIfError=" + stop), + Arrays.asList(b, a)); + } + } + + void test(Iterable<String> options, Iterable<JavaFileObject> files) throws IOException { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + TestListener listener = new TestListener(); + JavacTask task = tool.getTask(pw, fm, null, options, null, files); + + task.setTaskListener(listener); + + task.call(); + + for (Entry<Kind, Integer> e : listener.kind2Count.entrySet()) { + if (e.getValue() != null && e.getValue() != 0) { + throw new IllegalStateException("Not balanced event: " + e.getKey()); + } + } + } + + static class TestListener implements TaskListener { + final Map<Kind, Integer> kind2Count = new HashMap<>(); + + int get(Kind k) { + Integer count = kind2Count.get(k); + + if (count == null) + kind2Count.put(k, count = 0); + + return count; + } + + @Override + public void started(TaskEvent e) { + kind2Count.put(e.getKind(), get(e.getKind()) + 1); + } + + @Override + public void finished(TaskEvent e) { + int count = get(e.getKind()); + + if (count <= 0) + throw new IllegalStateException("count<=0 for: " + e.getKind()); + + kind2Count.put(e.getKind(), count - 1); + } + + } + static class TestSource extends SimpleJavaFileObject { + final String content; + public TestSource(String fileName, String content) { + super(URI.create("myfo:/" + fileName + ".java"), JavaFileObject.Kind.SOURCE); + this.content = content; + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return content; + } + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/WarnSerializableLambda.java Wed May 14 11:01:08 2014 -0700 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.warn.access.to.sensitive.member.from.serializable.element +// options: -XDwarnOnAccessToSensitiveMembers + +import java.io.Serializable; + +public class WarnSerializableLambda { + interface SAM { + void apply(String s); + } + + private void m1() { + SAM s = (SAM & Serializable) c -> { + packageField = ""; + }; + } + + String packageField; +}
--- a/test/tools/javac/generics/inference/7086586/T7086586.out Tue May 13 23:18:48 2014 -0700 +++ b/test/tools/javac/generics/inference/7086586/T7086586.out Wed May 14 11:01:08 2014 -0700 @@ -1,5 +1,5 @@ -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>)) -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>)) -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>)) -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>)) +T7086586.java:14:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.captureof: 1, ?, java.lang.String) +T7086586.java:15:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.captureof: 1, ?, java.lang.Number) +T7086586.java:16:31: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.captureof: 1, ?, java.lang.Exception) +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) 4 errors
--- a/test/tools/javac/generics/inference/7086586/T7086586b.java Tue May 13 23:18:48 2014 -0700 +++ b/test/tools/javac/generics/inference/7086586/T7086586b.java Wed May 14 11:01:08 2014 -0700 @@ -23,9 +23,10 @@ /* * @test - * @bug 7086586 + * @bug 7086586 8033718 * - * @summary Inference producing null type argument + * @summary Inference producing null type argument; inference ignores capture + * variable as upper bound */ import java.util.List; @@ -40,8 +41,8 @@ assertionCount++; } - <T> void m(List<? super T> dummy) { assertTrue(false); } - <T> void m(Object dummy) { assertTrue(true); } + <T> void m(List<? super T> dummy) { assertTrue(true); } + <T> void m(Object dummy) { assertTrue(false); } void test(List<?> l) { m(l);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/inference/LowerBoundGLB.java Wed May 14 11:01:08 2014 -0700 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8033718 + * @author dlsmith + * @summary GLB for two capture variables with lower bounds + * @compile LowerBoundGLB.java + */ + +public class LowerBoundGLB { + + interface Box<T> { + T get(); + void set(T arg); + } + + <T> T doGLB(Box<? super T> b1, Box<? super T> b2) { + return null; + } + + void test(Box<? super String> l1, Box<? super CharSequence> l2) { + doGLB(l1, l2).substring(3); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/inference/T8028503/PrimitiveTypeInBoundForMethodRefTest.java Wed May 14 11:01:08 2014 -0700 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8028503 + * @summary javac, for method references a primitive type can be added as a bound + * @compile PrimitiveTypeInBoundForMethodRefTest.java + */ + +class PrimitiveTypeInBoundForMethodRefTest { + + interface Mapper<T, U> { + U map(T t); + } + + static <U> Iterable<U> map(Mapper<String, U> mapper) { + return null; + } + + static void test() { + Iterable<Integer> map = map(PrimitiveTypeInBoundForMethodRefTest::length); + } + + public static <T> int length(String s) { + return 0; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/typevars/IntersectionSubVar.java Wed May 14 11:01:08 2014 -0700 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8042656 + * @summary Subtyping for intersection types containing type variables + * @compile IntersectionSubVar.java + */ + +class IntersectionSubVar { + + interface Box<T> { + void set(T arg); + T get(); + } + + <I> Box<I> glb(Box<? super I> arg1, Box<? super I> arg2) { + return null; + } + + <E extends Cloneable> void takeBox(Box<? super E> box) {} + + <T> void test(Box<T> arg1, Box<Cloneable> arg2, Box<? super T> arg3) { + T t = glb(arg1, arg2).get(); // assign T&Cloneable to T + takeBox(arg3); // inference tests Box<CAP> <: Box<? super CAP&Cloneable> + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/inference/EagerReturnTypeResolution/EagerReturnTypeResolutionTesta.java Wed May 14 11:01:08 2014 -0700 @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8030741 + * @summary Inference: implement eager resolution of return types, consistent with JDK-8028800 + * @compile EagerReturnTypeResolutionTesta.java + */ + +public class EagerReturnTypeResolutionTesta { + + abstract class Test1<T>{ + abstract <S> S foo(S x, S y); + <S extends Number & Comparable<? extends Number>> void baz(Test1<S> a){} + + void bar(Test1<Long> x, Test1<Integer> y){ + baz(foo(x, y)); + } + } + + abstract class Test2<T>{ + abstract <S> S foo(S x, S y); + abstract <S1> void baz(Test2<S1> a); + + void bar(Test2<Integer> y, Test2<Long> x){ + baz(foo(x, y)); + } + } + + abstract class Test3<T>{ + abstract <S> S foo(S x, S y); + <T extends Number & Comparable<?>, + S extends Number & Comparable<? extends T>> void baz(Test3<S> a){} + + void bar(Test3<Long> x, Test3<Integer> y){ + baz(foo(x, y)); + } + } + + abstract class Test4 { + abstract class A0<T> {} + + abstract class A1<T> extends A0<T> {} + + abstract class A2<T> extends A0<T> {} + + abstract <S> S foo(S x, S y); + abstract <S1> void baz(A0<S1> a); + + void bar(A2<Integer> y, A1<Long> x){ + baz(foo(x, y)); + } + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/inference/EagerReturnTypeResolution/EagerReturnTypeResolutionTestb.java Wed May 14 11:01:08 2014 -0700 @@ -0,0 +1,182 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8030741 + * @summary Inference: implement eager resolution of return types, consistent with JDK-8028800 + * @compile/fail/ref=EagerReturnTypeResolutionTestb.out -XDrawDiagnostics EagerReturnTypeResolutionTestb.java + * @author Dan Smith + */ + +import java.util.List; + +public class EagerReturnTypeResolutionTestb { + interface I<S> {} + interface J<S> extends I<S> {} + interface K extends I<String> {} + interface L<S> extends I {} + + <T> T lower(List<? extends T> l) { return null; } + <T> T lower2(List<? extends T> l1, List<? extends T> l2) { return null; } + + <T> T upper(List<? super T> l) { return null; } + <T> T upper2(List<? super T> l1, List<? super T> l2) { return null; } + + <T> T eq(List<T> l) { return null; } + <T> T eq2(List<T> l1, List<T> l2) { return null; } + + <X> void takeI(I<X> i) {} + void takeIString(I<String> i) {} + I<String> iStringField; + + void takeLong(long arg) {} + long longField; + + void testSimpleCaptureOK(List<I<?>> i1) { + takeI(lower(i1)); // ok* + takeI(eq(i1)); // ok* + takeI(upper(i1)); // ok, no capture + takeIString(upper(i1)); // ok + iStringField = upper(i1); // ok + } + + void testSimpleCaptureKO(List<I<?>> i1) { + takeIString(lower(i1)); // ERROR + takeIString(eq(i1)); // ERROR + iStringField = lower(i1); // ERROR + iStringField = eq(i1); // ERROR + } + + void testMultiCaptureOK(List<I<String>> i1, List<I<Integer>> i2, List<I<?>> i3, + List<J<String>> j1, List<J<Integer>> j2, List<K> k1) { + /* Lines marked with JDK-8029002 should be uncommented once this bug is + * fixed + */ + takeI(lower2(i1, i2)); // ok* + takeI(lower2(i1, i3)); // ok* + takeI(upper2(i1, i3)); // ok, no capture* JDK-8029002 + + takeIString(upper2(i1, i3)); // ok, no capture + iStringField = upper2(i1, i3); // ok, no capture + + takeI(lower2(j1, j2)); // ok* + takeI(lower2(j1, k1)); // ok, no capture + takeI(upper2(j1, k1)); // ok, no capture* JDK-8029002 + + takeIString(lower2(j1, k1)); // ok, no capture + takeIString(upper2(j1, k1)); // ok, no capture + + iStringField = lower2(j1, k1); // ok, no capture + iStringField = upper2(j1, k1); // ok, no capture + takeI(lower2(j2, k1)); // ok* + } + + void testMultiCaptureKO(List<I<String>> i1, List<I<Integer>> i2, List<I<?>> i3, + List<J<String>> j1, List<J<Integer>> j2, List<K> k1) { + takeI(eq2(i1, i2)); // ERROR, bad bounds + takeI(upper2(i1, i2)); // ERROR, bad bounds + + takeIString(lower2(i1, i2)); // ERROR + takeIString(eq2(i1, i2)); // ERROR, bad bounds + takeIString(upper2(i1, i2)); // ERROR, bad bounds + + iStringField = lower2(i1, i2); // ERROR + iStringField = eq2(i1, i2); // ERROR, bad bounds + iStringField = upper2(i1, i2); // ERROR, bad bounds + + takeI(eq2(i1, i3)); // ERROR, bad bounds + takeIString(lower2(i1, i3)); // ERROR + takeIString(eq2(i1, i3)); // ERROR, bad bounds + + iStringField = lower2(i1, i3); // ERROR + iStringField = eq2(i1, i3); // ERROR, bad bounds + takeI(eq2(j1, j2)); // ERROR, bad bounds + takeI(upper2(j1, j2)); // ERROR, bad bounds + + takeIString(lower2(j1, j2)); // ERROR + takeIString(eq2(j1, j2)); // ERROR, bad bounds + takeIString(upper2(j1, j2)); // ERROR, bad bounds + + iStringField = lower2(j1, j2); // ERROR + iStringField = eq2(j1, j2); // ERROR, bad bounds + iStringField = upper2(j1, j2); // ERROR, bad bounds + + takeI(eq2(j1, k1)); // ERROR, bad bounds + takeIString(eq2(j1, k1)); // ERROR, bad bounds + iStringField = eq2(j1, k1); // ERROR, bad bounds + takeI(eq2(j2, k1)); // ERROR, bad bounds + takeI(upper2(j2, k1)); // ERROR, bad bounds; actual: no error, see JDK-8037474 + + takeIString(lower2(j2, k1)); // ERROR + takeIString(eq2(j2, k1)); // ERROR, bad bounds + takeIString(upper2(j2, k1)); // ERROR, bad bounds + + iStringField = lower2(j2, k1); // ERROR + iStringField = eq2(j2, k1); // ERROR, bad bounds + iStringField = upper2(j2, k1); // ERROR, bad bounds + } + + void testRawOK(List<I> i1, List<J> j1, List<L<String>> l1) { + takeI(lower(i1)); // ok, unchecked + takeI(eq(i1)); // ok, unchecked + takeI(upper(i1)); // ok, no capture, not unchecked + + takeIString(lower(i1)); // ok, unchecked + takeIString(eq(i1)); // ok, unchecked + takeIString(upper(i1)); // ok, no capture, not unchecked + + iStringField = lower(i1); // ok, unchecked + iStringField = eq(i1); // ok, unchecked + iStringField = upper(i1); // ok, no capture, not unchecked + + takeI(lower(j1)); // ok, unchecked + takeI(eq(j1)); // ok, unchecked + takeI(upper(j1)); // bad bounds? -- spec is unclear + + takeIString(lower(j1)); // ok, unchecked + takeIString(eq(j1)); // ok, unchecked + takeIString(upper(j1)); // bad bounds? -- spec is unclear + + iStringField = lower(j1); // ok, unchecked + iStringField = eq(j1); // ok, unchecked + iStringField = upper(j1); // bad bounds? -- spec is unclear + + takeI(lower(l1)); // ok, unchecked + takeI(eq(l1)); // ok, unchecked + takeI(upper(l1)); // bad bounds? -- spec is unclear + + takeIString(lower(l1)); // ok, unchecked + takeIString(eq(l1)); // ok, unchecked + takeIString(upper(l1)); // bad bounds? -- spec is unclear + + iStringField = lower(l1); // ok, unchecked + iStringField = eq(l1); // ok, unchecked + iStringField = upper(l1); // bad bounds? -- spec is unclear + } + + void testPrimOK(List<Integer> i1, List<Long> l1, List<Double> d1) { + takeLong(lower(i1)); // ok + takeLong(eq(i1)); // ok + takeLong(upper(i1)); // ok* + + longField = lower(i1); // ok + longField = eq(i1); // ok + longField = upper(i1); // ok* + + takeLong(lower(l1)); // ok + takeLong(eq(l1)); // ok + takeLong(upper(l1)); // ok + + longField = lower(l1); // ok + longField = eq(l1); // ok + longField = upper(l1); // ok + } + + void testPrimKO(List<Integer> i1, List<Long> l1, List<Double> d1) { + takeLong(lower(d1)); // ERROR + takeLong(eq(d1)); // ERROR + takeLong(upper(d1)); // ERROR + + longField = lower(d1); // ERROR + longField = eq(d1); // ERROR + longField = upper(d1); // ERROR + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/inference/EagerReturnTypeResolution/EagerReturnTypeResolutionTestb.out Wed May 14 11:01:08 2014 -0700 @@ -0,0 +1,45 @@ +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)) +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)) +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) +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) +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>) +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) +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)) +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>) +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) +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) +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>) +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) +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>) +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)) +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>) +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) +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>) +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>) +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) +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)) +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>) +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) +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) +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>) +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) +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>) +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>) +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>) +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>) +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) +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)) +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>) +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)) +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) +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>) +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) +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)) +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)) +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)) +EagerReturnTypeResolutionTestb.java:178:26: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.instance.exists: , T, long) +EagerReturnTypeResolutionTestb.java:179:23: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.instance.exists: , T, long) +EagerReturnTypeResolutionTestb.java:180:26: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.instance.exists: , T, long) +- compiler.note.unchecked.filename: EagerReturnTypeResolutionTestb.java +- compiler.note.unchecked.recompile +42 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/inference/EagerReturnTypeResolution/PrimitiveTypeBoxingTest.java Wed May 14 11:01:08 2014 -0700 @@ -0,0 +1,25 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8030741 + * @summary Inference: implement eager resolution of return types, consistent with JDK-8028800 + * @compile/fail/ref=PrimitiveTypeBoxingTest.out -XDrawDiagnostics PrimitiveTypeBoxingTest.java + */ + +public class PrimitiveTypeBoxingTest { + + static void foo(long arg) {} + static void bar(int arg) {} + + interface F<X> { void get(X arg); } + + <Z> void m1(F<Z> f, Z arg) {} + <Z> void m2(Z arg, F<Z> f) {} + + void test() { + m1(PrimitiveTypeBoxingTest::foo, 23); // expected: error + m2(23, PrimitiveTypeBoxingTest::foo); // expected: error + + m1(PrimitiveTypeBoxingTest::bar, 23); // expected: success + m2(23, PrimitiveTypeBoxingTest::bar); // expected: success + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/inference/EagerReturnTypeResolution/PrimitiveTypeBoxingTest.out Wed May 14 11:01:08 2014 -0700 @@ -0,0 +1,3 @@ +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) +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) +2 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/LambdaLocalTest.java Wed May 14 11:01:08 2014 -0700 @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8029725 + * @summary Lambda reference to containing local class causes javac infinite recursion + * @author Robert Field + * @run main LambdaLocalTest + */ + +public class LambdaLocalTest { + interface F {void f();} + + static F f; + static StringBuffer sb = new StringBuffer(); + + static void assertEquals(Object val, Object expected) { + if (!val.equals(expected)) { + throw new AssertionError("expected '" + expected + "' got '" + val + "'"); + } + } + + public static void main(String[] args) { + class Local { + public Local() { + f = () -> new Local(); + sb.append("+"); + } + } + new Local(); + f.f(); + assertEquals(sb.toString(), "++"); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/LambdaMultiCatchTest.java Wed May 14 11:01:08 2014 -0700 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8036942 + * @summary javac generates incorrect exception table for multi-catch statements inside a lambda + * @run main LambdaMultiCatchTest + */ + +import java.io.IOException; +import java.util.function.Function; + +public class LambdaMultiCatchTest { + public static void main(String[] args) { + Function<String,String> fi = x -> { + String result = "nada"; + try { + switch (x) { + case "IO": throw new IOException(); + case "Illegal": throw new IllegalArgumentException(); + case "Run": throw new RuntimeException(); + } + } catch (IOException|IllegalArgumentException ex) { + result = "IO/Illegal"; + } catch (Exception ex) { + result = "Any"; + }; + return result; + }; + String val = fi.apply("Run"); + if (!val.equals("Any")) { + throw new AssertionError("Fail: Expected 'Any' but got '" + val + "'"); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/LambdaOuterLocalTest.java Wed May 14 11:01:08 2014 -0700 @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8029725 + * @summary Lambda reference to containing local class causes javac infinite recursion + * @author Robert Field + * @run main LambdaOuterLocalTest + */ + +public class LambdaOuterLocalTest { + interface F {void f();} + + static F f; + static StringBuffer sb = new StringBuffer(); + + static void assertEquals(Object val, Object expected) { + if (!val.equals(expected)) { + throw new AssertionError("expected '" + expected + "' got '" + val + "'"); + } + } + + public static void main(String[] args) { + class Local1 { + public Local1() { + class Local2 { + public Local2() { + f = () -> new Local1(); + sb.append("2"); + } + } + sb.append("1"); + new Local2(); + } + } + new Local1(); + f.f(); + assertEquals(sb.toString(), "1212"); + } +}
--- a/test/tools/javac/lambda/MethodReference42.out Tue May 13 23:18:48 2014 -0700 +++ b/test/tools/javac/lambda/MethodReference42.out Wed May 14 11:01:08 2014 -0700 @@ -1,4 +1,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)) -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)) +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))) +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))) MethodReference42.java:41:9: compiler.err.ref.ambiguous: m4, kindname.method, m4(MethodReference42.SAM2), MethodReference42, kindname.method, m4(MethodReference42.SAM3), MethodReference42 3 errors
--- a/test/tools/javac/lambda/MethodReference44.out Tue May 13 23:18:48 2014 -0700 +++ b/test/tools/javac/lambda/MethodReference44.out Wed May 14 11:01:08 2014 -0700 @@ -1,4 +1,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)) -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)) +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))) +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))) MethodReference44.java:43:9: compiler.err.ref.ambiguous: g4, kindname.method, g4(MethodReference44.SAM2), MethodReference44, kindname.method, g4(MethodReference44.SAM3), MethodReference44 3 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/SingleLocalTest.java Wed May 14 11:01:08 2014 -0700 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8029852 + * @summary Bad code generated (VerifyError) when lambda instantiates + * enclosing local class and has captured variables + */ +public class SingleLocalTest { + interface F {void f();} + + static F f; + + public static void main(String[] args) { + StringBuffer sb = new StringBuffer(); + class Local1 { + public Local1() { + f = () -> new Local1(); + sb.append("1"); + } + } + new Local1(); + f.f(); + String s = sb.toString(); + if (!s.equals("11")) { + throw new AssertionError("Expected '11' got '" + s + "'"); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/resolve/AmbiguityErrorTest.java Wed May 14 11:01:08 2014 -0700 @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8041663 + */ + +public class AmbiguityErrorTest { + + public interface A { } + + public interface B extends A { } + + public interface C { + A m(B strategy); + } + + public interface D { + A m(A strategy); + A m(B strategy); + } + + public interface T1 extends C, D { } + public interface T2 extends D, C { } + + int count; + + class T1Impl implements T1, T2 { + public A m(B strategy) { + count++; + return null; + } + public A m(A strategy) { + throw new AssertionError("Should not get here."); + } + } + + public static void main(String... args) { + new AmbiguityErrorTest().test(); + } + + void test() { + T1 t1 = new T1Impl(); + T2 t2 = new T1Impl(); + final B b = new B() { }; + t1.m(b); + t2.m(b); + + if (count != 2) { + throw new IllegalStateException("Did not call the methods properly"); + } + } + +}