Mercurial > hg > release > icedtea8-forest-3.0 > langtools
changeset 2519:948daf9c5e22 icedtea-3.0.0pre02
Merge jdk8u20-b23
author | andrew |
---|---|
date | Tue, 19 Aug 2014 23:57:05 +0100 |
parents | 655c9e5e37bc (current diff) 5c1d6da1445a (diff) |
children | b16cd22835f8 |
files | .hgtags src/share/classes/com/sun/tools/javac/jvm/ClassReader.java test/tools/javac/lambda/ErroneousLambdaExpr.java test/tools/javac/lambda/ErroneousLambdaExpr.out test/tools/javac/lambda/TargetType16.out |
diffstat | 186 files changed, 5885 insertions(+), 1122 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Mon Jun 02 18:51:25 2014 +0100 +++ b/.hgtags Tue Aug 19 23:57:05 2014 +0100 @@ -263,6 +263,7 @@ 9003a59a512e6b764d8a3f805aadc3996a58e5bd jdk8u5-b02 30e3dad0ebbdf3129bacd04a7f4cdecd3df92bb2 jdk8u5-b03 019dcdfffced0ca2026a0ad8c0e5fcb49d46116f jdk8u5-b04 +c9db8c800797258540e0411e58b8f7d59273de5f jdk8u11-b00 c9db8c800797258540e0411e58b8f7d59273de5f jdk8u5-b05 b1920c0b701d5ff219c9f622db5cafc9bf00d5c8 jdk8u5-b06 180df7f2c078f1efaa6fcd8ca9f55dc5f81b182c jdk8u5-b07 @@ -272,6 +273,20 @@ a12055904afd9f951131804868215e724c71b684 jdk8u5-b11 2a7002626e7997e946b96530629e2787bc1864bb jdk8u5-b12 9beafb58fb99e8b5f7577b2f26b12743ef4d07e7 jdk8u5-b13 +6614bfcdcd4d915b1b8e3ba3480d53ff83988290 jdk8u5-b31 +d37e407fba44f68c660f89be4e48f9e7b256a2d5 jdk8u11-b01 +e75f843c4bf81c79ca4c5d51dfe5fe39525c5301 jdk8u11-b02 +d9904b00b027b9176d6479dee7c7f4e054a68710 jdk8u11-b03 +5b5c46fe954cb744e2633e1ab097e934cc547a57 jdk8u11-b04 +f491f1581f196950c2cb858508dd06601968c417 jdk8u11-b05 +a4ecc38ec7910d5beb07be4623bd80dabe1fbfe8 jdk8u11-b06 +7803caf52e4b12f11e552565f55ef65aeb2be6a5 jdk8u11-b07 +a47aa3203c0210def786ab5ee685e97d07e8bf77 jdk8u11-b08 +e973a591a2182c0bdbdd9545ab13f83325acf1e6 jdk8u11-b09 +51cade4632608a6c0b8da33f420bd546aecf6faf jdk8u11-b10 +dc0d952b4199dc1cbc534c9afd535c78d21ed519 jdk8u11-b11 +0a79fea6f9cf713012211e933655175d52c6bc36 jdk8u11-b12 +16995a2b970df6be039cdaaedb5ade6099ffad8c jdk8u11-b31 26b33a6ea08810853af37e81c9b435465b289c98 jdk8u20-b02 a07271bca831cf1bab35a2ffbcebd8e060b2734b jdk8u20-b03 613c1d9930c9f650e3fc6926215931a85b679c66 jdk8u20-b04 @@ -284,3 +299,16 @@ 0f821eb7e92b242c878dca68ef63f9626643ee8f jdk8u20-b08 aa0cb3af23d376e012a142b0531c4f42032fdacf jdk8u20-b09 dd7b57ab4ab1a4bb93c543af3a13f66fe85a7802 icedtea-3.0.0pre01 +a0d9c18a1041c4217db9cda1817f0e348f1be885 jdk8u20-b10 +7ad480b982bf95b8a7290c8769b2698f6aacaf6b jdk8u20-b11 +e101a12a45a777268a2e729803499a7514255e5b jdk8u20-b12 +b5c2375893e2bca1883e5571bd911b6f0b533bf4 jdk8u20-b13 +5d39c29950f4d65e737f99e468427ae6454fa586 jdk8u20-b14 +9c577131ffa6aa0720c756232ae6e69bdff1c7ab jdk8u20-b15 +d9e6bb92751956ab7f0a469e2f3228a4dc5bb05f jdk8u20-b16 +b45fd486977d6cfe64c9947b7afd203c62ec4e98 jdk8u20-b17 +a550336d045faa63ac4439d4901d9f36e0b634bf jdk8u20-b18 +c04d99e00268ed87cfbdf76beb1a0ea08abd9a9c jdk8u20-b19 +e92effa22ecee1cb9965c278e45e2b1a6fbe0766 jdk8u20-b20 +7de1481c6cd88b42d815ae65e2d5b1cd918e11d1 jdk8u20-b21 +61fb0d8b169164ad5db15b6c497489cb30efb9c6 jdk8u20-b22
--- a/src/share/classes/com/sun/tools/classfile/Instruction.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/classfile/Instruction.java Tue Aug 19 23:57:05 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -25,6 +25,8 @@ package com.sun.tools.classfile; +import java.util.Locale; + /** * See JVMS, chapter 6. * @@ -211,7 +213,7 @@ if (opcode == null) return "bytecode " + getUnsignedByte(0); else - return opcode.toString().toLowerCase(); + return opcode.toString().toLowerCase(Locale.US); } /** Get the length, in bytes, of this instruction, including the opcode
--- a/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java Tue Aug 19 23:57:05 2014 +0100 @@ -37,6 +37,7 @@ import com.sun.tools.doclint.DocLint; import com.sun.tools.javac.file.JavacFileManager; import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.StringUtils; import com.sun.tools.javadoc.RootDocImpl; /** @@ -237,7 +238,7 @@ public void setSpecificDocletOptions(String[][] options) { for (int oi = 0; oi < options.length; ++oi) { String[] os = options[oi]; - String opt = os[0].toLowerCase(); + String opt = StringUtils.toLowerCase(os[0]); if (opt.equals("-footer")) { footer = os[1]; } else if (opt.equals("-header")) { @@ -325,7 +326,7 @@ return result; } // otherwise look for the options we have added - option = option.toLowerCase(); + option = StringUtils.toLowerCase(option); if (option.equals("-nodeprecatedlist") || option.equals("-noindex") || option.equals("-notree") || @@ -389,7 +390,7 @@ // otherwise look at our options for (int oi = 0; oi < options.length; ++oi) { String[] os = options[oi]; - String opt = os[0].toLowerCase(); + String opt = StringUtils.toLowerCase(os[0]); if (opt.equals("-helpfile")) { if (nohelp == true) { reporter.printError(getText("doclet.Option_conflict",
--- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Tue Aug 19 23:57:05 2014 +0100 @@ -28,12 +28,15 @@ import java.io.*; import java.text.SimpleDateFormat; import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import com.sun.javadoc.*; import com.sun.tools.doclets.formats.html.markup.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.taglets.*; import com.sun.tools.doclets.internal.toolkit.util.*; +import com.sun.tools.javac.util.StringUtils; /** * Class for the Html Format Code Generation specific to JavaDoc. @@ -138,42 +141,37 @@ if (index < 0) { return htmlstr; } - String lowerHtml = htmlstr.toLowerCase(); - // Return index of first occurrence of {@docroot} - // Note: {@docRoot} is not case sensitive when passed in w/command line option - index = lowerHtml.indexOf("{@docroot}", index); - if (index < 0) { + Matcher docrootMatcher = docrootPattern.matcher(htmlstr); + if (!docrootMatcher.find()) { return htmlstr; } StringBuilder buf = new StringBuilder(); - int previndex = 0; - while (true) { - final String docroot = "{@docroot}"; - // Search for lowercase version of {@docRoot} - index = lowerHtml.indexOf(docroot, previndex); - // If next {@docRoot} tag not found, append rest of htmlstr and exit loop - if (index < 0) { - buf.append(htmlstr.substring(previndex)); - break; - } - // If next {@docroot} tag found, append htmlstr up to start of tag - buf.append(htmlstr.substring(previndex, index)); - previndex = index + docroot.length(); - if (configuration.docrootparent.length() > 0 && htmlstr.startsWith("/..", previndex)) { + int prevEnd = 0; + do { + int match = docrootMatcher.start(); + // append htmlstr up to start of next {@docroot} + buf.append(htmlstr.substring(prevEnd, match)); + prevEnd = docrootMatcher.end(); + if (configuration.docrootparent.length() > 0 && htmlstr.startsWith("/..", prevEnd)) { // Insert the absolute link if {@docRoot} is followed by "/..". buf.append(configuration.docrootparent); - previndex += 3; + prevEnd += 3; } else { // Insert relative path where {@docRoot} was located buf.append(pathToRoot.isEmpty() ? "." : pathToRoot.getPath()); } // Append slash if next character is not a slash - if (previndex < htmlstr.length() && htmlstr.charAt(previndex) != '/') { + if (prevEnd < htmlstr.length() && htmlstr.charAt(prevEnd) != '/') { buf.append('/'); } - } + } while (docrootMatcher.find()); + buf.append(htmlstr.substring(prevEnd)); return buf.toString(); } + //where: + // Note: {@docRoot} is not case sensitive when passed in w/command line option: + private static final Pattern docrootPattern = + Pattern.compile(Pattern.quote("{@docroot}"), Pattern.CASE_INSENSITIVE); /** * Get the script to show or hide the All classes link. @@ -1689,13 +1687,13 @@ } //Redirect all relative links. - int end, begin = text.toLowerCase().indexOf("<a"); + int end, begin = StringUtils.indexOfIgnoreCase(text, "<a"); if(begin >= 0){ StringBuilder textBuff = new StringBuilder(text); while(begin >=0){ if (textBuff.length() > begin + 2 && ! Character.isWhitespace(textBuff.charAt(begin+2))) { - begin = textBuff.toString().toLowerCase().indexOf("<a", begin + 1); + begin = StringUtils.indexOfIgnoreCase(textBuff.toString(), "<a", begin + 1); continue; } @@ -1722,15 +1720,16 @@ } } String relativeLink = textBuff.substring(begin, end); - if (!(relativeLink.toLowerCase().startsWith("mailto:") || - relativeLink.toLowerCase().startsWith("http:") || - relativeLink.toLowerCase().startsWith("https:") || - relativeLink.toLowerCase().startsWith("file:"))) { + String relativeLinkLowerCase = StringUtils.toLowerCase(relativeLink); + if (!(relativeLinkLowerCase.startsWith("mailto:") || + relativeLinkLowerCase.startsWith("http:") || + relativeLinkLowerCase.startsWith("https:") || + relativeLinkLowerCase.startsWith("file:"))) { relativeLink = "{@"+(new DocRootTaglet()).getName() + "}/" + redirectPathFromRoot.resolve(relativeLink).getPath(); textBuff.replace(begin, end, relativeLink); } - begin = textBuff.toString().toLowerCase().indexOf("<a", begin + 1); + begin = StringUtils.indexOfIgnoreCase(textBuff.toString(), "<a", begin + 1); } return textBuff.toString(); } @@ -1771,7 +1770,7 @@ break main; ch = text.charAt(currPos); } - if (ch == '>' && blockTags.contains(text.substring(tagPos, currPos).toLowerCase())) { + if (ch == '>' && blockTags.contains(StringUtils.toLowerCase(text.substring(tagPos, currPos)))) { result.append(text, startPos, lessThanPos); startPos = currPos + 1; }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java Tue Aug 19 23:57:05 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -31,6 +31,7 @@ import com.sun.tools.doclets.formats.html.markup.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.util.*; +import com.sun.tools.javac.util.StringUtils; /** * Writes method documentation in HTML format. @@ -331,24 +332,6 @@ } /** - * Parse the <Code> tag and return the text. - */ - protected String parseCodeTag(String tag){ - if(tag == null){ - return ""; - } - - String lc = tag.toLowerCase(); - int begin = lc.indexOf("<code>"); - int end = lc.indexOf("</code>"); - if(begin == -1 || end == -1 || end <= begin){ - return tag; - } else { - return tag.substring(begin + 6, end); - } - } - - /** * {@inheritDoc} */ protected static void addImplementsInfo(HtmlDocletWriter writer,
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlAttr.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlAttr.java Tue Aug 19 23:57:05 2014 +0100 @@ -25,6 +25,8 @@ package com.sun.tools.doclets.formats.html.markup; +import com.sun.tools.javac.util.StringUtils; + /** * Enum representing HTML tag attributes. * @@ -64,7 +66,7 @@ private final String value; HtmlAttr() { - this.value = name().toLowerCase(); + this.value = StringUtils.toLowerCase(name()); } HtmlAttr(String name) {
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTag.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTag.java Tue Aug 19 23:57:05 2014 +0100 @@ -25,7 +25,7 @@ package com.sun.tools.doclets.formats.html.markup; -import java.util.Locale; +import com.sun.tools.javac.util.StringUtils; /** * Enum representing HTML tags. @@ -117,7 +117,7 @@ HtmlTag(BlockType blockType, EndTag endTag ) { this.blockType = blockType; this.endTag = endTag; - this.value = name().toLowerCase(Locale.US); + this.value = StringUtils.toLowerCase(name()); } /**
--- a/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_ja.properties Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_ja.properties Tue Aug 19 23:57:05 2014 +0100 @@ -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/Configuration.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java Tue Aug 19 23:57:05 2014 +0100 @@ -29,6 +29,7 @@ import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.tools.JavaFileManager; import com.sun.javadoc.*; import com.sun.tools.javac.sym.Profiles; @@ -36,7 +37,7 @@ import com.sun.tools.doclets.internal.toolkit.builders.BuilderFactory; import com.sun.tools.doclets.internal.toolkit.taglets.*; import com.sun.tools.doclets.internal.toolkit.util.*; -import javax.tools.JavaFileManager; +import com.sun.tools.javac.util.StringUtils; /** * Configure the output based on the options. Doclets should sub-class @@ -337,7 +338,7 @@ * Negative value means error occurred. */ public int optionLength(String option) { - option = option.toLowerCase(); + option = StringUtils.toLowerCase(option); if (option.equals("-author") || option.equals("-docfilessubdirs") || option.equals("-javafx") || @@ -454,7 +455,7 @@ // the output directory has already been created: so do that first. for (int oi = 0; oi < options.length; ++oi) { String[] os = options[oi]; - String opt = os[0].toLowerCase(); + String opt = StringUtils.toLowerCase(os[0]); if (opt.equals("-d")) { destDirName = addTrailingFileSep(os[1]); docFileDestDirName = destDirName; @@ -465,7 +466,7 @@ for (int oi = 0; oi < options.length; ++oi) { String[] os = options[oi]; - String opt = os[0].toLowerCase(); + String opt = StringUtils.toLowerCase(os[0]); if (opt.equals("-docfilessubdirs")) { copydocfilesubdirs = true; } else if (opt.equals("-docencoding")) { @@ -708,7 +709,7 @@ String encoding = ""; for (int oi = 0; oi < options.length; oi++) { String[] os = options[oi]; - String opt = os[0].toLowerCase(); + String opt = StringUtils.toLowerCase(os[0]); if (opt.equals("-docencoding")) { docencodingfound = true; if (!checkOutputFileEncoding(os[1], reporter)) {
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java Tue Aug 19 23:57:05 2014 +0100 @@ -384,13 +384,13 @@ commentTextBuilder.append( MessageFormat.format( configuration.getText("doclet.PropertySetterWithName"), - Util.propertyNameFromMethodName(member.name()))); + Util.propertyNameFromMethodName(configuration, member.name()))); } if (isGetter) { commentTextBuilder.append( MessageFormat.format( configuration.getText("doclet.PropertyGetterWithName"), - Util.propertyNameFromMethodName(member.name()))); + Util.propertyNameFromMethodName(configuration, member.name()))); } if (propertyDoc.commentText() != null && !propertyDoc.commentText().isEmpty()) {
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java Tue Aug 19 23:57:05 2014 +0100 @@ -31,6 +31,7 @@ import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.util.*; +import com.sun.tools.javac.util.StringUtils; /** * Builds the serialized form. @@ -567,7 +568,7 @@ } Tag[] serial = doc.tags("serial"); if (serial.length > 0) { - String serialtext = serial[0].text().toLowerCase(); + String serialtext = StringUtils.toLowerCase(serial[0].text()); if (serialtext.indexOf("exclude") >= 0) { return false; } else if (serialtext.indexOf("include") >= 0) {
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_ja.properties Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_ja.properties Tue Aug 19 23:57:05 2014 +0100 @@ -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/doclets/internal/toolkit/taglets/SimpleTaglet.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SimpleTaglet.java Tue Aug 19 23:57:05 2014 +0100 @@ -28,6 +28,7 @@ import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.Content; import com.sun.tools.doclets.internal.toolkit.util.DocFinder; +import com.sun.tools.javac.util.StringUtils; /** * A simple single argument custom tag. @@ -110,7 +111,7 @@ public SimpleTaglet(String tagName, String header, String locations) { this.tagName = tagName; this.header = header; - locations = locations.toLowerCase(); + locations = StringUtils.toLowerCase(locations); if (locations.indexOf(ALL) != -1 && locations.indexOf(EXCLUDED) == -1) { this.locations = PACKAGE + TYPE + FIELD + METHOD + CONSTRUCTOR + OVERVIEW; } else {
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java Tue Aug 19 23:57:05 2014 +0100 @@ -35,6 +35,7 @@ import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.util.*; +import com.sun.tools.javac.util.StringUtils; /** * Manages the<code>Taglet</code>s used by doclets. @@ -304,7 +305,7 @@ return; } Taglet tag = customTags.get(tagName); - locations = locations.toLowerCase(); + locations = StringUtils.toLowerCase(locations); if (tag == null || header != null) { customTags.remove(tagName); customTags.put(tagName, new SimpleTaglet(tagName, header, locations)); @@ -375,7 +376,7 @@ name = name.substring(1, name.length()); } if (! (standardTags.contains(name) || customTags.containsKey(name))) { - if (standardTagsLowercase.contains(name.toLowerCase())) { + if (standardTagsLowercase.contains(StringUtils.toLowerCase(name))) { message.warning(tags[i].position(), "doclet.UnknownTagLowercase", tags[i].name()); continue; } else { @@ -708,7 +709,7 @@ private void initStandardTagsLowercase() { Iterator<String> it = standardTags.iterator(); while (it.hasNext()) { - standardTagsLowercase.add(it.next().toLowerCase()); + standardTagsLowercase.add(StringUtils.toLowerCase(it.next())); } }
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java Tue Aug 19 23:57:05 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -177,7 +177,7 @@ try { url = adjustEndFileSeparator(url); if (isUrl(pkglisturl)) { - readPackageListFromURL(url, toURL(pkglisturl)); + readPackageListFromURL(url, toURL(adjustEndFileSeparator(pkglisturl))); } else { readPackageListFromFile(url, DocFile.createFileForInput(configuration, pkglisturl)); }
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java Tue Aug 19 23:57:05 2014 +0100 @@ -28,11 +28,12 @@ import java.io.*; import java.lang.annotation.ElementType; import java.util.*; +import javax.tools.StandardLocation; import com.sun.javadoc.*; import com.sun.javadoc.AnnotationDesc.ElementValuePair; import com.sun.tools.doclets.internal.toolkit.*; -import javax.tools.StandardLocation; +import com.sun.tools.javac.util.StringUtils; /** * Utilities Class for Doclets. @@ -253,8 +254,8 @@ */ private static class TypeComparator implements Comparator<Type> { public int compare(Type type1, Type type2) { - return type1.qualifiedTypeName().toLowerCase().compareTo( - type2.qualifiedTypeName().toLowerCase()); + return type1.qualifiedTypeName().compareToIgnoreCase( + type2.qualifiedTypeName()); } } @@ -589,7 +590,7 @@ typeName = "doclet.Enum"; } return config.getText( - lowerCaseOnly ? typeName.toLowerCase() : typeName); + lowerCaseOnly ? StringUtils.toLowerCase(typeName) : typeName); } /** @@ -724,7 +725,7 @@ * @param name name of the getter or setter method. * @return the name of the property of the given setter of getter. */ - public static String propertyNameFromMethodName(String name) { + public static String propertyNameFromMethodName(Configuration configuration, String name) { String propertyName = null; if (name.startsWith("get") || name.startsWith("set")) { propertyName = name.substring(3); @@ -734,7 +735,7 @@ if ((propertyName == null) || propertyName.isEmpty()){ return ""; } - return propertyName.substring(0, 1).toLowerCase() + return propertyName.substring(0, 1).toLowerCase(configuration.getLocale()) + propertyName.substring(1); }
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java Tue Aug 19 23:57:05 2014 +0100 @@ -702,7 +702,7 @@ private boolean isPropertyGetterOrSetter(MethodDoc[] members, MethodDoc methodDoc) { boolean found = false; - String propertyName = Util.propertyNameFromMethodName(methodDoc.name()); + String propertyName = Util.propertyNameFromMethodName(configuration, methodDoc.name()); if (!propertyName.isEmpty()) { String propertyMethodName = propertyName + "Property"; for (MethodDoc member: members) {
--- a/src/share/classes/com/sun/tools/doclint/Checker.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclint/Checker.java Tue Aug 19 23:57:05 2014 +0100 @@ -80,6 +80,7 @@ import com.sun.source.util.TreePath; import com.sun.tools.doclint.HtmlTag.AttrKind; import com.sun.tools.javac.tree.DocPretty; +import com.sun.tools.javac.util.StringUtils; import static com.sun.tools.doclint.Messages.Group.*; @@ -243,7 +244,7 @@ markEnclosingTag(Flag.HAS_TEXT); String name = tree.getName().toString(); if (name.startsWith("#")) { - int v = name.toLowerCase().startsWith("#x") + int v = StringUtils.toLowerCase(name).startsWith("#x") ? Integer.parseInt(name.substring(2), 16) : Integer.parseInt(name.substring(1), 10); if (!Entity.isValid(v)) {
--- a/src/share/classes/com/sun/tools/doclint/Env.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclint/Env.java Tue Aug 19 23:57:05 2014 +0100 @@ -44,6 +44,7 @@ import com.sun.source.util.TreePath; import com.sun.tools.javac.model.JavacTypes; import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.util.StringUtils; /** * Utility container for current execution environment, @@ -66,7 +67,7 @@ static boolean accepts(String opt) { for (AccessKind g: values()) - if (opt.equals(g.name().toLowerCase())) return true; + if (opt.equals(StringUtils.toLowerCase(g.name()))) return true; return false; }
--- a/src/share/classes/com/sun/tools/doclint/HtmlTag.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclint/HtmlTag.java Tue Aug 19 23:57:05 2014 +0100 @@ -36,6 +36,7 @@ import javax.lang.model.element.Name; import static com.sun.tools.doclint.HtmlTag.Attr.*; +import com.sun.tools.javac.util.StringUtils; /** * Enum representing HTML tags. @@ -352,7 +353,7 @@ WIDTH; public String getText() { - return toLowerCase(name()); + return StringUtils.toLowerCase(name()); } static final Map<String,Attr> index = new HashMap<String,Attr>(); @@ -431,11 +432,11 @@ } public String getText() { - return toLowerCase(name()); + return StringUtils.toLowerCase(name()); } public Attr getAttr(Name attrName) { - return Attr.index.get(toLowerCase(attrName.toString())); + return Attr.index.get(StringUtils.toLowerCase(attrName.toString())); } public AttrKind getAttrKind(Name attrName) { @@ -457,10 +458,7 @@ } static HtmlTag get(Name tagName) { - return index.get(toLowerCase(tagName.toString())); + return index.get(StringUtils.toLowerCase(tagName.toString())); } - private static String toLowerCase(String s) { - return s.toLowerCase(Locale.US); - } }
--- a/src/share/classes/com/sun/tools/doclint/Messages.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclint/Messages.java Tue Aug 19 23:57:05 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -42,6 +42,7 @@ import com.sun.source.doctree.DocTree; import com.sun.source.tree.Tree; import com.sun.tools.doclint.Env.AccessKind; +import com.sun.tools.javac.util.StringUtils; /** * Message reporting for DocLint. @@ -67,7 +68,7 @@ SYNTAX, REFERENCE; - String optName() { return name().toLowerCase(); } + String optName() { return StringUtils.toLowerCase(name()); } String notOptName() { return "-" + optName(); } static boolean accepts(String opt) { @@ -158,7 +159,7 @@ static boolean isValidOptions(String opts) { for (String opt: opts.split(",")) { - if (!isValidOption(opt.trim().toLowerCase())) + if (!isValidOption(StringUtils.toLowerCase(opt.trim()))) return false; } return true; @@ -203,7 +204,7 @@ setOption(ALL, Env.AccessKind.PRIVATE); else { for (String opt: opts.split(",")) - setOption(opt.trim().toLowerCase()); + setOption(StringUtils.toLowerCase(opt.trim())); } } @@ -215,7 +216,7 @@ int sep = arg.indexOf("/"); if (sep > 0) { - Env.AccessKind ak = Env.AccessKind.valueOf(arg.substring(sep + 1).toUpperCase()); + Env.AccessKind ak = Env.AccessKind.valueOf(StringUtils.toUpperCase(arg.substring(sep + 1))); setOption(arg.substring(0, sep), ak); } else { setOption(arg, null); @@ -290,7 +291,7 @@ out.println("By diagnostic kind..."); Table dkindTable = new Table(); for (Diagnostic.Kind k : Diagnostic.Kind.values()) { - dkindTable.put(k.toString().toLowerCase(), dkindCounts[k.ordinal()]); + dkindTable.put(StringUtils.toLowerCase(k.toString()), dkindCounts[k.ordinal()]); } dkindTable.print(out); out.println();
--- a/src/share/classes/com/sun/tools/doclint/resources/doclint_ja.properties Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclint/resources/doclint_ja.properties Tue Aug 19 23:57:05 2014 +0100 @@ -1,5 +1,5 @@ # -# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -75,4 +75,4 @@ dc.main.ioerror=IO\u30A8\u30E9\u30FC: {0} dc.main.no.files.given=\u30D5\u30A1\u30A4\u30EB\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093 dc.main.usage=\u4F7F\u7528\u65B9\u6CD5:\n doclint [options] source-files...\n\n\u30AA\u30D7\u30B7\u30E7\u30F3:\n -Xmsgs \n -Xmsgs:all\u3068\u540C\u3058\n -Xmsgs:values\n \u30C1\u30A7\u30C3\u30AF\u3059\u308B\u554F\u984C\u306E\u30AB\u30C6\u30B4\u30EA\u3092\u6307\u5B9A\u3057\u307E\u3059\u3002\u3053\u3053\u3067\u306E''values''\u306F\u3001\n \u30AB\u30F3\u30DE\u3067\u533A\u5207\u3089\u308C\u305F\u6B21\u306E\u5024\u306E\u30EA\u30B9\u30C8\u3067\u3059:\n reference Java\u30BD\u30FC\u30B9\u30FB\u30B3\u30FC\u30C9\u8981\u7D20\u3078\u306E\u4E0D\u6B63\u306A\u53C2\u7167\u3092\u542B\u3080\u30B3\u30E1\u30F3\u30C8\u306E\n \u5834\u6240\u3092\u8868\u793A\u3057\u307E\u3059\n syntax \u30B3\u30E1\u30F3\u30C8\u5185\u306E\u57FA\u672C\u69CB\u6587\u30A8\u30E9\u30FC\u3092\u8868\u793A\u3057\u307E\u3059\n html HTML\u30BF\u30D6\u304A\u3088\u3073\u5C5E\u6027\u306E\u554F\u984C\u3092\u8868\u793A\u3057\u307E\u3059\n accessibility \u30A2\u30AF\u30BB\u30B7\u30D3\u30EA\u30C6\u30A3\u306E\u554F\u984C\u3092\u8868\u793A\u3057\u307E\u3059\n missing \u6B20\u843D\u3057\u3066\u3044\u308B\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u554F\u984C\u3092\u8868\u793A\u3057\u307E\u3059\n all \u524D\u8FF0\u306E\u3059\u3079\u3066\n \u3053\u308C\u3092\u5426\u5B9A\u3059\u308B\u306B\u306F\u3001\u5024\u306E\u524D\u306B''-''\u3092\u6307\u5B9A\u3057\u307E\u3059\n \u30AB\u30C6\u30B4\u30EA\u306F\u3001\u6B21\u306E\u3044\u305A\u308C\u304B\u3067\u4FEE\u98FE\u3067\u304D\u307E\u3059:\n /public /protected /package /private\n \u6B63\u306E\u30AB\u30C6\u30B4\u30EA(''-''\u3067\u59CB\u307E\u3089\u306A\u3044)\u306E\u5834\u5408\n \u4FEE\u98FE\u5B50\u306F\u3001\u305D\u306E\u30A2\u30AF\u30BB\u30B9\u30FB\u30EC\u30D9\u30EB\u4EE5\u4E0A\u306B\u9069\u7528\u3055\u308C\u307E\u3059\u3002\n \u8CA0\u306E\u30AB\u30C6\u30B4\u30EA(''-''\u3067\u59CB\u307E\u308B)\u306E\u5834\u5408\n \u4FEE\u98FE\u5B50\u306F\u3001\u305D\u306E\u30A2\u30AF\u30BB\u30B9\u30FB\u30EC\u30D9\u30EB\u4EE5\u4E0B\u306B\u9069\u7528\u3055\u308C\u307E\u3059\u3002\n \u4FEE\u98FE\u5B50\u304C\u306A\u3044\u5834\u5408\u3001\u30AB\u30C6\u30B4\u30EA\u306F\u3059\u3079\u3066\u306E\u30A2\u30AF\u30BB\u30B9\u30FB\u30EC\u30D9\u30EB\u306B\n \u9069\u7528\u3055\u308C\u307E\u3059\u3002\n \u4F8B: -Xmsgs:all,-syntax/private\n \u3053\u306E\u5834\u5408\u3001private\u30E1\u30BD\u30C3\u30C9\u306Edoc\u30B3\u30E1\u30F3\u30C8\u5185\u306E\u69CB\u6587\u30A8\u30E9\u30FC\u3092\u9664\u304D\u3001\n \u3059\u3079\u3066\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u6709\u52B9\u5316\u3055\u308C\u307E\u3059\u3002\n -Xmsgs\u30AA\u30D7\u30B7\u30E7\u30F3\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u306A\u3044\u5834\u5408\u3001\u30C7\u30D5\u30A9\u30EB\u30C8\u306F\u3001\n -Xmsgs:all/protected\u3068\u540C\u7B49\u306B\u306A\u308A\u3001\u3053\u308C\u306F\n \u3059\u3079\u3066\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u3001protected\u304A\u3088\u3073public\u306E\u5BA3\u8A00\u306E\u307F\u306B\u5831\u544A\u3055\u308C\u308B\u3053\u3068\u3092\n \u610F\u5473\u3057\u307E\u3059\u3002\n -stats\n \u5831\u544A\u3055\u308C\u305F\u554F\u984C\u306B\u5BFE\u3057\u3066\u7D71\u8A08\u3092\u5831\u544A\u3057\u307E\u3059\u3002\n -h -help --help -usage -?\n \u3053\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u8868\u793A\u3055\u308C\u307E\u3059\u3002\n\n\u6B21\u306Ejavac\u30AA\u30D7\u30B7\u30E7\u30F3\u3082\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u3059\n \ --bootclasspath\u3001-classpath\u3001-cp\u3001-sourcepath\u3001-Xmaxerrs\u3001-Xmaxwarns\n\n\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u4E00\u90E8\u306B\u5BFE\u3057\u3066doclint\u3092\u5B9F\u884C\u3059\u308B\u306B\u306F\u3001\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u30B3\u30F3\u30D1\u30A4\u30EB\u3055\u308C\u305F\u30AF\u30E9\u30B9\u3092\n\u30AF\u30E9\u30B9\u30D1\u30B9(\u307E\u305F\u306F\u30D6\u30FC\u30C8\u30FB\u30AF\u30E9\u30B9\u30D1\u30B9)\u306B\u6307\u5B9A\u3057\u3001\u30B3\u30DE\u30F3\u30C9\u30FB\u30E9\u30A4\u30F3\u3067\n\u30C1\u30A7\u30C3\u30AF\u3059\u308B\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u6307\u5B9A\u3057\u307E\u3059\u3002 +-bootclasspath\u3001-classpath\u3001-cp\u3001-sourcepath\u3001-Xmaxerrs\u3001-Xmaxwarns\n\n\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u4E00\u90E8\u306B\u5BFE\u3057\u3066doclint\u3092\u5B9F\u884C\u3059\u308B\u306B\u306F\u3001\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u30B3\u30F3\u30D1\u30A4\u30EB\u3055\u308C\u305F\u30AF\u30E9\u30B9\u3092\n\u30AF\u30E9\u30B9\u30D1\u30B9(\u307E\u305F\u306F\u30D6\u30FC\u30C8\u30FB\u30AF\u30E9\u30B9\u30D1\u30B9)\u306B\u6307\u5B9A\u3057\u3001\u30B3\u30DE\u30F3\u30C9\u884C\u3067\n\u30C1\u30A7\u30C3\u30AF\u3059\u308B\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u6307\u5B9A\u3057\u307E\u3059\u3002
--- a/src/share/classes/com/sun/tools/javac/api/JavacTrees.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/api/JavacTrees.java Tue Aug 19 23:57:05 2014 +0100 @@ -407,7 +407,7 @@ paramTypes = lb.toList(); } - ClassSymbol sym = (ClassSymbol) types.upperBound(tsym.type).tsym; + ClassSymbol sym = (ClassSymbol) types.cvarUpperBound(tsym.type).tsym; Symbol msym = (memberName == sym.name) ? findConstructor(sym, paramTypes)
--- a/src/share/classes/com/sun/tools/javac/code/Flags.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Flags.java Tue Aug 19 23:57:05 2014 +0100 @@ -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 @@ -33,6 +33,7 @@ import javax.lang.model.element.Modifier; import com.sun.tools.javac.util.Assert; +import com.sun.tools.javac.util.StringUtils; /** Access flags and other modifiers for Java classes and members. * @@ -275,6 +276,11 @@ */ public static final long LAMBDA_METHOD = 1L<<49; + /** + * Flag to control recursion in TransTypes + */ + public static final long TYPE_TRANSLATED = 1L<<50; + /** Modifier masks. */ public static final int @@ -294,7 +300,8 @@ ModifierFlags = ((long)StandardFlags & ~INTERFACE) | DEFAULT, InterfaceMethodMask = ABSTRACT | STATIC | PUBLIC | STRICTFP | DEFAULT, AnnotationTypeElementMask = ABSTRACT | PUBLIC, - LocalVarFlags = FINAL | PARAMETER; + LocalVarFlags = FINAL | PARAMETER, + ReceiverParamFlags = PARAMETER; public static Set<Modifier> asModifierSet(long flags) { @@ -384,11 +391,12 @@ BAD_OVERRIDE(Flags.BAD_OVERRIDE), SIGNATURE_POLYMORPHIC(Flags.SIGNATURE_POLYMORPHIC), THROWS(Flags.THROWS), - LAMBDA_METHOD(Flags.LAMBDA_METHOD); + LAMBDA_METHOD(Flags.LAMBDA_METHOD), + TYPE_TRANSLATED(Flags.TYPE_TRANSLATED); Flag(long flag) { this.value = flag; - this.lowercaseName = name().toLowerCase(); + this.lowercaseName = StringUtils.toLowerCase(name()); } @Override
--- a/src/share/classes/com/sun/tools/javac/code/Source.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Source.java Tue Aug 19 23:57:05 2014 +0100 @@ -191,6 +191,9 @@ public boolean allowObjectToPrimitiveCast() { return compareTo(JDK1_7) >= 0; } + public boolean enforceThisDotInit() { + return compareTo(JDK1_7) >= 0; + } public boolean allowPoly() { return compareTo(JDK1_8) >= 0; } @@ -215,6 +218,9 @@ public boolean allowTypeAnnotations() { return compareTo(JDK1_8) >= 0; } + public boolean allowAnnotationsAfterTypeParams() { + return compareTo(JDK1_8) >= 0; + } public boolean allowRepeatedAnnotations() { return compareTo(JDK1_8) >= 0; } @@ -224,7 +230,7 @@ public boolean allowGraphInference() { return compareTo(JDK1_8) >= 0; } - public boolean allowStructuralMostSpecific() { + public boolean allowFunctionalInterfaceMostSpecific() { return compareTo(JDK1_8) >= 0; } public static SourceVersion toSourceVersion(Source source) {
--- a/src/share/classes/com/sun/tools/javac/code/Symbol.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java Tue Aug 19 23:57:05 2014 +0100 @@ -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) @@ -779,42 +779,41 @@ @Override public List<Attribute.Compound> getAnnotationMirrors() { - return onlyTypeVariableAnnotations(owner.getRawTypeAttributes()); - } - - private List<Attribute.Compound> onlyTypeVariableAnnotations( - List<Attribute.TypeCompound> candidates) { - // Declaration annotations on TypeParameters are stored in type attributes + // Declaration annotations on type variables are stored in type attributes + // on the owner of the TypeVariableSymbol + List<Attribute.TypeCompound> candidates = owner.getRawTypeAttributes(); + int index = owner.getTypeParameters().indexOf(this); List<Attribute.Compound> res = List.nil(); for (Attribute.TypeCompound a : candidates) { - if (a.position.type == TargetType.CLASS_TYPE_PARAMETER || - a.position.type == TargetType.METHOD_TYPE_PARAMETER) + if (isCurrentSymbolsAnnotation(a, index)) res = res.prepend(a); } - return res = res.reverse(); + return res.reverse(); } - - // Helper to getAnnotation[s] @Override public <A extends Annotation> Attribute.Compound getAttribute(Class<A> annoType) { - String name = annoType.getName(); // Declaration annotations on type variables are stored in type attributes // on the owner of the TypeVariableSymbol List<Attribute.TypeCompound> candidates = owner.getRawTypeAttributes(); + int index = owner.getTypeParameters().indexOf(this); for (Attribute.TypeCompound anno : candidates) - if (anno.position.type == TargetType.CLASS_TYPE_PARAMETER || - anno.position.type == TargetType.METHOD_TYPE_PARAMETER) - if (name.contentEquals(anno.type.tsym.flatName())) - return anno; + if (isCurrentSymbolsAnnotation(anno, index) && + name.contentEquals(anno.type.tsym.flatName())) + return anno; return null; } - + //where: + boolean isCurrentSymbolsAnnotation(Attribute.TypeCompound anno, int index) { + return (anno.position.type == TargetType.CLASS_TYPE_PARAMETER || + anno.position.type == TargetType.METHOD_TYPE_PARAMETER) && + anno.position.parameter_index == index; + } @Override
--- a/src/share/classes/com/sun/tools/javac/code/Type.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java Tue Aug 19 23:57:05 2014 +0100 @@ -72,13 +72,28 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { /** Constant type: no type at all. */ - public static final JCNoType noType = new JCNoType(); + public static final JCNoType noType = new JCNoType() { + @Override + public String toString() { + return "none"; + } + }; /** Constant type: special type to be used during recovery of deferred expressions. */ - public static final JCNoType recoveryType = new JCNoType(); + public static final JCNoType recoveryType = new JCNoType(){ + @Override + public String toString() { + return "recovery"; + } + }; /** Constant type: special type to be used for marking stuck trees. */ - public static final JCNoType stuckType = new JCNoType(); + public static final JCNoType stuckType = new JCNoType() { + @Override + public String toString() { + return "stuck"; + } + }; /** If this switch is turned on, the names of type variables * and anonymous classes are printed with hashcodes appended. @@ -1445,12 +1460,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 */
--- a/src/share/classes/com/sun/tools/javac/code/Types.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Tue Aug 19 23:57:05 2014 +0100 @@ -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.*; @@ -121,61 +122,57 @@ } // </editor-fold> - // <editor-fold defaultstate="collapsed" desc="upperBound"> + // <editor-fold defaultstate="collapsed" desc="bounds"> + /** + * Get a wildcard's upper bound, returning non-wildcards unchanged. + * @param t a type argument, either a wildcard or a type + */ + public Type wildUpperBound(Type t) { + if (t.hasTag(WILDCARD)) { + WildcardType w = (WildcardType) t.unannotatedType(); + if (w.isSuperBound()) + return w.bound == null ? syms.objectType : w.bound.bound; + else + return wildUpperBound(w.type); + } + else return t.unannotatedType(); + } + + /** + * Get a capture variable's upper bound, returning other types unchanged. + * @param t a type + */ + public Type cvarUpperBound(Type t) { + if (t.hasTag(TYPEVAR)) { + TypeVar v = (TypeVar) t.unannotatedType(); + return v.isCaptured() ? cvarUpperBound(v.bound) : v; + } + else return t.unannotatedType(); + } + /** - * The "rvalue conversion".<br> - * The upper bound of most types is the type - * itself. Wildcards, on the other hand have upper - * and lower bounds. - * @param t a type - * @return the upper 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 upperBound(Type t) { - return upperBound.visit(t).unannotatedType(); + public Type wildLowerBound(Type t) { + if (t.hasTag(WILDCARD)) { + WildcardType w = (WildcardType) t.unannotatedType(); + return w.isExtendsBound() ? syms.botType : wildLowerBound(w.type); + } + else return t.unannotatedType(); } - // where - private final MapVisitor<Void> upperBound = new MapVisitor<Void>() { - - @Override - public Type visitWildcardType(WildcardType t, Void ignored) { - if (t.isSuperBound()) - return t.bound == null ? syms.objectType : t.bound.bound; - else - return visit(t.type); - } - - @Override - public Type visitCapturedType(CapturedType t, Void ignored) { - return visit(t.bound); - } - }; - // </editor-fold> - - // <editor-fold defaultstate="collapsed" desc="lowerBound"> + /** - * The "lvalue conversion".<br> - * The lower bound of most types is the type - * itself. Wildcards, on the other hand have upper - * and lower bounds. + * Get a capture variable's lower bound, returning other types unchanged. * @param t a type - * @return the lower bound of the given type */ - public Type lowerBound(Type t) { - return lowerBound.visit(t); + public Type cvarLowerBound(Type t) { + if (t.hasTag(TYPEVAR)) { + TypeVar v = (TypeVar) t.unannotatedType(); + return v.isCaptured() ? cvarLowerBound(v.getLowerBound()) : v; + } + else return t.unannotatedType(); } - // 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="isUnbounded"> @@ -305,8 +302,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); @@ -632,7 +629,7 @@ * (ii) perform functional interface bridge calculation. */ public ClassSymbol makeFunctionalInterfaceClass(Env<AttrContext> env, Name name, List<Type> targets, long cflags) { - if (targets.isEmpty() || !isFunctionalInterface(targets.head)) { + if (targets.isEmpty()) { return null; } Symbol descSym = findDescriptorSymbol(targets.head.tsym); @@ -827,9 +824,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); } @@ -897,7 +900,7 @@ syms.boundClass); changed = true; } else if (s != orig) { - s = new WildcardType(upperBound(s), + s = new WildcardType(wildUpperBound(s), BoundKind.EXTENDS, syms.boundClass); changed = true; @@ -913,14 +916,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()); @@ -1109,7 +1109,7 @@ //check that u == t, where u has been set by Type.withTypeVar return s.isSuperBound() && !s.isExtendsBound() && - visit(t, upperBound(s)); + visit(t, wildUpperBound(s)); } } default: @@ -1136,7 +1136,7 @@ return visit(s, t); if (s.isSuperBound() && !s.isExtendsBound()) - return visit(t, upperBound(s)) && visit(t, lowerBound(s)); + return visit(t, wildUpperBound(s)) && visit(t, wildLowerBound(s)); if (t.isCompound() && s.isCompound()) { if (!visit(supertype(t), supertype(s))) @@ -1222,14 +1222,35 @@ TypeRelation isSameTypeLoose = new LooseSameTypeVisitor(); private class LooseSameTypeVisitor extends SameTypeVisitor { + + /** cache of the type-variable pairs being (recursively) tested. */ + private Set<TypePair> cache = new HashSet<>(); + @Override boolean sameTypeVars(TypeVar tv1, TypeVar tv2) { - return tv1.tsym == tv2.tsym && visit(tv1.getUpperBound(), tv2.getUpperBound()); + return tv1.tsym == tv2.tsym && checkSameBounds(tv1, tv2); } @Override protected boolean containsTypes(List<Type> ts1, List<Type> ts2) { return containsTypeEquivalent(ts1, ts2); } + + /** + * Since type-variable bounds can be recursive, we need to protect against + * infinite loops - where the same bounds are checked over and over recursively. + */ + private boolean checkSameBounds(TypeVar tv1, TypeVar tv2) { + TypePair p = new TypePair(tv1, tv2, true); + if (cache.add(p)) { + try { + return visit(tv1.getUpperBound(), tv2.getUpperBound()); + } finally { + cache.remove(p); + } + } else { + return false; + } + } }; /** @@ -1286,12 +1307,12 @@ switch(wt.kind) { case UNBOUND: //similar to ? extends Object case EXTENDS: { - Type bound = upperBound(s); + Type bound = wildUpperBound(s); undetvar.addBound(InferenceBound.UPPER, bound, this); break; } case SUPER: { - Type bound = lowerBound(s); + Type bound = wildLowerBound(s); undetvar.addBound(InferenceBound.LOWER, bound, this); break; } @@ -1347,28 +1368,6 @@ // where private TypeRelation containsType = new TypeRelation() { - private Type U(Type t) { - while (t.hasTag(WILDCARD)) { - WildcardType w = (WildcardType)t.unannotatedType(); - if (w.isSuperBound()) - return w.bound == null ? syms.objectType : w.bound.bound; - else - t = w.type; - } - return t; - } - - private Type L(Type t) { - while (t.hasTag(WILDCARD)) { - WildcardType w = (WildcardType)t.unannotatedType(); - if (w.isExtendsBound()) - return syms.botType; - else - t = w.type; - } - return t; - } - public Boolean visitType(Type t, Type s) { if (s.isPartial()) return containedBy(s, t); @@ -1380,13 +1379,13 @@ // System.err.println(); // System.err.format(" does %s contain %s?%n", t, s); // System.err.format(" %s U(%s) <: U(%s) %s = %s%n", -// upperBound(s), s, t, U(t), +// wildUpperBound(s), s, t, wildUpperBound(t), // t.isSuperBound() -// || isSubtypeNoCapture(upperBound(s), U(t))); +// || isSubtypeNoCapture(wildUpperBound(s), wildUpperBound(t))); // System.err.format(" %s L(%s) <: L(%s) %s = %s%n", -// L(t), t, s, lowerBound(s), +// wildLowerBound(t), t, s, wildLowerBound(s), // t.isExtendsBound() -// || isSubtypeNoCapture(L(t), lowerBound(s))); +// || isSubtypeNoCapture(wildLowerBound(t), wildLowerBound(s))); // System.err.println(); // } @@ -1398,8 +1397,9 @@ // debugContainsType(t, s); return isSameWildcard(t, s) || isCaptureOf(s, t) - || ((t.isExtendsBound() || isSubtypeNoCapture(L(t), lowerBound(s))) && - (t.isSuperBound() || isSubtypeNoCapture(upperBound(s), U(t)))); + || ((t.isExtendsBound() || isSubtypeNoCapture(wildLowerBound(t), cvarLowerBound(wildLowerBound(s)))) && + // TODO: JDK-8039214, cvarUpperBound call here is incorrect + (t.isSuperBound() || isSubtypeNoCapture(cvarUpperBound(wildUpperBound(s)), wildUpperBound(t)))); } } @@ -1517,7 +1517,7 @@ @Override public Boolean visitWildcardType(WildcardType t, Type s) { - return isCastable(upperBound(t), s, warnStack.head); + return isCastable(wildUpperBound(t), s, warnStack.head); } @Override @@ -1758,31 +1758,25 @@ if (t.isExtendsBound()) { if (s.isExtendsBound()) - return !isCastableRecursive(t.type, upperBound(s)); + return !isCastableRecursive(t.type, wildUpperBound(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)); + return notSoftSubtypeRecursive(t.type, wildUpperBound(s)); } return false; } }; // </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> @@ -1805,7 +1799,7 @@ noWarnings); } if (!s.hasTag(WILDCARD)) - s = upperBound(s); + s = cvarUpperBound(s); return !isSubtype(t, relaxBound(s)); } @@ -1862,7 +1856,7 @@ // <editor-fold defaultstate="collapsed" desc="Array Utils"> public boolean isArray(Type t) { while (t.hasTag(WILDCARD)) - t = upperBound(t); + t = wildUpperBound(t); return t.hasTag(ARRAY); } @@ -1872,7 +1866,7 @@ public Type elemtype(Type t) { switch (t.getTag()) { case WILDCARD: - return elemtype(upperBound(t)); + return elemtype(wildUpperBound(t)); case ARRAY: t = t.unannotatedType(); return ((ArrayType)t).elemtype; @@ -1934,6 +1928,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 +1954,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; @@ -2062,7 +2069,7 @@ @Override public Type visitWildcardType(WildcardType t, Symbol sym) { - return memberType(upperBound(t), sym); + return memberType(wildUpperBound(t), sym); } @Override @@ -2181,7 +2188,7 @@ @Override public Type visitWildcardType(WildcardType t, Boolean recurse) { - return erasure(upperBound(t), recurse); + return erasure(wildUpperBound(t), recurse); } @Override @@ -2240,7 +2247,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, @@ -2292,7 +2300,7 @@ public Type visitType(Type t, Void ignored) { // A note on wildcards: there is no good way to // determine a supertype for a super bounded wildcard. - return null; + return Type.noType; } @Override @@ -2389,8 +2397,7 @@ if (t.hasErasedSupertypes()) { t.interfaces_field = erasureRecursive(interfaces); } else if (formals.nonEmpty()) { - t.interfaces_field = - upperBounds(subst(interfaces, formals, actuals)); + t.interfaces_field = subst(interfaces, formals, actuals); } else { t.interfaces_field = interfaces; @@ -2460,7 +2467,7 @@ return false; return t.isRaw() || - supertype(t) != null && isDerivedRaw(supertype(t)) || + supertype(t) != Type.noType && isDerivedRaw(supertype(t)) || isDerivedRaw(interfaces(t)); } @@ -2959,7 +2966,7 @@ return new ClassType(outer1, typarams1, t.tsym); } else { Type st = subst(supertype(t)); - List<Type> is = upperBounds(subst(interfaces(t))); + List<Type> is = subst(interfaces(t)); if (st == supertype(t) && is == interfaces(t)) return t; else @@ -2976,7 +2983,7 @@ return t; } else { if (t.isExtendsBound() && bound.isExtendsBound()) - bound = upperBound(bound); + bound = wildUpperBound(bound); return new WildcardType(bound, t.kind, syms.boundClass, t.bound); } } @@ -3211,6 +3218,7 @@ return tvar.rank_field; } case ERROR: + case NONE: return 0; default: throw new AssertionError(); @@ -3330,12 +3338,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 +3358,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); } } @@ -3385,9 +3399,16 @@ class TypePair { final Type t1; final Type t2; + boolean strict; + TypePair(Type t1, Type t2) { + this(t1, t2, false); + } + + TypePair(Type t1, Type t2, boolean strict) { this.t1 = t1; this.t2 = t2; + this.strict = strict; } @Override public int hashCode() { @@ -3398,8 +3419,8 @@ if (!(obj instanceof TypePair)) return false; TypePair typePair = (TypePair)obj; - return isSameType(t1, typePair.t1) - && isSameType(t2, typePair.t2); + return isSameType(t1, typePair.t1, strict) + && isSameType(t2, typePair.t2, strict); } } Set<TypePair> mergeCache = new HashSet<TypePair>(); @@ -3420,8 +3441,8 @@ TypePair pair = new TypePair(c1, c2); Type m; if (mergeCache.add(pair)) { - m = new WildcardType(lub(upperBound(act1.head), - upperBound(act2.head)), + m = new WildcardType(lub(wildUpperBound(act1.head), + wildUpperBound(act2.head)), BoundKind.EXTENDS, syms.boundClass); mergeCache.remove(pair); @@ -3462,18 +3483,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 +3667,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 +3687,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 +3925,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()) { @@ -3917,8 +3975,13 @@ Si.lower = Ti.getSuperBound(); break; } - if (Si.bound == Si.lower) + Type tmpBound = Si.bound.hasTag(UNDETVAR) ? ((UndetVar)Si.bound).qtype : Si.bound; + Type tmpLower = Si.lower.hasTag(UNDETVAR) ? ((UndetVar)Si.lower).qtype : Si.lower; + if (!Si.bound.hasTag(ERROR) && + !Si.lower.hasTag(ERROR) && + isSameType(tmpBound, tmpLower, false)) { currentS.head = Si.bound; + } } currentA = currentA.tail; currentT = currentT.tail; @@ -3955,16 +4018,6 @@ // </editor-fold> // <editor-fold defaultstate="collapsed" desc="Internal utility methods"> - private List<Type> upperBounds(List<Type> ss) { - if (ss.isEmpty()) return ss; - Type head = upperBound(ss.head); - List<Type> tail = upperBounds(ss.tail); - if (head != ss.head || tail != ss.tail) - return tail.prepend(head); - else - return ss; - } - private boolean sideCast(Type from, Type to, Warner warn) { // We are casting from type $from$ to type $to$, which are // non-final unrelated types. This method @@ -4121,9 +4174,9 @@ @Override public Void visitWildcardType(WildcardType source, Type target) throws AdaptFailure { if (source.isExtendsBound()) - adaptRecursive(upperBound(source), upperBound(target)); + adaptRecursive(wildUpperBound(source), wildUpperBound(target)); else if (source.isSuperBound()) - adaptRecursive(lowerBound(source), lowerBound(target)); + adaptRecursive(wildLowerBound(source), wildLowerBound(target)); return null; } @@ -4135,10 +4188,10 @@ 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)) + val = isSubtype(wildUpperBound(val), wildUpperBound(target)) ? val : target; } else if (!isSameType(val, target)) { throw new AdaptFailure(); @@ -4249,7 +4302,7 @@ } public Type visitType(Type t, Void s) { - return high ? upperBound(t) : lowerBound(t); + return t; } @Override @@ -4647,7 +4700,7 @@ assembleClassSig(rawOuter ? types.erasure(outer) : outer); - append('.'); + append(rawOuter ? '$' : '.'); Assert.check(c.flatname.startsWith(c.owner.enclClass().flatname)); append(rawOuter ? c.flatname.subName(c.owner.enclClass().flatname.getByteLength() + 1, c.flatname.getByteLength())
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Aug 19 23:57:05 2014 +0100 @@ -94,6 +94,7 @@ final Annotate annotate; final TypeAnnotations typeAnnotations; final DeferredLintHandler deferredLintHandler; + final TypeEnvs typeEnvs; public static Attr instance(Context context) { Attr instance = context.get(attrKey); @@ -123,6 +124,7 @@ annotate = Annotate.instance(context); typeAnnotations = TypeAnnotations.instance(context); deferredLintHandler = DeferredLintHandler.instance(context); + typeEnvs = TypeEnvs.instance(context); Options options = Options.instance(context); @@ -138,6 +140,7 @@ allowTypeAnnos = source.allowTypeAnnotations(); allowLambda = source.allowLambda(); allowDefaultMethods = source.allowDefaultMethods(); + allowStaticInterfaceMethods = source.allowStaticInterfaceMethods(); sourceName = source.name; relax = (options.isSet("-retrofit") || options.isSet("-relax")); @@ -195,6 +198,10 @@ */ boolean allowDefaultMethods; + /** Switch: static interface methods enabled? + */ + boolean allowStaticInterfaceMethods; + /** Switch: allow references to surrounding object from anonymous * objects during constructor call? */ @@ -249,7 +256,7 @@ if (!owntype.hasTag(ERROR) && !resultInfo.pt.hasTag(METHOD) && !resultInfo.pt.hasTag(FORALL)) { if (allowPoly && inferenceContext.free(found)) { if ((ownkind & ~resultInfo.pkind) == 0) { - owntype = resultInfo.check(tree, inferenceContext.asFree(owntype)); + owntype = resultInfo.check(tree, inferenceContext.asUndetVar(owntype)); } else { log.error(tree.pos(), "unexpected.type", kindNames(resultInfo.pkind), @@ -427,7 +434,7 @@ } public Type attribType(JCTree node, TypeSymbol sym) { - Env<AttrContext> env = enter.typeEnvs.get(sym); + Env<AttrContext> env = typeEnvs.get(sym); Env<AttrContext> localEnv = env.dup(node, env.info.dup()); return attribTree(node, localEnv, unknownTypeInfo); } @@ -518,6 +525,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) { @@ -812,6 +823,10 @@ boolean classExpected, boolean interfaceExpected, boolean checkExtensible) { + if (t.tsym.isAnonymous()) { + log.error(tree.pos(), "cant.inherit.from.anon"); + return types.createErrorType(t); + } if (t.isErroneous()) return t; if (t.hasTag(TYPEVAR) && !classExpected && !interfaceExpected) { @@ -1167,7 +1182,7 @@ //the Formal Parameter of a for-each loop is not in the scope when //attributing the for-each expression; we mimick this by attributing //the for-each expression first (against original scope). - Type exprType = types.upperBound(attribExpr(tree.expr, loopEnv)); + Type exprType = types.cvarUpperBound(attribExpr(tree.expr, loopEnv)); attribStat(tree.var, loopEnv); chk.checkNonVoid(tree.pos(), exprType); Type elemtype = types.elemtype(exprType); // perhaps expr is an array? @@ -1184,7 +1199,7 @@ List<Type> iterableParams = base.allparams(); elemtype = iterableParams.isEmpty() ? syms.objectType - : types.upperBound(iterableParams.head); + : types.wildUpperBound(iterableParams.head); } } chk.checkType(tree.expr.pos(), elemtype, tree.var.sym.type); @@ -2048,7 +2063,7 @@ tree.constructor = constructor.baseSymbol(); final TypeSymbol csym = clazztype.tsym; - ResultInfo diamondResult = new ResultInfo(MTH, newMethodTemplate(resultInfo.pt, argtypes, typeargtypes), new Check.NestedCheckContext(resultInfo.checkContext) { + ResultInfo diamondResult = new ResultInfo(pkind, newMethodTemplate(resultInfo.pt, argtypes, typeargtypes), new Check.NestedCheckContext(resultInfo.checkContext) { @Override public void report(DiagnosticPosition _unused, JCDiagnostic details) { enclosingContext.report(tree.clazz, @@ -2139,6 +2154,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); @@ -2294,6 +2314,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 @@ -2398,7 +2421,7 @@ //add thrown types as bounds to the thrown types free variables if needed: if (resultInfo.checkContext.inferenceContext().free(lambdaType.getThrownTypes())) { List<Type> inferredThrownTypes = flow.analyzeLambdaThrownTypes(env, that, make); - List<Type> thrownTypes = resultInfo.checkContext.inferenceContext().asFree(lambdaType.getThrownTypes()); + List<Type> thrownTypes = resultInfo.checkContext.inferenceContext().asUndetVars(lambdaType.getThrownTypes()); chk.unhandled(inferredThrownTypes, thrownTypes); } @@ -2539,7 +2562,7 @@ @Override public boolean compatible(Type found, Type req, Warner warn) { //return type must be compatible in both current context and assignment context - return chk.basicHandler.compatible(found, inferenceContext().asFree(req), warn); + return chk.basicHandler.compatible(found, inferenceContext().asUndetVar(req), warn); } @Override @@ -2572,7 +2595,7 @@ * types must be compatible with the return type of the expected descriptor. */ private void checkLambdaCompatible(JCLambda tree, Type descriptor, CheckContext checkContext) { - Type returnType = checkContext.inferenceContext().asFree(descriptor.getReturnType()); + Type returnType = checkContext.inferenceContext().asUndetVar(descriptor.getReturnType()); //return values have already been checked - but if lambda has no return //values, we must ensure that void/value compatibility is correct; @@ -2584,7 +2607,7 @@ diags.fragment("missing.ret.val", returnType))); } - List<Type> argTypes = checkContext.inferenceContext().asFree(descriptor.getParameterTypes()); + List<Type> argTypes = checkContext.inferenceContext().asUndetVars(descriptor.getParameterTypes()); if (!types.isSameTypes(argTypes, TreeInfo.types(tree.params))) { checkContext.report(tree, diags.fragment("incompatible.arg.types.in.lambda")); } @@ -2614,7 +2637,7 @@ * - an instance field, we use the first constructor. * - a static field, we create a fake clinit method. */ - private Env<AttrContext> lambdaEnv(JCLambda that, Env<AttrContext> env) { + public Env<AttrContext> lambdaEnv(JCLambda that, Env<AttrContext> env) { Env<AttrContext> lambdaEnv; Symbol owner = env.info.scope.owner; if (owner.kind == VAR && owner.owner.kind == TYP) { @@ -2698,17 +2721,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; @@ -2750,7 +2776,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 ? @@ -2759,10 +2785,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) { @@ -2770,7 +2796,7 @@ } else { log.report(diag); } - result = that.type = types.createErrorType(target); + result = that.type = types.createErrorType(currentTarget); return; } } @@ -2781,7 +2807,7 @@ if (desc.getReturnType() == Type.recoveryType) { // stop here - result = that.type = target; + result = that.type = currentTarget; return; } @@ -2799,7 +2825,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; } @@ -2808,7 +2834,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; } @@ -2816,19 +2842,24 @@ // 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); if (that.kind.isUnbound() && resultInfo.checkContext.inferenceContext().free(argtypes.head)) { //re-generate inference constraints for unbound receiver - if (!types.isSubtype(resultInfo.checkContext.inferenceContext().asFree(argtypes.head), exprType)) { + if (!types.isSubtype(resultInfo.checkContext.inferenceContext().asUndetVar(argtypes.head), exprType)) { //cannot happen as this has already been checked - we just need //to regenerate the inference constraints, as that has been lost //as a result of the call to inferenceContext.save() @@ -2847,9 +2878,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); @@ -2866,7 +2897,7 @@ @SuppressWarnings("fallthrough") void checkReferenceCompatible(JCMemberReference tree, Type descriptor, Type refType, CheckContext checkContext, boolean speculativeAttr) { - Type returnType = checkContext.inferenceContext().asFree(descriptor.getReturnType()); + Type returnType = checkContext.inferenceContext().asUndetVar(descriptor.getReturnType()); Type resType; switch (tree.getMode()) { @@ -2898,7 +2929,7 @@ } if (!speculativeAttr) { - List<Type> thrownTypes = checkContext.inferenceContext().asFree(descriptor.getThrownTypes()); + List<Type> thrownTypes = checkContext.inferenceContext().asUndetVars(descriptor.getThrownTypes()); if (chk.unhandled(refType.getThrownTypes(), thrownTypes).nonEmpty()) { log.error(tree, "incompatible.thrown.types.in.mref", refType.getThrownTypes()); } @@ -2937,10 +2968,19 @@ if (checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK && pt != Type.recoveryType) { //check that functional interface class is well-formed - ClassSymbol csym = types.makeFunctionalInterfaceClass(env, - names.empty, List.of(fExpr.targets.head), ABSTRACT); - if (csym != null) { - chk.checkImplementations(env.tree, csym, csym); + try { + /* Types.makeFunctionalInterfaceClass() may throw an exception + * when it's executed post-inference. See the listener code + * above. + */ + ClassSymbol csym = types.makeFunctionalInterfaceClass(env, + names.empty, List.of(fExpr.targets.head), ABSTRACT); + if (csym != null) { + chk.checkImplementations(env.tree, csym, csym); + } + } catch (Types.FunctionDescriptorLookupError ex) { + JCDiagnostic cause = ex.getDiagnostic(); + resultInfo.checkContext.report(env.tree, cause); } } } @@ -3009,15 +3049,6 @@ Type ctype = cfolder.fold1(opc, argtype); if (ctype != null) { owntype = cfolder.coerce(ctype, owntype); - - // Remove constant types from arguments to - // conserve space. The parser will fold concatenations - // of string literals; the code here also - // gets rid of intermediate results when some of the - // operands are constant identifiers. - if (tree.arg.type.tsym == syms.stringType.tsym) { - tree.arg.type = syms.stringType; - } } } } @@ -3051,18 +3082,6 @@ Type ctype = cfolder.fold2(opc, left, right); if (ctype != null) { owntype = cfolder.coerce(ctype, owntype); - - // Remove constant types from arguments to - // conserve space. The parser will fold concatenations - // of string literals; the code here also - // gets rid of intermediate results when some of the - // operands are constant identifiers. - if (tree.lhs.type.tsym == syms.stringType.tsym) { - tree.lhs.type = syms.stringType; - } - if (tree.rhs.type.tsym == syms.stringType.tsym) { - tree.rhs.type = syms.stringType; - } } } @@ -3210,6 +3229,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); } @@ -3315,6 +3339,10 @@ tree.pos(), site, sym.name, true); } } + if (!allowStaticInterfaceMethods && sitesym.isInterface() && + sym.isStatic() && sym.kind == MTH) { + log.error(tree.pos(), "static.intf.method.invoke.not.supported.in.source", sourceName); + } } else if (sym.kind != ERR && (sym.flags() & STATIC) != 0 && sym.name != names._class) { // If the qualified item is not a type and the selected item is static, report // a warning. Make allowance for the class of an array type e.g. Object[].class) @@ -3334,6 +3362,10 @@ } } + if (env.info.isSerializable) { + chk.checkElemAccessFromSerializableLambda(tree); + } + env.info.selectSuper = selectSuperPrev; result = checkId(tree, site, sym, env, resultInfo); } @@ -4030,7 +4062,7 @@ // ... and attribute the bound class c.flags_field |= UNATTRIBUTED; Env<AttrContext> cenv = enter.classEnv(cd, env); - enter.typeEnvs.put(c, cenv); + typeEnvs.put(c, cenv); attribClass(c); return owntype; } @@ -4180,9 +4212,9 @@ c.flags_field &= ~UNATTRIBUTED; // Get environment current at the point of class definition. - Env<AttrContext> env = enter.typeEnvs.get(c); - - // The info.lint field in the envs stored in enter.typeEnvs is deliberately uninitialized, + Env<AttrContext> env = typeEnvs.get(c); + + // The info.lint field in the envs stored in typeEnvs is deliberately uninitialized, // because the annotations were not available at the time the env was created. Therefore, // we look up the environment chain for the first enclosing environment for which the // lint value is set. Typically, this is the parent env, but might be further if there @@ -4212,6 +4244,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); @@ -4325,7 +4362,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); @@ -4365,15 +4402,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. */ @@ -4654,16 +4691,30 @@ private void initTypeIfNeeded(JCTree that) { if (that.type == null) { if (that.hasTag(METHODDEF)) { - that.type = dummyMethodType(); + that.type = dummyMethodType((JCMethodDecl)that); } else { that.type = syms.unknownType; } } } + /* Construct a dummy method type. If we have a method declaration, + * and the declared return type is void, then use that return type + * instead of UNKNOWN to avoid spurious error messages in lambda + * bodies (see:JDK-8041704). + */ + private Type dummyMethodType(JCMethodDecl md) { + Type restype = syms.unknownType; + if (md != null && md.restype.hasTag(TYPEIDENT)) { + JCPrimitiveTypeTree prim = (JCPrimitiveTypeTree)md.restype; + if (prim.typetag == VOID) + restype = syms.voidType; + } + return new MethodType(List.<Type>nil(), restype, + List.<Type>nil(), syms.methodClass); + } private Type dummyMethodType() { - return new MethodType(List.<Type>nil(), syms.unknownType, - List.<Type>nil(), syms.methodClass); + return dummyMethodType(null); } @Override
--- a/src/share/classes/com/sun/tools/javac/comp/AttrContext.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/AttrContext.java Tue Aug 19 23:57:05 2014 +0100 @@ -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 Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Tue Aug 19 23:57:05 2014 +0100 @@ -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. @@ -611,12 +618,12 @@ if (a.isUnbound()) { return true; } else if (!a.hasTag(WILDCARD)) { - a = types.upperBound(a); + a = types.cvarUpperBound(a); return types.isSubtype(a, bound); } else if (a.isExtendsBound()) { - return types.isCastable(bound, types.upperBound(a), types.noWarnings); + return types.isCastable(bound, types.wildUpperBound(a), types.noWarnings); } else if (a.isSuperBound()) { - return !types.notSoftSubtype(types.lowerBound(a), bound); + return !types.notSoftSubtype(types.wildLowerBound(a), bound); } return true; } @@ -1031,7 +1038,9 @@ switch (sym.kind) { case VAR: - if (sym.owner.kind != TYP) + if (TreeInfo.isReceiverParam(tree)) + mask = ReceiverParamFlags; + else if (sym.owner.kind != TYP) mask = LocalVarFlags; else if ((sym.owner.flags_field & INTERFACE) != 0) mask = implicit = InterfaceVarFlags; @@ -1806,6 +1815,11 @@ Type t1, Type t2, Type site) { + if ((site.tsym.flags() & COMPOUND) != 0) { + // special case for intersections: need to eliminate wildcards in supertypes + t1 = types.capture(t1); + t2 = types.capture(t2); + } return firstIncompatibility(pos, t1, t2, site) == null; } @@ -2583,6 +2597,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) { @@ -2627,7 +2679,7 @@ checkClassBounds(pos, seensofar, it); } Type st = types.supertype(type); - if (st != null) checkClassBounds(pos, seensofar, st); + if (st != Type.noType) checkClassBounds(pos, seensofar, st); } /** Enter interface into into set. @@ -2680,7 +2732,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 Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Tue Aug 19 23:57:05 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ package com.sun.tools.javac.comp; -import com.sun.source.tree.MemberReferenceTree; +import com.sun.source.tree.LambdaExpressionTree.BodyKind; import com.sun.tools.javac.code.*; import com.sun.tools.javac.tree.*; import com.sun.tools.javac.util.*; @@ -35,10 +35,8 @@ import com.sun.tools.javac.comp.Attr.ResultInfo; import com.sun.tools.javac.comp.Infer.InferenceContext; import com.sun.tools.javac.comp.Resolve.MethodResolutionPhase; -import com.sun.tools.javac.comp.Resolve.ReferenceLookupHelper; import com.sun.tools.javac.tree.JCTree.*; - import java.util.ArrayList; import java.util.Collections; import java.util.EnumSet; @@ -48,6 +46,7 @@ import java.util.Set; import java.util.WeakHashMap; +import static com.sun.tools.javac.code.Kinds.VAL; import static com.sun.tools.javac.code.TypeTag.*; import static com.sun.tools.javac.tree.JCTree.Tag.*; @@ -76,6 +75,9 @@ final Symtab syms; final TreeMaker make; final Types types; + final Flow flow; + final Names names; + final TypeEnvs typeEnvs; public static DeferredAttr instance(Context context) { DeferredAttr instance = context.get(deferredAttrKey); @@ -96,8 +98,10 @@ syms = Symtab.instance(context); make = TreeMaker.instance(context); types = Types.instance(context); - Names names = Names.instance(context); + flow = Flow.instance(context); + names = Names.instance(context); stuckTree = make.Ident(names.empty).setType(Type.stuckType); + typeEnvs = TypeEnvs.instance(context); emptyDeferredAttrContext = new DeferredAttrContext(AttrMode.CHECK, null, MethodResolutionPhase.BOX, infer.emptyContext, null, null) { @Override @@ -108,6 +112,11 @@ void complete() { Assert.error("Empty deferred context!"); } + + @Override + public String toString() { + return "Empty deferred context!"; + } }; } @@ -139,6 +148,11 @@ return DEFERRED; } + @Override + public String toString() { + return "DeferredType"; + } + /** * A speculative cache is used to keep track of all overload resolution rounds * that triggered speculative attribution on a given deferred type. Each entry @@ -378,7 +392,9 @@ } } //where - protected TreeScanner unenterScanner = new TreeScanner() { + protected UnenterScanner unenterScanner = new UnenterScanner(); + + class UnenterScanner extends TreeScanner { @Override public void visitClassDef(JCClassDecl tree) { ClassSymbol csym = tree.sym; @@ -386,12 +402,12 @@ //it is possible that nested expressions inside argument expression //are left unchecked - in such cases there's nothing to clean up. if (csym == null) return; - enter.typeEnvs.remove(csym); + typeEnvs.remove(csym); chk.compiled.remove(csym.flatname); syms.classes.remove(csym.flatname); super.visitClassDef(tree); } - }; + } /** * A deferred context is created on each method check. A deferred context is @@ -595,19 +611,111 @@ public void visitLambda(JCLambda tree) { Check.CheckContext checkContext = resultInfo.checkContext; Type pt = resultInfo.pt; - if (inferenceContext.inferencevars.contains(pt)) { - //ok - return; - } else { + if (!inferenceContext.inferencevars.contains(pt)) { //must be a functional descriptor + Type descriptorType = null; try { - Type desc = types.findDescriptorType(pt); - if (desc.getParameterTypes().length() != tree.params.length()) { - checkContext.report(tree, diags.fragment("incompatible.arg.types.in.lambda")); - } + descriptorType = types.findDescriptorType(pt); } catch (Types.FunctionDescriptorLookupError ex) { checkContext.report(null, ex.getDiagnostic()); } + + if (descriptorType.getParameterTypes().length() != tree.params.length()) { + checkContext.report(tree, + diags.fragment("incompatible.arg.types.in.lambda")); + } + + Type currentReturnType = descriptorType.getReturnType(); + boolean returnTypeIsVoid = currentReturnType.hasTag(VOID); + if (tree.getBodyKind() == BodyKind.EXPRESSION) { + boolean isExpressionCompatible = !returnTypeIsVoid || + TreeInfo.isExpressionStatement((JCExpression)tree.getBody()); + if (!isExpressionCompatible) { + resultInfo.checkContext.report(tree.pos(), + diags.fragment("incompatible.ret.type.in.lambda", + diags.fragment("missing.ret.val", currentReturnType))); + } + } else { + LambdaBodyStructChecker lambdaBodyChecker = + new LambdaBodyStructChecker(); + + tree.body.accept(lambdaBodyChecker); + boolean isVoidCompatible = lambdaBodyChecker.isVoidCompatible; + + if (returnTypeIsVoid) { + if (!isVoidCompatible) { + resultInfo.checkContext.report(tree.pos(), + diags.fragment("unexpected.ret.val")); + } + } else { + boolean isValueCompatible = lambdaBodyChecker.isPotentiallyValueCompatible + && !canLambdaBodyCompleteNormally(tree); + if (!isValueCompatible && !isVoidCompatible) { + log.error(tree.body.pos(), + "lambda.body.neither.value.nor.void.compatible"); + } + + if (!isValueCompatible) { + resultInfo.checkContext.report(tree.pos(), + diags.fragment("incompatible.ret.type.in.lambda", + diags.fragment("missing.ret.val", currentReturnType))); + } + } + } + } + } + + boolean canLambdaBodyCompleteNormally(JCLambda tree) { + JCLambda newTree = new TreeCopier<>(make).copy(tree); + /* attr.lambdaEnv will create a meaningful env for the + * lambda expression. This is specially useful when the + * lambda is used as the init of a field. But we need to + * remove any added symbol. + */ + Env<AttrContext> localEnv = attr.lambdaEnv(newTree, env); + try { + List<JCVariableDecl> tmpParams = newTree.params; + while (tmpParams.nonEmpty()) { + tmpParams.head.vartype = make.at(tmpParams.head).Type(syms.errType); + tmpParams = tmpParams.tail; + } + + attr.attribStats(newTree.params, localEnv); + + /* set pt to Type.noType to avoid generating any bound + * which may happen if lambda's return type is an + * inference variable + */ + Attr.ResultInfo bodyResultInfo = attr.new ResultInfo(VAL, Type.noType); + localEnv.info.returnResult = bodyResultInfo; + + // discard any log output + Log.DiagnosticHandler diagHandler = new Log.DiscardDiagnosticHandler(log); + try { + JCBlock body = (JCBlock)newTree.body; + /* we need to attribute the lambda body before + * doing the aliveness analysis. This is because + * constant folding occurs during attribution + * and the reachability of some statements depends + * on constant values, for example: + * + * while (true) {...} + */ + attr.attribStats(body.stats, localEnv); + + attr.preFlow(newTree); + /* make an aliveness / reachability analysis of the lambda + * to determine if it can complete normally + */ + flow.analyzeLambda(localEnv, newTree, make, true); + } finally { + log.popDiagnosticHandler(diagHandler); + } + return newTree.canCompleteNormally; + } finally { + JCBlock body = (JCBlock)newTree.body; + unenterScanner.scan(body.stats); + localEnv.info.scope.leave(); } } @@ -625,10 +733,7 @@ public void visitReference(JCMemberReference tree) { Check.CheckContext checkContext = resultInfo.checkContext; Type pt = resultInfo.pt; - if (inferenceContext.inferencevars.contains(pt)) { - //ok - return; - } else { + if (!inferenceContext.inferencevars.contains(pt)) { try { types.findDescriptorType(pt); } catch (Types.FunctionDescriptorLookupError ex) { @@ -658,6 +763,40 @@ } } } + + /* This visitor looks for return statements, its analysis will determine if + * a lambda body is void or value compatible. We must analyze return + * statements contained in the lambda body only, thus any return statement + * contained in an inner class or inner lambda body, should be ignored. + */ + class LambdaBodyStructChecker extends TreeScanner { + boolean isVoidCompatible = true; + boolean isPotentiallyValueCompatible = true; + + @Override + public void visitClassDef(JCClassDecl tree) { + // do nothing + } + + @Override + public void visitLambda(JCLambda tree) { + // do nothing + } + + @Override + public void visitNewClass(JCNewClass tree) { + // do nothing + } + + @Override + public void visitReturn(JCReturn tree) { + if (tree.expr != null) { + isVoidCompatible = false; + } else { + isPotentiallyValueCompatible = false; + } + } + } } /** an empty deferred attribution context - all methods throw exceptions */ @@ -769,7 +908,7 @@ /** * handler that is executed when a node has been discarded */ - abstract void skip(JCTree tree); + void skip(JCTree tree) {} } /** @@ -781,11 +920,6 @@ PolyScanner() { super(EnumSet.of(CONDEXPR, PARENS, LAMBDA, REFERENCE)); } - - @Override - void skip(JCTree tree) { - //do nothing - } } /** @@ -796,12 +930,7 @@ LambdaReturnScanner() { super(EnumSet.of(BLOCK, CASE, CATCH, DOLOOP, FOREACHLOOP, - FORLOOP, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP)); - } - - @Override - void skip(JCTree tree) { - //do nothing + FORLOOP, IF, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP)); } } @@ -1091,25 +1220,102 @@ } //slow path + Symbol sym = quicklyResolveMethod(env, tree); + + if (sym == null) { + result = ArgumentExpressionKind.POLY; + return; + } + + result = analyzeCandidateMethods(sym, ArgumentExpressionKind.PRIMITIVE, + argumentKindAnalyzer); + } + //where + private boolean isSimpleReceiver(JCTree rec) { + switch (rec.getTag()) { + case IDENT: + return true; + case SELECT: + return isSimpleReceiver(((JCFieldAccess)rec).selected); + case TYPEAPPLY: + case TYPEARRAY: + return true; + case ANNOTATED_TYPE: + return isSimpleReceiver(((JCAnnotatedType)rec).underlyingType); + case APPLY: + return true; + default: + return false; + } + } + private ArgumentExpressionKind reduce(ArgumentExpressionKind kind) { + return argumentKindAnalyzer.reduce(result, kind); + } + MethodAnalyzer<ArgumentExpressionKind> argumentKindAnalyzer = + new MethodAnalyzer<ArgumentExpressionKind>() { + @Override + public ArgumentExpressionKind process(MethodSymbol ms) { + return ArgumentExpressionKind.methodKind(ms, types); + } + @Override + public ArgumentExpressionKind reduce(ArgumentExpressionKind kind1, + ArgumentExpressionKind kind2) { + switch (kind1) { + case PRIMITIVE: return kind2; + case NO_POLY: return kind2.isPoly() ? kind2 : kind1; + case POLY: return kind1; + default: + Assert.error(); + return null; + } + } + @Override + public boolean shouldStop(ArgumentExpressionKind result) { + return result.isPoly(); + } + }; + + @Override + public void visitLiteral(JCLiteral tree) { + Type litType = attr.litType(tree.typetag); + result = ArgumentExpressionKind.standaloneKind(litType, types); + } + + @Override + void skip(JCTree tree) { + result = ArgumentExpressionKind.NO_POLY; + } + + private Symbol quicklyResolveMethod(Env<AttrContext> env, final JCMethodInvocation tree) { final JCExpression rec = tree.meth.hasTag(SELECT) ? ((JCFieldAccess)tree.meth).selected : null; if (rec != null && !isSimpleReceiver(rec)) { - //give up if receiver is too complex (to cut down analysis time) - result = ArgumentExpressionKind.POLY; - return; + return null; } - Type site = rec != null ? - attribSpeculative(rec, env, attr.unknownTypeExprInfo).type : - env.enclClass.sym.type; + Type site; - while (site.hasTag(TYPEVAR)) { - site = site.getUpperBound(); + if (rec != null) { + if (rec.hasTag(APPLY)) { + Symbol recSym = quicklyResolveMethod(env, (JCMethodInvocation) rec); + if (recSym == null) + return null; + Symbol resolvedReturnType = + analyzeCandidateMethods(recSym, syms.errSymbol, returnSymbolAnalyzer); + if (resolvedReturnType == null) + return null; + site = resolvedReturnType.type; + } else { + site = attribSpeculative(rec, env, attr.unknownTypeExprInfo).type; + } + } else { + site = env.enclClass.sym.type; } List<Type> args = rs.dummyArgs(tree.args.length()); + Name name = TreeInfo.name(tree.meth); Resolve.LookupHelper lh = rs.new LookupHelper(name, site, args, List.<Type>nil(), MethodResolutionPhase.VARARITY) { @Override @@ -1124,61 +1330,60 @@ } }; - Symbol sym = rs.lookupMethod(env, tree, site.tsym, rs.arityMethodCheck, lh); + return rs.lookupMethod(env, tree, site.tsym, rs.arityMethodCheck, lh); + } + //where: + MethodAnalyzer<Symbol> returnSymbolAnalyzer = new MethodAnalyzer<Symbol>() { + @Override + public Symbol process(MethodSymbol ms) { + ArgumentExpressionKind kind = ArgumentExpressionKind.methodKind(ms, types); + return kind != ArgumentExpressionKind.POLY ? ms.getReturnType().tsym : null; + } + @Override + public Symbol reduce(Symbol s1, Symbol s2) { + return s1 == syms.errSymbol ? s2 : s1 == s2 ? s1 : null; + } + @Override + public boolean shouldStop(Symbol result) { + return result == null; + } + }; - if (sym.kind == Kinds.AMBIGUOUS) { - Resolve.AmbiguityError err = (Resolve.AmbiguityError)sym.baseSymbol(); - result = ArgumentExpressionKind.PRIMITIVE; - for (Symbol s : err.ambiguousSyms) { - if (result.isPoly()) break; - if (s.kind == Kinds.MTH) { - result = reduce(ArgumentExpressionKind.methodKind(s, types)); + /** + * Process the result of Resolve.lookupMethod. If sym is a method symbol, the result of + * MethodAnalyzer.process is returned. If sym is an ambiguous symbol, all the candidate + * methods are inspected one by one, using MethodAnalyzer.process. The outcomes are + * reduced using MethodAnalyzer.reduce (using defaultValue as the first value over which + * the reduction runs). MethodAnalyzer.shouldStop can be used to stop the inspection early. + */ + <E> E analyzeCandidateMethods(Symbol sym, E defaultValue, MethodAnalyzer<E> analyzer) { + switch (sym.kind) { + case Kinds.MTH: + return analyzer.process((MethodSymbol) sym); + case Kinds.AMBIGUOUS: + Resolve.AmbiguityError err = (Resolve.AmbiguityError)sym.baseSymbol(); + E res = defaultValue; + for (Symbol s : err.ambiguousSyms) { + if (s.kind == Kinds.MTH) { + res = analyzer.reduce(res, analyzer.process((MethodSymbol) s)); + if (analyzer.shouldStop(res)) + return res; + } } - } - } else { - result = (sym.kind == Kinds.MTH) ? - ArgumentExpressionKind.methodKind(sym, types) : - ArgumentExpressionKind.NO_POLY; + return res; + default: + return defaultValue; } } - //where - private boolean isSimpleReceiver(JCTree rec) { - switch (rec.getTag()) { - case IDENT: - return true; - case SELECT: - return isSimpleReceiver(((JCFieldAccess)rec).selected); - case TYPEAPPLY: - case TYPEARRAY: - return true; - case ANNOTATED_TYPE: - return isSimpleReceiver(((JCAnnotatedType)rec).underlyingType); - default: - return false; - } - } - private ArgumentExpressionKind reduce(ArgumentExpressionKind kind) { - switch (result) { - case PRIMITIVE: return kind; - case NO_POLY: return kind.isPoly() ? kind : result; - case POLY: return result; - default: - Assert.error(); - return null; - } - } + } - @Override - public void visitLiteral(JCLiteral tree) { - Type litType = attr.litType(tree.typetag); - result = ArgumentExpressionKind.standaloneKind(litType, types); - } + /** Analyzer for methods - used by analyzeCandidateMethods. */ + interface MethodAnalyzer<E> { + E process(MethodSymbol ms); + E reduce(E e1, E e2); + boolean shouldStop(E result); + } - @Override - void skip(JCTree tree) { - result = ArgumentExpressionKind.NO_POLY; - } - } //where private EnumSet<JCTree.Tag> deferredCheckerTags = EnumSet.of(LAMBDA, REFERENCE, PARENS, TYPECAST,
--- a/src/share/classes/com/sun/tools/javac/comp/Enter.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Enter.java Tue Aug 19 23:57:05 2014 +0100 @@ -105,6 +105,7 @@ Names names; JavaFileManager fileManager; PkgInfo pkginfoOpt; + TypeEnvs typeEnvs; private final Todo todo; @@ -142,14 +143,9 @@ Options options = Options.instance(context); pkginfoOpt = PkgInfo.get(options); + typeEnvs = TypeEnvs.instance(context); } - /** A hashtable mapping classes and packages to the environments current - * at the points of their definitions. - */ - Map<TypeSymbol,Env<AttrContext>> typeEnvs = - new HashMap<TypeSymbol,Env<AttrContext>>(); - /** Accessor for typeEnvs */ public Env<AttrContext> getEnv(TypeSymbol sym) {
--- a/src/share/classes/com/sun/tools/javac/comp/Flow.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java Tue Aug 19 23:57:05 2014 +0100 @@ -45,7 +45,7 @@ import static com.sun.tools.javac.tree.JCTree.Tag.*; /** This pass implements dataflow analysis for Java programs though - * different AST visitor steps. Liveness analysis (see AliveAlanyzer) checks that + * different AST visitor steps. Liveness analysis (see AliveAnalyzer) checks that * every statement is reachable. Exception analysis (see FlowAnalyzer) ensures that * every checked exception that is thrown is declared or caught. Definite assignment analysis * (see AssignAnalyzer) ensures that each variable is assigned when used. Definite @@ -197,6 +197,7 @@ private final boolean allowImprovedRethrowAnalysis; private final boolean allowImprovedCatchAnalysis; private final boolean allowEffectivelyFinalInInnerClasses; + private final boolean enforceThisDotInit; public static Flow instance(Context context) { Flow instance = context.get(flowKey); @@ -207,7 +208,7 @@ public void analyzeTree(Env<AttrContext> env, TreeMaker make) { new AliveAnalyzer().analyzeTree(env, make); - new AssignAnalyzer(log, syms, lint, names).analyzeTree(env); + new AssignAnalyzer(log, syms, lint, names, enforceThisDotInit).analyzeTree(env); new FlowAnalyzer().analyzeTree(env, make); new CaptureAnalyzer().analyzeTree(env, make); } @@ -231,7 +232,8 @@ } } - public List<Type> analyzeLambdaThrownTypes(Env<AttrContext> env, JCLambda that, TreeMaker make) { + public List<Type> analyzeLambdaThrownTypes(final Env<AttrContext> env, + JCLambda that, TreeMaker make) { //we need to disable diagnostics temporarily; the problem is that if //a lambda expression contains e.g. an unreachable statement, an error //message will be reported and will cause compilation to skip the flow analyis @@ -239,7 +241,13 @@ //related errors, which will allow for more errors to be detected Log.DiagnosticHandler diagHandler = new Log.DiscardDiagnosticHandler(log); try { - new AssignAnalyzer(log, syms, lint, names).analyzeTree(env); + new AssignAnalyzer(log, syms, lint, names, enforceThisDotInit) { + @Override + protected boolean trackable(VarSymbol sym) { + return !env.info.scope.includes(sym) && + sym.owner.kind == MTH; + } + }.analyzeTree(env); LambdaFlowAnalyzer flowAnalyzer = new LambdaFlowAnalyzer(); flowAnalyzer.analyzeTree(env, that, make); return flowAnalyzer.inferredThrownTypes; @@ -289,6 +297,7 @@ allowImprovedRethrowAnalysis = source.allowImprovedRethrowAnalysis(); allowImprovedCatchAnalysis = source.allowImprovedCatchAnalysis(); allowEffectivelyFinalInInnerClasses = source.allowEffectivelyFinalInInnerClasses(); + enforceThisDotInit = source.enforceThisDotInit(); } /** @@ -1427,6 +1436,8 @@ protected Names names; + final boolean enforceThisDotInit; + public static class AbstractAssignPendingExit extends BaseAnalyzer.PendingExit { final Bits inits; @@ -1449,7 +1460,7 @@ } } - public AbstractAssignAnalyzer(Bits inits, Symtab syms, Names names) { + public AbstractAssignAnalyzer(Bits inits, Symtab syms, Names names, boolean enforceThisDotInit) { this.inits = inits; uninits = new Bits(); uninitsTry = new Bits(); @@ -1459,6 +1470,7 @@ uninitsWhenFalse = new Bits(true); this.syms = syms; this.names = names; + this.enforceThisDotInit = enforceThisDotInit; } private boolean isInitialConstructor = false; @@ -2280,12 +2292,34 @@ public void visitAssign(JCAssign tree) { JCTree lhs = TreeInfo.skipParens(tree.lhs); - if (!(lhs instanceof JCIdent)) { + if (!isIdentOrThisDotIdent(lhs)) scanExpr(lhs); - } scanExpr(tree.rhs); letInit(lhs); } + private boolean isIdentOrThisDotIdent(JCTree lhs) { + if (lhs.hasTag(IDENT)) + return true; + if (!lhs.hasTag(SELECT)) + return false; + + JCFieldAccess fa = (JCFieldAccess)lhs; + return fa.selected.hasTag(IDENT) && + ((JCIdent)fa.selected).name == names._this; + } + + // check fields accessed through this.<field> are definitely + // assigned before reading their value + public void visitSelect(JCFieldAccess tree) { + super.visitSelect(tree); + if (enforceThisDotInit && + tree.selected.hasTag(IDENT) && + ((JCIdent)tree.selected).name == names._this && + tree.sym.kind == VAR) + { + checkInit(tree.pos(), (VarSymbol)tree.sym); + } + } public void visitAssignop(JCAssignOp tree) { scanExpr(tree.lhs); @@ -2419,8 +2453,8 @@ } } - public AssignAnalyzer(Log log, Symtab syms, Lint lint, Names names) { - super(new Bits(), syms, names); + public AssignAnalyzer(Log log, Symtab syms, Lint lint, Names names, boolean enforceThisDotInit) { + super(new Bits(), syms, names, enforceThisDotInit); this.log = log; this.lint = lint; }
--- a/src/share/classes/com/sun/tools/javac/comp/Infer.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Tue Aug 19 23:57:05 2014 +0100 @@ -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,11 +225,12 @@ * 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(); if (mt.getReturnType().containsAny(inferenceContext.inferencevars) && - resultInfo.checkContext.inferenceContext() != emptyContext) { + rsInfoInfContext != emptyContext) { from = types.capture(from); //add synthetic captured ivars for (Type t : from.getTypeArguments()) { @@ -231,13 +239,29 @@ } } } - Type qtype1 = inferenceContext.asFree(from); - Type to = returnConstraintTarget(qtype1, resultInfo.pt); - Assert.check(allowGraphInference || !resultInfo.checkContext.inferenceContext().free(to), + 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, resultInfo.checkContext.inferenceContext().asFree(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 @@ -247,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; } /** @@ -280,7 +370,7 @@ ListBuffer<Type> todo = new ListBuffer<>(); //step 1 - create fresh tvars for (Type t : vars) { - UndetVar uv = (UndetVar)inferenceContext.asFree(t); + UndetVar uv = (UndetVar)inferenceContext.asUndetVar(t); List<Type> upperBounds = uv.getBounds(InferenceBound.UPPER); if (Type.containsAny(upperBounds, vars)) { TypeSymbol fresh_tvar = new TypeVariableSymbol(Flags.SYNTHETIC, uv.qtype.tsym.name, null, uv.qtype.tsym.owner); @@ -399,7 +489,7 @@ return types.createErrorType(funcInterface); } for (Type p : descParameterTypes) { - if (!types.isSameType(funcInterfaceContext.asFree(p), paramTypes.head)) { + if (!types.isSameType(funcInterfaceContext.asUndetVar(p), paramTypes.head)) { checkContext.report(pos, diags.fragment("no.suitable.functional.intf.inst", funcInterface)); return types.createErrorType(funcInterface); } @@ -515,6 +605,32 @@ /** max number of incorporation rounds */ static final int MAX_INCORPORATION_STEPS = 100; + /* If for two types t and s there is a least upper bound that is a + * parameterized type G, then there exists a supertype of 't' of the form + * G<T1, ..., Tn> and a supertype of 's' of the form G<S1, ..., Sn> + * which will be returned by this method. If no such supertypes exists then + * null is returned. + * + * As an example for the following input: + * + * t = java.util.ArrayList<java.lang.String> + * s = java.util.List<T> + * + * we get this ouput: + * + * Pair[java.util.List<java.lang.String>,java.util.List<T>] + */ + private Pair<Type, Type> getParameterizedSupers(Type t, Type s) { + Type lubResult = types.lub(t, s); + if (lubResult == syms.errType || lubResult == syms.botType || + !lubResult.isParameterized()) { + return null; + } + Type asSuperOfT = types.asSuper(t, lubResult.tsym); + Type asSuperOfS = types.asSuper(s, lubResult.tsym); + return new Pair<>(asSuperOfT, asSuperOfS); + } + /** * This enumeration defines an entry point for doing inference variable * bound incorporation - it can be used to inject custom incorporation @@ -533,22 +649,23 @@ if (uv.inst != null) { Type inst = uv.inst; for (Type u : uv.getBounds(InferenceBound.UPPER)) { - if (!isSubtype(inst, inferenceContext.asFree(u), warn, infer)) { + if (!isSubtype(inst, inferenceContext.asUndetVar(u), warn, infer)) { infer.reportBoundError(uv, BoundErrorKind.UPPER); } } for (Type l : uv.getBounds(InferenceBound.LOWER)) { - if (!isSubtype(inferenceContext.asFree(l), inst, warn, infer)) { + if (!isSubtype(inferenceContext.asUndetVar(l), inst, warn, infer)) { infer.reportBoundError(uv, BoundErrorKind.LOWER); } } for (Type e : uv.getBounds(InferenceBound.EQ)) { - if (!isSameType(inst, inferenceContext.asFree(e), infer)) { + if (!isSameType(inst, inferenceContext.asUndetVar(e), infer)) { infer.reportBoundError(uv, BoundErrorKind.EQ); } } } } + @Override boolean accepts(UndetVar uv, InferenceContext inferenceContext) { //applies to all undetvars @@ -594,12 +711,12 @@ for (Type e : uv.getBounds(InferenceBound.EQ)) { if (e.containsAny(inferenceContext.inferenceVars())) continue; for (Type u : uv.getBounds(InferenceBound.UPPER)) { - if (!isSubtype(e, inferenceContext.asFree(u), warn, infer)) { + if (!isSubtype(e, inferenceContext.asUndetVar(u), warn, infer)) { infer.reportBoundError(uv, BoundErrorKind.BAD_EQ_UPPER); } } for (Type l : uv.getBounds(InferenceBound.LOWER)) { - if (!isSubtype(inferenceContext.asFree(l), e, warn, infer)) { + if (!isSubtype(inferenceContext.asUndetVar(l), e, warn, infer)) { infer.reportBoundError(uv, BoundErrorKind.BAD_EQ_LOWER); } } @@ -615,7 +732,7 @@ Infer infer = inferenceContext.infer(); for (Type b1 : uv.getBounds(InferenceBound.UPPER)) { for (Type b2 : uv.getBounds(InferenceBound.LOWER)) { - isSubtype(inferenceContext.asFree(b2), inferenceContext.asFree(b1), warn , infer); + isSubtype(inferenceContext.asUndetVar(b2), inferenceContext.asUndetVar(b1), warn , infer); } } } @@ -629,7 +746,7 @@ Infer infer = inferenceContext.infer(); for (Type b1 : uv.getBounds(InferenceBound.UPPER)) { for (Type b2 : uv.getBounds(InferenceBound.EQ)) { - isSubtype(inferenceContext.asFree(b2), inferenceContext.asFree(b1), warn, infer); + isSubtype(inferenceContext.asUndetVar(b2), inferenceContext.asUndetVar(b1), warn, infer); } } } @@ -643,12 +760,59 @@ Infer infer = inferenceContext.infer(); for (Type b1 : uv.getBounds(InferenceBound.EQ)) { for (Type b2 : uv.getBounds(InferenceBound.LOWER)) { - isSubtype(inferenceContext.asFree(b2), inferenceContext.asFree(b1), warn, infer); + isSubtype(inferenceContext.asUndetVar(b2), inferenceContext.asUndetVar(b1), warn, infer); } } } }, /** + * Given a bound set containing {@code alpha <: P<T>} and + * {@code alpha <: P<S>} where P is a parameterized type, + * perform {@code T = S} (which could lead to new bounds). + */ + CROSS_UPPER_UPPER() { + @Override + public void apply(UndetVar uv, InferenceContext inferenceContext, Warner warn) { + Infer infer = inferenceContext.infer(); + List<Type> boundList = uv.getBounds(InferenceBound.UPPER); + List<Type> boundListTail = boundList.tail; + while (boundList.nonEmpty()) { + List<Type> tmpTail = boundListTail; + while (tmpTail.nonEmpty()) { + Type b1 = boundList.head; + Type b2 = tmpTail.head; + if (b1 != b2) { + Pair<Type, Type> commonSupers = infer.getParameterizedSupers(b1, b2); + if (commonSupers != null) { + List<Type> allParamsSuperBound1 = commonSupers.fst.allparams(); + List<Type> allParamsSuperBound2 = commonSupers.snd.allparams(); + while (allParamsSuperBound1.nonEmpty() && allParamsSuperBound2.nonEmpty()) { + //traverse the list of all params comparing them + if (!allParamsSuperBound1.head.hasTag(WILDCARD) && + !allParamsSuperBound2.head.hasTag(WILDCARD)) { + isSameType(inferenceContext.asUndetVar(allParamsSuperBound1.head), + inferenceContext.asUndetVar(allParamsSuperBound2.head), infer); + } + allParamsSuperBound1 = allParamsSuperBound1.tail; + allParamsSuperBound2 = allParamsSuperBound2.tail; + } + Assert.check(allParamsSuperBound1.isEmpty() && allParamsSuperBound2.isEmpty()); + } + } + tmpTail = tmpTail.tail; + } + boundList = boundList.tail; + boundListTail = boundList.tail; + } + } + + @Override + boolean accepts(UndetVar uv, InferenceContext inferenceContext) { + return !uv.isCaptured() && + uv.getBounds(InferenceBound.UPPER).nonEmpty(); + } + }, + /** * Given a bound set containing {@code alpha == S} and {@code alpha == T} * perform {@code S == T} (which could lead to new bounds). */ @@ -658,7 +822,7 @@ for (Type b1 : uv.getBounds(InferenceBound.EQ)) { for (Type b2 : uv.getBounds(InferenceBound.EQ)) { if (b1 != b2) { - isSameType(inferenceContext.asFree(b2), inferenceContext.asFree(b1), infer); + isSameType(inferenceContext.asUndetVar(b2), inferenceContext.asUndetVar(b1), infer); } } } @@ -673,7 +837,7 @@ Infer infer = inferenceContext.infer(); for (Type b : uv.getBounds(InferenceBound.UPPER)) { if (inferenceContext.inferenceVars().contains(b)) { - UndetVar uv2 = (UndetVar)inferenceContext.asFree(b); + UndetVar uv2 = (UndetVar)inferenceContext.asUndetVar(b); if (uv2.isCaptured()) continue; //alpha <: beta //0. set beta :> alpha @@ -699,7 +863,7 @@ Infer infer = inferenceContext.infer(); for (Type b : uv.getBounds(InferenceBound.LOWER)) { if (inferenceContext.inferenceVars().contains(b)) { - UndetVar uv2 = (UndetVar)inferenceContext.asFree(b); + UndetVar uv2 = (UndetVar)inferenceContext.asUndetVar(b); if (uv2.isCaptured()) continue; //alpha :> beta //0. set beta <: alpha @@ -725,7 +889,7 @@ Infer infer = inferenceContext.infer(); for (Type b : uv.getBounds(InferenceBound.EQ)) { if (inferenceContext.inferenceVars().contains(b)) { - UndetVar uv2 = (UndetVar)inferenceContext.asFree(b); + UndetVar uv2 = (UndetVar)inferenceContext.asUndetVar(b); if (uv2.isCaptured()) continue; //alpha == beta //0. set beta == alpha @@ -1243,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 @@ -1475,7 +1639,7 @@ StringBuilder buf = new StringBuilder(); String sep = ""; for (Type from : data) { - UndetVar uv = (UndetVar)inferenceContext.asFree(from); + UndetVar uv = (UndetVar)inferenceContext.asUndetVar(from); for (Type bound : uv.getBounds(InferenceBound.values())) { if (bound.containsAny(List.from(to.data))) { buf.append(sep); @@ -1684,7 +1848,7 @@ Set<Type> optDepsByNode = stuckDeps.get(i); for (Node n_j : nodes) { Type j = n_j.data.first(); - UndetVar uv_i = (UndetVar)inferenceContext.asFree(i); + UndetVar uv_i = (UndetVar)inferenceContext.asUndetVar(i); if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) { //update i's bound dependencies n_i.addDependency(DependencyKind.BOUND, n_j); @@ -1833,6 +1997,8 @@ }); } + /* Returns the corresponding inference variables. + */ private List<Type> filterVars(Filter<UndetVar> fu) { ListBuffer<Type> res = new ListBuffer<>(); for (Type t : undetvars) { @@ -1890,14 +2056,14 @@ * undet vars (used ahead of subtyping/compatibility checks to allow propagation * of inference constraints). */ - final Type asFree(Type t) { + final Type asUndetVar(Type t) { return types.subst(t, inferencevars, undetvars); } - final List<Type> asFree(List<Type> ts) { + final List<Type> asUndetVars(List<Type> ts) { ListBuffer<Type> buf = new ListBuffer<>(); for (Type t : ts) { - buf.append(asFree(t)); + buf.append(asUndetVar(t)); } return buf.toList(); } @@ -2005,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) { @@ -2073,7 +2241,7 @@ private boolean solveBasic(List<Type> varsToSolve, EnumSet<InferenceStep> steps) { boolean changed = false; for (Type t : varsToSolve.intersect(restvars())) { - UndetVar uv = (UndetVar)asFree(t); + UndetVar uv = (UndetVar)asUndetVar(t); for (InferenceStep step : steps) { if (step.accepts(uv, this)) { uv.inst = step.solve(uv, this); @@ -2125,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 Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Tue Aug 19 23:57:05 2014 +0100 @@ -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,11 +1916,11 @@ }; break; case LOCAL_VAR: - ret = new VarSymbol(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: - ret = new VarSymbol(FINAL | PARAMETER, name, types.erasure(sym.type), translatedSym); + ret = new VarSymbol((sym.flags() & FINAL) | PARAMETER, name, types.erasure(sym.type), translatedSym); ((VarSymbol) ret).pos = ((VarSymbol) sym).pos; break; default:
--- a/src/share/classes/com/sun/tools/javac/comp/Lower.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java Tue Aug 19 23:57:05 2014 +0100 @@ -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 @@ -82,6 +82,7 @@ private ConstFold cfolder; private Target target; private Source source; + private final TypeEnvs typeEnvs; private boolean allowEnums; private final Name dollarAssertionsDisabled; private final Name classDollar; @@ -103,6 +104,7 @@ cfolder = ConstFold.instance(context); target = Target.instance(context); source = Source.instance(context); + typeEnvs = TypeEnvs.instance(context); allowEnums = source.allowEnums(); dollarAssertionsDisabled = names. fromString(target.syntheticNameChar() + "assertionsDisabled"); @@ -2360,6 +2362,7 @@ /** Visitor method: Translate a single node. * Attach the source position from the old tree to its replacement tree. */ + @Override public <T extends JCTree> T translate(T tree) { if (tree == null) { return null; @@ -2451,10 +2454,16 @@ } public void visitClassDef(JCClassDecl tree) { + Env<AttrContext> prevEnv = attrEnv; ClassSymbol currentClassPrev = currentClass; MethodSymbol currentMethodSymPrev = currentMethodSym; + currentClass = tree.sym; currentMethodSym = null; + attrEnv = typeEnvs.remove(currentClass); + if (attrEnv == null) + attrEnv = prevEnv; + classdefs.put(currentClass, tree); proxies = proxies.dup(currentClass); @@ -2526,6 +2535,7 @@ // Append translated tree to `translated' queue. translated.append(tree); + attrEnv = prevEnv; currentClass = currentClassPrev; currentMethodSym = currentMethodSymPrev; @@ -3471,7 +3481,7 @@ private void visitIterableForeachLoop(JCEnhancedForLoop tree) { make_at(tree.expr.pos()); Type iteratorTarget = syms.objectType; - Type iterableType = types.asSuper(types.upperBound(tree.expr.type), + Type iterableType = types.asSuper(types.cvarUpperBound(tree.expr.type), syms.iterableType.tsym); if (iterableType.getTypeArguments().nonEmpty()) iteratorTarget = types.erasure(iterableType.getTypeArguments().head); @@ -3505,7 +3515,7 @@ List.<Type>nil()); JCExpression vardefinit = make.App(make.Select(make.Ident(itvar), next)); if (tree.var.type.isPrimitive()) - vardefinit = make.TypeCast(types.upperBound(iteratorTarget), vardefinit); + vardefinit = make.TypeCast(types.cvarUpperBound(iteratorTarget), vardefinit); else vardefinit = make.TypeCast(tree.var.type, vardefinit); JCVariableDecl indexDef = (JCVariableDecl)make.VarDef(tree.var.mods,
--- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Tue Aug 19 23:57:05 2014 +0100 @@ -86,6 +86,7 @@ private final Target target; private final DeferredLintHandler deferredLintHandler; private final Lint lint; + private final TypeEnvs typeEnvs; public static MemberEnter instance(Context context) { MemberEnter instance = context.get(memberEnterKey); @@ -113,6 +114,7 @@ target = Target.instance(context); deferredLintHandler = DeferredLintHandler.instance(context); lint = Lint.instance(context); + typeEnvs = TypeEnvs.instance(context); allowTypeAnnos = source.allowTypeAnnotations(); allowRepeatedAnnos = source.allowRepeatedAnnotations(); } @@ -652,22 +654,8 @@ attr.attribIdentAsEnumType(localEnv, (JCIdent)tree.vartype); } else { attr.attribType(tree.vartype, localEnv); - if (tree.nameexpr != null) { - attr.attribExpr(tree.nameexpr, localEnv); - MethodSymbol m = localEnv.enclMethod.sym; - if (m.isConstructor()) { - Type outertype = m.owner.owner.type; - if (outertype.hasTag(TypeTag.CLASS)) { - checkType(tree.vartype, outertype, "incorrect.constructor.receiver.type"); - checkType(tree.nameexpr, outertype, "incorrect.constructor.receiver.name"); - } else { - log.error(tree, "receiver.parameter.not.applicable.constructor.toplevel.class"); - } - } else { - checkType(tree.vartype, m.owner.type, "incorrect.receiver.type"); - checkType(tree.nameexpr, m.owner.type, "incorrect.receiver.name"); - } - } + if (TreeInfo.isReceiverParam(tree)) + checkReceiver(tree, localEnv); } } finally { deferredLintHandler.setPos(prevLintPos); @@ -714,6 +702,26 @@ log.error(tree, diag, type, tree.type); } } + void checkReceiver(JCVariableDecl tree, Env<AttrContext> localEnv) { + attr.attribExpr(tree.nameexpr, localEnv); + MethodSymbol m = localEnv.enclMethod.sym; + if (m.isConstructor()) { + Type outertype = m.owner.owner.type; + if (outertype.hasTag(TypeTag.METHOD)) { + // we have a local inner class + outertype = m.owner.owner.owner.type; + } + if (outertype.hasTag(TypeTag.CLASS)) { + checkType(tree.vartype, outertype, "incorrect.constructor.receiver.type"); + checkType(tree.nameexpr, outertype, "incorrect.constructor.receiver.name"); + } else { + log.error(tree, "receiver.parameter.not.applicable.constructor.toplevel.class"); + } + } else { + checkType(tree.vartype, m.owner.type, "incorrect.receiver.type"); + checkType(tree.nameexpr, m.owner.type, "incorrect.receiver.name"); + } + } public boolean needsLazyConstValue(JCTree tree) { InitTreeVisitor initTreeVisitor = new InitTreeVisitor(); @@ -1018,7 +1026,7 @@ ClassSymbol c = (ClassSymbol)sym; ClassType ct = (ClassType)c.type; - Env<AttrContext> env = enter.typeEnvs.get(c); + Env<AttrContext> env = typeEnvs.get(c); JCClassDecl tree = (JCClassDecl)env.tree; boolean wasFirst = isFirst; isFirst = false;
--- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Tue Aug 19 23:57:05 2014 +0100 @@ -95,7 +95,7 @@ public final boolean boxingEnabled; public final boolean varargsEnabled; public final boolean allowMethodHandles; - public final boolean allowStructuralMostSpecific; + public final boolean allowFunctionalInterfaceMostSpecific; private final boolean debugResolve; private final boolean compactMethodDiags; final EnumSet<VerboseResolutionMode> verboseResolutionMode; @@ -136,7 +136,7 @@ verboseResolutionMode = VerboseResolutionMode.getVerboseResolutionMode(options); Target target = Target.instance(context); allowMethodHandles = target.hasMethodHandles(); - allowStructuralMostSpecific = source.allowStructuralMostSpecific(); + allowFunctionalInterfaceMostSpecific = source.allowFunctionalInterfaceMostSpecific(); polymorphicSignatureScope = new Scope(syms.noSymbol); inapplicableMethodException = new InapplicableMethodException(diags); @@ -348,7 +348,7 @@ boolean isAccessible(Env<AttrContext> env, Type t, boolean checkInner) { return (t.hasTag(ARRAY)) - ? isAccessible(env, types.upperBound(types.elemtype(t))) + ? isAccessible(env, types.cvarUpperBound(types.elemtype(t))) : isAccessible(env, t.tsym, checkInner); } @@ -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"; + } }; /** @@ -899,8 +910,10 @@ @Override public boolean compatible(Type found, Type req, Warner warn) { - found = pendingInferenceContext.asFree(found); - req = infer.returnConstraintTarget(found, req); + found = pendingInferenceContext.asUndetVar(found); + if (found.hasTag(UNDETVAR) && req.isPrimitive()) { + req = types.boxedClass(req).type; + } return super.compatible(found, req, warn); } @@ -936,8 +949,8 @@ public boolean compatible(Type found, Type req, Warner warn) { return strict ? - types.isSubtypeUnchecked(found, deferredAttrContext.inferenceContext.asFree(req), warn) : - types.isConvertible(found, deferredAttrContext.inferenceContext.asFree(req), warn); + types.isSubtypeUnchecked(found, deferredAttrContext.inferenceContext.asUndetVar(req), warn) : + types.isConvertible(found, deferredAttrContext.inferenceContext.asUndetVar(req), warn); } public void report(DiagnosticPosition pos, JCDiagnostic details) { @@ -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)); } } @@ -987,7 +1011,7 @@ */ private Type U(Type found) { return found == pt ? - found : types.upperBound(found); + found : types.cvarUpperBound(found); } @Override @@ -1057,50 +1081,47 @@ } public boolean compatible(Type found, Type req, Warner warn) { - if (!allowStructuralMostSpecific || actual == null) { - return super.compatible(found, req, warn); - } else { - switch (actual.getTag()) { - case DEFERRED: - DeferredType dt = (DeferredType) actual; - DeferredType.SpeculativeCache.Entry e = dt.speculativeCache.get(deferredAttrContext.msym, deferredAttrContext.phase); - return (e == null || e.speculativeTree == deferredAttr.stuckTree) - ? super.compatible(found, req, warn) : - mostSpecific(found, req, e.speculativeTree, warn); - default: - return standaloneMostSpecific(found, req, actual, warn); + if (allowFunctionalInterfaceMostSpecific && + unrelatedFunctionalInterfaces(found, req) && + (actual != null && actual.getTag() == DEFERRED)) { + DeferredType dt = (DeferredType) actual; + DeferredType.SpeculativeCache.Entry e = + dt.speculativeCache.get(deferredAttrContext.msym, deferredAttrContext.phase); + if (e != null && e.speculativeTree != deferredAttr.stuckTree) { + return functionalInterfaceMostSpecific(found, req, e.speculativeTree, warn); } } + return super.compatible(found, req, warn); } - private boolean mostSpecific(Type t, Type s, JCTree tree, Warner warn) { - MostSpecificChecker msc = new MostSpecificChecker(t, s, warn); + /** Whether {@code t} and {@code s} are unrelated functional interface types. */ + private boolean unrelatedFunctionalInterfaces(Type t, Type s) { + return types.isFunctionalInterface(t.tsym) && + types.isFunctionalInterface(s.tsym) && + types.asSuper(t, s.tsym) == null && + types.asSuper(s, t.tsym) == null; + } + + /** Parameters {@code t} and {@code s} are unrelated functional interface types. */ + private boolean functionalInterfaceMostSpecific(Type t, Type s, JCTree tree, Warner warn) { + FunctionalInterfaceMostSpecificChecker msc = new FunctionalInterfaceMostSpecificChecker(t, s, warn); msc.scan(tree); return msc.result; } - boolean polyMostSpecific(Type t1, Type t2, Warner warn) { - return (!t1.isPrimitive() && t2.isPrimitive()) - ? true : super.compatible(t1, t2, warn); - } - - boolean standaloneMostSpecific(Type t1, Type t2, Type exprType, Warner warn) { - return (exprType.isPrimitive() == t1.isPrimitive() - && exprType.isPrimitive() != t2.isPrimitive()) - ? true : super.compatible(t1, t2, warn); - } - /** - * Structural checker for most specific. + * Tests whether one functional interface type can be considered more specific + * than another unrelated functional interface type for the scanned expression. */ - class MostSpecificChecker extends DeferredAttr.PolyScanner { + class FunctionalInterfaceMostSpecificChecker extends DeferredAttr.PolyScanner { final Type t; final Type s; final Warner warn; boolean result; - MostSpecificChecker(Type t, Type s, Warner warn) { + /** Parameters {@code t} and {@code s} are unrelated functional interface types. */ + FunctionalInterfaceMostSpecificChecker(Type t, Type s, Warner warn) { this.t = t; this.s = s; this.warn = warn; @@ -1109,102 +1130,96 @@ @Override void skip(JCTree tree) { - result &= standaloneMostSpecific(t, s, tree.type, warn); + result &= false; } @Override public void visitConditional(JCConditional tree) { - if (tree.polyKind == PolyKind.STANDALONE) { - result &= standaloneMostSpecific(t, s, tree.type, warn); - } else { - super.visitConditional(tree); - } - } - - @Override - public void visitApply(JCMethodInvocation tree) { - result &= (tree.polyKind == PolyKind.STANDALONE) - ? standaloneMostSpecific(t, s, tree.type, warn) - : polyMostSpecific(t, s, warn); - } - - @Override - public void visitNewClass(JCNewClass tree) { - result &= (tree.polyKind == PolyKind.STANDALONE) - ? standaloneMostSpecific(t, s, tree.type, warn) - : polyMostSpecific(t, s, warn); + scan(tree.truepart); + scan(tree.falsepart); } @Override public void visitReference(JCMemberReference tree) { - if (types.isFunctionalInterface(t.tsym) && - types.isFunctionalInterface(s.tsym)) { - Type desc_t = types.findDescriptorType(t); - Type desc_s = types.findDescriptorType(s); - if (types.isSameTypes(desc_t.getParameterTypes(), - inferenceContext().asFree(desc_s.getParameterTypes()))) { - if (types.asSuper(t, s.tsym) != null || - types.asSuper(s, t.tsym) != null) { - result &= MostSpecificCheckContext.super.compatible(t, s, warn); - } else if (!desc_s.getReturnType().hasTag(VOID)) { - //perform structural comparison - Type ret_t = desc_t.getReturnType(); - Type ret_s = desc_s.getReturnType(); - result &= ((tree.refPolyKind == PolyKind.STANDALONE) - ? standaloneMostSpecific(ret_t, ret_s, tree.sym.type.getReturnType(), warn) - : polyMostSpecific(ret_t, ret_s, warn)); - } else { - return; - } + Type desc_t = types.findDescriptorType(t); + Type desc_s = types.findDescriptorType(s); + // use inference variables here for more-specific inference (18.5.4) + if (!types.isSameTypes(desc_t.getParameterTypes(), + inferenceContext().asUndetVars(desc_s.getParameterTypes()))) { + result &= false; + } else { + // compare return types + Type ret_t = desc_t.getReturnType(); + Type ret_s = desc_s.getReturnType(); + if (ret_s.hasTag(VOID)) { + result &= true; + } else if (ret_t.hasTag(VOID)) { + result &= false; + } else if (ret_t.isPrimitive() != ret_s.isPrimitive()) { + boolean retValIsPrimitive = + tree.refPolyKind == PolyKind.STANDALONE && + tree.sym.type.getReturnType().isPrimitive(); + result &= (retValIsPrimitive == ret_t.isPrimitive()) && + (retValIsPrimitive != ret_s.isPrimitive()); + } else { + result &= MostSpecificCheckContext.super.compatible(ret_t, ret_s, warn); } - } else { - result &= false; } } @Override public void visitLambda(JCLambda tree) { - if (types.isFunctionalInterface(t.tsym) && - types.isFunctionalInterface(s.tsym)) { - Type desc_t = types.findDescriptorType(t); - Type desc_s = types.findDescriptorType(s); - if (types.isSameTypes(desc_t.getParameterTypes(), - inferenceContext().asFree(desc_s.getParameterTypes()))) { - if (types.asSuper(t, s.tsym) != null || - types.asSuper(s, t.tsym) != null) { - result &= MostSpecificCheckContext.super.compatible(t, s, warn); - } else if (!desc_s.getReturnType().hasTag(VOID)) { - //perform structural comparison - Type ret_t = desc_t.getReturnType(); - Type ret_s = desc_s.getReturnType(); - scanLambdaBody(tree, ret_t, ret_s); - } else { - return; + Type desc_t = types.findDescriptorType(t); + Type desc_s = types.findDescriptorType(s); + // use inference variables here for more-specific inference (18.5.4) + if (!types.isSameTypes(desc_t.getParameterTypes(), + inferenceContext().asUndetVars(desc_s.getParameterTypes()))) { + result &= false; + } else { + // compare return types + Type ret_t = desc_t.getReturnType(); + Type ret_s = desc_s.getReturnType(); + if (ret_s.hasTag(VOID)) { + result &= true; + } else if (ret_t.hasTag(VOID)) { + result &= false; + } else if (unrelatedFunctionalInterfaces(ret_t, ret_s)) { + for (JCExpression expr : lambdaResults(tree)) { + result &= functionalInterfaceMostSpecific(ret_t, ret_s, expr, warn); } + } else if (ret_t.isPrimitive() != ret_s.isPrimitive()) { + for (JCExpression expr : lambdaResults(tree)) { + boolean retValIsPrimitive = expr.isStandalone() && expr.type.isPrimitive(); + result &= (retValIsPrimitive == ret_t.isPrimitive()) && + (retValIsPrimitive != ret_s.isPrimitive()); + } + } else { + result &= MostSpecificCheckContext.super.compatible(ret_t, ret_s, warn); } - } else { - result &= false; } } //where - void scanLambdaBody(JCLambda lambda, final Type t, final Type s) { + private List<JCExpression> lambdaResults(JCLambda lambda) { if (lambda.getBodyKind() == JCTree.JCLambda.BodyKind.EXPRESSION) { - result &= MostSpecificCheckContext.this.mostSpecific(t, s, lambda.body, warn); + return List.of((JCExpression) lambda.body); } else { + final ListBuffer<JCExpression> buffer = new ListBuffer<>(); DeferredAttr.LambdaReturnScanner lambdaScanner = new DeferredAttr.LambdaReturnScanner() { @Override public void visitReturn(JCReturn tree) { if (tree.expr != null) { - result &= MostSpecificCheckContext.this.mostSpecific(t, s, tree.expr, warn); + buffer.append(tree.expr); } } }; lambdaScanner.scan(lambda.body); + return buffer.toList(); } } } + } public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) { @@ -1408,7 +1423,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 +1515,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 +1548,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 +2191,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 +2580,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 +2988,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; @@ -3152,7 +3175,7 @@ if (TreeInfo.isStaticSelector(referenceTree.expr, names) && argtypes.nonEmpty() && (argtypes.head.hasTag(NONE) || - types.isSubtypeUnchecked(inferenceContext.asFree(argtypes.head), site))) { + types.isSubtypeUnchecked(inferenceContext.asUndetVar(argtypes.head), site))) { return new UnboundMethodReferenceLookupHelper(referenceTree, name, site, argtypes, typeargtypes, maxPhase); } else { @@ -4265,7 +4288,11 @@ } DeferredAttrContext deferredAttrContext(Symbol sym, InferenceContext inferenceContext, ResultInfo pendingResult, Warner warn) { - return deferredAttr.new DeferredAttrContext(attrMode, sym, step, inferenceContext, pendingResult != null ? pendingResult.checkContext.deferredAttrContext() : deferredAttr.emptyDeferredAttrContext, warn); + DeferredAttrContext parent = (pendingResult == null) + ? deferredAttr.emptyDeferredAttrContext + : pendingResult.checkContext.deferredAttrContext(); + return deferredAttr.new DeferredAttrContext(attrMode, sym, step, + inferenceContext, parent, warn); } /**
--- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Tue Aug 19 23:57:05 2014 +0100 @@ -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 @@ -835,6 +835,8 @@ public void visitReference(JCMemberReference tree) { tree.expr = translate(tree.expr, erasure(tree.expr.type)); tree.type = erasure(tree.type); + if (tree.varargsElement != null) + tree.varargsElement = erasure(tree.varargsElement); result = tree; } @@ -965,10 +967,11 @@ translateClass((ClassSymbol)st.tsym); } - Env<AttrContext> myEnv = enter.typeEnvs.remove(c); - if (myEnv == null) { + Env<AttrContext> myEnv = enter.getEnv(c); + if (myEnv == null || (c.flags_field & TYPE_TRANSLATED) != 0) { return; } + c.flags_field |= TYPE_TRANSLATED; /* The two assertions below are set for early detection of any attempt * to translate a class that:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/tools/javac/comp/TypeEnvs.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,63 @@ +/* + * 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. + */ + +package com.sun.tools.javac.comp; + +import java.util.Collection; +import java.util.HashMap; +import com.sun.tools.javac.code.Symbol.TypeSymbol; +import com.sun.tools.javac.util.Context; + +/** This class contains the type environments used by Enter, MemberEnter, + * Attr, DeferredAttr, and Lower. + * + * <p><b>This is NOT part of any supported API. + * If you write code that depends on this, you do so at your own risk. + * This code and its internal interfaces are subject to change or + * deletion without notice.</b> + */ +class TypeEnvs { + private static final long serialVersionUID = 571524752489954631L; + + protected static final Context.Key<TypeEnvs> typeEnvsKey = new Context.Key<>(); + public static TypeEnvs instance(Context context) { + TypeEnvs instance = context.get(typeEnvsKey); + if (instance == null) + instance = new TypeEnvs(context); + return instance; + } + + private HashMap<TypeSymbol,Env<AttrContext>> map; + protected TypeEnvs(Context context) { + map = new HashMap<>(); + context.put(typeEnvsKey, this); + } + + Env<AttrContext> get(TypeSymbol sym) { return map.get(sym); } + Env<AttrContext> put(TypeSymbol sym, Env<AttrContext> env) { return map.put(sym, env); } + Env<AttrContext> remove(TypeSymbol sym) { return map.remove(sym); } + Collection<Env<AttrContext>> values() { return map.values(); } + void clear() { map.clear(); } +}
--- a/src/share/classes/com/sun/tools/javac/file/Locations.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/file/Locations.java Tue Aug 19 23:57:05 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -51,6 +51,7 @@ import com.sun.tools.javac.util.ListBuffer; import com.sun.tools.javac.util.Log; import com.sun.tools.javac.util.Options; +import com.sun.tools.javac.util.StringUtils; import javax.tools.JavaFileManager; import javax.tools.StandardJavaFileManager; @@ -717,7 +718,7 @@ /** Is this the name of an archive file? */ private boolean isArchive(File file) { - String n = file.getName().toLowerCase(); + String n = StringUtils.toLowerCase(file.getName()); return fsInfo.isFile(file) && (n.endsWith(".jar") || n.endsWith(".zip")); }
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Tue Aug 19 23:57:05 2014 +0100 @@ -512,14 +512,14 @@ break; case CONSTANT_Fieldref: { ClassSymbol owner = readClassSymbol(getChar(index + 1)); - NameAndType nt = (NameAndType)readPool(getChar(index + 3)); + NameAndType nt = readNameAndType(getChar(index + 3)); poolObj[i] = new VarSymbol(0, nt.name, nt.uniqueType.type, owner); break; } case CONSTANT_Methodref: case CONSTANT_InterfaceMethodref: { ClassSymbol owner = readClassSymbol(getChar(index + 1)); - NameAndType nt = (NameAndType)readPool(getChar(index + 3)); + NameAndType nt = readNameAndType(getChar(index + 3)); poolObj[i] = new MethodSymbol(0, nt.name, nt.uniqueType.type, owner); break; } @@ -588,13 +588,34 @@ /** Read class entry. */ ClassSymbol readClassSymbol(int i) { - return (ClassSymbol) (readPool(i)); + Object obj = readPool(i); + if (obj != null && !(obj instanceof ClassSymbol)) + throw badClassFile("bad.const.pool.entry", + currentClassFile.toString(), + "CONSTANT_Class_info", i); + return (ClassSymbol)obj; } /** Read name. */ Name readName(int i) { - return (Name) (readPool(i)); + Object obj = readPool(i); + if (obj != null && !(obj instanceof Name)) + throw badClassFile("bad.const.pool.entry", + currentClassFile.toString(), + "CONSTANT_Utf8_info or CONSTANT_String_info", i); + return (Name)obj; + } + + /** Read name and type. + */ + NameAndType readNameAndType(int i) { + Object obj = readPool(i); + if (obj != null && !(obj instanceof NameAndType)) + throw badClassFile("bad.const.pool.entry", + currentClassFile.toString(), + "CONSTANT_NameAndType_info", i); + return (NameAndType)obj; } /************************************************************************ @@ -1245,7 +1266,7 @@ sym.owner.members().remove(sym); ClassSymbol self = (ClassSymbol)sym; ClassSymbol c = readClassSymbol(nextChar()); - NameAndType nt = (NameAndType)readPool(nextChar()); + NameAndType nt = readNameAndType(nextChar()); if (c.members_field == null) throw badClassFile("bad.enclosing.class", self, c);
--- a/src/share/classes/com/sun/tools/javac/jvm/Code.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java Tue Aug 19 23:57:05 2014 +0100 @@ -1925,6 +1925,13 @@ return aliveRanges.isEmpty() ? null : aliveRanges.get(aliveRanges.size() - 1); } + void removeLastRange() { + Range lastRange = lastRange(); + if (lastRange != null) { + aliveRanges.remove(lastRange); + } + } + @Override public String toString() { if (aliveRanges == null) { @@ -1955,9 +1962,7 @@ } } } else { - if (!aliveRanges.isEmpty()) { - aliveRanges.remove(aliveRanges.size() - 1); - } + removeLastRange(); } } @@ -1965,16 +1970,14 @@ if (aliveRanges.isEmpty()) { return false; } - Range range = lastRange(); - return range.length == Character.MAX_VALUE; + return lastRange().length == Character.MAX_VALUE; } public boolean isLastRangeInitialized() { if (aliveRanges.isEmpty()) { return false; } - Range range = lastRange(); - return range.start_pc != Character.MAX_VALUE; + return lastRange().start_pc != Character.MAX_VALUE; } public Range getWidestRange() { @@ -2095,7 +2098,7 @@ v.closeRange(length); putVar(v); } else { - v.lastRange().start_pc = Character.MAX_VALUE; + v.removeLastRange(); } } }
--- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java Tue Aug 19 23:57:05 2014 +0100 @@ -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 @@ -1811,8 +1811,7 @@ genStat(tree.thenpart, env, CRT_STATEMENT | CRT_FLOW_TARGET); thenExit = code.branch(goto_); if (varDebugInfo && lvtRanges.containsKey(code.meth, tree.thenpart)) { - code.closeAliveRanges(tree.thenpart, - thenExit != null && tree.elsepart == null ? thenExit.pc : code.cp); + code.closeAliveRanges(tree.thenpart, code.cp); } } if (elseChain != null) { @@ -2818,7 +2817,7 @@ } private LVTAssignAnalyzer(LVTRanges lvtRanges, Symtab syms, Names names) { - super(new LVTBits(), syms, names); + super(new LVTBits(), syms, names, false); lvtInits = (LVTBits)inits; this.lvtRanges = lvtRanges; }
--- a/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Tue Aug 19 23:57:05 2014 +0100 @@ -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/main/Option.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/main/Option.java Tue Aug 19 23:57:05 2014 +0100 @@ -47,6 +47,7 @@ import com.sun.tools.javac.util.Log.PrefixKind; import com.sun.tools.javac.util.Log.WriterKind; import com.sun.tools.javac.util.Options; +import com.sun.tools.javac.util.StringUtils; import static com.sun.tools.javac.main.Option.ChoiceKind.*; import static com.sun.tools.javac.main.Option.OptionGroup.*; import static com.sun.tools.javac.main.Option.OptionKind.*; @@ -713,7 +714,7 @@ String v = options.get(XPKGINFO); return (v == null ? PkgInfo.LEGACY - : PkgInfo.valueOf(v.toUpperCase())); + : PkgInfo.valueOf(StringUtils.toUpperCase(v))); } }
--- a/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Tue Aug 19 23:57:05 2014 +0100 @@ -57,6 +57,7 @@ import com.sun.tools.javac.util.Names; import com.sun.tools.javac.util.Options; import com.sun.tools.javac.util.Position; +import com.sun.tools.javac.util.StringUtils; import static com.sun.tools.javac.util.LayoutCharacters.*; /** @@ -993,7 +994,7 @@ "h1", "h2", "h3", "h4", "h5", "h6", "p", "pre")); protected boolean isSentenceBreak(Name n) { - return htmlBlockTags.contains(n.toString().toLowerCase()); + return htmlBlockTags.contains(StringUtils.toLowerCase(n.toString())); } protected boolean isSentenceBreak(DCTree t) {
--- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Tue Aug 19 23:57:05 2014 +0100 @@ -161,6 +161,7 @@ this.allowStaticInterfaceMethods = source.allowStaticInterfaceMethods(); this.allowIntersectionTypesInCast = source.allowIntersectionTypesInCast(); this.allowTypeAnnotations = source.allowTypeAnnotations(); + this.allowAnnotationsAfterTypeParams = source.allowAnnotationsAfterTypeParams(); this.keepDocComments = keepDocComments; docComments = newDocCommentTable(keepDocComments, fac); this.keepLineMap = keepLineMap; @@ -254,6 +255,10 @@ */ boolean allowTypeAnnotations; + /** Switch: should we allow annotations after the method type parameters? + */ + boolean allowAnnotationsAfterTypeParams; + /** Switch: is "this" allowed as an identifier? * This is needed to parse receiver types. */ @@ -2020,7 +2025,7 @@ /** Creator = [Annotations] Qualident [TypeArguments] ( ArrayCreatorRest | ClassCreatorRest ) */ JCExpression creator(int newpos, List<JCExpression> typeArgs) { - List<JCAnnotation> newAnnotations = annotationsOpt(Tag.ANNOTATION); + List<JCAnnotation> newAnnotations = typeAnnotationsOpt(); switch (token.kind) { case BYTE: case SHORT: case CHAR: case INT: case LONG: case FLOAT: @@ -3401,16 +3406,28 @@ * | ModifiersOpt * ( Type Ident * ( VariableDeclaratorsRest ";" | MethodDeclaratorRest ) - * | VOID Ident MethodDeclaratorRest - * | TypeParameters (Type | VOID) Ident MethodDeclaratorRest + * | VOID Ident VoidMethodDeclaratorRest + * | TypeParameters [Annotations] + * ( Type Ident MethodDeclaratorRest + * | VOID Ident VoidMethodDeclaratorRest + * ) * | Ident ConstructorDeclaratorRest * | TypeParameters Ident ConstructorDeclaratorRest * | ClassOrInterfaceOrEnumDeclaration * ) * InterfaceBodyDeclaration = * ";" - * | ModifiersOpt Type Ident - * ( ConstantDeclaratorsRest | InterfaceMethodDeclaratorRest ";" ) + * | ModifiersOpt + * ( Type Ident + * ( ConstantDeclaratorsRest ";" | MethodDeclaratorRest ) + * | VOID Ident MethodDeclaratorRest + * | TypeParameters [Annotations] + * ( Type Ident MethodDeclaratorRest + * | VOID Ident VoidMethodDeclaratorRest + * ) + * | ClassOrInterfaceOrEnumDeclaration + * ) + * */ protected List<JCTree> classOrInterfaceBodyDeclaration(Name className, boolean isInterface) { if (token.kind == SEMI) { @@ -3439,27 +3456,29 @@ } List<JCAnnotation> annosAfterParams = annotationsOpt(Tag.ANNOTATION); + if (annosAfterParams.nonEmpty()) { + checkAnnotationsAfterTypeParams(annosAfterParams.head.pos); + mods.annotations = mods.annotations.appendList(annosAfterParams); + if (mods.pos == Position.NOPOS) + mods.pos = mods.annotations.head.pos; + } + Token tk = token; pos = token.pos; JCExpression type; boolean isVoid = token.kind == VOID; if (isVoid) { - if (annosAfterParams.nonEmpty()) - illegal(annosAfterParams.head.pos); type = to(F.at(pos).TypeIdent(TypeTag.VOID)); nextToken(); } else { - if (annosAfterParams.nonEmpty()) { - mods.annotations = mods.annotations.appendList(annosAfterParams); - if (mods.pos == Position.NOPOS) - mods.pos = mods.annotations.head.pos; - } // method returns types are un-annotated types type = unannotatedType(); } if (token.kind == LPAREN && !isInterface && type.hasTag(IDENT)) { if (isInterface || tk.name() != className) error(pos, "invalid.meth.decl.ret.type.req"); + else if (annosAfterParams.nonEmpty()) + illegal(annosAfterParams.head.pos); return List.of(methodDeclaratorRest( pos, mods, null, names.init, typarams, isInterface, true, dc)); @@ -3491,13 +3510,9 @@ } /** MethodDeclaratorRest = - * FormalParameters BracketsOpt [Throws TypeList] ( MethodBody | [DEFAULT AnnotationValue] ";") + * FormalParameters BracketsOpt [THROWS TypeList] ( MethodBody | [DEFAULT AnnotationValue] ";") * VoidMethodDeclaratorRest = - * FormalParameters [Throws TypeList] ( MethodBody | ";") - * InterfaceMethodDeclaratorRest = - * FormalParameters BracketsOpt [THROWS TypeList] ";" - * VoidInterfaceMethodDeclaratorRest = - * FormalParameters [THROWS TypeList] ";" + * FormalParameters [THROWS TypeList] ( MethodBody | ";") * ConstructorDeclaratorRest = * "(" FormalParameterListOpt ")" [THROWS TypeList] MethodBody */ @@ -4041,21 +4056,28 @@ allowTypeAnnotations = true; } } + void checkAnnotationsAfterTypeParams(int pos) { + if (!allowAnnotationsAfterTypeParams) { + log.error(pos, "annotations.after.type.params.not.supported.in.source", source.name); + allowAnnotationsAfterTypeParams = true; + } + } /* * a functional source tree and end position mappings */ protected static class SimpleEndPosTable extends AbstractEndPosTable { - private final Map<JCTree, Integer> endPosMap; + private final IntHashTable endPosMap; SimpleEndPosTable(JavacParser parser) { super(parser); - endPosMap = new HashMap<JCTree, Integer>(); + endPosMap = new IntHashTable(); } public void storeEnd(JCTree tree, int endpos) { - endPosMap.put(tree, errorEndPos > endpos ? errorEndPos : endpos); + endPosMap.putAtIndex(tree, errorEndPos > endpos ? errorEndPos : endpos, + endPosMap.lookup(tree)); } protected <T extends JCTree> T to(T t) { @@ -4069,14 +4091,15 @@ } public int getEndPos(JCTree tree) { - Integer value = endPosMap.get(tree); - return (value == null) ? Position.NOPOS : value; + int value = endPosMap.getFromIndex(endPosMap.lookup(tree)); + // As long as Position.NOPOS==-1, this just returns value. + return (value == -1) ? Position.NOPOS : value; } public int replaceTree(JCTree oldTree, JCTree newTree) { - Integer pos = endPosMap.remove(oldTree); - if (pos != null) { - endPosMap.put(newTree, pos); + int pos = endPosMap.remove(oldTree); + if (pos != -1) { + storeEnd(newTree, pos); return pos; } return Position.NOPOS;
--- a/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java Tue Aug 19 23:57:05 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -36,6 +36,7 @@ import java.io.PrintWriter; import java.io.Writer; import java.util.*; +import com.sun.tools.javac.util.StringUtils; /** * A processor which prints out elements. Used to implement the @@ -202,7 +203,7 @@ writer.print("@interface"); break; default: - writer.print(kind.toString().toLowerCase()); + writer.print(StringUtils.toLowerCase(kind.toString())); } writer.print(" "); writer.print(e.getSimpleName());
--- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Tue Aug 19 23:57:05 2014 +0100 @@ -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 @@ -123,6 +123,9 @@ compiler.err.anon.class.impl.intf.no.qual.for.new=\ anonymous class implements interface; cannot have qualifier for new +compiler.err.cant.inherit.from.anon=\ + cannot inherit from anonymous class + # 0: symbol, 1: symbol, 2: symbol compiler.err.array.and.varargs=\ cannot declare both {0} and {1} in {2} @@ -732,6 +735,9 @@ bad return type in method reference\n\ {0} +compiler.err.lambda.body.neither.value.nor.void.compatible=\ + lambda body is neither value nor void compatible + # 0: list of type compiler.err.incompatible.thrown.types.in.mref=\ incompatible thrown types {0} in method reference @@ -1611,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 @@ -1699,6 +1709,11 @@ cannot access {0}\n\ {1} +# 0: file name, 1: expected CP entry type, 2: constant pool index +compiler.misc.bad.const.pool.entry=\ + bad constant pool entry in {0}\n\ + expected {1} at index {2} + # 0: file name, 1: message segment compiler.misc.bad.class.file.header=\ bad class file: {0}\n\ @@ -2311,6 +2326,11 @@ (use -source 8 or higher to enable type annotations) # 0: string +compiler.err.annotations.after.type.params.not.supported.in.source=\ + annotations after method type parameters are not supported in -source {0}\n\ +(use -source 8 or higher to enable annotations after method type parameters) + +# 0: string compiler.err.repeatable.annotations.not.supported.in.source=\ repeated annotations are not supported in -source {0}\n\ (use -source 8 or higher to enable repeated annotations) @@ -2370,6 +2390,11 @@ static interface methods are not supported in -source {0}\n\ (use -source 8 or higher to enable static interface methods) +# 0: string +compiler.err.static.intf.method.invoke.not.supported.in.source=\ + static interface method invocations are not supported in -source {0}\n\ + (use -source 8 or higher to enable static interface method invocations) + ######################################## # Diagnostics for verbose resolution # used by Resolve (debug only)
--- a/src/share/classes/com/sun/tools/javac/resources/compiler_ja.properties Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler_ja.properties Tue Aug 19 23:57:05 2014 +0100 @@ -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 @@ -98,11 +98,13 @@ compiler.err.annotation.value.not.allowable.type=\u4F7F\u7528\u3067\u304D\u306A\u3044\u578B\u306E\u6CE8\u91C8\u306E\u5024\u3067\u3059 -compiler.err.anon.class.impl.intf.no.args=\u540D\u524D\u306E\u306A\u3044\u30AF\u30E9\u30B9\u304C\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3092\u5B9F\u88C5\u3057\u3066\u3044\u307E\u3059\u3002\u5F15\u6570\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093 - -compiler.err.anon.class.impl.intf.no.typeargs=\u540D\u524D\u306E\u306A\u3044\u30AF\u30E9\u30B9\u304C\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3092\u5B9F\u88C5\u3057\u3066\u3044\u307E\u3059\u3002\u578B\u5F15\u6570\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093 - -compiler.err.anon.class.impl.intf.no.qual.for.new=\u540D\u524D\u306E\u306A\u3044\u30AF\u30E9\u30B9\u304C\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3092\u5B9F\u88C5\u3057\u3066\u3044\u307E\u3059\u3002new\u306B\u4FEE\u98FE\u5B50\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002 +compiler.err.anon.class.impl.intf.no.args=\u533F\u540D\u30AF\u30E9\u30B9\u304C\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3092\u5B9F\u88C5\u3057\u3066\u3044\u307E\u3059\u3002\u5F15\u6570\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093 + +compiler.err.anon.class.impl.intf.no.typeargs=\u533F\u540D\u30AF\u30E9\u30B9\u304C\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3092\u5B9F\u88C5\u3057\u3066\u3044\u307E\u3059\u3002\u578B\u5F15\u6570\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093 + +compiler.err.anon.class.impl.intf.no.qual.for.new=\u533F\u540D\u30AF\u30E9\u30B9\u304C\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3092\u5B9F\u88C5\u3057\u3066\u3044\u307E\u3059\u3002new\u306B\u4FEE\u98FE\u5B50\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002 + +compiler.err.cant.inherit.from.anon=\u533F\u540D\u30AF\u30E9\u30B9\u304B\u3089\u7D99\u627F\u3067\u304D\u307E\u305B\u3093 # 0: symbol, 1: symbol, 2: symbol compiler.err.array.and.varargs={2}\u3067{0}\u3068{1}\u306E\u4E21\u65B9\u3092\u5BA3\u8A00\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093 @@ -525,6 +527,8 @@ # 0: type compiler.misc.incompatible.ret.type.in.mref=\u30E1\u30BD\u30C3\u30C9\u53C2\u7167\u306E\u623B\u308A\u578B\u304C\u4E0D\u6B63\u3067\u3059\n{0} +compiler.err.lambda.body.neither.value.nor.void.compatible=\u30E9\u30E0\u30C0\u30FB\u30DC\u30C7\u30A3\u306F\u5024\u4E92\u63DB\u3067\u3082void\u4E92\u63DB\u3067\u3082\u3042\u308A\u307E\u305B\u3093 + # 0: list of type compiler.err.incompatible.thrown.types.in.mref=\u30E1\u30BD\u30C3\u30C9\u53C2\u7167\u306E\u30B9\u30ED\u30FC\u3055\u308C\u305F\u30BF\u30A4\u30D7{0}\u306F\u4E0D\u9069\u5408\u3067\u3059 @@ -1150,6 +1154,9 @@ # 0: symbol, 1: message segment compiler.warn.varargs.redundant.trustme.anno={0}\u6CE8\u91C8\u304C\u5197\u9577\u3067\u3059\u3002{1} +# 0: symbol +compiler.warn.access.to.sensitive.member.from.serializable.element=\u76F4\u5217\u5316\u53EF\u80FD\u8981\u7D20\u304B\u3089\u6A5F\u5BC6\u30E1\u30F3\u30D0\u30FC{0}\u3078\u306E\u30A2\u30AF\u30BB\u30B9\u306F\u3001\u4FE1\u983C\u3067\u304D\u306A\u3044\u30B3\u30FC\u30C9\u304B\u3089\u30D1\u30D6\u30EA\u30C3\u30AF\u306B\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u3067\u3042\u308B\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059 + ##### ## The following are tokens which are non-terminals in the language. They should @@ -1216,6 +1223,9 @@ # 0: symbol, 1: message segment compiler.err.cant.access={0}\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093\n{1} +# 0: file name, 1: expected CP entry type, 2: constant pool index +compiler.misc.bad.const.pool.entry={0}\u306E\u5B9A\u6570\u30D7\u30FC\u30EB\u30FB\u30A8\u30F3\u30C8\u30EA\u304C\u4E0D\u6B63\u3067\u3059\n\u7D22\u5F15{2}\u3067\u306F{1}\u304C\u5FC5\u8981\u3067\u3059 + # 0: file name, 1: message segment compiler.misc.bad.class.file.header=\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB{0}\u306F\u4E0D\u6B63\u3067\u3059\n{1}\n\u524A\u9664\u3059\u308B\u304B\u3001\u30AF\u30E9\u30B9\u30D1\u30B9\u306E\u6B63\u3057\u3044\u30B5\u30D6\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306B\u3042\u308B\u304B\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 @@ -1629,6 +1639,9 @@ compiler.err.type.annotations.not.supported.in.source=\u30BF\u30A4\u30D7\u6CE8\u91C8\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(\u30BF\u30A4\u30D7\u6CE8\u91C8\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 8\u4EE5\u4E0A\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044) # 0: string +compiler.err.annotations.after.type.params.not.supported.in.source=\u30E1\u30BD\u30C3\u30C9\u30FB\u30BF\u30A4\u30D7\u30FB\u30D1\u30E9\u30E1\u30FC\u30BF\u306E\u5F8C\u306E\u6CE8\u91C8\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(\u30E1\u30BD\u30C3\u30C9\u30FB\u30BF\u30A4\u30D7\u30FB\u30D1\u30E9\u30E1\u30FC\u30BF\u306E\u5F8C\u306E\u6CE8\u91C8\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 8\u4EE5\u4E0A\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044) + +# 0: string compiler.err.repeatable.annotations.not.supported.in.source=\u7E70\u8FD4\u3057\u6CE8\u91C8\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(\u7E70\u8FD4\u3057\u6CE8\u91C8\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 8\u4EE5\u4E0A\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044) # 0: string
--- a/src/share/classes/com/sun/tools/javac/resources/compiler_zh_CN.properties Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler_zh_CN.properties Tue Aug 19 23:57:05 2014 +0100 @@ -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 @@ -104,6 +104,8 @@ compiler.err.anon.class.impl.intf.no.qual.for.new=\u533F\u540D\u7C7B\u5B9E\u73B0\u63A5\u53E3; \u4E0D\u80FD\u6709\u9650\u5B9A\u7B26 - \u5BF9\u4E8E\u65B0 +compiler.err.cant.inherit.from.anon=\u65E0\u6CD5\u4ECE\u533F\u540D\u7C7B\u7EE7\u627F + # 0: symbol, 1: symbol, 2: symbol compiler.err.array.and.varargs=\u65E0\u6CD5\u5728{2}\u4E2D\u540C\u65F6\u58F0\u660E{0}\u548C{1} @@ -525,6 +527,8 @@ # 0: type compiler.misc.incompatible.ret.type.in.mref=\u65B9\u6CD5\u5F15\u7528\u4E2D\u7684\u8FD4\u56DE\u7C7B\u578B\u9519\u8BEF\n{0} +compiler.err.lambda.body.neither.value.nor.void.compatible=lambda \u4E3B\u4F53\u4E0D\u662F\u503C, \u4E5F\u4E0D\u4E0E void \u517C\u5BB9 + # 0: list of type compiler.err.incompatible.thrown.types.in.mref=\u65B9\u6CD5\u5F15\u7528\u4E2D\u629B\u51FA\u7684\u7C7B\u578B{0}\u4E0D\u517C\u5BB9 @@ -1150,6 +1154,9 @@ # 0: symbol, 1: message segment compiler.warn.varargs.redundant.trustme.anno=\u5197\u4F59\u7684 {0} \u6CE8\u91CA\u3002{1} +# 0: symbol +compiler.warn.access.to.sensitive.member.from.serializable.element=\u53EF\u4E32\u884C\u5316\u5143\u7D20\u5BF9\u654F\u611F\u6210\u5458 {0} \u7684\u8BBF\u95EE\u53EF\u4EE5\u7531\u4E0D\u53D7\u4FE1\u4EFB\u7684\u4EE3\u7801\u516C\u5F00\u6267\u884C + ##### ## The following are tokens which are non-terminals in the language. They should @@ -1216,6 +1223,9 @@ # 0: symbol, 1: message segment compiler.err.cant.access=\u65E0\u6CD5\u8BBF\u95EE{0}\n{1} +# 0: file name, 1: expected CP entry type, 2: constant pool index +compiler.misc.bad.const.pool.entry={0} \u4E2D\u9519\u8BEF\u7684\u5E38\u91CF\u6C60\u6761\u76EE\n\u9884\u671F\u4E3A\u7D22\u5F15 {2} \u5904\u7684 {1} + # 0: file name, 1: message segment compiler.misc.bad.class.file.header=\u9519\u8BEF\u7684\u7C7B\u6587\u4EF6: {0}\n{1}\n\u8BF7\u5220\u9664\u8BE5\u6587\u4EF6\u6216\u786E\u4FDD\u8BE5\u6587\u4EF6\u4F4D\u4E8E\u6B63\u786E\u7684\u7C7B\u8DEF\u5F84\u5B50\u76EE\u5F55\u4E2D\u3002 @@ -1629,6 +1639,9 @@ compiler.err.type.annotations.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301\u7C7B\u578B\u6CE8\u91CA\n(\u8BF7\u4F7F\u7528 -source 8 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528\u7C7B\u578B\u6CE8\u91CA) # 0: string +compiler.err.annotations.after.type.params.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301\u65B9\u6CD5\u7C7B\u578B\u53C2\u6570\u540E\u7684\u6CE8\u91CA\n(\u8BF7\u4F7F\u7528 -source 8 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528\u65B9\u6CD5\u7C7B\u578B\u53C2\u6570\u540E\u7684\u6CE8\u91CA) + +# 0: string compiler.err.repeatable.annotations.not.supported.in.source=-source {0}\u4E2D\u4E0D\u652F\u6301\u91CD\u590D\u6CE8\u91CA\n(\u8BF7\u4F7F\u7528 -source 8 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528\u91CD\u590D\u6CE8\u91CA) # 0: string
--- a/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties Tue Aug 19 23:57:05 2014 +0100 @@ -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/sym/Profiles.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/sym/Profiles.java Tue Aug 19 23:57:05 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -153,6 +153,8 @@ final int maxProfile = 4; // Three compact profiles plus full JRE MakefileProfiles(Properties p) { + // consider crypto, only if java/lang package exists + boolean foundJavaLang = false; for (int profile = 1; profile <= maxProfile; profile++) { String prefix = (profile < maxProfile ? "PROFILE_" + profile : "FULL_JRE"); String inclPackages = p.getProperty(prefix + "_RTJAR_INCLUDE_PACKAGES"); @@ -161,6 +163,8 @@ for (String pkg: inclPackages.substring(1).trim().split("\\s+")) { if (pkg.endsWith("/")) pkg = pkg.substring(0, pkg.length() - 1); + if (foundJavaLang == false && pkg.equals("java/lang")) + foundJavaLang = true; includePackage(profile, pkg); } String inclTypes = p.getProperty(prefix + "_RTJAR_INCLUDE_TYPES"); @@ -178,6 +182,15 @@ } } } + /* + * A hack to force javax/crypto package into the compact1 profile, + * because this package exists in jce.jar, and therefore not in + * ct.sym. Note javax/crypto should exist in a profile along with + * javax/net/ssl package. Thus, this package is added to compact1, + * implying that it should exist in all three profiles. + */ + if (foundJavaLang) + includePackage(1, "javax/crypto"); } @Override
--- a/src/share/classes/com/sun/tools/javac/tree/JCTree.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/tree/JCTree.java Tue Aug 19 23:57:05 2014 +0100 @@ -609,6 +609,9 @@ super.setPos(pos); return this; } + + public boolean isPoly() { return false; } + public boolean isStandalone() { return true; } } /** @@ -629,6 +632,9 @@ /** is this poly expression a 'true' poly expression? */ public PolyKind polyKind; + + @Override public boolean isPoly() { return polyKind == PolyKind.POLY; } + @Override public boolean isStandalone() { return polyKind == PolyKind.STANDALONE; } } /**
--- a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Tue Aug 19 23:57:05 2014 +0100 @@ -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 @@ -135,6 +135,14 @@ } } + public static boolean isReceiverParam(JCTree tree) { + if (tree.hasTag(VARDEF)) { + return ((JCVariableDecl)tree).nameexpr != null; + } else { + return false; + } + } + /** Is there a constructor declaration in the given list of trees? */ public static boolean hasConstructors(List<JCTree> trees) { @@ -831,6 +839,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/javac/tree/TreeTranslator.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java Tue Aug 19 23:57:05 2014 +0100 @@ -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 @@ -56,9 +56,9 @@ return null; } else { tree.accept(this); - JCTree result = this.result; + JCTree tmpResult = this.result; this.result = null; - return (T)result; // XXX cast + return (T)tmpResult; // XXX cast } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/tools/javac/util/IntHashTable.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,198 @@ +/* + * 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. + */ + +package com.sun.tools.javac.util; + +/** + * A hash table that maps Object to int. + * + * This is a custom hash table optimised for the Object -> int + * maps. This is done to avoid unnecessary object allocation in the image set. + * + * @author Charles Turner + * @author Per Bothner + */ +public class IntHashTable { + private static final int DEFAULT_INITIAL_SIZE = 64; + protected Object[] objs; // the domain set + protected int[] ints; // the image set + protected int mask; // used to clip int's into the domain + protected int num_bindings; // the number of mappings (including DELETED) + private final static Object DELETED = new Object(); + + /** + * Construct an Object -> int hash table. + * + * The default size of the hash table is 64 mappings. + */ + public IntHashTable() { + objs = new Object[DEFAULT_INITIAL_SIZE]; + ints = new int[DEFAULT_INITIAL_SIZE]; + mask = DEFAULT_INITIAL_SIZE - 1; + } + + /** + * Construct an Object -> int hash table with a specified amount of mappings. + * @param capacity The number of default mappings in this hash table. + */ + public IntHashTable(int capacity) { + int log2Size = 4; + while (capacity > (1 << log2Size)) { + log2Size++; + } + capacity = 1 << log2Size; + objs = new Object[capacity]; + ints = new int[capacity]; + mask = capacity - 1; + } + + /** + * Compute the hash code of a given object. + * + * @param key The object whose hash code is to be computed. + * @return zero if the object is null, otherwise the identityHashCode + */ + public int hash(Object key) { + return System.identityHashCode(key); + } + + /** + * Find either the index of a key's value, or the index of an available space. + * + * @param key The key to whose value you want to find. + * @param hash The hash code of this key. + * @return Either the index of the key's value, or an index pointing to + * unoccupied space. + */ + public int lookup(Object key, int hash) { + Object node; + int hash1 = hash ^ (hash >>> 15); + int hash2 = (hash ^ (hash << 6)) | 1; //ensure coprimeness + int deleted = -1; + for (int i = hash1 & mask;; i = (i + hash2) & mask) { + node = objs[i]; + if (node == key) + return i; + if (node == null) + return deleted >= 0 ? deleted : i; + if (node == DELETED && deleted < 0) + deleted = i; + } + } + + /** + * Lookup a given key's value in the hash table. + * + * @param key The key whose value you want to find. + * @return Either the index of the key's value, or an index pointing to + * unoccupied space. + */ + public int lookup(Object key) { + return lookup(key, hash(key)); + } + + /** + * Return the value stored at the specified index in the table. + * + * @param index The index to inspect, as returned from {@link #lookup} + * @return A non-negative integer if the index contains a non-null + * value, or -1 if it does. + */ + public int getFromIndex(int index) { + Object node = objs[index]; + return node == null || node == DELETED ? -1 : ints[index]; + } + + /** + * Associates the specified key with the specified value in this map. + * + * @param key key with which the specified value is to be associated. + * @param value value to be associated with the specified key. + * @param index the index at which to place this binding, as returned + * from {@link #lookup}. + * @return previous value associated with specified key, or -1 if there was + * no mapping for key. + */ + public int putAtIndex(Object key, int value, int index) { + Object old = objs[index]; + if (old == null || old == DELETED) { + objs[index] = key; + ints[index] = value; + if (old != DELETED) + num_bindings++; + if (3 * num_bindings >= 2 * objs.length) + rehash(); + return -1; + } else { // update existing mapping + int oldValue = ints[index]; + ints[index] = value; + return oldValue; + } + } + + public int remove(Object key) { + int index = lookup(key); + Object old = objs[index]; + if (old == null || old == DELETED) + return -1; + objs[index] = DELETED; + return ints[index]; + } + + /** + * Expand the hash table when it exceeds the load factor. + * + * Rehash the existing objects. + */ + protected void rehash() { + Object[] oldObjsTable = objs; + int[] oldIntsTable = ints; + int oldCapacity = oldObjsTable.length; + int newCapacity = oldCapacity << 1; + Object[] newObjTable = new Object[newCapacity]; + int[] newIntTable = new int[newCapacity]; + int newMask = newCapacity - 1; + objs = newObjTable; + ints = newIntTable; + mask = newMask; + num_bindings = 0; // this is recomputed below + Object key; + for (int i = oldIntsTable.length; --i >= 0;) { + key = oldObjsTable[i]; + if (key != null && key != DELETED) + putAtIndex(key, oldIntsTable[i], lookup(key, hash(key))); + } + } + + /** + * Removes all mappings from this map. + */ + public void clear() { + for (int i = objs.length; --i >= 0;) { + objs[i] = null; + } + num_bindings = 0; + } +}
--- a/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java Tue Aug 19 23:57:05 2014 +0100 @@ -355,13 +355,41 @@ private final DiagnosticType type; private final DiagnosticSource source; private final DiagnosticPosition position; - private final int line; - private final int column; private final String key; protected final Object[] args; private final Set<DiagnosticFlag> flags; private final LintCategory lintCategory; + /** source line position (set lazily) */ + private SourcePosition sourcePosition; + + /** + * This class is used to defer the line/column position fetch logic after diagnostic construction. + */ + class SourcePosition { + + private final int line; + private final int column; + + SourcePosition() { + int n = (position == null ? Position.NOPOS : position.getPreferredPosition()); + if (n == Position.NOPOS || source == null) + line = column = -1; + else { + line = source.getLineNumber(n); + column = source.getColumnNumber(n, true); + } + } + + public int getLineNumber() { + return line; + } + + public int getColumnNumber() { + return column; + } + } + /** * Create a diagnostic object. * @param formatter the formatter to use for the diagnostic @@ -391,14 +419,6 @@ this.position = pos; this.key = key; this.args = args; - - int n = (pos == null ? Position.NOPOS : pos.getPreferredPosition()); - if (n == Position.NOPOS || source == null) - line = column = -1; - else { - line = source.getLineNumber(n); - column = source.getColumnNumber(n, true); - } } /** @@ -495,7 +515,10 @@ * @return the line number within the source referred to by this diagnostic */ public long getLineNumber() { - return line; + if (sourcePosition == null) { + sourcePosition = new SourcePosition(); + } + return sourcePosition.getLineNumber(); } /** @@ -503,7 +526,10 @@ * @return the column number within the line of source referred to by this diagnostic */ public long getColumnNumber() { - return column; + if (sourcePosition == null) { + sourcePosition = new SourcePosition(); + } + return sourcePosition.getColumnNumber(); } /**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/tools/javac/util/StringUtils.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2013, 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. + */ + +package com.sun.tools.javac.util; + +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** A collection of utilities for String manipulation. + * + * <p><b>This is NOT part of any supported API. + * If you write code that depends on this, you do so at your own risk. + * This code and its internal interfaces are subject to change or + * deletion without notice.</b> + */ +public class StringUtils { + + /**Converts the given String to lower case using the {@link Locale#US US Locale}. The result + * is independent of the default Locale in the current JVM instance. + */ + public static String toLowerCase(String source) { + return source.toLowerCase(Locale.US); + } + + /**Converts the given String to upper case using the {@link Locale#US US Locale}. The result + * is independent of the default Locale in the current JVM instance. + */ + public static String toUpperCase(String source) { + return source.toUpperCase(Locale.US); + } + + /**Case insensitive version of {@link String#indexOf(java.lang.String)}. Equivalent to + * {@code text.indexOf(str)}, except the matching is case insensitive. + */ + public static int indexOfIgnoreCase(String text, String str) { + return indexOfIgnoreCase(text, str, 0); + } + + /**Case insensitive version of {@link String#indexOf(java.lang.String, int)}. Equivalent to + * {@code text.indexOf(str, startIndex)}, except the matching is case insensitive. + */ + public static int indexOfIgnoreCase(String text, String str, int startIndex) { + Matcher m = Pattern.compile(Pattern.quote(str), Pattern.CASE_INSENSITIVE).matcher(text); + return m.find(startIndex) ? m.start() : -1; + } + +}
--- a/src/share/classes/com/sun/tools/javadoc/JavadocTool.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javadoc/JavadocTool.java Tue Aug 19 23:57:05 2014 +0100 @@ -68,6 +68,7 @@ final Messager messager; final JavadocClassReader javadocReader; final JavadocEnter javadocEnter; + final Set<JavaFileObject> uniquefiles; /** * Construct a new JavaCompiler processor, using appropriately @@ -78,6 +79,7 @@ messager = Messager.instance0(context); javadocReader = JavadocClassReader.instance0(context); javadocEnter = JavadocEnter.instance0(context); + uniquefiles = new HashSet<>(); } /** @@ -148,9 +150,7 @@ String name = it.head; if (!docClasses && fm != null && name.endsWith(".java") && new File(name).exists()) { JavaFileObject fo = fm.getJavaFileObjects(name).iterator().next(); - docenv.notice("main.Loading_source_file", name); - JCCompilationUnit tree = parse(fo); - classTrees.append(tree); + parse(fo, classTrees, true); } else if (isValidPackageName(name)) { names = names.append(name); } else if (name.endsWith(".java")) { @@ -163,9 +163,7 @@ } } for (JavaFileObject fo: fileObjects) { - docenv.notice("main.Loading_source_file", fo.getName()); - JCCompilationUnit tree = parse(fo); - classTrees.append(tree); + parse(fo, classTrees, true); } if (!docClasses) { @@ -213,7 +211,7 @@ * .java files found in such a directory to args. */ private void parsePackageClasses(String name, - Iterable<JavaFileObject> files, + List<JavaFileObject> files, ListBuffer<JCCompilationUnit> trees, List<String> excludedPackages) throws IOException { @@ -221,7 +219,6 @@ return; } - boolean hasFiles = false; docenv.notice("main.Loading_source_files_for_package", name); if (files == null) { @@ -238,19 +235,22 @@ } files = lb.toList(); } + if (files.nonEmpty()) { + for (JavaFileObject fo : files) { + parse(fo, trees, false); + } + } else { + messager.warning(Messager.NOPOS, "main.no_source_files_for_package", + name.replace(File.separatorChar, '.')); + } + } - Set<JavaFileObject> ufiles = new HashSet<>(); - for (JavaFileObject fo : files) { - if (ufiles.add(fo)) { // ignore duplicates - // messager.notice("main.Loading_source_file", fn); - trees.append(parse(fo)); - hasFiles = true; - } - } - - if (!hasFiles) { - messager.warning(Messager.NOPOS, "main.no_source_files_for_package", - name.replace(File.separatorChar, '.')); + private void parse(JavaFileObject fo, ListBuffer<JCCompilationUnit> trees, + boolean trace) { + if (uniquefiles.add(fo)) { // ignore duplicates + if (trace) + docenv.notice("main.Loading_source_file", fo.getName()); + trees.append(parse(fo)); } }
--- a/src/share/classes/com/sun/tools/javadoc/resources/javadoc_ja.properties Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javadoc/resources/javadoc_ja.properties Tue Aug 19 23:57:05 2014 +0100 @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 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 @@ -28,7 +28,7 @@ main.warnings=\u8B66\u544A{0}\u500B main.warning=\u8B66\u544A{0}\u500B -main.usage=\u4F7F\u7528\u65B9\u6CD5: javadoc [options] [packagenames] [sourcefiles] [@files]\n -overview <file> HTML\u30D5\u30A1\u30A4\u30EB\u304B\u3089\u6982\u8981\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u8AAD\u307F\u8FBC\u3080\n -public public\u30AF\u30E9\u30B9\u3068\u30E1\u30F3\u30D0\u30FC\u306E\u307F\u3092\u793A\u3059\n -protected protected/public\u30AF\u30E9\u30B9\u3068\u30E1\u30F3\u30D0\u30FC\u3092\u793A\u3059(\u30C7\u30D5\u30A9\u30EB\u30C8)\n -package package/protected/public\u30AF\u30E9\u30B9\u3068\u30E1\u30F3\u30D0\u30FC\u3092\u793A\u3059\n -private \u3059\u3079\u3066\u306E\u30AF\u30E9\u30B9\u3068\u30E1\u30F3\u30D0\u30FC\u3092\u793A\u3059\n -help \u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u30FB\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u8868\u793A\u3057\u3066\u7D42\u4E86\u3059\u308B\n -doclet <class> \u4EE3\u66FFdoclet\u3092\u4ECB\u3057\u3066\u51FA\u529B\u3092\u751F\u6210\u3059\u308B\n -docletpath <path> doclet\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u63A2\u3059\u5834\u6240\u3092\u6307\u5B9A\u3059\u308B\n -sourcepath <pathlist> \u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u3042\u308B\u5834\u6240\u3092\u6307\u5B9A\u3059\u308B\n -classpath <pathlist> \u30E6\u30FC\u30B6\u30FC\u30FB\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u3042\u308B\u5834\u6240\u3092\u6307\u5B9A\u3059\u308B\n -cp <pathlist> \u30E6\u30FC\u30B6\u30FC\u30FB\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u3042\u308B\u5834\u6240\u3092\u6307\u5B9A\u3059\u308B\r\n -exclude <pkglist> \u9664\u5916\u3059\u308B\u30D1\u30C3\u30B1\u30FC\u30B8\u30FB\u30EA\u30B9\u30C8\u3092\u6307\u5B9A\u3059\u308B\n -subpackages <subpkglist> \u518D\u5E30\u7684\u306B\u30ED\u30FC\u30C9\u3059\u308B\u30B5\u30D6\u30D1\u30C3\u30B1\u30FC\u30B8\u3092\u6307\u5B9A\u3059\u308B\n -breakiterator BreakIterator\u3067\u6700\u521D\u306E\u6587\u3092\u8A08\u7B97\u3059\u308B\n -bootclasspath <pathlist> \u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u30AF\u30E9\u30B9\u30FB\u30ED\u30FC\u30C0\u30FC\u306B\u3088\u308A\u30ED\u30FC\u30C9\u3055\u308C\u305F\n \u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u5834\u6240\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B\n -source <release> \u6307\u5B9A\u3055\u308C\u305F\u30EA\u30EA\u30FC\u30B9\u3068\u30BD\u30FC\u30B9\u306E\u4E92\u63DB\u6027\u3092\u63D0\u4F9B\u3059\u308B\n -extdirs <dirlist> \u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3055\u308C\u305F\u62E1\u5F35\u6A5F\u80FD\u306E\u5834\u6240\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B\n -verbose Javadoc\u306E\u52D5\u4F5C\u306B\u3064\u3044\u3066\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u51FA\u529B\u3059\u308B\n -locale <name> en_US\u3084en_US_WIN\u306A\u3069\u306E\u4F7F\u7528\u3059\u308B\u30ED\u30B1\u30FC\u30EB\n -encoding <name> \u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0\u540D\n -quiet \u72B6\u614B\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u8868\u793A\u3057\u306A\u3044\n -J<flag> <flag>\u3092\u5B9F\u884C\u6642\u30B7\u30B9\u30C6\u30E0\u306B\u76F4\u63A5\u6E21\u3059\n -X \u975E\u6A19\u6E96\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u6982\u8981\u3092\u51FA\u529B\u3057\u7D42\u4E86\u3059\u308B\n +main.usage=\u4F7F\u7528\u65B9\u6CD5: javadoc [options] [packagenames] [sourcefiles] [@files]\n -overview <file> HTML\u30D5\u30A1\u30A4\u30EB\u304B\u3089\u6982\u8981\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u8AAD\u307F\u8FBC\u3080\n -public public\u30AF\u30E9\u30B9\u3068\u30E1\u30F3\u30D0\u30FC\u306E\u307F\u3092\u793A\u3059\n -protected protected/public\u30AF\u30E9\u30B9\u3068\u30E1\u30F3\u30D0\u30FC\u3092\u793A\u3059(\u30C7\u30D5\u30A9\u30EB\u30C8)\n -package package/protected/public\u30AF\u30E9\u30B9\u3068\u30E1\u30F3\u30D0\u30FC\u3092\u793A\u3059\n -private \u3059\u3079\u3066\u306E\u30AF\u30E9\u30B9\u3068\u30E1\u30F3\u30D0\u30FC\u3092\u793A\u3059\n -help \u30B3\u30DE\u30F3\u30C9\u884C\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u8868\u793A\u3057\u3066\u7D42\u4E86\u3059\u308B\n -doclet <class> \u4EE3\u66FFdoclet\u3092\u4ECB\u3057\u3066\u51FA\u529B\u3092\u751F\u6210\u3059\u308B\n -docletpath <path> doclet\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u63A2\u3059\u5834\u6240\u3092\u6307\u5B9A\u3059\u308B\n -sourcepath <pathlist> \u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u3042\u308B\u5834\u6240\u3092\u6307\u5B9A\u3059\u308B\n -classpath <pathlist> \u30E6\u30FC\u30B6\u30FC\u30FB\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u3042\u308B\u5834\u6240\u3092\u6307\u5B9A\u3059\u308B\n -cp <pathlist> \u30E6\u30FC\u30B6\u30FC\u30FB\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u3042\u308B\u5834\u6240\u3092\u6307\u5B9A\u3059\u308B\r\n -exclude <pkglist> \u9664\u5916\u3059\u308B\u30D1\u30C3\u30B1\u30FC\u30B8\u30FB\u30EA\u30B9\u30C8\u3092\u6307\u5B9A\u3059\u308B\n -subpackages <subpkglist> \u518D\u5E30\u7684\u306B\u30ED\u30FC\u30C9\u3059\u308B\u30B5\u30D6\u30D1\u30C3\u30B1\u30FC\u30B8\u3092\u6307\u5B9A\u3059\u308B\n -breakiterator BreakIterator\u3067\u6700\u521D\u306E\u6587\u3092\u8A08\u7B97\u3059\u308B\n -bootclasspath <pathlist> \u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u30AF\u30E9\u30B9\u30FB\u30ED\u30FC\u30C0\u30FC\u306B\u3088\u308A\u30ED\u30FC\u30C9\u3055\u308C\u305F\n \u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u5834\u6240\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B\n -source <release> \u6307\u5B9A\u3055\u308C\u305F\u30EA\u30EA\u30FC\u30B9\u3068\u30BD\u30FC\u30B9\u306E\u4E92\u63DB\u6027\u3092\u63D0\u4F9B\u3059\u308B\n -extdirs <dirlist> \u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3055\u308C\u305F\u62E1\u5F35\u6A5F\u80FD\u306E\u5834\u6240\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B\n -verbose Javadoc\u306E\u52D5\u4F5C\u306B\u3064\u3044\u3066\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u51FA\u529B\u3059\u308B\n -locale <name> en_US\u3084en_US_WIN\u306A\u3069\u306E\u4F7F\u7528\u3059\u308B\u30ED\u30B1\u30FC\u30EB\n -encoding <name> \u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0\u540D\n -quiet \u72B6\u614B\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u8868\u793A\u3057\u306A\u3044\n -J<flag> <flag>\u3092\u5B9F\u884C\u6642\u30B7\u30B9\u30C6\u30E0\u306B\u76F4\u63A5\u6E21\u3059\n -X \u975E\u6A19\u6E96\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u6982\u8981\u3092\u51FA\u529B\u3057\u7D42\u4E86\u3059\u308B\n main.Xusage=\ -Xmaxerrs <number> \u51FA\u529B\u3059\u308B\u30A8\u30E9\u30FC\u306E\u6700\u5927\u6570\u3092\u8A2D\u5B9A\u3059\u308B\n -Xmaxwarns <number> \u51FA\u529B\u3059\u308B\u8B66\u544A\u306E\u6700\u5927\u6570\u3092\u8A2D\u5B9A\u3059\u308B\n @@ -36,7 +36,7 @@ main.option.already.seen={0}\u30AA\u30D7\u30B7\u30E7\u30F3\u304C\u8907\u6570\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u3059\u3002 main.requires_argument=\u30AA\u30D7\u30B7\u30E7\u30F3{0}\u306B\u306F\u5F15\u6570\u304C\u5FC5\u8981\u3067\u3059\u3002 -main.locale_first=\u30AA\u30D7\u30B7\u30E7\u30F3-locale\u306F\u3001\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u306E\u6700\u521D\u306B\u6307\u5B9A\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002 +main.locale_first=\u30AA\u30D7\u30B7\u30E7\u30F3-locale\u306F\u3001\u30B3\u30DE\u30F3\u30C9\u884C\u306E\u6700\u521D\u306B\u6307\u5B9A\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002 main.invalid_flag={0}\u306F\u7121\u52B9\u306A\u30D5\u30E9\u30B0\u3067\u3059 main.No_packages_or_classes_specified=\u30D1\u30C3\u30B1\u30FC\u30B8\u307E\u305F\u306F\u30AF\u30E9\u30B9\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002 main.incompatible.access.flags=-public\u3001-private\u3001-package\u307E\u305F\u306F-protected\u306E\u3046\u3061\u306E2\u3064\u4EE5\u4E0A\u3092\u6307\u5B9A\u3057\u307E\u3057\u305F\u3002
--- a/src/share/classes/com/sun/tools/javah/resources/l10n_ja.properties Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javah/resources/l10n_ja.properties Tue Aug 19 23:57:05 2014 +0100 @@ -1,5 +1,5 @@ # -# Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1998, 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 @@ -27,9 +27,9 @@ # User errors, command line errors. # cant.create.dir=\u51FA\u529B\u7528\u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA{0}\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093\u3002 -at.args.cant.read=\u30D5\u30A1\u30A4\u30EB{1}\u304B\u3089\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u5F15\u6570\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3002 +at.args.cant.read=\u30D5\u30A1\u30A4\u30EB{1}\u304B\u3089\u30B3\u30DE\u30F3\u30C9\u884C\u5F15\u6570\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3002 at.args.file.not.found=\u30D5\u30A1\u30A4\u30EB{0}\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002 -at.args.io.exception=\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u306E@\u5F15\u6570\u306E\u51E6\u7406\u4E2D\u306B\u3001\u6B21\u306E\u5165\u51FA\u529B\u306E\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F: {0}\u3002 +at.args.io.exception=\u30B3\u30DE\u30F3\u30C9\u884C\u306E@\u5F15\u6570\u306E\u51E6\u7406\u4E2D\u306B\u3001\u6B21\u306E\u5165\u51FA\u529B\u306E\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F: {0}\u3002 old.jni.mixed=\u30AA\u30D7\u30B7\u30E7\u30F3-jni\u3068-old\u3092\u540C\u6642\u306B\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 old.llni.mixed=\u30AA\u30D7\u30B7\u30E7\u30F3-old\u3068-llni\u3092\u540C\u6642\u306B\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 old.not.supported=\u3053\u306E\u30D0\u30FC\u30B8\u30E7\u30F3\u306Ejavah\u3067\u306F\u30AA\u30D7\u30B7\u30E7\u30F3-old\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002 @@ -38,11 +38,11 @@ jni.no.stubs=JNI\u306F\u30B9\u30BF\u30D6\u3092\u5FC5\u8981\u3068\u3057\u307E\u305B\u3093\u3002JNI\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002 jni.sigerror={0}\u306E\u30B7\u30B0\u30CD\u30C1\u30E3\u3092\u5224\u5225\u3067\u304D\u307E\u305B\u3093 dir.file.mixed=\u30AA\u30D7\u30B7\u30E7\u30F3-d\u3068-o\u3092\u540C\u6642\u306B\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 -no.classes.specified=\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u3067\u30AF\u30E9\u30B9\u304C\u6307\u5B9A\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 -no.outputfile.specified=\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u3067\u51FA\u529B\u30D5\u30A1\u30A4\u30EB\u304C\u6307\u5B9A\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 -no.outputdir.specified=\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u3067\u51FA\u529B\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304C\u6307\u5B9A\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 -no.classpath.specified=\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u3067\u30AF\u30E9\u30B9\u30D1\u30B9\u304C\u6307\u5B9A\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 -no.bootclasspath.specified=\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u3067\u30D6\u30FC\u30C8\u30FB\u30AF\u30E9\u30B9\u30D1\u30B9\u304C\u6307\u5B9A\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 +no.classes.specified=\u30B3\u30DE\u30F3\u30C9\u884C\u3067\u30AF\u30E9\u30B9\u304C\u6307\u5B9A\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 +no.outputfile.specified=\u30B3\u30DE\u30F3\u30C9\u884C\u3067\u51FA\u529B\u30D5\u30A1\u30A4\u30EB\u304C\u6307\u5B9A\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 +no.outputdir.specified=\u30B3\u30DE\u30F3\u30C9\u884C\u3067\u51FA\u529B\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304C\u6307\u5B9A\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 +no.classpath.specified=\u30B3\u30DE\u30F3\u30C9\u884C\u3067\u30AF\u30E9\u30B9\u30D1\u30B9\u304C\u6307\u5B9A\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 +no.bootclasspath.specified=\u30B3\u30DE\u30F3\u30C9\u884C\u3067\u30D6\u30FC\u30C8\u30FB\u30AF\u30E9\u30B9\u30D1\u30B9\u304C\u6307\u5B9A\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 unknown.option={0}\u306F\u4E0D\u6B63\u306A\u5F15\u6570\u3067\u3059\n tracing.not.supported=\u8B66\u544A: \u30C8\u30EC\u30FC\u30B9\u306F\u73FE\u5728\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002\u304B\u308F\u308A\u306B\u3001Virtual Machine\u306E-verbose:jni\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002
--- a/src/share/classes/com/sun/tools/javap/AttributeWriter.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javap/AttributeWriter.java Tue Aug 19 23:57:05 2014 +0100 @@ -62,6 +62,7 @@ import com.sun.tools.classfile.Synthetic_attribute; import static com.sun.tools.classfile.AccessFlags.*; +import com.sun.tools.javac.util.StringUtils; /* * A writer for writing Attributes as text. @@ -690,14 +691,14 @@ } static String toHex(int i) { - return Integer.toString(i, 16).toUpperCase(); + return StringUtils.toUpperCase(Integer.toString(i, 16)); } static String toHex(int i, int w) { - String s = Integer.toHexString(i).toUpperCase(); + String s = StringUtils.toUpperCase(Integer.toHexString(i)); while (s.length() < w) s = "0" + s; - return s.toUpperCase(); + return StringUtils.toUpperCase(s); } private AnnotationWriter annotationWriter;
--- a/src/share/classes/com/sun/tools/javap/TypeAnnotationWriter.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javap/TypeAnnotationWriter.java Tue Aug 19 23:57:05 2014 +0100 @@ -37,6 +37,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import com.sun.tools.javac.util.StringUtils; /** * Annotate instructions with details about type annotations. @@ -115,7 +116,7 @@ print("@"); annotationWriter.write(n.anno, false, true); print(", "); - println(n.kind.toString().toLowerCase()); + println(StringUtils.toLowerCase(n.kind.toString())); } } }
--- a/src/share/classes/com/sun/tools/javap/resources/javap_ja.properties Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javap/resources/javap_ja.properties Tue Aug 19 23:57:05 2014 +0100 @@ -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 Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/javap/resources/javap_zh_CN.properties Tue Aug 19 23:57:05 2014 +0100 @@ -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/src/share/classes/com/sun/tools/jdeps/resources/jdeps_ja.properties Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/jdeps/resources/jdeps_ja.properties Tue Aug 19 23:57:05 2014 +0100 @@ -11,7 +11,7 @@ main.opt.v=\ -v -verbose \u30AF\u30E9\u30B9\u30FB\u30EC\u30D9\u30EB\u306E\u4F9D\u5B58\u6027\u3092\u3059\u3079\u3066\u51FA\u529B\u3057\u307E\u3059\n -verbose:package \u30D1\u30C3\u30B1\u30FC\u30B8\u30FB\u30EC\u30D9\u30EB\u306E\u4F9D\u5B58\u6027\u3092\u51FA\u529B\u3057\u307E\u3059\n (\u540C\u3058\u30A2\u30FC\u30AB\u30A4\u30D6\u5185\u306E\u4F9D\u5B58\u6027\u3092\u9664\u304F)\n -verbose:class \u30AF\u30E9\u30B9\u30FB\u30EC\u30D9\u30EB\u306E\u4F9D\u5B58\u6027\u3092\u51FA\u529B\u3057\u307E\u3059\n (\u540C\u3058\u30A2\u30FC\u30AB\u30A4\u30D6\u5185\u306E\u4F9D\u5B58\u6027\u3092\u9664\u304F) -main.opt.s=\ -s -summary \u4F9D\u5B58\u6027\u306E\u8981\u7D04\u306E\u307F\u51FA\u529B\u3057\u307E\u3059 +main.opt.s=\ -s -summary \u4F9D\u5B58\u6027\u306E\u30B5\u30DE\u30EA\u30FC\u306E\u307F\u51FA\u529B\u3057\u307E\u3059 main.opt.p=\ -p <pkgname> -package <pkgname> \u6307\u5B9A\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u5185\u306E\u4F9D\u5B58\u6027\u3092\u691C\u51FA\u3057\u307E\u3059\n (\u8907\u6570\u56DE\u6307\u5B9A\u53EF\u80FD)
--- a/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java Mon Jun 02 18:51:25 2014 +0100 +++ b/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java Tue Aug 19 23:57:05 2014 +0100 @@ -49,6 +49,7 @@ import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.Log; import com.sun.tools.javac.util.BaseFileManager; +import com.sun.tools.javac.util.StringUtils; import com.sun.tools.sjavac.comp.Dependencies; import com.sun.tools.sjavac.comp.JavaCompilerWithDeps; import com.sun.tools.sjavac.comp.SmartFileManager; @@ -256,7 +257,7 @@ // Load visible sources Set<URI> visibleSources = new HashSet<URI>(); boolean fix_drive_letter_case = - System.getProperty("os.name").toLowerCase().startsWith("windows"); + StringUtils.toLowerCase(System.getProperty("os.name")).startsWith("windows"); for (;;) { String l = in.readLine(); if (l == null)
--- a/test/Makefile Mon Jun 02 18:51:25 2014 +0100 +++ b/test/Makefile Tue Aug 19 23:57:05 2014 +0100 @@ -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) \
--- a/test/com/sun/javadoc/testLinkOption/TestLinkOption.java Mon Jun 02 18:51:25 2014 +0100 +++ b/test/com/sun/javadoc/testLinkOption/TestLinkOption.java Tue Aug 19 23:57:05 2014 +0100 @@ -23,18 +23,20 @@ /* * @test - * @bug 4720957 5020118 8026567 + * @bug 4720957 5020118 8026567 8038976 * @summary Test to make sure that -link and -linkoffline link to - * right files. + * right files, and URLs with and without trailing slash are accepted. * @author jamieh * @library ../lib/ * @build JavadocTester TestLinkOption * @run main TestLinkOption */ +import java.io.File; + public class TestLinkOption extends JavadocTester { - private static final String BUG_ID = "4720957-5020118"; + private static final String BUG_ID = "4720957-5020118-8038976"; //Generate the documentation using -linkoffline and a URL as the first parameter. private static final String[] ARGS1 = new String[] { @@ -83,7 +85,34 @@ } }; private static final String[][] NEGATED_TEST2 = NO_TEST; - + /* + * Create the documentation using the -link option, vary the behavior with + * both trailing and no trailing slash. We are only interested in ensuring + * that the command executes with no errors or related warnings. + */ + static String[] createArguments(boolean withTrailingSlash) { + String packagePath = new File(BUG_ID + "-1").getAbsolutePath(); + String outputDirName = BUG_ID; + if (withTrailingSlash) { + // add the trailing slash, if it is not present! + if (!packagePath.endsWith(FS)) { + packagePath = packagePath + FS; + } + outputDirName = outputDirName + "-3"; + } else { + // remove the trailing slash, if it is present! + if (packagePath.endsWith(FS)) { + packagePath = packagePath.substring(0, packagePath.length() - 1); + } + outputDirName = outputDirName + "-4"; + } + String args[] = { + "-d", outputDirName, "-sourcepath", SRC_DIR, + "-link", "file:///" + packagePath, "-package", "pkg2" + }; + System.out.println("packagePath: " + packagePath); + return args; + } /** * The entry point of the test. * @param args the array of command line arguments. @@ -92,6 +121,12 @@ TestLinkOption tester = new TestLinkOption(); run(tester, ARGS1, TEST1, NEGATED_TEST1); run(tester, ARGS2, TEST2, NEGATED_TEST2); + tester.runJavadoc(createArguments(true)); // with trailing slash + tester.runJavadoc(createArguments(false)); // without trailing slash + tester.printSummary(); + if (tester.getWarningOutput().contains("warning - Error fetching URL")) { + throw new Error("URL rejected ?"); + } tester.printSummary(); }
--- a/test/com/sun/javadoc/testRelativeLinks/TestRelativeLinks.java Mon Jun 02 18:51:25 2014 +0100 +++ b/test/com/sun/javadoc/testRelativeLinks/TestRelativeLinks.java Tue Aug 19 23:57:05 2014 +0100 @@ -23,7 +23,7 @@ /* * @test - * @bug 4460354 8014636 + * @bug 4460354 8014636 8043186 * @summary Test to make sure that relative paths are redirected in the * output so that they are not broken. * @author jamieh
--- a/test/com/sun/javadoc/testRelativeLinks/pkg/C.java Mon Jun 02 18:51:25 2014 +0100 +++ b/test/com/sun/javadoc/testRelativeLinks/pkg/C.java Tue Aug 19 23:57:05 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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,7 +30,7 @@ public class C { /** - * Here is a relative link in a field: + * Here is a relative link in a field:\u0130 * <a href="relative-field-link.html">relative field link</a>. */ public C field = null;
--- a/test/com/sun/javadoc/testTopOption/TestTopOption.java Mon Jun 02 18:51:25 2014 +0100 +++ b/test/com/sun/javadoc/testTopOption/TestTopOption.java Tue Aug 19 23:57:05 2014 +0100 @@ -23,7 +23,7 @@ /* * @test - * @bug 6227616 + * @bug 6227616 8043186 * @summary Test the new -top option. * @author jamieh * @library ../lib/ @@ -39,7 +39,7 @@ //Javadoc arguments. private static final String[] ARGS = new String[] { - "-overview", "SRC_DIR + FS + overview.html", "-use", "-top", "TOP TEXT", "-d", BUG_ID, "-sourcepath", + "-overview", SRC_DIR + FS + "overview.html", "-use", "-top", "\u0130{@docroot}TOP TEXT", "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg" };
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/AnonymousSubclassTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,91 @@ +/* + * 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 8023945 + * @summary javac wrongly allows a subclass of an anonymous class + * @library /tools/javac/lib + * @build ToolBox + * @run main AnonymousSubclassTest + */ + +import java.util.ArrayList; +import java.io.IOException; + +public class AnonymousSubclassTest { + public static void main(String... args) throws Exception { + new AnonymousSubclassTest().run(); + } + + // To trigger the error we want, first we need to compile + // a class with an anonymous inner class: Foo$1. + final String foo = + "public class Foo {" + + " void m() { Foo f = new Foo() {}; }" + + "}"; + + // Then, we try to subclass the anonymous class + // Note: we must do this in two classes because a different + // error will be generated if we don't load Foo$1 through the + // class reader. + final String test1 = + "public class Test1 {" + + " void m() {"+ + " Foo f1 = new Foo();"+ + " Foo f2 = new Foo$1(f1) {};"+ + " }" + + "}"; + + final String test2 = + "public class Test2 {" + + " class T extends Foo$1 {" + + " public T(Foo f) { super(f); }" + + " }"+ + "}"; + + void compOk(String code) throws Exception { + ToolBox.javac(new ToolBox.JavaToolArgs().setSources(code)); + } + + void compFail(String code) throws Exception { + ArrayList<String> errors = new ArrayList<>(); + ToolBox.JavaToolArgs args = new ToolBox.JavaToolArgs(); + args.setSources(code) + .appendArgs("-cp", ".", "-XDrawDiagnostics") + .set(ToolBox.Expect.FAIL) + .setErrOutput(errors); + ToolBox.javac(args); + + if (!errors.get(0).contains("cant.inherit.from.anon")) { + System.out.println(errors.get(0)); + throw new Exception("test failed"); + } + } + + void run() throws Exception { + compOk(foo); + compFail(test1); + compFail(test2); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/DefiniteAssignment/T8039026.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,21 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8039026 + * @summary Definitely unassigned field can be accessed + * @compile/fail/ref=T8039026.out -XDrawDiagnostics T8039026.java + */ + +public class T8039026 { + final int x,y,z; + final int a = this.y; // <- error + { + int b = true ? this.x : 0; // <- error + System.out.println(this.x); // <- error + this.y = 1; + } + T8039026() { + this.x = 1; // <- no error! + this.y = 1; // <- error + this.z = this.x; // <- no error + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/DefiniteAssignment/T8039026.out Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,4 @@ +T8039026.java:10:23: compiler.err.var.might.not.have.been.initialized: y +T8039026.java:12:28: compiler.err.var.might.not.have.been.initialized: x +T8039026.java:18:13: compiler.err.var.might.already.be.assigned: y +3 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/NoStringToLower.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,136 @@ +/* + * 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 8029800 + * @summary String.toLowerCase()/toUpperCase is generally dangerous, check it is not used in langtools + */ + +import java.io.*; +import java.util.*; +import javax.tools.*; +import com.sun.tools.classfile.*; +import com.sun.tools.classfile.ConstantPool.CONSTANT_Methodref_info; + +public class NoStringToLower { + public static void main(String... args) throws Exception { + NoStringToLower c = new NoStringToLower(); + if (c.run(args)) + return; + + if (is_jtreg()) + throw new Exception(c.errors + " errors occurred"); + else + System.exit(1); + } + + static boolean is_jtreg() { + return (System.getProperty("test.src") != null); + } + + /** + * Main entry point. + */ + boolean run(String... args) throws Exception { + JavaCompiler c = ToolProvider.getSystemJavaCompiler(); + JavaFileManager fm = c.getStandardFileManager(null, null, null); + JavaFileManager.Location javacLoc = findJavacLocation(fm); + String[] pkgs = { + "javax.annotation.processing", + "javax.lang.model", + "javax.tools", + "com.sun.source", + "com.sun.tools.classfile", + "com.sun.tools.doclet", + "com.sun.tools.doclint", + "com.sun.tools.javac", + "com.sun.tools.javadoc", + "com.sun.tools.javah", + "com.sun.tools.javap", + "com.sun.tools.jdeps", + "com.sun.tools.sjavac" + }; + for (String pkg: pkgs) { + for (JavaFileObject fo: fm.list(javacLoc, + pkg, EnumSet.of(JavaFileObject.Kind.CLASS), true)) { + scan(fo); + } + } + + return (errors == 0); + } + + // depending on how the test is run, javac may be on bootclasspath or classpath + JavaFileManager.Location findJavacLocation(JavaFileManager fm) { + JavaFileManager.Location[] locns = + { StandardLocation.PLATFORM_CLASS_PATH, StandardLocation.CLASS_PATH }; + try { + for (JavaFileManager.Location l: locns) { + JavaFileObject fo = fm.getJavaFileForInput(l, + "com.sun.tools.javac.Main", JavaFileObject.Kind.CLASS); + if (fo != null) + return l; + } + } catch (IOException e) { + throw new Error(e); + } + throw new IllegalStateException("Cannot find javac"); + } + + /** + * Verify there are no references to String.toLowerCase() in a class file. + */ + void scan(JavaFileObject fo) throws IOException { + InputStream in = fo.openInputStream(); + try { + ClassFile cf = ClassFile.read(in); + for (ConstantPool.CPInfo cpinfo: cf.constant_pool.entries()) { + if (cpinfo.getTag() == ConstantPool.CONSTANT_Methodref) { + CONSTANT_Methodref_info ref = (CONSTANT_Methodref_info) cpinfo; + String methodDesc = ref.getClassInfo().getName() + "." + ref.getNameAndTypeInfo().getName() + ":" + ref.getNameAndTypeInfo().getType(); + + if ("java/lang/String.toLowerCase:()Ljava/lang/String;".equals(methodDesc)) { + error("found reference to String.toLowerCase() in: " + fo.getName()); + } + if ("java/lang/String.toUpperCase:()Ljava/lang/String;".equals(methodDesc)) { + error("found reference to String.toLowerCase() in: " + fo.getName()); + } + } + } + } catch (ConstantPoolException ignore) { + } finally { + in.close(); + } + } + + /** + * Report an error. + */ + void error(String msg) { + System.err.println("Error: " + msg); + errors++; + } + + int errors; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T8029002/MultipleUpperBoundsIncorporationTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,72 @@ +/* + * 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 8029002 + * @summary javac should take multiple upper bounds into account in incorporation + * @compile MultipleUpperBoundsIncorporationTest.java + */ + +import java.util.ArrayList; +import java.util.List; + +public class MultipleUpperBoundsIncorporationTest { + + static class TestCase1 { + interface Task<E extends Exception> {} + + class Comparator<T> {} + + class CustomException extends Exception {} + + class TaskQueue<E extends Exception, T extends Task<E>> {} + + abstract class Test { + abstract <E extends Exception, T extends Task<E>> TaskQueue<E, T> create(Comparator<? super T> comparator); + + void f(Comparator<Task<CustomException>> comp) { + TaskQueue<CustomException, Task<CustomException>> queue = create(comp); + queue.getClass(); + } + } + } + + static class TestCase2 { + public <T, E extends List<T>> E typedNull() { + return null; + } + + public void call() { + ArrayList<String> list = typedNull(); + } + } + + static class TestCase3 { + interface I extends Iterable<String> {} + + <T, Exp extends Iterable<T>> Exp typedNull() { return null; } + I i = typedNull(); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T8029102/WarnSerializableLambdaTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -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 Tue Aug 19 23:57:05 2014 +0100 @@ -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 Tue Aug 19 23:57:05 2014 +0100 @@ -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 Tue Aug 19 23:57:05 2014 +0100 @@ -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 Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -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 Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.out Tue Aug 19 23:57:05 2014 +0100 @@ -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
--- a/test/tools/javac/T8030816/CrashLambdaExpressionWithNonAccessibleIdTest.out Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/T8030816/CrashLambdaExpressionWithNonAccessibleIdTest.out Tue Aug 19 23:57:05 2014 +0100 @@ -1,3 +1,2 @@ -CrashLambdaExpressionWithNonAccessibleIdTest.java:15:35: compiler.err.missing.ret.stmt CrashLambdaExpressionWithNonAccessibleIdTest.java:14:17: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, CrashLambdaExpressionWithNonAccessibleIdTest, null) -2 errors +1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T8038975/AccessTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,39 @@ +/* + * 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 8038975 + * @summary Access control in enhanced for + * @compile AccessTest.java + */ + +import a.*; +public class AccessTest { + private static class Impl extends B { + public void method(Inner inner) { + for (A a : inner) + System.out.println(a); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T8038975/a/A.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package a; +public class A { }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T8038975/a/B.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package a; +public class B { + protected abstract class Inner implements Iterable<A> { } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/FinalReceiverTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,14 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8027886 + * @summary Receiver parameters must not be final + * @compile/fail/ref=FinalReceiverTest.out -XDrawDiagnostics FinalReceiverTest.java + */ + +class FinalReceiverTest { + void m() { + class Inner { + Inner(final FinalReceiverTest FinalReceiverTest.this) {} + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/FinalReceiverTest.out Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,2 @@ +FinalReceiverTest.java:11:43: compiler.err.mod.not.allowed.here: final +1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/LocalInnerReceiverTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,37 @@ +/* + * 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 8029042 + * @summary Receiver parameter not supported on local class constructor + * @compile LocalInnerReceiverTest.java + */ + +class LocalInnerReceiverTest { + void m() { + class Inner { + Inner(LocalInnerReceiverTest LocalInnerReceiverTest.this) {} + } + } +}
--- a/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateScoping.out Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateScoping.out Tue Aug 19 23:57:05 2014 +0100 @@ -6,6 +6,7 @@ CantAnnotateScoping.java:56:37: compiler.err.cant.type.annotate.scoping: @TA,@TA2 CantAnnotateScoping.java:40:14: compiler.err.cant.type.annotate.scoping.1: @TA CantAnnotateScoping.java:42:34: compiler.err.cant.type.annotate.scoping: @TA,@DA,@TA2 +CantAnnotateScoping.java:42:25: compiler.err.annotation.type.not.applicable CantAnnotateScoping.java:44:38: compiler.err.cant.type.annotate.scoping: @TA,@DA CantAnnotateScoping.java:44:34: compiler.err.annotation.type.not.applicable -10 errors \ No newline at end of file +11 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/typeAnnotations/failures/CheckErrorsForSource7.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,195 @@ +/* + * 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 8035890 + * @summary Verify that the parser correctly checks for source level 8 on the new places where + * annotations can appear in 8. + * @run main CheckErrorsForSource7 CheckErrorsForSource7.java + */ +import java.io.File; +import java.io.IOException; +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import javax.tools.Diagnostic; +import javax.tools.DiagnosticCollector; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import com.sun.source.tree.AnnotationTree; +import com.sun.source.tree.CompilationUnitTree; +import com.sun.source.tree.IdentifierTree; +import com.sun.source.tree.Tree.Kind; +import com.sun.source.util.JavacTask; +import com.sun.source.util.TreePathScanner; +import com.sun.source.util.Trees; +import com.sun.tools.javac.api.JavacTool; +import com.sun.tools.javac.file.JavacFileManager; + +/**For each place where an annotation can syntactically appear with -source 8, but not with + * -source 7, this test verifies that an error is correctly emitted from the parser for + * the annotation for -source 7. This test first gathers the occurrences of @TA from + * the CheckErrorsForSource7Data class below, and then repeatedly removes all these annotations + * except one and checks the parser reports an expected error. This is needed as as the parser + * typically produces only one 'insufficient source level' error for each new feature used. + */ +public class CheckErrorsForSource7 { + public static void main(String... args) throws IOException, URISyntaxException { + new CheckErrorsForSource7().run(args); + } + + private void run(String... args) throws IOException, URISyntaxException { + //the first and only parameter must be the name of the file to be analyzed: + if (args.length != 1) throw new IllegalStateException("Must provide source file!"); + File testSrc = new File(System.getProperty("test.src")); + File testFile = new File(testSrc, args[0]); + if (!testFile.canRead()) throw new IllegalStateException("Cannot read the test source"); + JavacFileManager fm = JavacTool.create().getStandardFileManager(null, null, null); + + //gather spans of the @TA annotations into typeAnnotationSpans: + JavacTask task = JavacTool.create().getTask(null, + fm, + null, + Collections.<String>emptyList(), + null, + fm.getJavaFileObjects(testFile)); + final Trees trees = Trees.instance(task); + final CompilationUnitTree cut = task.parse().iterator().next(); + final List<int[]> typeAnnotationSpans = new ArrayList<>(); + + new TreePathScanner<Void, Void>() { + @Override + public Void visitAnnotation(AnnotationTree node, Void p) { + if (node.getAnnotationType().getKind() == Kind.IDENTIFIER && + ((IdentifierTree) node.getAnnotationType()).getName().contentEquals("TA")) { + int start = (int) trees.getSourcePositions().getStartPosition(cut, node); + int end = (int) trees.getSourcePositions().getEndPosition(cut, node); + typeAnnotationSpans.add(new int[] {start, end}); + } + return null; + } + }.scan(cut, null); + + //sort the spans in the reverse order, to simplify removing them from the source: + Collections.sort(typeAnnotationSpans, new Comparator<int[]>() { + @Override + public int compare(int[] o1, int[] o2) { + return o2[0] - o1[0]; + } + }); + + //verify the errors are produce correctly: + String originalSource = cut.getSourceFile().getCharContent(false).toString(); + + for (int[] toKeep : typeAnnotationSpans) { + //prepare updated source code by removing all the annotations except the toKeep one: + String updated = originalSource; + + for (int[] span : typeAnnotationSpans) { + if (span == toKeep) continue; + + updated = updated.substring(0, span[0]) + updated.substring(span[1]); + } + + //parse and verify: + JavaFileObject updatedFile = new TestFO(cut.getSourceFile().toUri(), updated); + DiagnosticCollector<JavaFileObject> errors = new DiagnosticCollector<>(); + JavacTask task2 = JavacTool.create().getTask(null, + fm, + errors, + Arrays.asList("-source", "7"), + null, + Arrays.asList(updatedFile)); + task2.parse(); + + boolean found = false; + + for (Diagnostic<? extends JavaFileObject> d : errors.getDiagnostics()) { + if (d.getKind() == Diagnostic.Kind.ERROR && EXPECTED_ERRORS.contains(d.getCode())) { + if (found) { + throw new IllegalStateException("More than one expected error found."); + } + found = true; + } + } + + if (!found) + throw new IllegalStateException("Did not produce proper errors for: " + updated); + } + } + + static final Set<String> EXPECTED_ERRORS = new HashSet<>(Arrays.asList( + "compiler.err.type.annotations.not.supported.in.source", + "compiler.err.annotations.after.type.params.not.supported.in.source" + )); + + class TestFO extends SimpleJavaFileObject { + private final String content; + public TestFO(URI uri, String content) { + super(uri, Kind.SOURCE); + this.content = content; + } + + @Override public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { + return content; + } + + @Override public boolean isNameCompatible(String simpleName, Kind kind) { + return true; + } + } +} + +//data on which the source level check is verified: +class CheckErrorsForSource7Data { + @Target(ElementType.TYPE_USE) + @interface TA { } + + Object n1 = new @TA ArrayList<@TA String>(); + Object n2 = new @TA Object() {}; + Object [] @TA [] arr @TA[]; + <T> @TA int @TA[] ret(Object obj) @TA[] throws @TA Exception { + this.<@TA String>ret(null); + Object c1 = new @TA String[1]; + + int val = obj instanceof @TA String ? ((@TA String) obj).length() : 0; + List<@TA ?> l; + return null; + } + void vararg(String @TA ... args) { } + + abstract class C<@TA T extends @TA Number & @TA Runnable> + extends @TA ArrayList<@TA String> + implements java.util. @TA Comparator<@TA T> { } + + interface I extends java.util. @TA Comparator<@TA String> { } + +}
--- a/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DeclarationAnnotation.out Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DeclarationAnnotation.out Tue Aug 19 23:57:05 2014 +0100 @@ -1,5 +1,5 @@ +DeclarationAnnotation.java:13:21: compiler.err.annotation.type.not.applicable DeclarationAnnotation.java:10:21: compiler.err.annotation.type.not.applicable DeclarationAnnotation.java:11:21: compiler.err.annotation.type.not.applicable DeclarationAnnotation.java:12:21: compiler.err.annotation.type.not.applicable -DeclarationAnnotation.java:13:21: compiler.err.annotation.type.not.applicable 4 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/typeAnnotations/newlocations/AfterMethodTypeParams.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,138 @@ +/* + * 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 8038788 + * @summary Verify proper handling of annotations after method's type parameters. + * @build AfterMethodTypeParams + * @run main AfterMethodTypeParams + */ + +import java.io.IOException; +import java.io.StringWriter; +import java.net.URI; +import java.util.*; + +import javax.lang.model.element.Name; +import javax.tools.*; + +import com.sun.source.tree.*; +import com.sun.source.util.*; + +public class AfterMethodTypeParams { + + public static void main(String... args) throws IOException { + new AfterMethodTypeParams().run(); + } + + void run() throws IOException { + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + + for (TestCase tc : testCases) { + String test = TEMPLATE.replace("CONTENT", tc.snippet); + List<JavaFileObject> files = Arrays.asList(new MyFileObject(test)); + StringWriter out = new StringWriter(); + List<String> options = Arrays.asList("-XDrawDiagnostics", "-XDshouldStopPolicy=FLOW"); + JavacTask task = (JavacTask) compiler.getTask(out, null, null, options, null, files); + + new TreePathScanner<Void, Void>() { + boolean seenAnnotation; + @Override + public Void visitAnnotation(AnnotationTree node, Void p) { + Name name = ((IdentifierTree) node.getAnnotationType()).getName(); + seenAnnotation |= name.contentEquals("TA") || name.contentEquals("DA"); + return null; + } + @Override + public Void visitCompilationUnit(CompilationUnitTree node, Void p) { + super.visitCompilationUnit(node, p); + if (!seenAnnotation) + error(test, "Annotation was missing"); + return null; + } + }.scan(task.parse(), null); + + task.analyze(); + + if (!tc.error.equals(out.toString().trim())) { + error(test, "Incorrect errors: " + out.toString()); + } + } + + if (errors > 0) { + throw new IllegalStateException("Errors found"); + } + } + + int errors; + + void error(String code, String error) { + System.out.println("Error detected: " + error); + System.out.println("Code:"); + System.out.println(code); + errors++; + } + + static String TEMPLATE = + "import java.lang.annotation.*;\n" + + "public class Test {\n" + + " CONTENT\n" + + "}\n" + + "@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})\n" + + "@interface DA { }\n" + + "@Target(ElementType.TYPE_USE)\n" + + "@interface TA { }\n"; + + static class MyFileObject extends SimpleJavaFileObject { + final String text; + public MyFileObject(String text) { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + this.text = text; + } + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return text; + } + } + + static TestCase[] testCases = new TestCase[] { + new TestCase("<T> @DA int foo1() { return 0;}", ""), + new TestCase("<T> @DA void foo2() { }", ""), + new TestCase("<T> @TA int foo3() { return 0;}", ""), + new TestCase("<T> @TA void foo4() { }", + "Test.java:3:9: compiler.err.annotation.type.not.applicable"), + new TestCase("<T> @DA Test() { }", "Test.java:3:9: compiler.err.illegal.start.of.type"), + new TestCase("<T> @TA Test() { }", "Test.java:3:9: compiler.err.illegal.start.of.type"), + }; + + static class TestCase { + final String snippet; + final String error; + public TestCase(String snippet, String error) { + this.snippet = snippet; + this.error = error; + } + } +} +
--- a/test/tools/javac/annotations/typeAnnotations/newlocations/Receivers.java Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/annotations/typeAnnotations/newlocations/Receivers.java Tue Aug 19 23:57:05 2014 +0100 @@ -54,14 +54,6 @@ <T extends Runnable> void accept(@B("m") WithValue this, T r) throws Exception { } } -class WithFinal { - void plain(final @B("m") WithFinal this) { } - <T> void generic(final @B("m") WithFinal this) { } - void withException(final @B("m") WithFinal this) throws Exception { } - String nonVoid(final @B("m") WithFinal this) { return null; } - <T extends Runnable> void accept(final @B("m") WithFinal this, T r) throws Exception { } -} - class WithBody { Object f;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/api/taskListeners/EventsBalancedTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -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; + } + } + +}
--- a/test/tools/javac/classfiles/InnerClasses/SyntheticClasses.java Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/classfiles/InnerClasses/SyntheticClasses.java Tue Aug 19 23:57:05 2014 +0100 @@ -41,7 +41,7 @@ private void run() throws IOException, ConstantPoolException { File testClasses = new File(System.getProperty("test.classes")); - for (File classFile : testClasses.listFiles()) { + for (File classFile : testClasses.listFiles(f -> f.getName().endsWith(".class"))) { ClassFile cf = ClassFile.read(classFile); if (cf.getName().matches(".*\\$[0-9]+")) { EnclosingMethod_attribute encl =
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/defaultMethods/static/StaticInvoke.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,15 @@ +/* @test /nodynamiccopyright/ + * @bug 8037385 + * @summary Must not allow static interface method invocation in legacy code + * @compile -source 8 -Xlint:-options StaticInvoke.java + * @compile/fail/ref=StaticInvoke7.out -source 7 -Xlint:-options -XDrawDiagnostics StaticInvoke.java + * @compile/fail/ref=StaticInvoke6.out -source 6 -Xlint:-options -XDrawDiagnostics StaticInvoke.java + */ +import java.util.stream.Stream; + +class StaticInvoke { + void test() { + Stream.empty(); + java.util.stream.Stream.empty(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/defaultMethods/static/StaticInvoke6.out Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,3 @@ +StaticInvoke.java:12:15: compiler.err.static.intf.method.invoke.not.supported.in.source: 1.6 +StaticInvoke.java:13:32: compiler.err.static.intf.method.invoke.not.supported.in.source: 1.6 +2 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/defaultMethods/static/StaticInvoke7.out Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,3 @@ +StaticInvoke.java:12:15: compiler.err.static.intf.method.invoke.not.supported.in.source: 1.7 +StaticInvoke.java:13:32: compiler.err.static.intf.method.invoke.not.supported.in.source: 1.7 +2 errors
--- a/test/tools/javac/defaultMethods/static/hiding/InterfaceMethodHidingTest.java Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/defaultMethods/static/hiding/InterfaceMethodHidingTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @bug 8005166 * @summary Add support for static interface methods * Smoke test for static interface method hiding + * @run main/timeout=600 InterfaceMethodHidingTest */ import com.sun.source.util.JavacTask;
--- a/test/tools/javac/diags/examples.not-yet.txt Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/diags/examples.not-yet.txt Tue Aug 19 23:57:05 2014 +0100 @@ -110,4 +110,5 @@ compiler.warn.unknown.enum.constant # in bad class file compiler.warn.unknown.enum.constant.reason # in bad class file compiler.warn.override.equals.but.not.hashcode # when a class overrides equals but not hashCode method from Object - +compiler.err.cant.inherit.from.anon # error for subclass of anonymous class +compiler.misc.bad.const.pool.entry # constant pool entry has wrong type
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/AnnotationsAfterTypeParamsNotSupportedInSource.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,34 @@ +/* + * 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.err.annotations.after.type.params.not.supported.in.source +// key: compiler.warn.source.no.bootclasspath +// options: -source 7 + +@interface Anno { } + +class AnnotationsAfterTypeParamsNotSupportedInSource { + <T> @Anno int m() { + return 0; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/LambdaBodyNeitherValueNorVoidCompatible.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,46 @@ +/* + * 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.err.lambda.body.neither.value.nor.void.compatible +// key: compiler.err.cant.apply.symbol +// key: compiler.misc.incompatible.ret.type.in.lambda +// key: compiler.misc.missing.ret.val +// key: compiler.misc.no.conforming.assignment.exists + +class LambdaBodyNeitherValueNorVoidCompatible { + interface I { + String f(String x); + } + + static void foo(I i) {} + + void m() { + foo((x) -> { + if (x == null) { + return; + } else { + return x; + } + }); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/StaticIntfMethodInvokeNotSupported.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,32 @@ +/* + * 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.err.static.intf.method.invoke.not.supported.in.source +// options: -source 7 -Xlint:-options +import java.util.stream.Stream; + +class StaticIntfMethodInvokeNotSupported { + void test() { + Stream.empty(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/WarnSerializableLambda.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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/flow/LVTHarness.java Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/flow/LVTHarness.java Tue Aug 19 23:57:05 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -23,8 +23,8 @@ /* * @test - * @bug 7047734 8027660 - * @summary The LVT is not generated correctly during some try/catch scenarios; + * @bug 7047734 8027660 8037937 + * @summary The LVT is not generated correctly during some try/catch scenarios * javac crash while creating LVT entry for a local variable defined in * an inner block * @library /tools/javac/lib @@ -120,7 +120,7 @@ for (Map.Entry<ElementKey, AliveRanges> entry : aliveRangeMap.entrySet()) { if (!seenAliveRanges.contains(entry.getKey())) { error("Redundant @AliveRanges annotation on method " + - entry.getKey().elem); + entry.getKey().elem + " with key " + entry.getKey()); } } } @@ -134,7 +134,7 @@ for (Method method : classFile.methods) { for (ElementKey elementKey: aliveRangeMap.keySet()) { String methodDesc = method.getName(constantPool) + - method.descriptor.getParameterTypes(constantPool); + method.descriptor.getParameterTypes(constantPool).replace(" ", ""); if (methodDesc.equals(elementKey.elem.toString())) { checkMethod(constantPool, method, aliveRangeMap.get(elementKey)); seenAliveRanges.add(elementKey);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/flow/T8042741/A.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,37 @@ +/* + * 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. + */ + +// str must be at absolute position greater than that of lambda +// expression in PositionTest.java +// padding..........................................................padding +// padding..........................................................padding +// padding..........................................................padding +// padding..........................................................padding +// padding..........................................................padding + +public class A { + public final String str; + { + str = ""; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/flow/T8042741/PositionTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,62 @@ +/* + * 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 8042741 + * @summary Java 8 compiler throws NullPointerException depending location in source file + * @compile A.java PositionTest.java + */ + +public class PositionTest extends A { + <E extends Exception> void test(SAM<E> r) throws E { + test(() -> { System.err.println(str); }); + } + interface SAM<E extends Exception> { + public void run() throws E; + } + void f() { + try { + test(() -> { + test(() -> { + try { + test(() -> { System.err.println(str); }); + System.err.println(str); + } catch (Exception e) {} + System.err.println(str); + }); + System.err.println(str); + }); + } catch (Exception e) { } + } + void g() throws Exception { + test(() -> { + try { + try { + test(() -> { System.err.println(str); }); + } catch (Exception e) {} + System.err.println(str); + } catch (Exception e) {} + System.err.println(str); + }); + } +}
--- a/test/tools/javac/flow/tests/TestCaseIfElse.java Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/flow/tests/TestCaseIfElse.java Tue Aug 19 23:57:05 2014 +0100 @@ -33,7 +33,7 @@ @AliveRange(varName="o", bytecodeStart=10, bytecodeLength=8) @AliveRange(varName="o", bytecodeStart=21, bytecodeLength=9) - void m2(String[] args) { + void m2() { Object o; int i = 5; if (i != 5) { @@ -45,4 +45,19 @@ } o = "finish"; } + + @AliveRange(varName="o", bytecodeStart=11, bytecodeLength=3) + @AliveRange(varName="o", bytecodeStart=17, bytecodeLength=2) + Object m3(boolean cond1, boolean cond2) { + Object o; + if (cond1) { + if (cond2) { + o = "then"; + } else { + o = "else"; + return null; + } + } + return null; + } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/diamond/T8041713/DiamondPlusUnexistingMethodRefCrashTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,11 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8041713 + * @summary Type inference of non-existent method references crashes the compiler + * @compile/fail/ref=DiamondPlusUnexistingMethodRefCrashTest.out -XDrawDiagnostics DiamondPlusUnexistingMethodRefCrashTest.java + */ + +public class DiamondPlusUnexistingMethodRefCrashTest<T> { + DiamondPlusUnexistingMethodRefCrashTest<String> m = + new DiamondPlusUnexistingMethodRefCrashTest<>(DiamondPlusUnexistingMethodRefCrashTest::doNotExists); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/diamond/T8041713/DiamondPlusUnexistingMethodRefCrashTest.out Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,2 @@ +DiamondPlusUnexistingMethodRefCrashTest.java:10:55: compiler.err.invalid.mref: kindname.method, (compiler.misc.cant.resolve.location.args: kindname.method, doNotExists, , , (compiler.misc.location: kindname.class, DiamondPlusUnexistingMethodRefCrashTest, null)) +1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/inference/8043725/T8043725.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,36 @@ +/* + * 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 8043725 + * @summary javac fails with StackOverflowException + * @compile T8043725.java + */ +class T8043725 { + <T extends Comparable<T>> T m(T v) { + //this will generate two upper bounds, T and Comparable<T'> respectively + //causing infinite recursion in lub (because of JLS 18.3.1). + return m(v); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/inference/EagerReturnTypeResolution/EagerReturnTypeResolutionTesta.java Tue Aug 19 23:57:05 2014 +0100 @@ -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/generics/inference/EagerReturnTypeResolution/EagerReturnTypeResolutionTestb.java Tue Aug 19 23:57:05 2014 +0100 @@ -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/generics/inference/EagerReturnTypeResolution/EagerReturnTypeResolutionTestb.out Tue Aug 19 23:57:05 2014 +0100 @@ -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/generics/inference/EagerReturnTypeResolution/PrimitiveTypeBoxingTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -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/generics/inference/EagerReturnTypeResolution/PrimitiveTypeBoxingTest.out Tue Aug 19 23:57:05 2014 +0100 @@ -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/generics/inference/LowerBoundGLB.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 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/NestedWildcards.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,44 @@ +/* + * 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 8039214 + * @summary Nested generic methods that work on wildcard-parameterized types + * @compile NestedWildcards.java + */ + +public class NestedWildcards { + + public static void test(Box<String> b) { + foo(bar(b)); + } + private static <X> Box<? extends X> foo(Box<? extends X> ts) { + return null; + } + public static <Y> Box<? extends Y> bar(Box<? extends Y> language) { + return null; + } + + interface Box<T> {} +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/inference/T8028503/PrimitiveTypeInBoundForMethodRefTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -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 Tue Aug 19 23:57:05 2014 +0100 @@ -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> + } + +}
--- a/test/tools/javac/generics/wildcards/7034495/T7034495.out Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/generics/wildcards/7034495/T7034495.out Tue Aug 19 23:57:05 2014 +0100 @@ -1,2 +1,2 @@ -T7034495.java:40:17: compiler.err.types.incompatible.diff.ret: T7034495.B<?>, T7034495.A<?>, foo() +T7034495.java:40:17: compiler.err.types.incompatible.diff.ret: T7034495.B<compiler.misc.type.captureof: 1, ?>, T7034495.A<compiler.misc.type.captureof: 2, ?>, foo() 1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/wildcards/RefQueue.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,24 @@ +/* + * 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. + */ + +public class RefQueue<S> { }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/wildcards/RefQueueBug.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,38 @@ +/* + * 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 8033437 + * @summary inconsistent generic types behaviour when compiling together vs. separate + * @compile RefQueue.java + * @compile RefQueueBug.java + */ + +public class RefQueueBug<T> { + final RefQueue<? super T> queue = new RefQueue<>(); + public static void main(String[] args) { + RefQueueBug<Object> r = new RefQueueBug<>(); + RefQueue<Object> q = r.queue; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/wildcards/T8015101.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,44 @@ +/* + * 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 8015101 + * @summary Mishandling of wildcards in intersection member method check + * @compile T8015101.java + */ +class T8015101 { + + public static class Bug<X extends Child<?, ?> & Runnable> { + } + + interface Parent<C> { + public C get(); + } + + interface Child<C, S extends C> extends Parent<C> { + @Override + public S get(); + } + + }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/wildcards/T8034147.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,35 @@ +/* + * 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 8034147 + * @summary javac crashes with a NullPointerException during bounds checking + * @compile T8034147.java + */ + +class T8034147 { + static class One<X extends Two<? super X>> {} + static class Two<Y extends Three<? extends Y>> implements Three<Y> {} + interface Three<Z> {} +}
--- a/test/tools/javac/lambda/ErroneousLambdaExpr.java Mon Jun 02 18:51:25 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2012, 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 8003280 - * @summary Add lambda tests - * stale state after speculative attribution round leads to missing classfiles - * @compile/fail/ref=ErroneousLambdaExpr.out -XDrawDiagnostics ErroneousLambdaExpr.java - */ -public class ErroneousLambdaExpr<T> { - - static int assertionCount = 0; - - static void assertTrue(boolean cond) { - assertionCount++; - if (!cond) - throw new AssertionError(); - } - - interface SAM1<X> { - X m(X t, String s); - } - - interface SAM2 { - void m(String s, int i); - } - - interface SAM3<X> { - X m(X t, String s, int i); - } - - void call(SAM1<T> s1) { assertTrue(true); } - - void call(SAM2 s2) { assertTrue(false); } - - void call(SAM3<T> s3) { assertTrue(false); } - - public static void main(String[] args) { - ErroneousLambdaExpr<StringBuilder> test = - new ErroneousLambdaExpr<>(); - - test.call((builder, string) -> { builder.append(string); return builder; }); - assertTrue(assertionCount == 1); - } -}
--- a/test/tools/javac/lambda/ErroneousLambdaExpr.out Mon Jun 02 18:51:25 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -ErroneousLambdaExpr.java:63:13: compiler.err.ref.ambiguous: call, kindname.method, call(ErroneousLambdaExpr.SAM1<T>), ErroneousLambdaExpr, kindname.method, call(ErroneousLambdaExpr.SAM2), ErroneousLambdaExpr -1 error
--- a/test/tools/javac/lambda/FunctionalInterfaceConversionTest.java Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/lambda/FunctionalInterfaceConversionTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ * @author Maurizio Cimadamore * @library ../lib * @build JavacTestingAbstractThreadedTest - * @run main/othervm FunctionalInterfaceConversionTest + * @run main/timeout=600/othervm FunctionalInterfaceConversionTest */ // use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/LambdaExprLeadsToMissingClassFilesTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2012, 2014 Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 8003280 + * @summary Add lambda tests + * stale state after speculative attribution round leads to missing classfiles + */ +public class LambdaExprLeadsToMissingClassFilesTest<T> { + + static int assertionCount = 0; + + static void assertTrue(boolean cond) { + assertionCount++; + if (!cond) { + throw new AssertionError(); + } + } + + interface SAM1<X> { + X m(X t, String s); + } + + interface SAM2 { + void m(String s, int i); + } + + interface SAM3<X> { + X m(X t, String s, int i); + } + + void call(SAM1<T> s1) { assertTrue(true); } + + void call(SAM2 s2) { assertTrue(false); } + + void call(SAM3<T> s3) { assertTrue(false); } + + public static void main(String[] args) { + LambdaExprLeadsToMissingClassFilesTest<StringBuilder> test = + new LambdaExprLeadsToMissingClassFilesTest<>(); + + test.call((builder, string) -> { builder.append(string); return builder; }); + assertTrue(assertionCount == 1); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/LambdaLocalTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -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 Tue Aug 19 23:57:05 2014 +0100 @@ -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 Tue Aug 19 23:57:05 2014 +0100 @@ -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 Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/lambda/MethodReference42.out Tue Aug 19 23:57:05 2014 +0100 @@ -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 Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/lambda/MethodReference44.out Tue Aug 19 23:57:05 2014 +0100 @@ -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/MostSpecific09.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,81 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8029718 + * @summary Should always use lambda body structure to disambiguate overload resolution + * @compile/fail/ref=MostSpecific09.out -XDrawDiagnostics -XDshouldStopPolicy=ATTR -XDverboseResolution=applicable,success MostSpecific09.java + */ + +class MostSpecific09 { + + interface I { + String xoo(String x); + } + + interface J { + void xoo(int x); + } + + static void foo(I i) {} + static void foo(J j) {} + + static void moo(I i) {} + static void moo(J j) {} + + void m() { + foo((x) -> { return x += 1; }); + foo((x) -> { return ""; }); + foo((x) -> { System.out.println(""); }); + foo((x) -> { return ""; System.out.println(""); }); + foo((x) -> { throw new RuntimeException(); }); + foo((x) -> { while (true); }); + + foo((x) -> x += 1); + foo((x) -> ""); + } + + /* any return statement that is not in the body of the lambda but in an + * inner class or another lambda should be ignored for value void compatibility + * determination. + */ + void m1() { + boolean cond = true; + foo((x) -> { + if (cond) { + return ""; + } + System.out.println(""); + }); + + foo((x)->{ + class Bar { + String m() { + return "from Bar.m()"; + } + } + class Boo { + Bar b = new Bar (){ + String m() { + return "from Bar$1.m()"; + } + }; + } + moo((y) -> { return ""; }); + return; + }); + + foo((x)->{ + class Bar { + void m() {} + } + class Boo { + Bar b = new Bar (){ + void m() { + return; + } + }; + } + moo((y) -> { System.out.println(""); }); + return ""; + }); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/MostSpecific09.out Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,27 @@ +MostSpecific09.java:25:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.I), null)} +MostSpecific09.java:26:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.I), null)} +MostSpecific09.java:27:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.J), null)} +MostSpecific09.java:27:32: compiler.note.verbose.resolve.multi: println, java.io.PrintStream, 1, BASIC, java.lang.String, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, println(java.lang.Object), null),(compiler.misc.applicable.method.found: 1, println(java.lang.String), null)} +MostSpecific09.java:28:13: compiler.err.lambda.body.neither.value.nor.void.compatible +MostSpecific09.java:28:9: compiler.err.cant.apply.symbols: kindname.method, foo, @680,{(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.I), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.J), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.unexpected.ret.val)))} +MostSpecific09.java:28:43: compiler.note.verbose.resolve.multi: println, java.io.PrintStream, 1, BASIC, java.lang.String, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, println(java.lang.Object), null),(compiler.misc.applicable.method.found: 1, println(java.lang.String), null)} +MostSpecific09.java:29:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(MostSpecific09.I), MostSpecific09, kindname.method, foo(MostSpecific09.J), MostSpecific09 +MostSpecific09.java:29:28: compiler.note.verbose.resolve.multi: <init>, java.lang.RuntimeException, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, java.lang.RuntimeException(), null)} +MostSpecific09.java:30:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(MostSpecific09.I), MostSpecific09, kindname.method, foo(MostSpecific09.J), MostSpecific09 +MostSpecific09.java:32:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(MostSpecific09.I), MostSpecific09, kindname.method, foo(MostSpecific09.J), MostSpecific09 +MostSpecific09.java:33:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.I), null)} +MostSpecific09.java:42:13: compiler.err.lambda.body.neither.value.nor.void.compatible +MostSpecific09.java:42:9: compiler.err.cant.apply.symbols: kindname.method, foo, @1129,{(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.I), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.J), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.unexpected.ret.val)))} +MostSpecific09.java:46:23: compiler.note.verbose.resolve.multi: println, java.io.PrintStream, 1, BASIC, java.lang.String, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, println(java.lang.Object), null),(compiler.misc.applicable.method.found: 1, println(java.lang.String), null)} +MostSpecific09.java:49:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.J), null)} +MostSpecific09.java:56:25: compiler.note.verbose.resolve.multi: <init>, Bar, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, Bar(), null)} +MostSpecific09.java:56:35: compiler.note.verbose.resolve.multi: <init>, Bar, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, Bar(), null)} +MostSpecific09.java:56:25: compiler.note.verbose.resolve.multi: <init>, compiler.misc.anonymous.class: MostSpecific09$1Boo$1, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, compiler.misc.anonymous.class: MostSpecific09$1Boo$1(), null)} +MostSpecific09.java:62:13: compiler.note.verbose.resolve.multi: moo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, moo(MostSpecific09.I), null)} +MostSpecific09.java:66:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.I), null)} +MostSpecific09.java:71:25: compiler.note.verbose.resolve.multi: <init>, Bar, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, Bar(), null)} +MostSpecific09.java:71:35: compiler.note.verbose.resolve.multi: <init>, Bar, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, Bar(), null)} +MostSpecific09.java:71:25: compiler.note.verbose.resolve.multi: <init>, compiler.misc.anonymous.class: MostSpecific09$2Boo$1, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, compiler.misc.anonymous.class: MostSpecific09$2Boo$1(), null)} +MostSpecific09.java:77:13: compiler.note.verbose.resolve.multi: moo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, moo(MostSpecific09.J), null)} +MostSpecific09.java:77:36: compiler.note.verbose.resolve.multi: println, java.io.PrintStream, 1, BASIC, java.lang.String, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, println(java.lang.Object), null),(compiler.misc.applicable.method.found: 1, println(java.lang.String), null)} +7 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/MostSpecific10.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,54 @@ +/* + * 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 8034223 + * @summary Structural most-specific logic for lambdas, method refs, parens, and conditionals + * @compile MostSpecific10.java + */ +class MostSpecific10 { + + interface GetInt { + int get(); + } + + interface GetInteger { + Integer get(); + } + + void m(GetInt getter) {} + void m(GetInteger getter) {} + + void test(boolean cond) { + m(() -> 23); + m("abc"::length); + m(( () -> 23 )); + m(( "abc"::length )); + m(cond ? () -> 23 : "abc"::length); + m(( cond ? () -> 23 : "abc"::length )); + m(cond ? (() -> 23) : ("abc"::length) ); + m(( cond ? () -> 23 : cond ? ("abc"::length) : (() -> 23) )); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/MostSpecific11.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8034223 + * @summary Return type Object is not more specific than return type String + * @compile MostSpecific11.java + */ +class MostSpecific11 { + + interface I { Object run(); } + interface J { String run(); } + + void m(I arg) {} + void m(J arg) {} + + void test() { + m(() -> { throw new RuntimeException(); }); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/MostSpecific12.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,38 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8034223 + * @summary Most-specific testing with inference variables in function parameter types + * @compile/fail/ref=MostSpecific12.out -XDrawDiagnostics MostSpecific12.java + */ +class MostSpecific12 { + + interface I<T> { void take(T arg1, String arg2); } + interface J<T> { void take(String arg1, T arg2); } + interface K { void take(String arg1, String arg2); } + + <T> void m1(I<T> arg) {} + void m1(K arg) {} + + <T> void m2(J<T> arg) {} + <T> void m2(K arg) {} + + <T> void m3(I<T> arg) {} + <T> void m3(J<T> arg) {} + + void test() { + m1((String s1, String s2) -> {}); // ok + m2((String s1, String s2) -> {}); // ok + m3((String s1, String s2) -> {}); // error + + m1(this::referencedMethod); // ok + m2(this::referencedMethod); // ok + m3(this::referencedMethod); // error + + m1(String::compareTo); // ok + m2(String::compareTo); // ok + m3(String::compareTo); // error + } + + void referencedMethod(String s1, String s2) {} + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/MostSpecific12.out Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,4 @@ +MostSpecific12.java:25:9: compiler.err.ref.ambiguous: m3, kindname.method, <T>m3(MostSpecific12.I<T>), MostSpecific12, kindname.method, <T>m3(MostSpecific12.J<T>), MostSpecific12 +MostSpecific12.java:29:9: compiler.err.ref.ambiguous: m3, kindname.method, <T>m3(MostSpecific12.I<T>), MostSpecific12, kindname.method, <T>m3(MostSpecific12.J<T>), MostSpecific12 +MostSpecific12.java:33:9: compiler.err.ref.ambiguous: m3, kindname.method, <T>m3(MostSpecific12.I<T>), MostSpecific12, kindname.method, <T>m3(MostSpecific12.J<T>), MostSpecific12 +3 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/MostSpecific13.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,21 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8034223 + * @summary Most-specific testing with inference variables in function parameter types + * @compile/fail/ref=MostSpecific13.out -XDrawDiagnostics MostSpecific13.java + */ +class MostSpecific13 { + + interface UnaryOp<T> { T apply(T arg); } + interface IntegerToNumber { Number apply(Integer arg); } + + <T> void m(UnaryOp<T> f) {} + void m(IntegerToNumber f) {} + + void test() { + m((Integer i) -> i); // error + m(this::id); // error + } + + Integer id(Integer arg) { return arg; } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/MostSpecific13.out Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,3 @@ +MostSpecific13.java:16:9: compiler.err.ref.ambiguous: m, kindname.method, <T>m(MostSpecific13.UnaryOp<T>), MostSpecific13, kindname.method, m(MostSpecific13.IntegerToNumber), MostSpecific13 +MostSpecific13.java:17:9: compiler.err.ref.ambiguous: m, kindname.method, <T>m(MostSpecific13.UnaryOp<T>), MostSpecific13, kindname.method, m(MostSpecific13.IntegerToNumber), MostSpecific13 +2 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/MostSpecific14.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,33 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8034223 + * @summary Most-specific testing for nested functional interface types + * @compile/fail/ref=MostSpecific14.out -XDrawDiagnostics MostSpecific14.java + */ +class MostSpecific14 { + interface ToNumber { Number get(); } + interface ToToNumber { ToNumber get(); } + interface Factory<T> { T get(); } + + void m1(Factory<Factory<Object>> f) {} + void m1(ToToNumber f) {} + + void m2(Factory<Factory<Number>> f) {} + void m2(ToToNumber f) {} + + void m3(Factory<Factory<Integer>> f) {} + void m3(ToToNumber f) {} + + + void test() { + m1(() -> () -> 23); // ok: choose ToToNumber + m2(() -> () -> 23); // error: ambiguous + m3(() -> () -> 23); // ok: choose Factory<Factory<Integer>> + + m1(() -> this::getInteger); // ok: choose ToToNumber + m2(() -> this::getInteger); // error: ambiguous + m3(() -> this::getInteger); // ok: choose Factory<Factory<Integer>> + } + + Integer getInteger() { return 23; } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/MostSpecific14.out Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,3 @@ +MostSpecific14.java:24:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(MostSpecific14.Factory<MostSpecific14.Factory<java.lang.Number>>), MostSpecific14, kindname.method, m2(MostSpecific14.ToToNumber), MostSpecific14 +MostSpecific14.java:28:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(MostSpecific14.Factory<MostSpecific14.Factory<java.lang.Number>>), MostSpecific14, kindname.method, m2(MostSpecific14.ToToNumber), MostSpecific14 +2 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/SingleLocalTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 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/lambda/T8031967.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,137 @@ +/* + * 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 8031967 + * @summary Ensure javac can handle very deeply nested chain of method invocations occurring as + * a parameter to other method invocations. + * @run main T8031967 + */ + +import java.io.IOException; +import java.net.URI; +import java.util.Arrays; +import java.util.List; + +import javax.tools.DiagnosticListener; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.ToolProvider; + +import com.sun.source.util.JavacTask; + +public class T8031967 { + + public static void main(String... args) throws IOException { + new T8031967().run(); + } + + final int depth = 50; + + private void run() throws IOException { + runTestCase(true); + runTestCase(false); + } + + private void runTestCase(boolean withErrors) throws IOException { + StringBuilder code = new StringBuilder(); + + code.append("public class Test {\n" + + " private void test() {\n" + + " GroupLayout l = new GroupLayout();\n" + + " l.setHorizontalGroup(\n"); + + gen(code, depth); + code.append(" );\n" + + " }\n"); + if (!withErrors) { + code.append(" class GroupLayout {\n" + + " ParallelGroup createParallelGroup() {return null;}\n" + + " ParallelGroup createParallelGroup(int i) {return null;}\n" + + " ParallelGroup createParallelGroup(int i, int j) {return null;}\n" + + " void setHorizontalGroup(Group g) { }\n" + + " }\n" + + " \n" + + " class Group {\n" + + " Group addGroup(Group g) { return this; }\n" + + " Group addGroup(int i, Group g) { return this; }\n" + + " Group addGap(int i) { return this; }\n" + + " Group addGap(long l) { return this; }\n" + + " Group addGap(int i, int j) { return this; }\n" + + " Group addComponent(Object c) { return this; }\n" + + " Group addComponent(int i, Object c) { return this; }\n" + + " }\n" + + " class ParallelGroup extends Group {\n" + + " Group addGroup(Group g) { return this; }\n" + + " Group addGroup(int i, Group g) { return this; }\n" + + " Group addGap(int i) { return this; }\n" + + " Group addGap(int i, int j) { return this; }\n" + + " Group addComponent(Object c) { return this; }\n" + + " Group addComponent(int i, Object c) { return this; }\n" + + " }\n"); + } + + code.append("}\n"); + + JavaSource source = new JavaSource(code.toString()); + List<JavaSource> sourceList = Arrays.asList(source); + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + DiagnosticListener<JavaFileObject> noErrors = (diagnostic) -> { + throw new IllegalStateException("Should not produce errors: " + diagnostic); + }; + JavacTask task = (JavacTask) compiler.getTask(null, null, withErrors ? null : noErrors, + null, null, sourceList); + + task.analyze(); + } + + private void gen(StringBuilder code, int depth) { + code.append("l.createParallelGroup()\n"); + if (depth > 0) { + code.append(".addGroup(\n"); + gen(code, depth - 1); + code.append(")"); + } + + code.append(".addGap(1)\n" + + ".addComponent(new Object())\n" + + ".addGap(1)\n" + + ".addComponent(new Object())"); + } + + class JavaSource extends SimpleJavaFileObject { + + final String code; + public JavaSource(String code) { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + this.code = code; + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return code; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/T8037935/LambdaWithBinOpConstRefToConstString.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,43 @@ +/* + * 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 8037935 + * @summary Javac: final local String var referenced in binary/unary op in lambda produces code that does not verify + * @run main LambdaWithBinOpConstRefToConstString + */ + +interface MyFI { + void accept(); +} + +public class LambdaWithBinOpConstRefToConstString { + public static void main(String[] args) { + final String CONSTANT_STRING_VALUE = "mwmwm"; + + MyFI consumeStrings = () -> { + System.out.println(" local constant: " + CONSTANT_STRING_VALUE); + }; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,24 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8038182 + * @summary javac crash with FunctionDescriptorLookupError for invalid functional interface + * @compile/fail/ref=CrashFunctionDescriptorExceptionTest.out -XDrawDiagnostics CrashFunctionDescriptorExceptionTest.java + */ + +class CrashFunctionDescriptorExceptionTest { + + @SuppressWarnings("unchecked") + void m () { + bar((B b) -> {}); + } + + <E extends A<E>> void bar(I<E> i) {} + + class A<E> {} + + class B<E> extends A<E> {} + + interface I<E extends A<E>> { + void foo(E e); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.out Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,2 @@ +CrashFunctionDescriptorExceptionTest.java:12:13: compiler.err.prob.found.req: (compiler.misc.no.suitable.functional.intf.inst: CrashFunctionDescriptorExceptionTest.I<CrashFunctionDescriptorExceptionTest.B>) +1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/T8038420/LambdaIncrement.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,52 @@ +/* + * 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 8038420 + * @summary Lambda returning post-increment generates wrong code + * @run main LambdaIncrement + */ + +public class LambdaIncrement { + + interface IntegerOp { Integer apply(Integer arg); } + + private static void assertNotIncremented(IntegerOp lmb, String label) { + int result = lmb.apply(3); + if (result != 3) { + throw new AssertionError("Post-increment failure. Expected 3, got: " + + result + " " + label); + } + } + + public static void main(String... args) throws Exception { + assertNotIncremented(x -> x++, "PostIncExpr"); + assertNotIncremented(x -> { return x++; }, "PostIncReturn"); + assertNotIncremented(x -> { int y = x; return y++; }, "PostIncLocal"); + assertNotIncremented(x -> { Integer y = x; return y++; }, "PostIncLocalBox"); + assertNotIncremented(x -> { int y = x; return y; }, "HASINIT"); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/T8041704/ErrorMessageTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,12 @@ +/** + * @test /nodynamiccopyright/ + * @bug 8041704 + * @summary wrong error message when mixing lambda expression and inner class + * @compile/fail/ref=ErrorMessageTest.out -XDrawDiagnostics ErrorMessageTest.java + */ + +public class ErrorMessageTest { + void f(Runnable r) { + f(() -> { f(new MISSING() { public void run() {} }); }); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/T8041704/ErrorMessageTest.out Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,2 @@ +ErrorMessageTest.java:10:25: compiler.err.cant.resolve.location: kindname.class, MISSING, , , (compiler.misc.location: kindname.class, ErrorMessageTest, null) +1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,33 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8042759 + * @summary Lambda returning implicitly-typed lambdas considered pertinent to applicability + * @compile/fail/ref=ImplicitLambdaConsideredForApplicabilityTest.out -XDrawDiagnostics ImplicitLambdaConsideredForApplicabilityTest.java + */ + +abstract class ImplicitLambdaConsideredForApplicabilityTest { + interface A { + B m(int a, int b); + } + + interface C { + String m(int a, int b); + } + + interface B { + int m(int c); + } + + abstract void foo(A a); + + abstract void foo(C c); + + void bar() { + foo((int a, int b) -> { + if(a < b) + return c -> 0; + else + return c -> 0; + }); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.out Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,2 @@ +ImplicitLambdaConsideredForApplicabilityTest.java:26:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(ImplicitLambdaConsideredForApplicabilityTest.A), ImplicitLambdaConsideredForApplicabilityTest, kindname.method, foo(ImplicitLambdaConsideredForApplicabilityTest.C), ImplicitLambdaConsideredForApplicabilityTest +1 error
--- a/test/tools/javac/lambda/TargetType01.java Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/lambda/TargetType01.java Tue Aug 19 23:57:05 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -42,6 +42,10 @@ static String M(F_S_S f){ return null; } static { - M(x1 -> { return M( x2 -> { return x1 + x2; });}); //ambiguous + M(x1 -> { + return M( x2 -> { + return x1 + x2; + }); + }); //ambiguous } }
--- a/test/tools/javac/lambda/TargetType01.out Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/lambda/TargetType01.out Tue Aug 19 23:57:05 2014 +0100 @@ -1,3 +1,3 @@ TargetType01.java:45:9: compiler.err.ref.ambiguous: M, kindname.method, M(TargetType01.F_I_I), TargetType01, kindname.method, M(TargetType01.F_S_S), TargetType01 -TargetType01.java:45:26: compiler.err.ref.ambiguous: M, kindname.method, M(TargetType01.F_I_I), TargetType01, kindname.method, M(TargetType01.F_S_S), TargetType01 +TargetType01.java:46:20: compiler.err.ref.ambiguous: M, kindname.method, M(TargetType01.F_I_I), TargetType01, kindname.method, M(TargetType01.F_S_S), TargetType01 2 errors
--- a/test/tools/javac/lambda/TargetType02.java Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/lambda/TargetType02.java Tue Aug 19 23:57:05 2014 +0100 @@ -1,31 +1,9 @@ /* - * Copyright (c) 2011, 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 8003280 + * @test /nodynamiccopyright/ + * @bug 8003280 8029718 * @summary Add lambda tests * check overload resolution and target type inference w.r.t. generic methods + * Should always use lambda body structure to disambiguate overload resolution * @author Maurizio Cimadamore * @compile/fail/ref=TargetType02.out -XDrawDiagnostics TargetType02.java */ @@ -47,9 +25,18 @@ static <Z extends Number> void call3(S1<Z> s) { } static <Z extends String> void call3(S2<Z> s) { } + static <Z extends Number> Z call4(S1<Z> s) { return null; } + static <Z extends String> Z call4(S2<Z> s) { return null; } + void test() { call1(i -> { toString(); return i; }); call2(i -> { toString(); return i; }); call3(i -> { toString(); return i; }); + call3(i -> { + toString(); + return call4(j -> { + return j; + }); + }); } }
--- a/test/tools/javac/lambda/TargetType02.out Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/lambda/TargetType02.out Tue Aug 19 23:57:05 2014 +0100 @@ -1,3 +1,5 @@ -TargetType02.java:52:14: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, java.lang.String) -TargetType02.java:53:9: compiler.err.ref.ambiguous: call3, kindname.method, <Z>call3(TargetType02.S1<Z>), TargetType02, kindname.method, <Z>call3(TargetType02.S2<Z>), TargetType02 -2 errors +TargetType02.java:33:14: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, java.lang.String) +TargetType02.java:34:9: compiler.err.ref.ambiguous: call3, kindname.method, <Z>call3(TargetType02.S1<Z>), TargetType02, kindname.method, <Z>call3(TargetType02.S2<Z>), TargetType02 +TargetType02.java:35:9: compiler.err.ref.ambiguous: call3, kindname.method, <Z>call3(TargetType02.S1<Z>), TargetType02, kindname.method, <Z>call3(TargetType02.S2<Z>), TargetType02 +TargetType02.java:37:20: compiler.err.ref.ambiguous: call4, kindname.method, <Z>call4(TargetType02.S1<Z>), TargetType02, kindname.method, <Z>call4(TargetType02.S2<Z>), TargetType02 +4 errors
--- a/test/tools/javac/lambda/TargetType16.java Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/lambda/TargetType16.java Tue Aug 19 23:57:05 2014 +0100 @@ -1,9 +1,9 @@ /* * @test /nodynamiccopyright/ - * @bug 8003280 + * @bug 8003280 8034223 * @summary Add lambda tests * Check void-compatibility in strict vs. loose conversion contexts - * @compile/fail/ref=TargetType16.out -XDrawDiagnostics TargetType16.java + * @compile TargetType16.java */ class TargetType16 { @@ -20,6 +20,6 @@ static <T> void m(SAM2<T> s2) { } public static void main(String[] args) { - m(() -> { throw new AssertionError(); }); //ambiguous + m(() -> { throw new AssertionError(); }); // prefer SAM2 } }
--- a/test/tools/javac/lambda/TargetType16.out Mon Jun 02 18:51:25 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -TargetType16.java:23:9: compiler.err.ref.ambiguous: m, kindname.method, m(TargetType16.SAM1), TargetType16, kindname.method, <T>m(TargetType16.SAM2<T>), TargetType16 -1 error
--- a/test/tools/javac/lambda/TargetType21.out Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/lambda/TargetType21.out Tue Aug 19 23:57:05 2014 +0100 @@ -1,7 +1,5 @@ TargetType21.java:28:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM2), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21 -TargetType21.java:31:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM2), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21 -TargetType21.java:32:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM2), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21 -TargetType21.java:32:13: compiler.err.cant.apply.symbol: kindname.method, call, TargetType21.SAM2, @888, kindname.class, TargetType21, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.unexpected.ret.val))) -TargetType21.java:33:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM2), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21 -TargetType21.java:33:13: compiler.err.cant.apply.symbol: kindname.method, call, TargetType21.SAM2, @946, kindname.class, TargetType21, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.unexpected.ret.val))) -6 errors +TargetType21.java:32:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM1), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21 +TargetType21.java:32:13: compiler.err.cant.apply.symbol: kindname.method, call, TargetType21.SAM1, @888, kindname.class, TargetType21, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, java.lang.String))) +TargetType21.java:33:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM1), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21 +4 errors
--- a/test/tools/javac/lambda/TargetType23.java Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/lambda/TargetType23.java Tue Aug 19 23:57:05 2014 +0100 @@ -31,7 +31,12 @@ void call(Sam2 s) { } <Z> void call(Sam3<Z> s) { } + void call2(Sam0 s) { } + void call2(Sam2 s) { } + <Z> void call2(Sam3<Z> s) { } + void test() { - call(()-> { throw new RuntimeException(); }); //ambiguous - both call(Sam0), call(Sam2), call(Sam3) match + call(()-> { throw new RuntimeException(); }); // ambiguous - call(Sam1) vs. call(Sam2) + call2(()-> { throw new RuntimeException(); }); // ok } }
--- a/test/tools/javac/lambda/TargetType23.out Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/lambda/TargetType23.out Tue Aug 19 23:57:05 2014 +0100 @@ -1,2 +1,2 @@ -TargetType23.java:35:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType23.Sam2), TargetType23, kindname.method, <Z>call(TargetType23.Sam3<Z>), TargetType23 +TargetType23.java:39:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType23.Sam1), TargetType23, kindname.method, call(TargetType23.Sam2), TargetType23 1 error
--- a/test/tools/javac/lambda/TargetType42.java Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/lambda/TargetType42.java Tue Aug 19 23:57:05 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,12 +31,18 @@ class TargetType42 { interface SAM<X, Y> { - Y f(X x); + Y f(X x); } <Z> void m(SAM<String, SAM<Z, Object>> s, Z z) { } void test(Object obj) { - m((x)->{ class Foo { }; return (x2)-> { new Foo(); return null; }; }, obj); + m((x)->{ + class Foo { } + return (x2)-> { + new Foo(); + return null; + }; + }, obj); } }
--- a/test/tools/javac/lambda/lambdaExpression/LambdaTest1.java Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/lambda/lambdaExpression/LambdaTest1.java Tue Aug 19 23:57:05 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -33,7 +33,6 @@ import java.util.Collections; import java.util.List; import java.util.ArrayList; -import java.util.Date; public class LambdaTest1 {
--- a/test/tools/javac/lambda/lambdaExpression/SamConversionComboTest.java Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/lambda/lambdaExpression/SamConversionComboTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -209,7 +209,11 @@ final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); DiagnosticChecker dc = new DiagnosticChecker(); JavacTask ct = (JavacTask)tool.getTask(null, null, dc, null, null, Arrays.asList(samSourceFile, clientSourceFile)); - ct.analyze(); + try { + ct.analyze(); + } catch (Exception e) { + throw new AssertionError("failing SAM source file \n" + samSourceFile + "\n\n" + "failing client source file \n"+ clientSourceFile); + } if (dc.errorFound == checkSamConversion()) { throw new AssertionError(samSourceFile + "\n\n" + clientSourceFile); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/missingSuperRecovery/MissingInterfaceTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,15 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8036007 + * @summary javac crashes when encountering an unresolvable interface + * @build MissingInterfaceTestDep + * @clean Closeable + * @compile/fail/ref=MissingInterfaceTest.out -XDrawDiagnostics MissingInterfaceTest.java + */ + +public class MissingInterfaceTest { + void test(MissingInterfaceTestDep s) { + s.call(); + s.another(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/missingSuperRecovery/MissingInterfaceTest.out Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,3 @@ +MissingInterfaceTest.java:12:10: compiler.err.cant.access: Closeable, (compiler.misc.class.file.not.found: Closeable) +MissingInterfaceTest.java:13:10: compiler.err.cant.resolve.location.args: kindname.method, another, , , (compiler.misc.location.1: kindname.variable, s, MissingInterfaceTestDep) +2 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/missingSuperRecovery/MissingInterfaceTestDep.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,26 @@ +/* + * 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. + */ + +public class MissingInterfaceTestDep implements Intermediate {} +interface Intermediate extends Closeable { } +interface Closeable {}
--- a/test/tools/javac/processing/environment/round/ErroneousAnnotations.out Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/processing/environment/round/ErroneousAnnotations.out Tue Aug 19 23:57:05 2014 +0100 @@ -1,4 +1,3 @@ ErroneousAnnotations.java:8:2: compiler.err.cant.resolve: kindname.class, Undefined, , ErroneousAnnotations.java:10:6: compiler.err.cant.resolve.location: kindname.class, Undefined, , , (compiler.misc.location: kindname.class, ErroneousAnnotations, null) 2 errors -Results: []
--- a/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java Tue Aug 19 23:57:05 2014 +0100 @@ -93,7 +93,8 @@ roundEnvironment. getElementsAnnotatedWith(elements.getTypeElement(annotatedElementInfo.annotationName())); - System.err.println("Results: " + resultsMeta); + if (!resultsMeta.isEmpty()) + System.err.println("Results: " + resultsMeta); if (resultsMeta.size() != annotatedElementInfo.expectedSize()) { failed = true;
--- a/test/tools/javac/processing/model/element/TestTypeParameterAnnotations.java Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/processing/model/element/TestTypeParameterAnnotations.java Tue Aug 19 23:57:05 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8011027 + * @bug 8011027 8046916 * @library /tools/javac/lib * @build JavacTestingAbstractProcessor TestTypeParameterAnnotations * @compile -processor TestTypeParameterAnnotations -proc:only TestTypeParameterAnnotations.java @@ -33,10 +33,16 @@ import java.lang.annotation.*; import javax.annotation.processing.*; import javax.lang.model.element.*; -import javax.lang.model.util.*; import javax.tools.*; -public class TestTypeParameterAnnotations<@Foo @Bar @Baz T> extends JavacTestingAbstractProcessor { +@ExpectedTypeParameterAnnotations(typeParameterName="T1", + annotations={"Foo1", "Bar1", "Baz1"}) +@ExpectedTypeParameterAnnotations(typeParameterName="T2", annotations={}) +@ExpectedTypeParameterAnnotations(typeParameterName="T3", + annotations={"Foo2", "Bar2", "Baz2"}) +@ExpectedTypeParameterAnnotations(typeParameterName="T4", annotations={}) +public class TestTypeParameterAnnotations<@Foo1 @Bar1 @Baz1 T1, T2, @Foo2 @Bar2 @Baz2 T3, T4> extends + JavacTestingAbstractProcessor { int round = 0; public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { @@ -74,82 +80,69 @@ int check(Element e, List<? extends TypeParameterElement> typarams) { if (typarams.isEmpty()) return 0; - if (typarams.size() != 1) - return 0; - for (TypeParameterElement tpe: typarams) { - boolean b1 = checkAnnotationMirrors(tpe, tpe.getAnnotationMirrors()); - boolean b2 = checkAnnotationMirrors(tpe, elements.getAllAnnotationMirrors(tpe)); - boolean b3 = checkGetAnnotation(tpe); - boolean b4 = checkGetAnnotations(tpe); - return b1 && b2 && b3 && b4 ? 1 : 0; - } - return 0; - } - - boolean checkAnnotationMirrors(TypeParameterElement tpe, List<? extends AnnotationMirror> l) { - if (l.size() != 3) { - error("To few annotations, got " + l.size() + - ", should be 3", tpe); - return false; + for (TypeParameterElement tpe : typarams) { + ExpectedTypeParameterAnnotations expected = null; + for (ExpectedTypeParameterAnnotations a : e.getAnnotationsByType(ExpectedTypeParameterAnnotations.class)) { + if (tpe.getSimpleName().contentEquals(a.typeParameterName())) { + expected = a; + break; + } + } + if (expected == null) { + throw new IllegalStateException("Does not have expected values annotation."); + } + checkAnnotationMirrors(tpe, tpe.getAnnotationMirrors(), expected); + checkAnnotationMirrors(tpe, elements.getAllAnnotationMirrors(tpe), expected); + checkGetAnnotation(tpe, expected); + checkGetAnnotations(tpe, expected); } - AnnotationMirror m = l.get(0); - if (!m.getAnnotationType().asElement().equals(elements.getTypeElement("Foo"))) { - error("Wrong type of annotation, was expecting @Foo", m.getAnnotationType().asElement()); - return false; - } - m = l.get(1); - if (!m.getAnnotationType().asElement().equals(elements.getTypeElement("Bar"))) { - error("Wrong type of annotation, was expecting @Bar", m.getAnnotationType().asElement()); - return false; - } - m = l.get(2); - if (!m.getAnnotationType().asElement().equals(elements.getTypeElement("Baz"))) { - error("Wrong type of annotation, was expecting @Baz", m.getAnnotationType().asElement()); - return false; - } - return true; + return typarams.size(); } - boolean checkGetAnnotation(TypeParameterElement tpe) { - Foo f = tpe.getAnnotation(Foo.class); - if (f == null) - error("Expecting @Foo to be present in getAnnotation()", tpe); + void checkAnnotationMirrors(TypeParameterElement tpe, List<? extends AnnotationMirror> l, ExpectedTypeParameterAnnotations expected) { + String[] expectedAnnotations = expected.annotations(); - Bar b = tpe.getAnnotation(Bar.class); - if (b == null) - error("Expecting @Bar to be present in getAnnotation()", tpe); + if (l.size() != expectedAnnotations.length) { + error("Incorrect number of annotations, got " + l.size() + + ", should be " + expectedAnnotations.length, tpe); + return ; + } - Baz z = tpe.getAnnotation(Baz.class); - if (z == null) - error("Expecting @Baz to be present in getAnnotation()", tpe); - - return f != null && - b != null && - z != null; + for (int i = 0; i < expectedAnnotations.length; i++) { + AnnotationMirror m = l.get(i); + if (!m.getAnnotationType().asElement().equals(elements.getTypeElement(expectedAnnotations[i]))) { + error("Wrong type of annotation, was expecting @Foo", m.getAnnotationType().asElement()); + return ; + } + } } - boolean checkGetAnnotations(TypeParameterElement tpe) { - Foo[] f = tpe.getAnnotationsByType(Foo.class); - if (f.length != 1) { - error("Expecting 1 @Foo to be present in getAnnotationsByType()", tpe); - return false; - } + void checkGetAnnotation(TypeParameterElement tpe, ExpectedTypeParameterAnnotations expected) { + List<String> expectedAnnotations = Arrays.asList(expected.annotations()); + + for (Class<? extends Annotation> c : ALL_ANNOTATIONS) { + Object a = tpe.getAnnotation(c); - Bar[] b = tpe.getAnnotationsByType(Bar.class); - if (b.length != 1) { - error("Expecting 1 @Bar to be present in getAnnotationsByType()", tpe); - return false; + if (a != null ^ expectedAnnotations.indexOf(c.getName()) != (-1)) { + error("Unexpected behavior for " + c.getName(), tpe); + return ; + } } + } - Baz[] z = tpe.getAnnotationsByType(Baz.class); - if (z.length != 1) { - error("Expecting 1 @Baz to be present in getAnnotationsByType()", tpe); - return false; + void checkGetAnnotations(TypeParameterElement tpe, ExpectedTypeParameterAnnotations expected) { + List<String> expectedAnnotations = Arrays.asList(expected.annotations()); + + for (Class<? extends Annotation> c : ALL_ANNOTATIONS) { + Object[] a = tpe.getAnnotationsByType(c); + + if (a.length > 0 ^ expectedAnnotations.indexOf(c.getName()) != (-1)) { + error("Unexpected behavior for " + c.getName(), tpe); + return ; + } } - - return true; } void note(String msg) { @@ -168,23 +161,71 @@ messager.printMessage(Diagnostic.Kind.ERROR, msg); } + Class<? extends Annotation>[] ALL_ANNOTATIONS = new Class[] { + Foo1.class, Bar1.class, Baz1.class, + Foo2.class, Bar2.class, Baz2.class, + }; + // additional generic elements to test - <@Foo @Bar @Baz X> X m(X x) { return x; } + @ExpectedTypeParameterAnnotations(typeParameterName="W", + annotations={"Foo1", "Bar1", "Baz1"}) + @ExpectedTypeParameterAnnotations(typeParameterName="X", annotations={}) + @ExpectedTypeParameterAnnotations(typeParameterName="Y", + annotations={"Foo2", "Bar2", "Baz2"}) + @ExpectedTypeParameterAnnotations(typeParameterName="Z", annotations={}) + <@Foo1 @Bar1 @Baz1 W, X, @Foo2 @Bar2 @Baz2 Y, Z> X m(X x) { return x; } - interface Intf<@Foo @Bar @Baz X> { X m() ; } + @ExpectedTypeParameterAnnotations(typeParameterName="W", + annotations={"Foo1", "Bar1", "Baz1"}) + @ExpectedTypeParameterAnnotations(typeParameterName="X", annotations={}) + @ExpectedTypeParameterAnnotations(typeParameterName="Y", + annotations={"Foo2", "Bar2", "Baz2"}) + @ExpectedTypeParameterAnnotations(typeParameterName="Z", annotations={}) + interface Intf<@Foo1 @Bar1 @Baz1 W, X, @Foo2 @Bar2 @Baz2 Y, Z> { X m() ; } - class Class<@Foo @Bar @Baz X> { - <@Foo @Bar @Baz Y> Class() { } + @ExpectedTypeParameterAnnotations(typeParameterName="W", + annotations={"Foo1", "Bar1", "Baz1"}) + @ExpectedTypeParameterAnnotations(typeParameterName="X", annotations={}) + @ExpectedTypeParameterAnnotations(typeParameterName="Y", + annotations={"Foo2", "Bar2", "Baz2"}) + @ExpectedTypeParameterAnnotations(typeParameterName="Z", annotations={}) + class Clazz<@Foo1 @Bar1 @Baz1 W, X, @Foo2 @Bar2 @Baz2 Y, Z> { + @ExpectedTypeParameterAnnotations(typeParameterName="W", + annotations={"Foo1", "Bar1", "Baz1"}) + @ExpectedTypeParameterAnnotations(typeParameterName="X", annotations={}) + @ExpectedTypeParameterAnnotations(typeParameterName="Y", + annotations={"Foo2", "Bar2", "Baz2"}) + @ExpectedTypeParameterAnnotations(typeParameterName="Z", annotations={}) + <@Foo1 @Bar1 @Baz1 W, X, @Foo2 @Bar2 @Baz2 Y, Z> Clazz() { } } - final int expect = 5; // top level class, plus preceding examples + final int expect = 5 * 4; // top level class, plus preceding examples, 4 type variables each } @Target(ElementType.TYPE_PARAMETER) -@interface Foo {} +@interface Foo1 {} + +@Target(ElementType.TYPE_PARAMETER) +@interface Bar1 {} + +@Target(ElementType.TYPE_PARAMETER) +@interface Baz1 {} + +@Target(ElementType.TYPE_PARAMETER) +@interface Foo2 {} @Target(ElementType.TYPE_PARAMETER) -@interface Bar {} +@interface Bar2 {} @Target(ElementType.TYPE_PARAMETER) -@interface Baz {} +@interface Baz2 {} + +@Repeatable(ExpectedTypeParameterAnnotationsCollection.class) +@interface ExpectedTypeParameterAnnotations { + public String typeParameterName(); + public String[] annotations(); +} + +@interface ExpectedTypeParameterAnnotationsCollection { + public ExpectedTypeParameterAnnotations[] value(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/resolve/AmbiguityErrorTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -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"); + } + } + +}
--- a/test/tools/javac/resolve/ResolveHarness.java Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/resolve/ResolveHarness.java Tue Aug 19 23:57:05 2014 +0100 @@ -23,8 +23,8 @@ /* * @test - * @bug 7098660 8014649 - * @summary Write better overload resolution/inference tests + * @bug 7098660 8014649 8034223 + * @summary Test harness for overload resolution/inference tests * @library /tools/javac/lib * @build JavacTestingAbstractProcessor ResolveHarness * @run main ResolveHarness
--- a/test/tools/javac/resolve/tests/PrimitiveOverReferenceVarargsAmbiguous.java Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javac/resolve/tests/PrimitiveOverReferenceVarargsAmbiguous.java Tue Aug 19 23:57:05 2014 +0100 @@ -23,44 +23,44 @@ @TraceResolve(keys={"compiler.err.ref.ambiguous"}) class PrimitiveOverReferenceVarargsAmbiguous { - @Candidate(applicable=Phase.VARARGS, mostSpecific=true) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_byte(byte... b) {} - @Candidate(applicable=Phase.VARARGS) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_byte(Byte... b) {} - @Candidate(applicable=Phase.VARARGS, mostSpecific=true) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_short(short... s) {} - @Candidate(applicable=Phase.VARARGS) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_short(Short... s) {} - @Candidate(applicable=Phase.VARARGS, mostSpecific=true) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_int(int... i) {} - @Candidate(applicable=Phase.VARARGS) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_int(Integer... i) {} - @Candidate(applicable=Phase.VARARGS, mostSpecific=true) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_long(long... l) {} - @Candidate(applicable=Phase.VARARGS) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_long(Long... l) {} - @Candidate(applicable=Phase.VARARGS, mostSpecific=true) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_float(float... f) {} - @Candidate(applicable=Phase.VARARGS) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_float(Float... f) {} - @Candidate(applicable=Phase.VARARGS, mostSpecific=true) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_double(double... d) {} - @Candidate(applicable=Phase.VARARGS) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_double(Double... d) {} - @Candidate(applicable=Phase.VARARGS, mostSpecific=true) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_char(char... c) {} - @Candidate(applicable=Phase.VARARGS) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_char(Character... c) {} - @Candidate(applicable=Phase.VARARGS, mostSpecific=true) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_bool(boolean... z) {} - @Candidate(applicable=Phase.VARARGS) + @Candidate(applicable=Phase.VARARGS, mostSpecific=false) static void m_bool(Boolean... z) {} {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/resolve/tests/PrimitiveVsReferenceSamePhase.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,76 @@ +/* + * 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. + */ + +@TraceResolve(keys={"compiler.err.ref.ambiguous"}) +class PrimitiveVsReferenceSamePhase { + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_byte(Byte b1, byte b2) {} + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_byte(Byte b1, Byte b2) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_short(Short s1, short s2) {} + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_short(Short s1, Short s2) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_int(Integer i1, int i2) {} + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_int(Integer i1, Integer i2) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_long(Long l1, long l2) {} + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_long(Long l1, Long l2) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_float(Float f1, float f2) {} + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_float(Float f1, Float f2) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_double(Double d1, double d2) {} + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_double(Double d1, Double d2) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_char(Character c1, char c2) {} + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_char(Character c1, Character c2) {} + + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_bool(Boolean z1, boolean z2) {} + @Candidate(applicable=Phase.BOX, mostSpecific=false) + static void m_bool(Boolean z1, Boolean z2) {} + + { + m_byte((byte)0, (byte)0); + m_short((short)0, (short)0); + m_int(0, 0); + m_long(0L, 0L); + m_float(0.0f, 0.0f); + m_double(0.0, 0.0); + m_char('?', '?'); + m_bool(false, false); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/types/BadSigTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,40 @@ +/* + * 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 8037934 + * @summary Javac generates invalid signatures for local types + * @run main BadSigTest + */ + +public class BadSigTest<Outer> { + void m(){ + class Local1{} + class Local2 extends Local1{} + Local2.class.getTypeParameters(); + } + public static void main(String[] args) { + new BadSigTest().m(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/util/StringUtilsTest.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2013, 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 8029800 8043186 + * @summary Unit test StringUtils + * @run main StringUtilsTest + */ + +import java.util.Locale; +import java.util.Objects; +import com.sun.tools.javac.util.StringUtils; + +public class StringUtilsTest { + public static void main(String... args) throws Exception { + new StringUtilsTest().run(); + } + + void run() throws Exception { + Locale.setDefault(new Locale("tr", "TR")); + + //verify the properties of the default locale: + assertEquals("\u0131", "I".toLowerCase()); + assertEquals("\u0130", "i".toUpperCase()); + + //verify the StringUtils.toLowerCase/toUpperCase do what they should: + assertEquals("i", StringUtils.toLowerCase("I")); + assertEquals("I", StringUtils.toUpperCase("i")); + + //verify StringUtils.caseInsensitiveIndexOf works: + assertEquals(2, StringUtils.indexOfIgnoreCase(" lookFor", "lookfor")); + assertEquals(11, StringUtils.indexOfIgnoreCase(" lookFor LOOKfor", "lookfor", 11)); + assertEquals(2, StringUtils.indexOfIgnoreCase("\u0130\u0130lookFor", "lookfor")); + } + + void assertEquals(String expected, String actual) { + if (!Objects.equals(expected, actual)) { + throw new IllegalStateException("expected=" + expected + "; actual=" + actual); + } + } + + void assertEquals(int expected, int actual) { + if (expected != actual) { + throw new IllegalStateException("expected=" + expected + "; actual=" + actual); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/MethodHandleCrash.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,36 @@ +/* + * 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 8034048 + * @summary javac crash with method references plus lambda plus var args + * @author govereau + * + * @compile MethodHandleCrash.java + */ +public interface MethodHandleCrash { + static<T> void functional(T... input) { + java.util.function.Consumer<T> c = MethodHandleCrash::functional; + } +}
--- a/test/tools/javadoc/parser/7091528/T7091528.java Mon Jun 02 18:51:25 2014 +0100 +++ b/test/tools/javadoc/parser/7091528/T7091528.java Tue Aug 19 23:57:05 2014 +0100 @@ -23,7 +23,7 @@ /** * @test - * @bug 7091528 8029145 + * @bug 7091528 8029145 8037484 * @summary ensures javadoc parses unique source files and ignores all class files * @compile p/C1.java p/q/C2.java * @run main T7091528 @@ -50,6 +50,16 @@ "-sourcepath", testSrc.getAbsolutePath(), "-subpackages", "p:p.q"); + File testPkgDir = new File(testSrc, "p"); + File testFile = new File(testPkgDir, "C3.java"); + runTest("-d", ".", + "-sourcepath", testSrc.getAbsolutePath(), + testFile.getAbsolutePath(), + "p"); + runTest("-d", ".", + "-classpath", testSrc.getAbsolutePath(), + testFile.getAbsolutePath(), + "p"); } void runTest(String... args) { @@ -65,7 +75,7 @@ } if (rc != 0) - System.err.println("javadoc failed: exit code = " + rc); + throw new Error("javadoc failed: exit code = " + rc); if (out.matches("(?s).*p/[^ ]+\\.class.*")) throw new Error("reading .class files");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javadoc/parser/7091528/p/C3.java Tue Aug 19 23:57:05 2014 +0100 @@ -0,0 +1,27 @@ +/* + * 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. + */ + + +/** This is class C3, and no package for me please */ +public class C3 {} +