Mercurial > hg > openjdk > aarch64-port > langtools
changeset 2523:df9cb52f5dd7 jdk8u40-b02
Merge
line wrap: on
line diff
--- a/.hgtags Thu Jun 05 13:08:52 2014 +0100 +++ b/.hgtags Thu Sep 04 12:43:12 2014 -0400 @@ -269,6 +269,7 @@ 9003a59a512e6b764d8a3f805aadc3996a58e5bd jdk8u5-b02 30e3dad0ebbdf3129bacd04a7f4cdecd3df92bb2 jdk8u5-b03 019dcdfffced0ca2026a0ad8c0e5fcb49d46116f jdk8u5-b04 +c9db8c800797258540e0411e58b8f7d59273de5f jdk8u11-b00 c9db8c800797258540e0411e58b8f7d59273de5f jdk8u5-b05 b1920c0b701d5ff219c9f622db5cafc9bf00d5c8 jdk8u5-b06 180df7f2c078f1efaa6fcd8ca9f55dc5f81b182c jdk8u5-b07 @@ -278,6 +279,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 @@ -296,3 +311,12 @@ 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 +5c1d6da1445aa3a2e5cf6101c70e79bfbe2745a5 jdk8u20-b23 +d231957fe3103e790465fcf058fb8cb33bbc4c4e jdk8u40-b00 +bf89a471779d13a9407f7d1c86f7716258bc4aa6 jdk8u40-b01
--- a/THIRD_PARTY_README Thu Jun 05 13:08:52 2014 +0100 +++ b/THIRD_PARTY_README Thu Sep 04 12:43:12 2014 -0400 @@ -2,7 +2,7 @@ ----------------------------- %% This notice is provided with respect to ASM Bytecode Manipulation -Framework v5.0, which may be included with JRE 8, and JDK 8, and +Framework v5.0.3, which may be included with JRE 8, and JDK 8, and OpenJDK 8. --- begin of LICENSE --- @@ -1471,7 +1471,7 @@ version 2.0. The NSS libraries are supplied in executable form, built from unmodified -NSS source code labeled with the "NSS_3.13.1_RTM" release tag. +NSS source code labeled with the "NSS_3_16_RTM" HG tag. The NSS source code is available in the OpenJDK source code repository at: jdk/test/sun/security/pkcs11/nss/src @@ -3349,14 +3349,14 @@ ------------------------------------------------------------------------------- -%% This notice is provided with respect to zlib v1.2.5, which may be included +%% This notice is provided with respect to zlib v1.2.8, which may be included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- - version 1.2.5, July 18th, 2005 - - Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler + version 1.2.8, April 28th, 2013 + + Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -3382,11 +3382,11 @@ ------------------------------------------------------------------------------- %% This notice is provided with respect to the following which may be -included with JRE 8, JDK 8, and OpenJDK 8, except where noted: - - Apache Commons Math 2.2 - Apache Derby 10.10.1.2 [included with JDK 8] - Apache Jakarta BCEL 5.2 +included with JRE 8, JDK 8, and OpenJDK 8. + + Apache Commons Math 3.2 + Apache Derby 10.10.1.3 + Apache Jakarta BCEL 5.1 Apache Jakarta Regexp 1.4 Apache Santuario XML Security for Java 1.5.4 Apache Xalan-Java 2.7.1
--- a/src/share/classes/com/sun/tools/classfile/Instruction.java Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/classfile/Instruction.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlAttr.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTag.java Thu Sep 04 12:43:12 2014 -0400 @@ -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/internal/toolkit/Configuration.java Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java Thu Sep 04 12:43:12 2014 -0400 @@ -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/taglets/SimpleTaglet.java Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SimpleTaglet.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java Thu Sep 04 12:43:12 2014 -0400 @@ -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/Util.java Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclint/Checker.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclint/Env.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclint/HtmlTag.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclint/Messages.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/doclint/resources/doclint_ja.properties Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/api/JavacTrees.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Flags.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Source.java Thu Sep 04 12:43:12 2014 -0400 @@ -233,6 +233,9 @@ public boolean allowFunctionalInterfaceMostSpecific() { return compareTo(JDK1_8) >= 0; } + public boolean allowPostApplicabilityVarargsAccessCheck() { + return compareTo(JDK1_8) >= 0; + } public static SourceVersion toSourceVersion(Source source) { switch(source) { case JDK1_2:
--- a/src/share/classes/com/sun/tools/javac/code/Symbol.java Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java Thu Sep 04 12:43:12 2014 -0400 @@ -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. @@ -1643,9 +1658,6 @@ //only change bounds if request comes from substBounds super.addBound(ib, bound, types, update); } - else if (bound.hasTag(UNDETVAR) && !((UndetVar) bound).isCaptured()) { - ((UndetVar) bound).addBound(ib.complement(), this, types, false); - } } @Override
--- a/src/share/classes/com/sun/tools/javac/code/Types.java Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Thu Sep 04 12:43:12 2014 -0400 @@ -122,60 +122,56 @@ } // </editor-fold> - // <editor-fold defaultstate="collapsed" desc="upperBound"> - /** - * 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 - */ - public Type upperBound(Type t) { - return upperBound.visit(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="wildLowerBound"> + // <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(); + } + /** * Get a wildcard's lower bound, returning non-wildcards unchanged. * @param t a type argument, either a wildcard or a type */ public Type wildLowerBound(Type t) { if (t.hasTag(WILDCARD)) { - WildcardType w = (WildcardType) t; + WildcardType w = (WildcardType) t.unannotatedType(); return w.isExtendsBound() ? syms.botType : wildLowerBound(w.type); } - else return t; + else return t.unannotatedType(); } - // </editor-fold> - - // <editor-fold defaultstate="collapsed" desc="cvarLowerBound"> + /** * Get a capture variable's lower bound, returning other types unchanged. * @param t a type */ public Type cvarLowerBound(Type t) { - if (t.hasTag(TYPEVAR) && ((TypeVar) t).isCaptured()) { - return cvarLowerBound(t.getLowerBound()); + if (t.hasTag(TYPEVAR)) { + TypeVar v = (TypeVar) t.unannotatedType(); + return v.isCaptured() ? cvarLowerBound(v.getLowerBound()) : v; } - else return t; + else return t.unannotatedType(); } // </editor-fold> @@ -633,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); @@ -904,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; @@ -1113,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: @@ -1140,7 +1136,7 @@ return visit(s, t); if (s.isSuperBound() && !s.isExtendsBound()) - return visit(t, upperBound(s)) && visit(t, wildLowerBound(s)); + return visit(t, wildUpperBound(s)) && visit(t, wildLowerBound(s)); if (t.isCompound() && s.isCompound()) { if (!visit(supertype(t), supertype(s))) @@ -1226,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; + } + } }; /** @@ -1288,9 +1305,10 @@ UndetVar undetvar = (UndetVar)t; WildcardType wt = (WildcardType)s.unannotatedType(); switch(wt.kind) { - case UNBOUND: //similar to ? extends Object + case UNBOUND: + break; case EXTENDS: { - Type bound = upperBound(s); + Type bound = wildUpperBound(s); undetvar.addBound(InferenceBound.UPPER, bound, this); break; } @@ -1351,28 +1369,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); @@ -1384,13 +1380,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, wildLowerBound(s), +// wildLowerBound(t), t, s, wildLowerBound(s), // t.isExtendsBound() -// || isSubtypeNoCapture(L(t), wildLowerBound(s))); +// || isSubtypeNoCapture(wildLowerBound(t), wildLowerBound(s))); // System.err.println(); // } @@ -1401,9 +1397,11 @@ else { // debugContainsType(t, s); return isSameWildcard(t, s) + || t.type == s || isCaptureOf(s, t) - || ((t.isExtendsBound() || isSubtypeNoCapture(L(t), wildLowerBound(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)))); } } @@ -1521,7 +1519,7 @@ @Override public Boolean visitWildcardType(WildcardType t, Type s) { - return isCastable(upperBound(t), s, warnStack.head); + return isCastable(wildUpperBound(t), s, warnStack.head); } @Override @@ -1762,12 +1760,12 @@ if (t.isExtendsBound()) { if (s.isExtendsBound()) - return !isCastableRecursive(t.type, upperBound(s)); + return !isCastableRecursive(t.type, wildUpperBound(s)); else if (s.isSuperBound()) 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; } @@ -1803,7 +1801,7 @@ noWarnings); } if (!s.hasTag(WILDCARD)) - s = upperBound(s); + s = cvarUpperBound(s); return !isSubtype(t, relaxBound(s)); } @@ -1860,7 +1858,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); } @@ -1870,7 +1868,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; @@ -2073,7 +2071,7 @@ @Override public Type visitWildcardType(WildcardType t, Symbol sym) { - return memberType(upperBound(t), sym); + return memberType(wildUpperBound(t), sym); } @Override @@ -2192,7 +2190,7 @@ @Override public Type visitWildcardType(WildcardType t, Boolean recurse) { - return erasure(upperBound(t), recurse); + return erasure(wildUpperBound(t), recurse); } @Override @@ -2304,7 +2302,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 @@ -2401,8 +2399,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; @@ -2472,7 +2469,7 @@ return false; return t.isRaw() || - supertype(t) != null && isDerivedRaw(supertype(t)) || + supertype(t) != Type.noType && isDerivedRaw(supertype(t)) || isDerivedRaw(interfaces(t)); } @@ -2959,6 +2956,12 @@ } @Override + public Type visitUndetVar(UndetVar t, Void ignored) { + //do nothing - we should not replace inside undet variables + return t; + } + + @Override public Type visitClassType(ClassType t, Void ignored) { if (!t.isCompound()) { List<Type> typarams = t.getTypeArguments(); @@ -2971,7 +2974,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 @@ -2988,7 +2991,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); } } @@ -3223,6 +3226,7 @@ return tvar.rank_field; } case ERROR: + case NONE: return 0; default: throw new AssertionError(); @@ -3403,9 +3407,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() { @@ -3416,8 +3427,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>(); @@ -3438,8 +3449,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); @@ -3972,8 +3983,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; @@ -4010,16 +4026,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 @@ -4176,7 +4182,7 @@ @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(wildLowerBound(source), wildLowerBound(target)); return null; @@ -4193,7 +4199,7 @@ 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(); @@ -4304,7 +4310,7 @@ } public Type visitType(Type t, Void s) { - return high ? upperBound(t) : t; + return t; } @Override @@ -4702,7 +4708,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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Thu Sep 04 12:43:12 2014 -0400 @@ -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? */ @@ -245,36 +252,30 @@ */ Type check(final JCTree tree, final Type found, final int ownkind, final ResultInfo resultInfo) { InferenceContext inferenceContext = resultInfo.checkContext.inferenceContext(); - Type owntype = found; - 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.asUndetVar(owntype)); - } else { - log.error(tree.pos(), "unexpected.type", - kindNames(resultInfo.pkind), - kindName(ownkind)); - owntype = types.createErrorType(owntype); - } + Type owntype; + if (!found.hasTag(ERROR) && !resultInfo.pt.hasTag(METHOD) && !resultInfo.pt.hasTag(FORALL)) { + if ((ownkind & ~resultInfo.pkind) != 0) { + log.error(tree.pos(), "unexpected.type", + kindNames(resultInfo.pkind), + kindName(ownkind)); + owntype = types.createErrorType(found); + } else if (allowPoly && inferenceContext.free(found)) { + //delay the check if there are inference variables in the found type + //this means we are dealing with a partially inferred poly expression + owntype = resultInfo.pt; inferenceContext.addFreeTypeListener(List.of(found, resultInfo.pt), new FreeTypeListener() { @Override public void typesInferred(InferenceContext inferenceContext) { ResultInfo pendingResult = - resultInfo.dup(inferenceContext.asInstType(resultInfo.pt)); + resultInfo.dup(inferenceContext.asInstType(resultInfo.pt)); check(tree, inferenceContext.asInstType(found), ownkind, pendingResult); } }); - return tree.type = resultInfo.pt; } else { - if ((ownkind & ~resultInfo.pkind) == 0) { - owntype = resultInfo.check(tree, owntype); - } else { - log.error(tree.pos(), "unexpected.type", - kindNames(resultInfo.pkind), - kindName(ownkind)); - owntype = types.createErrorType(owntype); - } + owntype = resultInfo.check(tree, found); } + } else { + owntype = found; } tree.type = owntype; return owntype; @@ -427,7 +428,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); } @@ -1175,7 +1176,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? @@ -1192,7 +1193,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); @@ -2056,7 +2057,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, @@ -2328,6 +2329,7 @@ currentTarget = infer.instantiateFunctionalInterface(that, currentTarget, explicitParamTypes, resultInfo.checkContext); } + currentTarget = types.removeWildcards(currentTarget); lambdaType = types.findDescriptorType(currentTarget); } else { currentTarget = Type.recoveryType; @@ -2720,7 +2722,7 @@ resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK && isSerializable(currentTarget); if (currentTarget != Type.recoveryType) { - currentTarget = targetChecker.visit(currentTarget, that); + currentTarget = types.removeWildcards(targetChecker.visit(currentTarget, that)); desc = types.findDescriptorType(currentTarget); } else { currentTarget = Type.recoveryType; @@ -2961,10 +2963,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); } } } @@ -3323,6 +3334,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) @@ -4042,7 +4057,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; } @@ -4192,9 +4207,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 @@ -4671,16 +4686,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/Check.java Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Thu Sep 04 12:43:12 2014 -0400 @@ -531,8 +531,8 @@ Type checkType(final DiagnosticPosition pos, final Type found, final Type req, final CheckContext checkContext) { final Infer.InferenceContext inferenceContext = checkContext.inferenceContext(); - if (inferenceContext.free(req)) { - inferenceContext.addFreeTypeListener(List.of(req), new FreeTypeListener() { + if (inferenceContext.free(req) || inferenceContext.free(found)) { + inferenceContext.addFreeTypeListener(List.of(req, found), new FreeTypeListener() { @Override public void typesInferred(InferenceContext inferenceContext) { checkType(pos, inferenceContext.asInstType(found), inferenceContext.asInstType(req), checkContext); @@ -618,10 +618,10 @@ 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.wildLowerBound(a), bound); } @@ -1038,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; @@ -1813,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; } @@ -2672,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.
--- a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Thu Sep 04 12:43:12 2014 -0400 @@ -77,6 +77,7 @@ final Types types; final Flow flow; final Names names; + final TypeEnvs typeEnvs; public static DeferredAttr instance(Context context) { DeferredAttr instance = context.get(deferredAttrKey); @@ -100,6 +101,7 @@ 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 @@ -400,7 +402,7 @@ //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); @@ -928,7 +930,7 @@ LambdaReturnScanner() { super(EnumSet.of(BLOCK, CASE, CATCH, DOLOOP, FOREACHLOOP, - FORLOOP, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP)); + FORLOOP, IF, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP)); } } @@ -1218,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 @@ -1251,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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Enter.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java Thu Sep 04 12:43:12 2014 -0400 @@ -232,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 @@ -240,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, enforceThisDotInit).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;
--- a/src/share/classes/com/sun/tools/javac/comp/Infer.java Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Thu Sep 04 12:43:12 2014 -0400 @@ -353,6 +353,7 @@ Type to, Attr.ResultInfo resultInfo, InferenceContext inferenceContext) { inferenceContext.solve(List.of(from.qtype), new Warner()); + inferenceContext.notifyChange(); Type capturedType = resultInfo.checkContext.inferenceContext() .cachedCapture(tree, from.inst, false); if (types.isConvertible(capturedType, @@ -449,7 +450,7 @@ class ImplicitArgType extends DeferredAttr.DeferredTypeMap { public ImplicitArgType(Symbol msym, Resolve.MethodResolutionPhase phase) { - rs.deferredAttr.super(AttrMode.SPECULATIVE, msym, phase); + (rs.deferredAttr).super(AttrMode.SPECULATIVE, msym, phase); } public Type apply(Type t) { @@ -517,6 +518,8 @@ //or if it's not a subtype of the original target, issue an error checkContext.report(pos, diags.fragment("no.suitable.functional.intf.inst", funcInterface)); } + //propagate constraints as per JLS 18.2.1 + checkContext.compatible(owntype, funcInterface, types.noWarnings); return owntype; } }
--- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Thu Sep 04 12:43:12 2014 -0400 @@ -1994,7 +1994,11 @@ // If instance access isn't needed, make it static. // Interface instance methods must be default methods. // Lambda methods are private synthetic. + // Inherit ACC_STRICT from the enclosing method, or, for clinit, + // from the class. translatedSym.flags_field = SYNTHETIC | LAMBDA_METHOD | + owner.flags_field & STRICTFP | + owner.owner.flags_field & STRICTFP | PRIVATE | (thisReferenced? (inInterface? DEFAULT : 0) : STATIC);
--- a/src/share/classes/com/sun/tools/javac/comp/Lower.java Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java Thu Sep 04 12:43:12 2014 -0400 @@ -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"); @@ -2452,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); @@ -2527,6 +2535,7 @@ // Append translated tree to `translated' queue. translated.append(tree); + attrEnv = prevEnv; currentClass = currentClassPrev; currentMethodSym = currentMethodSymPrev; @@ -3472,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); @@ -3506,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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Thu Sep 04 12:43:12 2014 -0400 @@ -96,6 +96,7 @@ public final boolean varargsEnabled; public final boolean allowMethodHandles; public final boolean allowFunctionalInterfaceMostSpecific; + public final boolean checkVarargsAccessAfterResolution; private final boolean debugResolve; private final boolean compactMethodDiags; final EnumSet<VerboseResolutionMode> verboseResolutionMode; @@ -137,6 +138,8 @@ Target target = Target.instance(context); allowMethodHandles = target.hasMethodHandles(); allowFunctionalInterfaceMostSpecific = source.allowFunctionalInterfaceMostSpecific(); + checkVarargsAccessAfterResolution = + source.allowPostApplicabilityVarargsAccessCheck(); polymorphicSignatureScope = new Scope(syms.noSymbol); inapplicableMethodException = new InapplicableMethodException(diags); @@ -348,7 +351,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); } @@ -835,9 +838,15 @@ super.argumentsAcceptable(env, deferredAttrContext, argtypes, formals, warn); //should we expand formals? if (deferredAttrContext.phase.isVarargsRequired()) { - //check varargs element type accessibility - varargsAccessible(env, types.elemtype(formals.last()), - deferredAttrContext.inferenceContext); + Type typeToCheck = null; + if (!checkVarargsAccessAfterResolution) { + typeToCheck = types.elemtype(formals.last()); + } else if (deferredAttrContext.mode == AttrMode.CHECK) { + typeToCheck = types.erasure(types.elemtype(formals.last())); + } + if (typeToCheck != null) { + varargsAccessible(env, typeToCheck, deferredAttrContext.inferenceContext); + } } } @@ -948,9 +957,10 @@ } public boolean compatible(Type found, Type req, Warner warn) { + InferenceContext inferenceContext = deferredAttrContext.inferenceContext; return strict ? - types.isSubtypeUnchecked(found, deferredAttrContext.inferenceContext.asUndetVar(req), warn) : - types.isConvertible(found, deferredAttrContext.inferenceContext.asUndetVar(req), warn); + types.isSubtypeUnchecked(inferenceContext.asUndetVar(found), inferenceContext.asUndetVar(req), warn) : + types.isConvertible(inferenceContext.asUndetVar(found), inferenceContext.asUndetVar(req), warn); } public void report(DiagnosticPosition pos, JCDiagnostic details) { @@ -1011,7 +1021,7 @@ */ private Type U(Type found) { return found == pt ? - found : types.upperBound(found); + found : types.cvarUpperBound(found); } @Override
--- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Thu Sep 04 12:43:12 2014 -0400 @@ -967,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 Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/file/Locations.java Thu Sep 04 12:43:12 2014 -0400 @@ -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/Code.java Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java Thu Sep 04 12:43:12 2014 -0400 @@ -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) { @@ -1946,18 +1953,16 @@ } } - public void closeRange(char end) { - if (isLastRangeInitialized()) { + public void closeRange(char length) { + if (isLastRangeInitialized() && length > 0) { Range range = lastRange(); if (range != null) { if (range.length == Character.MAX_VALUE) { - range.length = end; + range.length = length; } } } 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() { @@ -2019,7 +2022,7 @@ } if (localVar.sym == aliveLocal && localVar.lastRange() != null) { char length = (char)(closingCP - localVar.lastRange().start_pc); - if (length > 0 && length < Character.MAX_VALUE) { + if (length < Character.MAX_VALUE) { localVar.closeRange(length); } } @@ -2090,12 +2093,12 @@ lvar[adr].isLastRangeInitialized()) { LocalVar v = lvar[adr]; char length = (char)(curCP() - v.lastRange().start_pc); - if (length > 0 && length < Character.MAX_VALUE) { + if (length < Character.MAX_VALUE) { lvar[adr] = v.dup(); 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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java Thu Sep 04 12:43:12 2014 -0400 @@ -1194,7 +1194,7 @@ boolean testFirst) { Env<GenContext> loopEnv = env.dup(loop, new GenContext()); int startpc = code.entryPoint(); - if (testFirst) { + if (testFirst) { //while or for loop CondItem c; if (cond != null) { code.statBegin(cond.pos); @@ -1240,6 +1240,9 @@ code.resolve(c.falseJumps); } code.resolve(loopEnv.info.exit); + if (loopEnv.info.exit != null) { + loopEnv.info.exit.state.defined.excludeFrom(code.nextreg); + } } private enum LoopLocalVarRangeEndingPoint { @@ -1811,8 +1814,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) { @@ -2787,7 +2789,7 @@ boolean trackVar(VarSymbol var) { return (var.owner.kind == MTH && - (var.flags() & (PARAMETER | HASINIT)) == 0 && + (var.flags() & PARAMETER) == 0 && analyzer.trackable(var)); }
--- a/src/share/classes/com/sun/tools/javac/main/Option.java Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/main/Option.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Thu Sep 04 12:43:12 2014 -0400 @@ -4068,15 +4068,16 @@ */ 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) { @@ -4090,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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Thu Sep 04 12:43:12 2014 -0400 @@ -2390,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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler_ja.properties Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler_zh_CN.properties Thu Sep 04 12:43:12 2014 -0400 @@ -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/tree/TreeInfo.java Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Thu Sep 04 12:43:12 2014 -0400 @@ -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) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/tools/javac/util/IntHashTable.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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/resources/javadoc_ja.properties Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javadoc/resources/javadoc_ja.properties Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javah/resources/l10n_ja.properties Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javap/AttributeWriter.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/javap/TypeAnnotationWriter.java Thu Sep 04 12:43:12 2014 -0400 @@ -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/jdeps/Analyzer.java Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/jdeps/Analyzer.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 @@ -24,10 +24,8 @@ */ package com.sun.tools.jdeps; -import com.sun.tools.classfile.Dependency.Location; -import com.sun.tools.jdeps.PlatformClassPath.JDKArchive; -import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; @@ -37,6 +35,9 @@ import java.util.TreeMap; import java.util.TreeSet; +import com.sun.tools.classfile.Dependency.Location; +import com.sun.tools.jdeps.PlatformClassPath.JDKArchive; + /** * Dependency Analyzer. */ @@ -52,7 +53,16 @@ VERBOSE }; + /** + * Filter to be applied when analyzing the dependencies from the given archives. + * Only the accepted dependencies are recorded. + */ + interface Filter { + boolean accepts(Location origin, Archive originArchive, Location target, Archive targetArchive); + } + private final Type type; + private final Filter filter; private final Map<Archive, ArchiveDeps> results = new HashMap<>(); private final Map<Location, Archive> map = new HashMap<>(); private final Archive NOT_FOUND @@ -62,9 +72,11 @@ * Constructs an Analyzer instance. * * @param type Type of the dependency analysis + * @param filter */ - public Analyzer(Type type) { + public Analyzer(Type type, Filter filter) { this.type = type; + this.filter = filter; } /** @@ -72,6 +84,18 @@ */ public void run(List<Archive> archives) { // build a map from Location to Archive + buildLocationArchiveMap(archives); + + // traverse and analyze all dependencies + for (Archive archive : archives) { + ArchiveDeps deps = new ArchiveDeps(archive, type); + archive.visitDependences(deps); + results.put(archive, deps); + } + } + + private void buildLocationArchiveMap(List<Archive> archives) { + // build a map from Location to Archive for (Archive archive: archives) { for (Location l: archive.getClasses()) { if (!map.containsKey(l)) { @@ -81,190 +105,236 @@ } } } - // traverse and analyze all dependencies - for (Archive archive : archives) { - ArchiveDeps deps; - if (type == Type.CLASS || type == Type.VERBOSE) { - deps = new ClassVisitor(archive); - } else { - deps = new PackageVisitor(archive); - } - archive.visitDependences(deps); - results.put(archive, deps); - } } public boolean hasDependences(Archive archive) { if (results.containsKey(archive)) { - return results.get(archive).deps.size() > 0; + return results.get(archive).dependencies().size() > 0; } return false; } + public Set<String> dependences(Archive source) { + ArchiveDeps result = results.get(source); + return result.targetDependences(); + } + public interface Visitor { /** - * Visits the source archive to its destination archive of - * a recorded dependency. - */ - void visitArchiveDependence(Archive origin, Archive target, Profile profile); - /** * Visits a recorded dependency from origin to target which can be - * a fully-qualified classname, a package name, a profile or + * a fully-qualified classname, a package name, a module or * archive name depending on the Analyzer's type. */ - void visitDependence(String origin, Archive source, String target, Archive archive, Profile profile); + public void visitDependence(String origin, Archive originArchive, + String target, Archive targetArchive); } - public void visitArchiveDependences(Archive source, Visitor v) { - ArchiveDeps r = results.get(source); - for (ArchiveDeps.Dep d: r.requireArchives()) { - v.visitArchiveDependence(r.archive, d.archive, d.profile); - } - } - - public void visitDependences(Archive source, Visitor v) { - ArchiveDeps r = results.get(source); - for (Map.Entry<String, SortedSet<ArchiveDeps.Dep>> e: r.deps.entrySet()) { - String origin = e.getKey(); - for (ArchiveDeps.Dep d: e.getValue()) { - // filter intra-dependency unless in verbose mode - if (type == Type.VERBOSE || d.archive != source) { - v.visitDependence(origin, source, d.target, d.archive, d.profile); - } + /** + * Visit the dependencies of the given source. + * If the requested level is SUMMARY, it will visit the required archives list. + */ + public void visitDependences(Archive source, Visitor v, Type level) { + if (level == Type.SUMMARY) { + final ArchiveDeps result = results.get(source); + SortedMap<String, Archive> sorted = new TreeMap<>(); + for (Archive a : result.requires()) { + sorted.put(a.getName(), a); + } + for (Archive archive : sorted.values()) { + Profile profile = result.getTargetProfile(archive); + v.visitDependence(source.getName(), source, + profile != null ? profile.profileName() : archive.getName(), archive); + } + } else { + ArchiveDeps result = results.get(source); + if (level != type) { + // requesting different level of analysis + result = new ArchiveDeps(source, level); + source.visitDependences(result); + } + SortedSet<Dep> sorted = new TreeSet<>(result.dependencies()); + for (Dep d : sorted) { + v.visitDependence(d.origin(), d.originArchive(), d.target(), d.targetArchive()); } } } + public void visitDependences(Archive source, Visitor v) { + visitDependences(source, v, type); + } + /** - * ArchiveDeps contains the dependencies for an Archive that - * can have one or more classes. + * ArchiveDeps contains the dependencies for an Archive that can have one or + * more classes. */ - private abstract class ArchiveDeps implements Archive.Visitor { - final Archive archive; - final SortedMap<String, SortedSet<Dep>> deps; - ArchiveDeps(Archive archive) { + class ArchiveDeps implements Archive.Visitor { + protected final Archive archive; + protected final Set<Archive> requires; + protected final Set<Dep> deps; + protected final Type level; + private Profile profile; + ArchiveDeps(Archive archive, Type level) { this.archive = archive; - this.deps = new TreeMap<>(); - } - - void add(String origin, String target, Archive targetArchive, String pkgName) { - SortedSet<Dep> set = deps.get(origin); - if (set == null) { - deps.put(origin, set = new TreeSet<>()); - } - Profile p = targetArchive instanceof JDKArchive - ? Profile.getProfile(pkgName) : null; - set.add(new Dep(target, targetArchive, p)); + this.deps = new HashSet<>(); + this.requires = new HashSet<>(); + this.level = level; } - /** - * Returns the list of Archive dependences. The returned - * list contains one {@code Dep} instance per one archive - * and with the minimum profile this archive depends on. - */ - List<Dep> requireArchives() { - Map<Archive,Profile> map = new HashMap<>(); - for (Set<Dep> set: deps.values()) { - for (Dep d: set) { - if (this.archive != d.archive) { - Profile p = map.get(d.archive); - if (p == null || (d.profile != null && p.profile < d.profile.profile)) { - map.put(d.archive, d.profile); - } - } - } + Set<Dep> dependencies() { + return deps; + } + + Set<String> targetDependences() { + Set<String> targets = new HashSet<>(); + for (Dep d : deps) { + targets.add(d.target()); } - List<Dep> list = new ArrayList<>(); - for (Map.Entry<Archive,Profile> e: map.entrySet()) { - list.add(new Dep("", e.getKey(), e.getValue())); + return targets; + } + + Set<Archive> requires() { + return requires; + } + + Profile getTargetProfile(Archive target) { + return JDKArchive.isProfileArchive(target) ? profile : null; + } + + Archive findArchive(Location t) { + Archive target = archive.getClasses().contains(t) ? archive : map.get(t); + if (target == null) { + map.put(t, target = NOT_FOUND); } - return list; + return target; } - /** - * Dep represents a dependence where the target can be - * a classname or packagename and the archive and profile - * the target belongs to. - */ - class Dep implements Comparable<Dep> { - final String target; - final Archive archive; - final Profile profile; - Dep(String target, Archive archive, Profile p) { - this.target = target; - this.archive = archive; - this.profile = p; + // return classname or package name depedning on the level + private String getLocationName(Location o) { + if (level == Type.CLASS || level == Type.VERBOSE) { + return o.getClassName(); + } else { + String pkg = o.getPackageName(); + return pkg.isEmpty() ? "<unnamed>" : pkg; + } + } + + @Override + public void visit(Location o, Location t) { + Archive targetArchive = findArchive(t); + if (filter.accepts(o, archive, t, targetArchive)) { + addDep(o, t); + if (!requires.contains(targetArchive)) { + requires.add(targetArchive); + } } + if (targetArchive instanceof JDKArchive) { + Profile p = Profile.getProfile(t.getPackageName()); + if (profile == null || (p != null && p.compareTo(profile) > 0)) { + profile = p; + } + } + } - @Override - public boolean equals(Object o) { - if (o instanceof Dep) { - Dep d = (Dep)o; - return this.archive == d.archive && this.target.equals(d.target); - } - return false; + private Dep curDep; + protected Dep addDep(Location o, Location t) { + String origin = getLocationName(o); + String target = getLocationName(t); + Archive targetArchive = findArchive(t); + if (curDep != null && + curDep.origin().equals(origin) && + curDep.originArchive() == archive && + curDep.target().equals(target) && + curDep.targetArchive() == targetArchive) { + return curDep; } - @Override - public int hashCode() { - int hash = 3; - hash = 17 * hash + Objects.hashCode(this.archive); - hash = 17 * hash + Objects.hashCode(this.target); - return hash; - } - - @Override - public int compareTo(Dep o) { - if (this.target.equals(o.target)) { - if (this.archive == o.archive) { - return 0; - } else { - return this.archive.getFileName().compareTo(o.archive.getFileName()); + Dep e = new Dep(origin, archive, target, targetArchive); + if (deps.contains(e)) { + for (Dep e1 : deps) { + if (e.equals(e1)) { + curDep = e1; } } - return this.target.compareTo(o.target); + } else { + deps.add(e); + curDep = e; } - } - public abstract void visit(Location o, Location t); - } - - private class ClassVisitor extends ArchiveDeps { - ClassVisitor(Archive archive) { - super(archive); - } - @Override - public void visit(Location o, Location t) { - Archive targetArchive = - this.archive.getClasses().contains(t) ? this.archive : map.get(t); - if (targetArchive == null) { - map.put(t, targetArchive = NOT_FOUND); - } - - String origin = o.getClassName(); - String target = t.getClassName(); - add(origin, target, targetArchive, t.getPackageName()); + return curDep; } } - private class PackageVisitor extends ArchiveDeps { - PackageVisitor(Archive archive) { - super(archive); + /* + * Class-level or package-level dependency + */ + class Dep implements Comparable<Dep> { + final String origin; + final Archive originArchive; + final String target; + final Archive targetArchive; + + Dep(String origin, Archive originArchive, String target, Archive targetArchive) { + this.origin = origin; + this.originArchive = originArchive; + this.target = target; + this.targetArchive = targetArchive; } + + String origin() { + return origin; + } + + Archive originArchive() { + return originArchive; + } + + String target() { + return target; + } + + Archive targetArchive() { + return targetArchive; + } + @Override - public void visit(Location o, Location t) { - Archive targetArchive = - this.archive.getClasses().contains(t) ? this.archive : map.get(t); - if (targetArchive == null) { - map.put(t, targetArchive = NOT_FOUND); + @SuppressWarnings("unchecked") + public boolean equals(Object o) { + if (o instanceof Dep) { + Dep d = (Dep) o; + return this.origin.equals(d.origin) && + this.originArchive == d.originArchive && + this.target.equals(d.target) && + this.targetArchive == d.targetArchive; } + return false; + } - String origin = packageOf(o); - String target = packageOf(t); - add(origin, target, targetArchive, t.getPackageName()); + @Override + public int hashCode() { + int hash = 7; + hash = 67*hash + Objects.hashCode(this.origin) + + Objects.hashCode(this.originArchive) + + Objects.hashCode(this.target) + + Objects.hashCode(this.targetArchive); + return hash; } - public String packageOf(Location o) { - String pkg = o.getPackageName(); - return pkg.isEmpty() ? "<unnamed>" : pkg; + + @Override + public int compareTo(Dep o) { + if (this.origin.equals(o.origin)) { + if (this.target.equals(o.target)) { + if (this.originArchive == o.originArchive && + this.targetArchive == o.targetArchive) { + return 0; + } else if (this.originArchive == o.originArchive) { + return this.targetArchive.getPathName().compareTo(o.targetArchive.getPathName()); + } else { + return this.originArchive.getPathName().compareTo(o.originArchive.getPathName()); + } + } else { + return this.target.compareTo(o.target); + } + } + return this.origin.compareTo(o.origin); } } }
--- a/src/share/classes/com/sun/tools/jdeps/Archive.java Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/jdeps/Archive.java Thu Sep 04 12:43:12 2014 -0400 @@ -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,28 +25,34 @@ package com.sun.tools.jdeps; import com.sun.tools.classfile.Dependency.Location; + +import java.io.IOException; import java.nio.file.Path; -import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; /** * Represents the source of the class files. */ public class Archive { + public static Archive getInstance(Path p) throws IOException { + return new Archive(p, ClassFileReader.newInstance(p)); + } + private final Path path; private final String filename; private final ClassFileReader reader; - private final Map<Location, Set<Location>> deps = new HashMap<>(); + protected Map<Location, Set<Location>> deps = new ConcurrentHashMap<>(); - public Archive(String name) { + protected Archive(String name) { this.path = null; this.filename = name; this.reader = null; } - public Archive(Path p, ClassFileReader reader) { + protected Archive(Path p, ClassFileReader reader) { this.path = p; this.filename = path.getFileName().toString(); this.reader = reader; @@ -56,7 +62,7 @@ return reader; } - public String getFileName() { + public String getName() { return filename; } @@ -89,6 +95,10 @@ } } + public boolean isEmpty() { + return getClasses().isEmpty(); + } + public String getPathName() { return path != null ? path.toString() : filename; }
--- a/src/share/classes/com/sun/tools/jdeps/ClassFileReader.java Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/jdeps/ClassFileReader.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 @@ -68,7 +68,8 @@ protected final Path path; protected final String baseFileName; - private ClassFileReader(Path path) { + protected final List<String> skippedEntries = new ArrayList<>(); + protected ClassFileReader(Path path) { this.path = path; this.baseFileName = path.getFileName() != null ? path.getFileName().toString() @@ -79,6 +80,10 @@ return baseFileName; } + public List<String> skippedEntries() { + return skippedEntries; + } + /** * Returns the ClassFile matching the given binary name * or a fully-qualified class name. @@ -232,11 +237,12 @@ } } - private static class JarFileReader extends ClassFileReader { - final JarFile jarfile; + static class JarFileReader extends ClassFileReader { + private final JarFile jarfile; JarFileReader(Path path) throws IOException { - this(path, new JarFile(path.toFile())); + this(path, new JarFile(path.toFile(), false)); } + JarFileReader(Path path, JarFile jf) throws IOException { super(path); this.jarfile = jf; @@ -252,18 +258,18 @@ + entryName.substring(i + 1, entryName.length())); } if (e != null) { - return readClassFile(e); + return readClassFile(jarfile, e); } } else { JarEntry e = jarfile.getJarEntry(name + ".class"); if (e != null) { - return readClassFile(e); + return readClassFile(jarfile, e); } } return null; } - private ClassFile readClassFile(JarEntry e) throws IOException { + protected ClassFile readClassFile(JarFile jarfile, JarEntry e) throws IOException { InputStream is = null; try { is = jarfile.getInputStream(e); @@ -277,60 +283,76 @@ } public Iterable<ClassFile> getClassFiles() throws IOException { - final Iterator<ClassFile> iter = new JarFileIterator(); + final Iterator<ClassFile> iter = new JarFileIterator(this, jarfile); return new Iterable<ClassFile>() { public Iterator<ClassFile> iterator() { return iter; } }; } + } - class JarFileIterator implements Iterator<ClassFile> { - private Enumeration<JarEntry> entries; - private JarEntry nextEntry; - JarFileIterator() { - this.entries = jarfile.entries(); - while (entries.hasMoreElements()) { - JarEntry e = entries.nextElement(); - String name = e.getName(); - if (name.endsWith(".class")) { - this.nextEntry = e; - break; - } + class JarFileIterator implements Iterator<ClassFile> { + protected final JarFileReader reader; + protected Enumeration<JarEntry> entries; + protected JarFile jf; + protected JarEntry nextEntry; + protected ClassFile cf; + JarFileIterator(JarFileReader reader) { + this(reader, null); + } + JarFileIterator(JarFileReader reader, JarFile jarfile) { + this.reader = reader; + setJarFile(jarfile); + } + + void setJarFile(JarFile jarfile) { + if (jarfile == null) return; + + this.jf = jarfile; + this.entries = jf.entries(); + this.nextEntry = nextEntry(); + } + + public boolean hasNext() { + if (nextEntry != null && cf != null) { + return true; + } + while (nextEntry != null) { + try { + cf = reader.readClassFile(jf, nextEntry); + return true; + } catch (ClassFileError | IOException ex) { + skippedEntries.add(nextEntry.getName()); + } + nextEntry = nextEntry(); + } + return false; + } + + public ClassFile next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + ClassFile classFile = cf; + cf = null; + nextEntry = nextEntry(); + return classFile; + } + + protected JarEntry nextEntry() { + while (entries.hasMoreElements()) { + JarEntry e = entries.nextElement(); + String name = e.getName(); + if (name.endsWith(".class")) { + return e; } } - - public boolean hasNext() { - return nextEntry != null; - } - - public ClassFile next() { - if (!hasNext()) { - throw new NoSuchElementException(); - } + return null; + } - ClassFile cf; - try { - cf = readClassFile(nextEntry); - } catch (IOException ex) { - throw new ClassFileError(ex); - } - JarEntry entry = nextEntry; - nextEntry = null; - while (entries.hasMoreElements()) { - JarEntry e = entries.nextElement(); - String name = e.getName(); - if (name.endsWith(".class")) { - nextEntry = e; - break; - } - } - return cf; - } - - public void remove() { - throw new UnsupportedOperationException("Not supported yet."); - } + public void remove() { + throw new UnsupportedOperationException("Not supported yet."); } } }
--- a/src/share/classes/com/sun/tools/jdeps/JdepsTask.java Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/jdeps/JdepsTask.java Thu Sep 04 12:43:12 2014 -0400 @@ -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,9 @@ import com.sun.tools.classfile.Dependencies; import com.sun.tools.classfile.Dependencies.ClassFileError; import com.sun.tools.classfile.Dependency; +import com.sun.tools.classfile.Dependency.Location; import com.sun.tools.jdeps.PlatformClassPath.JDKArchive; +import static com.sun.tools.jdeps.Analyzer.Type.*; import java.io.*; import java.nio.file.DirectoryStream; import java.nio.file.Files; @@ -110,7 +112,7 @@ void process(JdepsTask task, String opt, String arg) throws BadArgs { Path p = Paths.get(arg); if (Files.exists(p) && (!Files.isDirectory(p) || !Files.isWritable(p))) { - throw new BadArgs("err.dot.output.path", arg); + throw new BadArgs("err.invalid.path", arg); } task.options.dotOutputDir = arg; } @@ -118,25 +120,26 @@ new Option(false, "-s", "-summary") { void process(JdepsTask task, String opt, String arg) { task.options.showSummary = true; - task.options.verbose = Analyzer.Type.SUMMARY; + task.options.verbose = SUMMARY; } }, new Option(false, "-v", "-verbose", "-verbose:package", - "-verbose:class") - { + "-verbose:class") { void process(JdepsTask task, String opt, String arg) throws BadArgs { switch (opt) { case "-v": case "-verbose": - task.options.verbose = Analyzer.Type.VERBOSE; + task.options.verbose = VERBOSE; + task.options.filterSameArchive = false; + task.options.filterSamePackage = false; break; case "-verbose:package": - task.options.verbose = Analyzer.Type.PACKAGE; - break; + task.options.verbose = PACKAGE; + break; case "-verbose:class": - task.options.verbose = Analyzer.Type.CLASS; - break; + task.options.verbose = CLASS; + break; default: throw new BadArgs("err.invalid.arg.for.option", opt); } @@ -157,6 +160,32 @@ task.options.regex = arg; } }, + + new Option(true, "-f", "-filter") { + void process(JdepsTask task, String opt, String arg) { + task.options.filterRegex = arg; + } + }, + new Option(false, "-filter:package", + "-filter:archive", + "-filter:none") { + void process(JdepsTask task, String opt, String arg) { + switch (opt) { + case "-filter:package": + task.options.filterSamePackage = true; + task.options.filterSameArchive = false; + break; + case "-filter:archive": + task.options.filterSameArchive = true; + task.options.filterSamePackage = false; + break; + case "-filter:none": + task.options.filterSameArchive = false; + task.options.filterSamePackage = false; + break; + } + } + }, new Option(true, "-include") { void process(JdepsTask task, String opt, String arg) throws BadArgs { task.options.includePattern = Pattern.compile(arg); @@ -178,12 +207,15 @@ new Option(false, "-R", "-recursive") { void process(JdepsTask task, String opt, String arg) { task.options.depth = 0; + // turn off filtering + task.options.filterSameArchive = false; + task.options.filterSamePackage = false; } }, new Option(false, "-jdkinternals") { void process(JdepsTask task, String opt, String arg) { task.options.findJDKInternals = true; - task.options.verbose = Analyzer.Type.CLASS; + task.options.verbose = CLASS; if (task.options.includePattern == null) { task.options.includePattern = Pattern.compile(".*"); } @@ -204,6 +236,11 @@ task.options.showLabel = true; } }, + new HiddenOption(false, "-q", "-quiet") { + void process(JdepsTask task, String opt, String arg) { + task.options.nowarning = true; + } + }, new HiddenOption(true, "-depth") { void process(JdepsTask task, String opt, String arg) throws BadArgs { try { @@ -217,7 +254,7 @@ private static final String PROGNAME = "jdeps"; private final Options options = new Options(); - private final List<String> classes = new ArrayList<String>(); + private final List<String> classes = new ArrayList<>(); private PrintWriter log; void setLog(PrintWriter out) { @@ -262,7 +299,7 @@ showHelp(); return EXIT_CMDERR; } - if (options.showSummary && options.verbose != Analyzer.Type.SUMMARY) { + if (options.showSummary && options.verbose != SUMMARY) { showHelp(); return EXIT_CMDERR; } @@ -283,9 +320,30 @@ private final List<Archive> sourceLocations = new ArrayList<>(); private boolean run() throws IOException { + // parse classfiles and find all dependencies findDependencies(); - Analyzer analyzer = new Analyzer(options.verbose); + + Analyzer analyzer = new Analyzer(options.verbose, new Analyzer.Filter() { + @Override + public boolean accepts(Location origin, Archive originArchive, + Location target, Archive targetArchive) + { + if (options.findJDKInternals) { + // accepts target that is JDK class but not exported + return isJDKArchive(targetArchive) && + !((JDKArchive) targetArchive).isExported(target.getClassName()); + } else if (options.filterSameArchive) { + // accepts origin and target that from different archive + return originArchive != targetArchive; + } + return true; + } + }); + + // analyze the dependencies analyzer.run(sourceLocations); + + // output result if (options.dotOutputDir != null) { Path dir = Paths.get(options.dotOutputDir); Files.createDirectories(dir); @@ -293,30 +351,41 @@ } else { printRawOutput(log, analyzer); } + + if (options.findJDKInternals && !options.nowarning) { + showReplacements(analyzer); + } return true; } + private void generateSummaryDotFile(Path dir, Analyzer analyzer) throws IOException { + // If verbose mode (-v or -verbose option), + // the summary.dot file shows package-level dependencies. + Analyzer.Type summaryType = + (options.verbose == PACKAGE || options.verbose == SUMMARY) ? SUMMARY : PACKAGE; + Path summary = dir.resolve("summary.dot"); + try (PrintWriter sw = new PrintWriter(Files.newOutputStream(summary)); + SummaryDotFile dotfile = new SummaryDotFile(sw, summaryType)) { + for (Archive archive : sourceLocations) { + if (!archive.isEmpty()) { + if (options.verbose == PACKAGE || options.verbose == SUMMARY) { + if (options.showLabel) { + // build labels listing package-level dependencies + analyzer.visitDependences(archive, dotfile.labelBuilder(), PACKAGE); + } + } + analyzer.visitDependences(archive, dotfile, summaryType); + } + } + } + } + private void generateDotFiles(Path dir, Analyzer analyzer) throws IOException { - Path summary = dir.resolve("summary.dot"); - boolean verbose = options.verbose == Analyzer.Type.VERBOSE; - DotGraph<?> graph = verbose ? new DotSummaryForPackage() - : new DotSummaryForArchive(); - for (Archive archive : sourceLocations) { - analyzer.visitArchiveDependences(archive, graph); - if (verbose || options.showLabel) { - // traverse detailed dependences to generate package-level - // summary or build labels for edges - analyzer.visitDependences(archive, graph); - } - } - try (PrintWriter sw = new PrintWriter(Files.newOutputStream(summary))) { - graph.writeTo(sw); - } // output individual .dot file for each archive - if (options.verbose != Analyzer.Type.SUMMARY) { + if (options.verbose != SUMMARY) { for (Archive archive : sourceLocations) { if (analyzer.hasDependences(archive)) { - Path dotfile = dir.resolve(archive.getFileName() + ".dot"); + Path dotfile = dir.resolve(archive.getName() + ".dot"); try (PrintWriter pw = new PrintWriter(Files.newOutputStream(dotfile)); DotFileFormatter formatter = new DotFileFormatter(pw, archive)) { analyzer.visitDependences(archive, formatter); @@ -324,17 +393,23 @@ } } } + // generate summary dot file + generateSummaryDotFile(dir, analyzer); } private void printRawOutput(PrintWriter writer, Analyzer analyzer) { + RawOutputFormatter depFormatter = new RawOutputFormatter(writer); + RawSummaryFormatter summaryFormatter = new RawSummaryFormatter(writer); for (Archive archive : sourceLocations) { - RawOutputFormatter formatter = new RawOutputFormatter(writer); - analyzer.visitArchiveDependences(archive, formatter); - if (options.verbose != Analyzer.Type.SUMMARY) { - analyzer.visitDependences(archive, formatter); + if (!archive.isEmpty()) { + analyzer.visitDependences(archive, summaryFormatter, SUMMARY); + if (analyzer.hasDependences(archive) && options.verbose != SUMMARY) { + analyzer.visitDependences(archive, depFormatter); + } } } } + private boolean isValidClassName(String name) { if (!Character.isJavaIdentifierStart(name.charAt(0))) { return false; @@ -348,21 +423,54 @@ return true; } - private Dependency.Filter getDependencyFilter() { - if (options.regex != null) { - return Dependencies.getRegexFilter(Pattern.compile(options.regex)); - } else if (options.packageNames.size() > 0) { - return Dependencies.getPackageFilter(options.packageNames, false); - } else { - return new Dependency.Filter() { - @Override - public boolean accepts(Dependency dependency) { - return !dependency.getOrigin().equals(dependency.getTarget()); - } - }; + /* + * Dep Filter configured based on the input jdeps option + * 1. -p and -regex to match target dependencies + * 2. -filter:package to filter out same-package dependencies + * + * This filter is applied when jdeps parses the class files + * and filtered dependencies are not stored in the Analyzer. + * + * -filter:archive is applied later in the Analyzer as the + * containing archive of a target class may not be known until + * the entire archive + */ + class DependencyFilter implements Dependency.Filter { + final Dependency.Filter filter; + final Pattern filterPattern; + DependencyFilter() { + if (options.regex != null) { + this.filter = Dependencies.getRegexFilter(Pattern.compile(options.regex)); + } else if (options.packageNames.size() > 0) { + this.filter = Dependencies.getPackageFilter(options.packageNames, false); + } else { + this.filter = null; + } + + this.filterPattern = + options.filterRegex != null ? Pattern.compile(options.filterRegex) : null; + } + @Override + public boolean accepts(Dependency d) { + if (d.getOrigin().equals(d.getTarget())) { + return false; + } + String pn = d.getTarget().getPackageName(); + if (options.filterSamePackage && d.getOrigin().getPackageName().equals(pn)) { + return false; + } + + if (filterPattern != null && filterPattern.matcher(pn).matches()) { + return false; + } + return filter != null ? filter.accepts(d) : true; } } + /** + * Tests if the given class matches the pattern given in the -include option + * or if it's a public class if -apionly option is specified + */ private boolean matches(String classname, AccessFlags flags) { if (options.apiOnly && !flags.is(AccessFlags.ACC_PUBLIC)) { return false; @@ -377,14 +485,14 @@ Dependency.Finder finder = options.apiOnly ? Dependencies.getAPIFinder(AccessFlags.ACC_PROTECTED) : Dependencies.getClassDependencyFinder(); - Dependency.Filter filter = getDependencyFilter(); + Dependency.Filter filter = new DependencyFilter(); List<Archive> archives = new ArrayList<>(); Deque<String> roots = new LinkedList<>(); for (String s : classes) { Path p = Paths.get(s); if (Files.exists(p)) { - archives.add(new Archive(p, ClassFileReader.newInstance(p))); + archives.add(Archive.getInstance(p)); } else { if (isValidClassName(s)) { roots.add(s); @@ -421,19 +529,26 @@ throw new ClassFileError(e); } - if (matches(classFileName, cf.access_flags)) { - if (!doneClasses.contains(classFileName)) { - doneClasses.add(classFileName); + // tests if this class matches the -include or -apiOnly option if specified + if (!matches(classFileName, cf.access_flags)) { + continue; + } + + if (!doneClasses.contains(classFileName)) { + doneClasses.add(classFileName); + } + + for (Dependency d : finder.findDependencies(cf)) { + if (filter.accepts(d)) { + String cn = d.getTarget().getName(); + if (!doneClasses.contains(cn) && !deque.contains(cn)) { + deque.add(cn); + } + a.addClass(d.getOrigin(), d.getTarget()); } - for (Dependency d : finder.findDependencies(cf)) { - if (filter.accepts(d)) { - String cn = d.getTarget().getName(); - if (!doneClasses.contains(cn) && !deque.contains(cn)) { - deque.add(cn); - } - a.addClass(d.getOrigin(), d.getTarget()); - } - } + } + for (String name : a.reader().skippedEntries()) { + warning("warn.skipped.entry", name, a.getPathName()); } } } @@ -462,6 +577,10 @@ // if name is a fully-qualified class name specified // from command-line, this class might already be parsed doneClasses.add(classFileName); + // process @jdk.Exported for JDK classes + if (isJDKArchive(a)) { + ((JDKArchive)a).processJdkExported(cf); + } for (Dependency d : finder.findDependencies(cf)) { if (depth == 0) { // ignore the dependency @@ -544,7 +663,7 @@ for (Option o : recognizedOptions) { String name = o.aliases[0].substring(1); // there must always be at least one name name = name.charAt(0) == '-' ? name.substring(1) : name; - if (o.isHidden() || name.equals("h")) { + if (o.isHidden() || name.equals("h") || name.startsWith("filter:")) { continue; } log.println(getMessage("main.opt." + name)); @@ -582,14 +701,19 @@ boolean fullVersion; boolean showProfile; boolean showSummary; - boolean wildcard; boolean apiOnly; boolean showLabel; boolean findJDKInternals; + boolean nowarning; + // default is to show package-level dependencies + // and filter references from same package + Analyzer.Type verbose = PACKAGE; + boolean filterSamePackage = true; + boolean filterSameArchive = false; + String filterRegex; String dotOutputDir; String classpath = ""; int depth = 1; - Analyzer.Type verbose = Analyzer.Type.PACKAGE; Set<String> packageNames = new HashSet<>(); String regex; // apply to the dependences Pattern includePattern; // apply to classes @@ -597,6 +721,7 @@ private static class ResourceBundleHelper { static final ResourceBundle versionRB; static final ResourceBundle bundle; + static final ResourceBundle jdkinternals; static { Locale locale = Locale.getDefault(); @@ -610,20 +735,12 @@ } catch (MissingResourceException e) { throw new InternalError("version.resource.missing"); } - } - } - - private List<Archive> getArchives(List<String> filenames) throws IOException { - List<Archive> result = new ArrayList<Archive>(); - for (String s : filenames) { - Path p = Paths.get(s); - if (Files.exists(p)) { - result.add(new Archive(p, ClassFileReader.newInstance(p))); - } else { - warning("warn.file.not.exist", s); + try { + jdkinternals = ResourceBundle.getBundle("com.sun.tools.jdeps.resources.jdkinternals"); + } catch (MissingResourceException e) { + throw new InternalError("Cannot find jdkinternals resource bundle"); } } - return result; } private List<Archive> getClassPathArchives(String paths) throws IOException { @@ -648,7 +765,7 @@ } for (Path f : files) { if (Files.exists(f)) { - result.add(new Archive(f, ClassFileReader.newInstance(f))); + result.add(Archive.getInstance(f)); } } } @@ -656,81 +773,50 @@ return result; } - /** - * If the given archive is JDK archive and non-null Profile, - * this method returns the profile name only if -profile option is specified; - * a null profile indicates it accesses a private JDK API and this method - * will return "JDK internal API". - * - * For non-JDK archives, this method returns the file name of the archive. - */ - private String getProfileArchiveInfo(Archive source, Profile profile) { - if (options.showProfile && profile != null) - return profile.toString(); - - if (source instanceof JDKArchive) { - return profile == null ? "JDK internal API (" + source.getFileName() + ")" : ""; - } - return source.getFileName(); - } - - /** - * Returns the profile name or "JDK internal API" for JDK archive; - * otherwise empty string. - */ - private String profileName(Archive archive, Profile profile) { - if (archive instanceof JDKArchive) { - return Objects.toString(profile, "JDK internal API"); - } else { - return ""; - } - } - class RawOutputFormatter implements Analyzer.Visitor { private final PrintWriter writer; + private String pkg = ""; RawOutputFormatter(PrintWriter writer) { this.writer = writer; } - - private String pkg = ""; @Override - public void visitDependence(String origin, Archive source, - String target, Archive archive, Profile profile) { - if (options.findJDKInternals && - !(archive instanceof JDKArchive && profile == null)) { - // filter dependences other than JDK internal APIs - return; - } - if (options.verbose == Analyzer.Type.VERBOSE) { - writer.format(" %-50s -> %-50s %s%n", - origin, target, getProfileArchiveInfo(archive, profile)); + public void visitDependence(String origin, Archive originArchive, + String target, Archive targetArchive) { + String tag = toTag(target, targetArchive); + if (options.verbose == VERBOSE) { + writer.format(" %-50s -> %-50s %s%n", origin, target, tag); } else { if (!origin.equals(pkg)) { pkg = origin; - writer.format(" %s (%s)%n", origin, source.getFileName()); + writer.format(" %s (%s)%n", origin, originArchive.getName()); } - writer.format(" -> %-50s %s%n", - target, getProfileArchiveInfo(archive, profile)); - } - } - - @Override - public void visitArchiveDependence(Archive origin, Archive target, Profile profile) { - writer.format("%s -> %s", origin.getPathName(), target.getPathName()); - if (options.showProfile && profile != null) { - writer.format(" (%s)%n", profile); - } else { - writer.format("%n"); + writer.format(" -> %-50s %s%n", target, tag); } } } - class DotFileFormatter extends DotGraph<String> implements AutoCloseable { + class RawSummaryFormatter implements Analyzer.Visitor { + private final PrintWriter writer; + RawSummaryFormatter(PrintWriter writer) { + this.writer = writer; + } + @Override + public void visitDependence(String origin, Archive originArchive, + String target, Archive targetArchive) { + writer.format("%s -> %s", originArchive.getName(), targetArchive.getPathName()); + if (options.showProfile && JDKArchive.isProfileArchive(targetArchive)) { + writer.format(" (%s)", target); + } + writer.format("%n"); + } + } + + class DotFileFormatter implements Analyzer.Visitor, AutoCloseable { private final PrintWriter writer; private final String name; DotFileFormatter(PrintWriter writer, Archive archive) { this.writer = writer; - this.name = archive.getFileName(); + this.name = archive.getName(); writer.format("digraph \"%s\" {%n", name); writer.format(" // Path: %s%n", archive.getPathName()); } @@ -741,173 +827,176 @@ } @Override - public void visitDependence(String origin, Archive source, - String target, Archive archive, Profile profile) { - if (options.findJDKInternals && - !(archive instanceof JDKArchive && profile == null)) { - // filter dependences other than JDK internal APIs - return; - } - // if -P option is specified, package name -> profile will - // be shown and filter out multiple same edges. - String name = getProfileArchiveInfo(archive, profile); - writeEdge(writer, new Edge(origin, target, getProfileArchiveInfo(archive, profile))); - } - @Override - public void visitArchiveDependence(Archive origin, Archive target, Profile profile) { - throw new UnsupportedOperationException(); + public void visitDependence(String origin, Archive originArchive, + String target, Archive targetArchive) { + String tag = toTag(target, targetArchive); + writer.format(" %-50s -> \"%s\";%n", + String.format("\"%s\"", origin), + tag.isEmpty() ? target + : String.format("%s (%s)", target, tag)); } } - class DotSummaryForArchive extends DotGraph<Archive> { + class SummaryDotFile implements Analyzer.Visitor, AutoCloseable { + private final PrintWriter writer; + private final Analyzer.Type type; + private final Map<Archive, Map<Archive,StringBuilder>> edges = new HashMap<>(); + SummaryDotFile(PrintWriter writer, Analyzer.Type type) { + this.writer = writer; + this.type = type; + writer.format("digraph \"summary\" {%n"); + } + @Override - public void visitDependence(String origin, Archive source, - String target, Archive archive, Profile profile) { - Edge e = findEdge(source, archive); - assert e != null; - // add the dependency to the label if enabled and not compact1 - if (profile == Profile.COMPACT1) { - return; - } - e.addLabel(origin, target, profileName(archive, profile)); + public void close() { + writer.println("}"); } + @Override - public void visitArchiveDependence(Archive origin, Archive target, Profile profile) { - // add an edge with the archive's name with no tag - // so that there is only one node for each JDK archive - // while there may be edges to different profiles - Edge e = addEdge(origin, target, ""); - if (target instanceof JDKArchive) { - // add a label to print the profile - if (profile == null) { - e.addLabel("JDK internal API"); - } else if (options.showProfile && !options.showLabel) { - e.addLabel(profile.toString()); + public void visitDependence(String origin, Archive originArchive, + String target, Archive targetArchive) { + String targetName = type == PACKAGE ? target : targetArchive.getName(); + if (type == PACKAGE) { + String tag = toTag(target, targetArchive, type); + if (!tag.isEmpty()) + targetName += " (" + tag + ")"; + } else if (options.showProfile && JDKArchive.isProfileArchive(targetArchive)) { + targetName += " (" + target + ")"; + } + String label = getLabel(originArchive, targetArchive); + writer.format(" %-50s -> \"%s\"%s;%n", + String.format("\"%s\"", origin), targetName, label); + } + + String getLabel(Archive origin, Archive target) { + if (edges.isEmpty()) + return ""; + + StringBuilder label = edges.get(origin).get(target); + return label == null ? "" : String.format(" [label=\"%s\",fontsize=9]", label.toString()); + } + + Analyzer.Visitor labelBuilder() { + // show the package-level dependencies as labels in the dot graph + return new Analyzer.Visitor() { + @Override + public void visitDependence(String origin, Archive originArchive, + String target, Archive targetArchive) + { + Map<Archive,StringBuilder> labels = edges.get(originArchive); + if (!edges.containsKey(originArchive)) { + edges.put(originArchive, labels = new HashMap<>()); + } + StringBuilder sb = labels.get(targetArchive); + if (sb == null) { + labels.put(targetArchive, sb = new StringBuilder()); + } + String tag = toTag(target, targetArchive, PACKAGE); + addLabel(sb, origin, target, tag); } - } + + void addLabel(StringBuilder label, String origin, String target, String tag) { + label.append(origin).append(" -> ").append(target); + if (!tag.isEmpty()) { + label.append(" (" + tag + ")"); + } + label.append("\\n"); + } + }; } } - // DotSummaryForPackage generates the summary.dot file for verbose mode - // (-v or -verbose option) that includes all class dependencies. - // The summary.dot file shows package-level dependencies. - class DotSummaryForPackage extends DotGraph<String> { - private String packageOf(String cn) { - int i = cn.lastIndexOf('.'); - return i > 0 ? cn.substring(0, i) : "<unnamed>"; - } - @Override - public void visitDependence(String origin, Archive source, - String target, Archive archive, Profile profile) { - // add a package dependency edge - String from = packageOf(origin); - String to = packageOf(target); - Edge e = addEdge(from, to, getProfileArchiveInfo(archive, profile)); - - // add the dependency to the label if enabled and not compact1 - if (!options.showLabel || profile == Profile.COMPACT1) { - return; - } + /** + * Test if the given archive is part of the JDK + */ + private boolean isJDKArchive(Archive archive) { + return JDKArchive.class.isInstance(archive); + } - // trim the package name of origin to shorten the label - int i = origin.lastIndexOf('.'); - String n1 = i < 0 ? origin : origin.substring(i+1); - e.addLabel(n1, target, profileName(archive, profile)); - } - @Override - public void visitArchiveDependence(Archive origin, Archive target, Profile profile) { - // nop - } - } - abstract class DotGraph<T> implements Analyzer.Visitor { - private final Set<Edge> edges = new LinkedHashSet<>(); - private Edge curEdge; - public void writeTo(PrintWriter writer) { - writer.format("digraph \"summary\" {%n"); - for (Edge e: edges) { - writeEdge(writer, e); - } - writer.println("}"); - } - - void writeEdge(PrintWriter writer, Edge e) { - writer.format(" %-50s -> \"%s\"%s;%n", - String.format("\"%s\"", e.from.toString()), - e.tag.isEmpty() ? e.to - : String.format("%s (%s)", e.to, e.tag), - getLabel(e)); + /** + * If the given archive is JDK archive, this method returns the profile name + * only if -profile option is specified; it accesses a private JDK API and + * the returned value will have "JDK internal API" prefix + * + * For non-JDK archives, this method returns the file name of the archive. + */ + private String toTag(String name, Archive source, Analyzer.Type type) { + if (!isJDKArchive(source)) { + return source.getName(); } - Edge addEdge(T origin, T target, String tag) { - Edge e = new Edge(origin, target, tag); - if (e.equals(curEdge)) { - return curEdge; - } + JDKArchive jdk = (JDKArchive)source; + boolean isExported = false; + if (type == CLASS || type == VERBOSE) { + isExported = jdk.isExported(name); + } else { + isExported = jdk.isExportedPackage(name); + } + Profile p = getProfile(name, type); + if (isExported) { + // exported API + return options.showProfile && p != null ? p.profileName() : ""; + } else { + return "JDK internal API (" + source.getName() + ")"; + } + } + + private String toTag(String name, Archive source) { + return toTag(name, source, options.verbose); + } + + private Profile getProfile(String name, Analyzer.Type type) { + String pn = name; + if (type == CLASS || type == VERBOSE) { + int i = name.lastIndexOf('.'); + pn = i > 0 ? name.substring(0, i) : ""; + } + return Profile.getProfile(pn); + } - if (edges.contains(e)) { - for (Edge e1 : edges) { - if (e.equals(e1)) { - curEdge = e1; - } - } - } else { - edges.add(e); - curEdge = e; + /** + * Returns the recommended replacement API for the given classname; + * or return null if replacement API is not known. + */ + private String replacementFor(String cn) { + String name = cn; + String value = null; + while (value == null && name != null) { + try { + value = ResourceBundleHelper.jdkinternals.getString(name); + } catch (MissingResourceException e) { + // go up one subpackage level + int i = name.lastIndexOf('.'); + name = i > 0 ? name.substring(0, i) : null; } - return curEdge; } + return value; + }; - Edge findEdge(T origin, T target) { - for (Edge e : edges) { - if (e.from.equals(origin) && e.to.equals(target)) { - return e; + private void showReplacements(Analyzer analyzer) { + Map<String,String> jdkinternals = new TreeMap<>(); + boolean useInternals = false; + for (Archive source : sourceLocations) { + useInternals = useInternals || analyzer.hasDependences(source); + for (String cn : analyzer.dependences(source)) { + String repl = replacementFor(cn); + if (repl != null && !jdkinternals.containsKey(cn)) { + jdkinternals.put(cn, repl); } } - return null; + } + if (useInternals) { + log.println(); + warning("warn.replace.useJDKInternals", getMessage("jdeps.wiki.url")); } - - String getLabel(Edge e) { - String label = e.label.toString(); - return label.isEmpty() ? "" : String.format("[label=\"%s\",fontsize=9]", label); + if (!jdkinternals.isEmpty()) { + log.println(); + log.format("%-40s %s%n", "JDK Internal API", "Suggested Replacement"); + log.format("%-40s %s%n", "----------------", "---------------------"); + for (Map.Entry<String,String> e : jdkinternals.entrySet()) { + log.format("%-40s %s%n", e.getKey(), e.getValue()); + } } - class Edge { - final T from; - final T to; - final String tag; // optional tag - final StringBuilder label = new StringBuilder(); - Edge(T from, T to, String tag) { - this.from = from; - this.to = to; - this.tag = tag; - } - void addLabel(String s) { - label.append(s).append("\\n"); - } - void addLabel(String origin, String target, String profile) { - label.append(origin).append(" -> ").append(target); - if (!profile.isEmpty()) { - label.append(" (" + profile + ")"); - } - label.append("\\n"); - } - @Override @SuppressWarnings("unchecked") - public boolean equals(Object o) { - if (o instanceof DotGraph<?>.Edge) { - DotGraph<?>.Edge e = (DotGraph<?>.Edge)o; - return this.from.equals(e.from) && - this.to.equals(e.to) && - this.tag.equals(e.tag); - } - return false; - } - @Override - public int hashCode() { - int hash = 7; - hash = 67 * hash + Objects.hashCode(this.from) + - Objects.hashCode(this.to) + Objects.hashCode(this.tag); - return hash; - } - } } }
--- a/src/share/classes/com/sun/tools/jdeps/Main.java Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/jdeps/Main.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 @@ -63,4 +63,3 @@ return t.run(args); } } -
--- a/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 @@ -24,6 +24,12 @@ */ package com.sun.tools.jdeps; +import com.sun.tools.classfile.Annotation; +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.ConstantPool; +import com.sun.tools.classfile.ConstantPoolException; +import com.sun.tools.classfile.RuntimeAnnotations_attribute; +import com.sun.tools.classfile.Dependencies.ClassFileError; import java.io.IOException; import java.nio.file.FileVisitResult; import java.nio.file.Files; @@ -33,11 +39,15 @@ import java.nio.file.attribute.BasicFileAttributes; import java.util.*; +import static com.sun.tools.classfile.Attribute.*; + /** * ClassPath for Java SE and JDK */ class PlatformClassPath { - private final static List<Archive> javaHomeArchives = init(); + private static final List<String> NON_PLATFORM_JARFILES = + Arrays.asList("alt-rt.jar", "jfxrt.jar", "ant-javafx.jar", "javafx-mx.jar"); + private static final List<Archive> javaHomeArchives = init(); static List<Archive> getArchives() { return javaHomeArchives; @@ -50,12 +60,19 @@ if (home.endsWith("jre")) { // jar files in <javahome>/jre/lib result.addAll(addJarFiles(home.resolve("lib"))); + if (home.getParent() != null) { + // add tools.jar and other JDK jar files + Path lib = home.getParent().resolve("lib"); + if (Files.exists(lib)) { + result.addAll(addJarFiles(lib)); + } + } } else if (Files.exists(home.resolve("lib"))) { // either a JRE or a jdk build image Path classes = home.resolve("classes"); if (Files.isDirectory(classes)) { // jdk build outputdir - result.add(new JDKArchive(classes, ClassFileReader.newInstance(classes))); + result.add(new JDKArchive(classes)); } // add other JAR files result.addAll(addJarFiles(home.resolve("lib"))); @@ -91,9 +108,9 @@ if (fn.endsWith(".jar")) { // JDK may cobundle with JavaFX that doesn't belong to any profile // Treat jfxrt.jar as regular Archive - result.add(fn.equals("jfxrt.jar") - ? new Archive(p, ClassFileReader.newInstance(p)) - : new JDKArchive(p, ClassFileReader.newInstance(p))); + result.add(NON_PLATFORM_JARFILES.contains(fn) + ? Archive.getInstance(p) + : new JDKArchive(p)); } return FileVisitResult.CONTINUE; } @@ -106,8 +123,91 @@ * or implementation classes (i.e. JDK internal API) */ static class JDKArchive extends Archive { - JDKArchive(Path p, ClassFileReader reader) { - super(p, reader); + private static List<String> PROFILE_JARS = Arrays.asList("rt.jar", "jce.jar"); + public static boolean isProfileArchive(Archive archive) { + if (archive instanceof JDKArchive) { + return PROFILE_JARS.contains(archive.getName()); + } + return false; + } + + private final Map<String,Boolean> exportedPackages = new HashMap<>(); + private final Map<String,Boolean> exportedTypes = new HashMap<>(); + JDKArchive(Path p) throws IOException { + super(p, ClassFileReader.newInstance(p)); + } + + /** + * Tests if a given fully-qualified name is an exported type. + */ + public boolean isExported(String cn) { + int i = cn.lastIndexOf('.'); + String pn = i > 0 ? cn.substring(0, i) : ""; + + boolean isJdkExported = isExportedPackage(pn); + if (exportedTypes.containsKey(cn)) { + return exportedTypes.get(cn); + } + return isJdkExported; + } + + /** + * Tests if a given package name is exported. + */ + public boolean isExportedPackage(String pn) { + if (Profile.getProfile(pn) != null) { + return true; + } + return exportedPackages.containsKey(pn) ? exportedPackages.get(pn) : false; + } + + private static final String JDK_EXPORTED_ANNOTATION = "Ljdk/Exported;"; + private Boolean isJdkExported(ClassFile cf) throws ConstantPoolException { + RuntimeAnnotations_attribute attr = (RuntimeAnnotations_attribute) + cf.attributes.get(RuntimeVisibleAnnotations); + if (attr != null) { + for (int i = 0; i < attr.annotations.length; i++) { + Annotation ann = attr.annotations[i]; + String annType = cf.constant_pool.getUTF8Value(ann.type_index); + if (JDK_EXPORTED_ANNOTATION.equals(annType)) { + boolean isJdkExported = true; + for (int j = 0; j < ann.num_element_value_pairs; j++) { + Annotation.element_value_pair pair = ann.element_value_pairs[j]; + Annotation.Primitive_element_value ev = (Annotation.Primitive_element_value) pair.value; + ConstantPool.CONSTANT_Integer_info info = (ConstantPool.CONSTANT_Integer_info) + cf.constant_pool.get(ev.const_value_index); + isJdkExported = info.value != 0; + } + return Boolean.valueOf(isJdkExported); + } + } + } + return null; + } + + void processJdkExported(ClassFile cf) throws IOException { + try { + String cn = cf.getName(); + String pn = cn.substring(0, cn.lastIndexOf('/')).replace('/', '.'); + + Boolean b = isJdkExported(cf); + if (b != null) { + exportedTypes.put(cn.replace('/', '.'), b); + } + if (!exportedPackages.containsKey(pn)) { + // check if package-info.class has @jdk.Exported + Boolean isJdkExported = null; + ClassFile pcf = reader().getClassFile(cn.substring(0, cn.lastIndexOf('/')+1) + "package-info"); + if (pcf != null) { + isJdkExported = isJdkExported(pcf); + } + if (isJdkExported != null) { + exportedPackages.put(pn, isJdkExported); + } + } + } catch (ConstantPoolException e) { + throw new ClassFileError(e); + } } } }
--- a/src/share/classes/com/sun/tools/jdeps/Profile.java Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/jdeps/Profile.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 @@ -43,7 +43,6 @@ * Build the profile information from ct.sym if exists. */ enum Profile { - COMPACT1("compact1", 1), COMPACT2("compact2", 2), COMPACT3("compact3", 3), @@ -61,8 +60,7 @@ this.proprietaryPkgs = new HashSet<>(); } - @Override - public String toString() { + public String profileName() { return name; } @@ -77,7 +75,7 @@ public static Profile getProfile(String pn) { Profile profile = PackageToProfile.map.get(pn); return (profile != null && profile.packages.contains(pn)) - ? profile : null; + ? profile : null; } static class PackageToProfile {
--- a/src/share/classes/com/sun/tools/jdeps/resources/jdeps.properties Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/jdeps/resources/jdeps.properties Thu Sep 04 12:43:12 2014 -0400 @@ -1,6 +1,6 @@ main.usage.summary=\ Usage: {0} <options> <classes...>\n\ -use -h, -? or --help for a list of possible options +use -h, -? or -help for a list of possible options main.usage=\ Usage: {0} <options> <classes...>\n\ @@ -18,20 +18,29 @@ main.opt.v=\ \ -v -verbose Print all class level dependencies\n\ +\ Equivalent to -verbose:class -filter:none.\n\ \ -verbose:package Print package-level dependencies excluding\n\ -\ dependencies within the same archive\n\ +\ dependencies within the same package by default\n\ \ -verbose:class Print class-level dependencies excluding\n\ -\ dependencies within the same archive +\ dependencies within the same package by default + +main.opt.f=\ +\ -f <regex> -filter <regex> Filter dependences matching the given pattern\n\ +\ If given multiple times, the last one will be used.\n\ +\ -filter:package Filter dependences within the same package (default)\n\ +\ -filter:archive Filter dependences within the same archive\n\ +\ -filter:none No -filter:package and -filter:archive filtering\n\ +\ Filtering specified via the -filter option still applies. main.opt.s=\ \ -s -summary Print dependency summary only main.opt.p=\ -\ -p <pkgname> -package <pkgname> Finds dependences in the given package\n\ +\ -p <pkgname> -package <pkgname> Finds dependences matching the given package name\n\ \ (may be given multiple times) main.opt.e=\ -\ -e <regex> -regex <regex> Finds dependences in packages matching pattern\n\ +\ -e <regex> -regex <regex> Finds dependences matching the given pattern\n\ \ (-p and -e are exclusive) main.opt.include=\ @@ -47,7 +56,10 @@ \ -cp <path> -classpath <path> Specify where to find class files main.opt.R=\ -\ -R -recursive Recursively traverse all dependencies +\ -R -recursive Recursively traverse all dependencies.\n\ +\ The -R option implies -filter:none. If -p, -e, -f\n\ +\ option is specified, only the matching dependences\n\ +\ are analyzed. main.opt.apionly=\ \ -apionly Restrict analysis to APIs i.e. dependences\n\ @@ -74,13 +86,19 @@ err.unknown.option=unknown option: {0} err.missing.arg=no value given for {0} -err.internal.error=internal error: {0} {1} {2} err.invalid.arg.for.option=invalid argument for option: {0} err.option.after.class=option must be specified before classes: {0} err.option.unsupported={0} not supported: {1} err.profiles.msg=No profile information -err.dot.output.path=invalid path: {0} +err.invalid.path=invalid path: {0} warn.invalid.arg=Invalid classname or pathname not exist: {0} warn.split.package=package {0} defined in {1} {2} +warn.replace.useJDKInternals=\ +JDK internal APIs are unsupported and private to JDK implementation that are\n\ +subject to be removed or changed incompatibly and could break your application.\n\ +Please modify your code to eliminate dependency on any JDK internal APIs.\n\ +For the most recent update on JDK internal API replacements, please check:\n\ +{0} artifact.not.found=not found +jdeps.wiki.url=https://wiki.openjdk.java.net/display/JDK8/Java+Dependency+Analysis+Tool
--- a/src/share/classes/com/sun/tools/jdeps/resources/jdeps_ja.properties Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/jdeps/resources/jdeps_ja.properties Thu Sep 04 12:43:12 2014 -0400 @@ -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)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/tools/jdeps/resources/jdkinternals.properties Thu Sep 04 12:43:12 2014 -0400 @@ -0,0 +1,22 @@ +// No translation needed +com.sun.crypto.provider.SunJCE=Use java.security.Security.getProvider(provider-name) @since 1.3 +com.sun.image.codec=Use javax.imageio @since 1.4 +com.sun.org.apache.xml.internal.security=Use java.xml.crypto @since 1.6 +com.sun.org.apache.xml.internal.security.utils.Base64=Use java.util.Base64 @since 1.8 +com.sun.net.ssl=Use javax.net.ssl @since 1.4 +com.sun.net.ssl.internal.ssl.Provider=Use java.security.Security.getProvider(provider-name) @since 1.3 +com.sun.rowset=Use javax.sql.rowset.RowSetProvider @since 1.7 +com.sun.tools.javac.tree=Use com.sun.source @since 1.6 +com.sun.tools.javac=Use javax.tools and javax.lang.model @since 1.6 +sun.awt.image.codec=Use javax.imageio @since 1.4 +sun.misc.BASE64Encoder=Use java.util.Base64 @since 1.8 +sun.misc.BASE64Decoder=Use java.util.Base64 @since 1.8 +sun.misc.Cleaner=Use java.lang.ref.PhantomReference @since 1.2 +sun.misc.Service=Use java.util.ServiceLoader @since 1.6 +sun.security.action=Use java.security.PrivilegedAction @since 1.1 +sun.security.krb5=Use com.sun.security.jgss +sun.security.provider.PolicyFile=Use java.security.Policy.getInstance("JavaPolicy", new URIParameter(uri)) @since 1.6 +sun.security.provider.Sun=Use java.security.Security.getProvider(provider-name) @since 1.3 +sun.security.util.SecurityConstants=Use appropriate java.security.Permission subclass @since 1.1 +sun.security.x509.X500Name=Use javax.security.auth.x500.X500Principal @since 1.4 +sun.tools.jar=Use java.util.jar or jar tool @since 1.2
--- a/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java Thu Jun 05 13:08:52 2014 +0100 +++ b/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java Thu Sep 04 12:43:12 2014 -0400 @@ -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/com/sun/javadoc/testRelativeLinks/TestRelativeLinks.java Thu Jun 05 13:08:52 2014 +0100 +++ b/test/com/sun/javadoc/testRelativeLinks/TestRelativeLinks.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/test/com/sun/javadoc/testRelativeLinks/pkg/C.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/test/com/sun/javadoc/testTopOption/TestTopOption.java Thu Sep 04 12:43:12 2014 -0400 @@ -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/NoStringToLower.java Thu Sep 04 12:43:12 2014 -0400 @@ -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; +}
--- a/test/tools/javac/T8030816/CrashLambdaExpressionWithNonAccessibleIdTest.out Thu Jun 05 13:08:52 2014 +0100 +++ b/test/tools/javac/T8030816/CrashLambdaExpressionWithNonAccessibleIdTest.out Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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/T8050386/WrongStackframeGenerationTest1.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 8050386 + * @summary Verification error due to a bad stackmap frame generated by javac + */ + +public class WrongStackframeGenerationTest1 { + public static void main(String[] args) {} + + static void foo(){ + while (true) { + int i = 0; + break; + } + switch (1) { + case 1: + int j = 0; + case 2: + bar(); + } + } + + static void bar() {} +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T8050386/WrongStackframeGenerationTest2.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 8050386 + * @summary Verification error due to a bad stackmap frame generated by javac + */ + +public class WrongStackframeGenerationTest2 { + public static void main(String[] args) {} + + static void foo() { + int len; + for (;;) { + try { + len = 1; + break; + } catch (Exception e) { + } + } + + try { + if (len == -1) { + len = 0; + } + } finally { + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/FinalReceiverTest.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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/newlocations/Receivers.java Thu Jun 05 13:08:52 2014 +0100 +++ b/test/tools/javac/annotations/typeAnnotations/newlocations/Receivers.java Thu Sep 04 12:43:12 2014 -0400 @@ -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/defaultMethods/static/StaticInvoke.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/StaticIntfMethodInvokeNotSupported.java Thu Sep 04 12:43:12 2014 -0400 @@ -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(); + } +}
--- a/test/tools/javac/flow/LVTHarness.java Thu Jun 05 13:08:52 2014 +0100 +++ b/test/tools/javac/flow/LVTHarness.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 8047719 + * @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 Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Jun 05 13:08:52 2014 +0100 +++ b/test/tools/javac/flow/tests/TestCaseIfElse.java Thu Sep 04 12:43:12 2014 -0400 @@ -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; + } }
--- a/test/tools/javac/flow/tests/TestCaseSwitch.java Thu Jun 05 13:08:52 2014 +0100 +++ b/test/tools/javac/flow/tests/TestCaseSwitch.java Thu Sep 04 12:43:12 2014 -0400 @@ -5,7 +5,7 @@ @AliveRange(varName="o", bytecodeStart=31, bytecodeLength=16) @AliveRange(varName="o", bytecodeStart=50, bytecodeLength=15) @AliveRange(varName="o", bytecodeStart=68, bytecodeLength=1) - @AliveRange(varName="oo", bytecodeStart=39, bytecodeLength=26) + @AliveRange(varName="oo", bytecodeStart=39, bytecodeLength=8) @AliveRange(varName="uu", bytecodeStart=59, bytecodeLength=6) void m1(String[] args) { Object o; @@ -29,7 +29,7 @@ @AliveRange(varName="o", bytecodeStart=95, bytecodeLength=18) @AliveRange(varName="o", bytecodeStart=116, bytecodeLength=15) @AliveRange(varName="o", bytecodeStart=134, bytecodeLength=1) - @AliveRange(varName="oo", bytecodeStart=104, bytecodeLength=27) + @AliveRange(varName="oo", bytecodeStart=104, bytecodeLength=9) @AliveRange(varName="uu", bytecodeStart=125, bytecodeLength=6) void m2(String[] args) { Object o; @@ -50,12 +50,14 @@ o = "return"; } - @AliveRange(varName="o", bytecodeStart=31, bytecodeLength=8) - @AliveRange(varName="o", bytecodeStart=42, bytecodeLength=8) - @AliveRange(varName="o", bytecodeStart=53, bytecodeLength=9) - void m3(String[] args) { + @AliveRange(varName="o", bytecodeStart=35, bytecodeLength=8) + @AliveRange(varName="o", bytecodeStart=46, bytecodeLength=8) + @AliveRange(varName="o", bytecodeStart=78, bytecodeLength=5) + @AliveRange(varName="o", bytecodeStart=86, bytecodeLength=1) + @AliveRange(varName="oo", bytecodeStart=56, bytecodeLength=16) + void m3(int i) { Object o; - switch (args.length) { + switch (i) { case 0: o = "0"; o.hashCode(); @@ -64,10 +66,19 @@ o = "1"; o.hashCode(); break; + case 2: + int oo = i; + if (oo > 1) { + System.out.println("greater"); + } + break; + case 3: + int uu = i; default: o = "default"; o.hashCode(); } o = "finish"; } + }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/diamond/T8041713/DiamondPlusUnexistingMethodRefCrashTest.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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
--- a/test/tools/javac/generics/inference/7086586/T7086586.out Thu Jun 05 13:08:52 2014 +0100 +++ b/test/tools/javac/generics/inference/7086586/T7086586.out Thu Sep 04 12:43:12 2014 -0400 @@ -1,5 +1,5 @@ -T7086586.java:14:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.captureof: 1, ?, java.lang.String) -T7086586.java:15:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.captureof: 1, ?, java.lang.Number) -T7086586.java:16:31: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.captureof: 1, ?, java.lang.Exception) -T7086586.java:17:13: compiler.err.cant.resolve.location.args: kindname.method, nonExistentMethod, , , (compiler.misc.location: kindname.interface, java.util.List<compiler.misc.type.captureof: 1, ?>, null) +T7086586.java:14:20: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>)) +T7086586.java:15:20: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>)) +T7086586.java:16:23: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>)) +T7086586.java:17:9: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>)) 4 errors
--- a/test/tools/javac/generics/inference/7086586/T7086586b.java Thu Jun 05 13:08:52 2014 +0100 +++ b/test/tools/javac/generics/inference/7086586/T7086586b.java Thu Sep 04 12:43:12 2014 -0400 @@ -23,10 +23,9 @@ /* * @test - * @bug 7086586 8033718 + * @bug 7086586 * - * @summary Inference producing null type argument; inference ignores capture - * variable as upper bound + * @summary Inference producing null type argument */ import java.util.List; @@ -41,8 +40,8 @@ assertionCount++; } - <T> void m(List<? super T> dummy) { assertTrue(true); } - <T> void m(Object dummy) { assertTrue(false); } + <T> void m(List<? super T> dummy) { assertTrue(false); } + <T> void m(Object dummy) { assertTrue(true); } void test(List<?> l) { m(l);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/inference/8043725/T8043725.java Thu Sep 04 12:43:12 2014 -0400 @@ -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/8043926/T8043926.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 8043926 + * @summary javac, code valid in 7 is not compiling for 8 + * @compile T8043926.java + */ +class T8043926 { + interface Iface<T1> {} + + static class Impl implements Iface<Impl> {} + + static class Acceptor<T2 extends Iface<T2>> { + public Acceptor(T2 obj) {} + } + + void test(Impl impl) { + Acceptor<?> acceptor1 = new Acceptor<>(impl); + Acceptor<? extends Object> acceptor2 = new Acceptor<>(impl); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/inference/EagerReturnTypeResolution/EagerReturnTypeResolutionTesta.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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/NestedWildcards.java Thu Sep 04 12:43:12 2014 -0400 @@ -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/T8044546/CrashImplicitLambdaTest.java Thu Sep 04 12:43:12 2014 -0400 @@ -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. + */ + +/** + * @test + * @bug 8044546 + * @summary Crash on faulty reduce/lambda + * @compile CrashImplicitLambdaTest.java + */ + +abstract class CrashImplicitLambdaTest { + boolean foo() { + return bar(true, a -> {}); + } + + abstract <T1> T1 bar(T1 t1, S<T1> s); + + interface S<S1> { + void baz(S1 s1); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/inference/T8044546/NestedInvocationsTest.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 8044546 + * @summary Crash on faulty reduce/lambda + * @compile NestedInvocationsTest.java + */ + +class NestedInvocationsTest<T> { + boolean foo(I<T> i) { + return baz(zas(i)); + } + + <U> J<U, Boolean> zas(I<U> i) { + return null; + } + + <R> R baz(J<T, R> j) { + return null; + } + + interface I<I1> {} + + interface J<J1, J2> {} +}
--- a/test/tools/javac/generics/wildcards/7034495/T7034495.out Thu Jun 05 13:08:52 2014 +0100 +++ b/test/tools/javac/generics/wildcards/7034495/T7034495.out Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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> {} +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/wildcards/T8051402/WildcardAndCAPSubtypeTest.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 8051402 + * @summary javac, type containment should accept that CAP <= ? extends CAP and CAP <= ? super CAP + * @compile WildcardAndCAPSubtypeTest.java + */ + +import java.util.List; + +public abstract class WildcardAndCAPSubtypeTest { + abstract <T> List<T> copyOf(List<? extends T> lx); + abstract <E> List<E> filter(List<E> lx); + + void g(List<?> lx) { + copyOf(filter(lx)); + } +}
--- a/test/tools/javac/inference/EagerReturnTypeResolution/EagerReturnTypeResolutionTesta.java Thu Jun 05 13:08:52 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. 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)); - } - } - -}
--- a/test/tools/javac/inference/EagerReturnTypeResolution/EagerReturnTypeResolutionTestb.java Thu Jun 05 13:08:52 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,182 +0,0 @@ -/* - * @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 - } -}
--- a/test/tools/javac/inference/EagerReturnTypeResolution/EagerReturnTypeResolutionTestb.out Thu Jun 05 13:08:52 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -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
--- a/test/tools/javac/inference/EagerReturnTypeResolution/PrimitiveTypeBoxingTest.java Thu Jun 05 13:08:52 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -/* - * @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 - } -}
--- a/test/tools/javac/inference/EagerReturnTypeResolution/PrimitiveTypeBoxingTest.out Thu Jun 05 13:08:52 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -PrimitiveTypeBoxingTest.java:19:9: compiler.err.cant.apply.symbol: kindname.method, m1, PrimitiveTypeBoxingTest.F<Z>,Z, @490,int, kindname.class, PrimitiveTypeBoxingTest, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, java.lang.Long,java.lang.Object) -PrimitiveTypeBoxingTest.java:20:9: compiler.err.cant.apply.symbol: kindname.method, m2, Z,PrimitiveTypeBoxingTest.F<Z>, int,@559, kindname.class, PrimitiveTypeBoxingTest, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, java.lang.Long,java.lang.Object) -2 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/LambdaTestStrictFP.java Thu Sep 04 12:43:12 2014 -0400 @@ -0,0 +1,70 @@ +/* + * 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 8046060 + * @summary Different results of floating point multiplication for lambda code block + */ + +strictfp +public class LambdaTestStrictFP { + + static double fld = eval(() -> { + double x = Double.longBitsToDouble(0x1e7ee00000000000L); + double y = Double.longBitsToDouble(0x2180101010101010L); + + return x * y; + }); + + public static void main(String args[]) { + double result = eval(() -> { + double x = Double.longBitsToDouble(0x1e7ee00000000000L); + double y = Double.longBitsToDouble(0x2180101010101010L); + + return x * y; + }); + { + double x = Double.longBitsToDouble(0x1e7ee00000000000L); + double y = Double.longBitsToDouble(0x2180101010101010L); + + double z = x * y; + check(z, result, "method"); + check(z, fld, "field"); + } + } + + private static void check(double expected, double got, String where) { + if (got != expected) { + throw new AssertionError(where + ": Non-strictfp " + got + " != " + expected); + } + } + + private static double eval(Face arg) { + return arg.m(); + } + + private interface Face { + double m(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/LambdaTestStrictFPFlag.java Thu Sep 04 12:43:12 2014 -0400 @@ -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. + */ + +/* + * @test + * @bug 8046060 + * @summary Different results of floating point multiplication for lambda code block + */ + +import java.io.*; +import java.net.URL; +import com.sun.tools.classfile.*; +import static com.sun.tools.classfile.AccessFlags.ACC_STRICT; + +public class LambdaTestStrictFPFlag { + public static void main(String[] args) throws Exception { + new LambdaTestStrictFPFlag().run(); + } + + void run() throws Exception { + ClassFile cf = getClassFile("LambdaTestStrictFPFlag$Test.class"); + ConstantPool cp = cf.constant_pool; + boolean found = false; + for (Method meth: cf.methods) { + if (meth.getName(cp).startsWith("lambda$")) { + if ((meth.access_flags.flags & ACC_STRICT) == 0) { + throw new Exception("strict flag missing from lambda"); + } + found = true; + } + } + if (!found) { + throw new Exception("did not find lambda method"); + } + } + + ClassFile getClassFile(String name) throws IOException, ConstantPoolException { + URL url = getClass().getResource(name); + InputStream in = url.openStream(); + try { + return ClassFile.read(in); + } finally { + in.close(); + } + } + + class Test { + strictfp void test() { + Face itf = () -> { }; + } + } + + interface Face { + void m(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/LambdaTestStrictFPMethod.java Thu Sep 04 12:43:12 2014 -0400 @@ -0,0 +1,65 @@ +/* + * 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 8046060 + * @summary Different results of floating point multiplication for lambda code block + */ + +public class LambdaTestStrictFPMethod { + + public static void main(String args[]) { + new LambdaTestStrictFPMethod().test(); + } + + strictfp void test() { + double result = eval(() -> { + double x = Double.longBitsToDouble(0x1e7ee00000000000L); + double y = Double.longBitsToDouble(0x2180101010101010L); + + return x * y; + }); + { + double x = Double.longBitsToDouble(0x1e7ee00000000000L); + double y = Double.longBitsToDouble(0x2180101010101010L); + + double z = x * y; + check(z, result, "method"); + } + } + + strictfp void check(double expected, double got, String where) { + if (got != expected) { + throw new AssertionError(where + ": Non-strictfp " + got + " != " + expected); + } + } + + static double eval(Face arg) { + return arg.m(); + } + + interface Face { + double m(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/T8031967.java Thu Sep 04 12:43:12 2014 -0400 @@ -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/T8038182/CrashFunctionDescriptorExceptionTest.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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/T8041704/ErrorMessageTest.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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/TargetType61.java Thu Jun 05 13:08:52 2014 +0100 +++ b/test/tools/javac/lambda/TargetType61.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 8007464 + * @bug 8007464 8051402 * @summary Add graph inference support * check that new wildcards inference strategy doesn't run into 7190296 * @compile TargetType61.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/missingSuperRecovery/MissingInterfaceTest.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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/model/element/TestTypeParameterAnnotations.java Thu Jun 05 13:08:52 2014 +0100 +++ b/test/tools/javac/processing/model/element/TestTypeParameterAnnotations.java Thu Sep 04 12:43:12 2014 -0400 @@ -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/types/BadSigTest.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 Thu Sep 04 12:43:12 2014 -0400 @@ -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); + } + } +}
--- a/test/tools/javac/varargs/6313164/T6313164.java Thu Jun 05 13:08:52 2014 +0100 +++ b/test/tools/javac/varargs/6313164/T6313164.java Thu Sep 04 12:43:12 2014 -0400 @@ -1,18 +1,26 @@ /* * @test /nodynamiccopyright/ - * @bug 6313164 + * @bug 6313164 8036953 * @author mcimadamore * @summary javac generates code that fails byte code verification for the varargs feature - * @compile/fail/ref=T6313164.out -XDrawDiagnostics T6313164.java + * @compile/fail/ref=T6313164Source7.out -source 7 -XDrawDiagnostics T6313164.java + * @compile/fail/ref=T6313164Source8AndHigher.out -XDrawDiagnostics T6313164.java */ import p1.*; class T6313164 { - { B b = new B(); - b.foo1(new B(), new B()); //error - A not accesible - b.foo2(new B(), new B()); //ok - A not accessible, but foo2(Object...) applicable - b.foo3(null, null); //error - A (inferred) not accesible - b.foo4(null, null); //error - A (inferred in 15.12.2.8 - no resolution backtrack) not accesible - b.foo4(new B(), new C()); //ok - A (inferred in 15.12.2.7) not accessible, but foo4(Object...) applicable + { + B b = new B(); + b.foo1(new B(), new B()); //error - A not accessible + /* 7 : ok - A not accessible, but foo2(Object...) applicable + * 8+ : error - A not accessible + */ + b.foo2(new B(), new B()); + b.foo3(null, null); //error - A (inferred) not accessible + b.foo4(null, null); //error - A not accesible + /* 7 : ok - A not accessible, but foo4(Object...) applicable + * 8+ : error - A not accessible + */ + b.foo4(new B(), new C()); } }
--- a/test/tools/javac/varargs/6313164/T6313164.out Thu Jun 05 13:08:52 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -T6313164.java:12:8: compiler.err.cant.apply.symbol: kindname.method, foo1, p1.A[], p1.B,p1.B, kindname.class, p1.B, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) -T6313164.java:14:13: compiler.err.prob.found.req: (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) -T6313164.java:15:13: compiler.err.prob.found.req: (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) -- compiler.note.unchecked.filename: B.java -- compiler.note.unchecked.recompile -3 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/6313164/T6313164Source7.out Thu Sep 04 12:43:12 2014 -0400 @@ -0,0 +1,6 @@ +- compiler.warn.source.no.bootclasspath: 1.7 +T6313164.java:14:10: compiler.err.cant.apply.symbol: kindname.method, foo1, p1.A[], p1.B,p1.B, kindname.class, p1.B, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) +T6313164.java:19:15: compiler.err.prob.found.req: (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) +T6313164.java:20:15: compiler.err.prob.found.req: (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) +3 errors +1 warning
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/6313164/T6313164Source8AndHigher.out Thu Sep 04 12:43:12 2014 -0400 @@ -0,0 +1,6 @@ +T6313164.java:14:15: compiler.err.cant.apply.symbol: kindname.method, foo1, p1.A[], p1.B,p1.B, kindname.class, p1.B, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) +T6313164.java:18:15: compiler.err.cant.apply.symbol: kindname.method, foo2, p1.A[], p1.B,p1.B, kindname.class, p1.B, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) +T6313164.java:19:15: compiler.err.prob.found.req: (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) +T6313164.java:20:15: compiler.err.prob.found.req: (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) +T6313164.java:24:15: compiler.err.prob.found.req: (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) +5 errors
--- a/test/tools/javac/varargs/6313164/T7175433.java Thu Jun 05 13:08:52 2014 +0100 +++ b/test/tools/javac/varargs/6313164/T7175433.java Thu Sep 04 12:43:12 2014 -0400 @@ -1,31 +1,8 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * 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 + * @test /nodynamiccopyright/ * @bug 7175433 6313164 * @summary Inference cleanup: add helper class to handle inference variables - * + * @compile/fail/ref=T7175433.out -XDrawDiagnostics T7175433.java */ import java.util.List; @@ -34,26 +11,16 @@ private class Foo { } - <Z> List<Z> m(Object... o) { T7175433.assertTrue(true); return null; } - <Z> List<Z> m(Foo... o) { T7175433.assertTrue(false); return null; } + <Z> List<Z> m(Object... o) { return null; } + <Z> List<Z> m(Foo... o) { return null; } Foo getFoo() { return null; } } public class T7175433 { - static int assertionCount; - - static void assertTrue(boolean b) { - assertionCount++; - if (!b) { - throw new AssertionError(); - } - } - public static void main(String[] args) { Bar b = new Bar(); b.m(b.getFoo()); - assertTrue(assertionCount == 1); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/6313164/T7175433.out Thu Sep 04 12:43:12 2014 -0400 @@ -0,0 +1,2 @@ +T7175433.java:24:12: compiler.err.prob.found.req: (compiler.misc.inaccessible.varargs.type: Bar.Foo, kindname.class, T7175433) +1 error
--- a/test/tools/javac/varargs/6313164/p1/B.java Thu Jun 05 13:08:52 2014 +0100 +++ b/test/tools/javac/varargs/6313164/p1/B.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 @@ -23,13 +23,12 @@ package p1; +@SuppressWarnings("unchecked") public class B extends A { - public B() {} public void foo1(A... args) { } public void foo2(A... args) { } public void foo2(Object... args) { } public <X extends A> void foo3(X... args) { } public <X extends A> void foo4(X... args) { } public void foo4(Object... args) { } - }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/T8049075/VarargsAndWildcardParameterizedTypeTest.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 8049075 + * @summary javac, wildcards and generic vararg method invocation not accepted + * @compile VarargsAndWildcardParameterizedTypeTest.java + */ + +class VarargsAndWildcardParameterizedTypeTest { + interface I<T> { + String m(T... t); + } + + void m() { + I<? super Integer> i = null; + i.m(Integer.valueOf(1), Integer.valueOf(1)); + } +}
--- a/test/tools/jdeps/APIDeps.java Thu Jun 05 13:08:52 2014 +0100 +++ b/test/tools/jdeps/APIDeps.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8015912 8029216 + * @bug 8015912 8029216 8048063 8050804 * @summary Test -apionly and -jdkinternals options * @build m.Bar m.Foo m.Gee b.B c.C c.I d.D e.E f.F g.G * @run main APIDeps @@ -81,27 +81,39 @@ new String[] {"compact1", "compact3", testDirBasename}, new String[] {"-classpath", testDir.getPath(), "-verbose", "-P"}); test(new File(mDir, "Foo.class"), + new String[] {"c.I", "e.E", "f.F"}, + new String[] {testDirBasename}, + new String[] {"-classpath", testDir.getPath(), "-verbose:class", "-P"}); + test(new File(mDir, "Foo.class"), new String[] {"c.I", "e.E", "f.F", "m.Bar"}, new String[] {testDirBasename}, - new String[] {"-classpath", testDir.getPath(), "-verbose", "-P"}); + new String[] {"-classpath", testDir.getPath(), "-verbose:class", "-filter:none", "-P"}); test(new File(mDir, "Gee.class"), - new String[] {"g.G", "sun.misc.Lock"}, - new String[] {testDirBasename, "JDK internal API"}, - new String[] {"-classpath", testDir.getPath(), "-verbose"}); + new String[] {"g.G", "sun.misc.Lock", "com.sun.tools.classfile.ClassFile", + "com.sun.management.ThreadMXBean", "com.sun.source.tree.BinaryTree"}, + new String[] {testDirBasename, "JDK internal API", "compact3", ""}, + new String[] {"-classpath", testDir.getPath(), "-verbose", "-P"}); // -jdkinternals test(new File(mDir, "Gee.class"), - new String[] {"sun.misc.Lock"}, + new String[] {"sun.misc.Lock", "com.sun.tools.classfile.ClassFile"}, new String[] {"JDK internal API"}, new String[] {"-jdkinternals"}); // -jdkinternals parses all classes on -classpath and the input arguments test(new File(mDir, "Gee.class"), - new String[] {"sun.misc.Lock", "sun.misc.Unsafe"}, + new String[] {"com.sun.tools.jdeps.Main", "com.sun.tools.classfile.ClassFile", + "sun.misc.Lock", "sun.misc.Unsafe"}, new String[] {"JDK internal API"}, new String[] {"-classpath", testDir.getPath(), "-jdkinternals"}); // parse only APIs - // parse only APIs + test(mDir, + new String[] {"java.lang.Object", "java.lang.String", + "java.util.Set", + "c.C", "d.D", "c.I", "e.E"}, + new String[] {"compact1", testDirBasename}, + new String[] {"-classpath", testDir.getPath(), "-verbose:class", "-P", "-apionly"}); + test(mDir, new String[] {"java.lang.Object", "java.lang.String", "java.util.Set",
--- a/test/tools/jdeps/Basic.java Thu Jun 05 13:08:52 2014 +0100 +++ b/test/tools/jdeps/Basic.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8003562 8005428 8015912 8027481 + * @bug 8003562 8005428 8015912 8027481 8048063 * @summary Basic tests for jdeps tool * @build Test p.Foo p.Bar javax.activity.NotCompactProfile * @run main Basic @@ -86,6 +86,16 @@ new String[] {"java.lang.Object", "java.lang.String", "p.Foo", "p.Bar"}, new String[] {"compact1", "compact1", "not found", "not found"}, new String[] {"-verbose:class"}); + // test -filter:none option + test(new File(testDir, "p"), + new String[] {"java.lang", "java.util", "java.lang.management", "javax.activity", "javax.crypto", "p"}, + new String[] {"compact1", "compact1", "compact3", testDir.getName(), "compact1", "p"}, + new String[] {"-classpath", testDir.getPath(), "-verbose:package", "-filter:none"}); + // test -filter:archive option + test(new File(testDir, "p"), + new String[] {"java.lang", "java.util", "java.lang.management", "javax.activity", "javax.crypto"}, + new String[] {"compact1", "compact1", "compact3", testDir.getName(), "compact1"}, + new String[] {"-classpath", testDir.getPath(), "-verbose:package", "-filter:archive"}); // test -p option test(new File(testDir, "Test.class"), new String[] {"p.Foo", "p.Bar"}, @@ -100,11 +110,12 @@ new String[] {"java.lang"}, new String[] {"compact1"}, new String[] {"-verbose:package", "-e", "java\\.lang\\..*"}); + // test -classpath and -include options test(null, - new String[] {"java.lang", "java.util", - "java.lang.management", "javax.crypto"}, - new String[] {"compact1", "compact1", "compact3", "compact1"}, + new String[] {"java.lang", "java.util", "java.lang.management", + "javax.activity", "javax.crypto"}, + new String[] {"compact1", "compact1", "compact3", testDir.getName(), "compact1"}, new String[] {"-classpath", testDir.getPath(), "-include", "p.+|Test.class"}); test(new File(testDir, "Test.class"), new String[] {"java.lang.Object", "java.lang.String", "p.Foo", "p.Bar"},
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/jdeps/DotFileTest.java Thu Sep 04 12:43:12 2014 -0400 @@ -0,0 +1,272 @@ +/* + * 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 8003562 + * @summary Basic tests for jdeps -dotoutput option + * @build Test p.Foo p.Bar javax.activity.NotCompactProfile + * @run main DotFileTest + */ + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.file.DirectoryStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.*; +import java.util.regex.*; + +public class DotFileTest { + private static boolean symbolFileExist = initProfiles(); + private static boolean initProfiles() { + // check if ct.sym exists; if not use the profiles.properties file + Path home = Paths.get(System.getProperty("java.home")); + if (home.endsWith("jre")) { + home = home.getParent(); + } + Path ctsym = home.resolve("lib").resolve("ct.sym"); + boolean symbolExists = ctsym.toFile().exists(); + if (!symbolExists) { + Path testSrcProfiles = + Paths.get(System.getProperty("test.src", "."), "profiles.properties"); + if (!testSrcProfiles.toFile().exists()) + throw new Error(testSrcProfiles + " does not exist"); + System.out.format("%s doesn't exist.%nUse %s to initialize profiles info%n", + ctsym, testSrcProfiles); + System.setProperty("jdeps.profiles", testSrcProfiles.toString()); + } + return symbolExists; + } + + public static void main(String... args) throws Exception { + int errors = 0; + errors += new DotFileTest().run(); + if (errors > 0) + throw new Exception(errors + " errors found"); + } + + final Path dir; + final Path dotoutput; + DotFileTest() { + this.dir = Paths.get(System.getProperty("test.classes", ".")); + this.dotoutput = dir.resolve("dots"); + } + + int run() throws IOException { + File testDir = dir.toFile(); + // test a .class file + test(new File(testDir, "Test.class"), + new String[] {"java.lang", "p"}, + new String[] {"compact1", "not found"}); + // test a directory + // also test non-SE javax.activity class dependency + test(new File(testDir, "p"), + new String[] {"java.lang", "java.util", "java.lang.management", "javax.activity", "javax.crypto"}, + new String[] {"compact1", "compact1", "compact3", testDir.getName(), "compact1"}, + new String[] {"-classpath", testDir.getPath()}); + // test class-level dependency output + test(new File(testDir, "Test.class"), + new String[] {"java.lang.Object", "java.lang.String", "p.Foo", "p.Bar"}, + new String[] {"compact1", "compact1", "not found", "not found"}, + new String[] {"-verbose:class"}); + // test -filter:none option + test(new File(testDir, "p"), + new String[] {"java.lang", "java.util", "java.lang.management", "javax.activity", "javax.crypto", "p"}, + new String[] {"compact1", "compact1", "compact3", testDir.getName(), "compact1", "p"}, + new String[] {"-classpath", testDir.getPath(), "-verbose:package", "-filter:none"}); + // test -filter:archive option + test(new File(testDir, "p"), + new String[] {"java.lang", "java.util", "java.lang.management", "javax.activity", "javax.crypto"}, + new String[] {"compact1", "compact1", "compact3", testDir.getName(), "compact1"}, + new String[] {"-classpath", testDir.getPath(), "-verbose:package", "-filter:archive"}); + // test -p option + test(new File(testDir, "Test.class"), + new String[] {"p.Foo", "p.Bar"}, + new String[] {"not found", "not found"}, + new String[] {"-verbose:class", "-p", "p"}); + // test -e option + test(new File(testDir, "Test.class"), + new String[] {"p.Foo", "p.Bar"}, + new String[] {"not found", "not found"}, + new String[] {"-verbose:class", "-e", "p\\..*"}); + test(new File(testDir, "Test.class"), + new String[] {"java.lang"}, + new String[] {"compact1"}, + new String[] {"-verbose:package", "-e", "java\\.lang\\..*"}); + // test -classpath options + test(new File(testDir, "Test.class"), + new String[] {"java.lang.Object", "java.lang.String", "p.Foo", "p.Bar"}, + new String[] {"compact1", "compact1", testDir.getName(), testDir.getName()}, + new String[] {"-v", "-classpath", testDir.getPath()}); + + testSummary(new File(testDir, "Test.class"), + new String[] {"rt.jar", testDir.getName()}, + new String[] {"compact1", ""}, + new String[] {"-classpath", testDir.getPath()}); + testSummary(new File(testDir, "Test.class"), + new String[] {"java.lang", "p"}, + new String[] {"compact1", testDir.getName()}, + new String[] {"-v", "-classpath", testDir.getPath()}); + return errors; + } + + void test(File file, String[] expect, String[] profiles) throws IOException { + test(file, expect, profiles, new String[0]); + } + + void test(File file, String[] expect, String[] profiles, String[] options) + throws IOException + { + Path dotfile = dotoutput.resolve(file.toPath().getFileName().toString() + ".dot"); + + List<String> args = new ArrayList<>(Arrays.asList(options)); + args.add("-dotoutput"); + args.add(dotoutput.toString()); + if (file != null) { + args.add(file.getPath()); + } + + Map<String,String> result = jdeps(args, dotfile); + checkResult("dependencies", expect, result.keySet()); + + // with -P option + List<String> argsWithDashP = new ArrayList<>(); + argsWithDashP.add("-dotoutput"); + argsWithDashP.add(dotoutput.toString()); + argsWithDashP.add("-P"); + argsWithDashP.addAll(args); + + result = jdeps(argsWithDashP, dotfile); + checkResult("profiles", expect, profiles, result); + } + + void testSummary(File file, String[] expect, String[] profiles, String[] options) + throws IOException + { + Path dotfile = dotoutput.resolve("summary.dot"); + + List<String> args = new ArrayList<>(Arrays.asList(options)); + args.add("-dotoutput"); + args.add(dotoutput.toString()); + if (file != null) { + args.add(file.getPath()); + } + + Map<String,String> result = jdeps(args, dotfile); + checkResult("dependencies", expect, result.keySet()); + + // with -P option + List<String> argsWithDashP = new ArrayList<>(); + argsWithDashP.add("-dotoutput"); + argsWithDashP.add(dotoutput.toString()); + argsWithDashP.add("-P"); + argsWithDashP.addAll(args); + + result = jdeps(argsWithDashP, dotfile); + checkResult("profiles", expect, profiles, result); + } + + Map<String,String> jdeps(List<String> args, Path dotfile) throws IOException { + if (Files.exists(dotoutput)) { + try (DirectoryStream<Path> stream = Files.newDirectoryStream(dotoutput)) { + for (Path p : stream) { + Files.delete(p); + } + } + Files.delete(dotoutput); + } + // invoke jdeps + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + System.err.println("jdeps " + args); + int rc = com.sun.tools.jdeps.Main.run(args.toArray(new String[0]), pw); + pw.close(); + String out = sw.toString(); + if (!out.isEmpty()) + System.err.println(out); + if (rc != 0) + throw new Error("jdeps failed: rc=" + rc); + + // check output files + if (Files.notExists(dotfile)) { + throw new RuntimeException(dotfile + " doesn't exist"); + } + return parse(dotfile); + } + private static Pattern pattern = Pattern.compile("(.*) -> +([^ ]*) (.*)"); + private Map<String,String> parse(Path outfile) throws IOException { + Map<String,String> result = new LinkedHashMap<>(); + for (String line : Files.readAllLines(outfile)) { + line = line.replace('"', ' ').replace(';', ' '); + Matcher pm = pattern.matcher(line); + if (pm.find()) { + String origin = pm.group(1).trim(); + String target = pm.group(2).trim(); + String module = pm.group(3).replace('(', ' ').replace(')', ' ').trim(); + result.put(target, module); + } + } + return result; + } + + void checkResult(String label, String[] expect, Collection<String> found) { + List<String> list = Arrays.asList(expect); + if (!isEqual(list, found)) + error("Unexpected " + label + " found: '" + found + "', expected: '" + list + "'"); + } + + void checkResult(String label, String[] expect, String[] profiles, Map<String,String> result) { + if (expect.length != profiles.length) + error("Invalid expected names and profiles"); + + // check the dependencies + checkResult(label, expect, result.keySet()); + // check profile information + checkResult(label, profiles, result.values()); + for (int i=0; i < expect.length; i++) { + String profile = result.get(expect[i]); + if (!profile.equals(profiles[i])) + error("Unexpected profile: '" + profile + "', expected: '" + profiles[i] + "'"); + } + } + + boolean isEqual(List<String> expected, Collection<String> found) { + if (expected.size() != found.size()) + return false; + + List<String> list = new ArrayList<>(found); + list.removeAll(expected); + return list.isEmpty(); + } + + void error(String msg) { + System.err.println("Error: " + msg); + errors++; + } + + int errors; +}
--- a/test/tools/jdeps/m/Gee.java Thu Jun 05 13:08:52 2014 +0100 +++ b/test/tools/jdeps/m/Gee.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 @@ -26,5 +26,7 @@ class Gee extends g.G { public sun.misc.Lock lock; + public com.sun.tools.classfile.ClassFile cf; // @jdk.Exported(false) + public com.sun.source.tree.BinaryTree tree; // @jdk.Exported + public com.sun.management.ThreadMXBean mxbean; // @jdk.Exported on package-info } -
--- a/test/tools/jdeps/p/Bar.java Thu Jun 05 13:08:52 2014 +0100 +++ b/test/tools/jdeps/p/Bar.java Thu Sep 04 12:43:12 2014 -0400 @@ -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 @@ -30,4 +30,8 @@ public javax.crypto.Cipher getCiper() { return null; } + + public Foo foo() { + return new Foo(); + } }