Thu, 26 Jun 2014 08:46:07 -0700
Merge
.hgtags | file | annotate | diff | comparison | revisions |
1.1 --- a/.hgtags Wed Jun 18 13:32:11 2014 -0700 1.2 +++ b/.hgtags Thu Jun 26 08:46:07 2014 -0700 1.3 @@ -270,6 +270,7 @@ 1.4 a12055904afd9f951131804868215e724c71b684 jdk8u5-b11 1.5 2a7002626e7997e946b96530629e2787bc1864bb jdk8u5-b12 1.6 9beafb58fb99e8b5f7577b2f26b12743ef4d07e7 jdk8u5-b13 1.7 +6614bfcdcd4d915b1b8e3ba3480d53ff83988290 jdk8u5-b31 1.8 d37e407fba44f68c660f89be4e48f9e7b256a2d5 jdk8u11-b01 1.9 e75f843c4bf81c79ca4c5d51dfe5fe39525c5301 jdk8u11-b02 1.10 d9904b00b027b9176d6479dee7c7f4e054a68710 jdk8u11-b03 1.11 @@ -303,6 +304,7 @@ 1.12 b45fd486977d6cfe64c9947b7afd203c62ec4e98 jdk8u20-b17 1.13 a550336d045faa63ac4439d4901d9f36e0b634bf jdk8u20-b18 1.14 c04d99e00268ed87cfbdf76beb1a0ea08abd9a9c jdk8u20-b19 1.15 +e92effa22ecee1cb9965c278e45e2b1a6fbe0766 jdk8u20-b20 1.16 f491f1581f196950c2cb858508dd06601968c417 jdk8u25-b00 1.17 5bc865e0a2e3c59c1c8bc41e731509e1737ddea1 jdk8u25-b01 1.18 4dec0c684a9ead80ea2bca6b042682367c1abf90 jdk8u25-b02
2.1 --- a/src/share/classes/com/sun/tools/classfile/Instruction.java Wed Jun 18 13:32:11 2014 -0700 2.2 +++ b/src/share/classes/com/sun/tools/classfile/Instruction.java Thu Jun 26 08:46:07 2014 -0700 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. 2.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 * 2.9 * This code is free software; you can redistribute it and/or modify it 2.10 @@ -25,6 +25,8 @@ 2.11 2.12 package com.sun.tools.classfile; 2.13 2.14 +import java.util.Locale; 2.15 + 2.16 /** 2.17 * See JVMS, chapter 6. 2.18 * 2.19 @@ -211,7 +213,7 @@ 2.20 if (opcode == null) 2.21 return "bytecode " + getUnsignedByte(0); 2.22 else 2.23 - return opcode.toString().toLowerCase(); 2.24 + return opcode.toString().toLowerCase(Locale.US); 2.25 } 2.26 2.27 /** Get the length, in bytes, of this instruction, including the opcode
3.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java Wed Jun 18 13:32:11 2014 -0700 3.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java Thu Jun 26 08:46:07 2014 -0700 3.3 @@ -37,6 +37,7 @@ 3.4 import com.sun.tools.doclint.DocLint; 3.5 import com.sun.tools.javac.file.JavacFileManager; 3.6 import com.sun.tools.javac.util.Context; 3.7 +import com.sun.tools.javac.util.StringUtils; 3.8 import com.sun.tools.javadoc.RootDocImpl; 3.9 3.10 /** 3.11 @@ -237,7 +238,7 @@ 3.12 public void setSpecificDocletOptions(String[][] options) { 3.13 for (int oi = 0; oi < options.length; ++oi) { 3.14 String[] os = options[oi]; 3.15 - String opt = os[0].toLowerCase(); 3.16 + String opt = StringUtils.toLowerCase(os[0]); 3.17 if (opt.equals("-footer")) { 3.18 footer = os[1]; 3.19 } else if (opt.equals("-header")) { 3.20 @@ -325,7 +326,7 @@ 3.21 return result; 3.22 } 3.23 // otherwise look for the options we have added 3.24 - option = option.toLowerCase(); 3.25 + option = StringUtils.toLowerCase(option); 3.26 if (option.equals("-nodeprecatedlist") || 3.27 option.equals("-noindex") || 3.28 option.equals("-notree") || 3.29 @@ -389,7 +390,7 @@ 3.30 // otherwise look at our options 3.31 for (int oi = 0; oi < options.length; ++oi) { 3.32 String[] os = options[oi]; 3.33 - String opt = os[0].toLowerCase(); 3.34 + String opt = StringUtils.toLowerCase(os[0]); 3.35 if (opt.equals("-helpfile")) { 3.36 if (nohelp == true) { 3.37 reporter.printError(getText("doclet.Option_conflict",
4.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Wed Jun 18 13:32:11 2014 -0700 4.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Thu Jun 26 08:46:07 2014 -0700 4.3 @@ -28,12 +28,15 @@ 4.4 import java.io.*; 4.5 import java.text.SimpleDateFormat; 4.6 import java.util.*; 4.7 +import java.util.regex.Matcher; 4.8 +import java.util.regex.Pattern; 4.9 4.10 import com.sun.javadoc.*; 4.11 import com.sun.tools.doclets.formats.html.markup.*; 4.12 import com.sun.tools.doclets.internal.toolkit.*; 4.13 import com.sun.tools.doclets.internal.toolkit.taglets.*; 4.14 import com.sun.tools.doclets.internal.toolkit.util.*; 4.15 +import com.sun.tools.javac.util.StringUtils; 4.16 4.17 /** 4.18 * Class for the Html Format Code Generation specific to JavaDoc. 4.19 @@ -138,42 +141,37 @@ 4.20 if (index < 0) { 4.21 return htmlstr; 4.22 } 4.23 - String lowerHtml = htmlstr.toLowerCase(); 4.24 - // Return index of first occurrence of {@docroot} 4.25 - // Note: {@docRoot} is not case sensitive when passed in w/command line option 4.26 - index = lowerHtml.indexOf("{@docroot}", index); 4.27 - if (index < 0) { 4.28 + Matcher docrootMatcher = docrootPattern.matcher(htmlstr); 4.29 + if (!docrootMatcher.find()) { 4.30 return htmlstr; 4.31 } 4.32 StringBuilder buf = new StringBuilder(); 4.33 - int previndex = 0; 4.34 - while (true) { 4.35 - final String docroot = "{@docroot}"; 4.36 - // Search for lowercase version of {@docRoot} 4.37 - index = lowerHtml.indexOf(docroot, previndex); 4.38 - // If next {@docRoot} tag not found, append rest of htmlstr and exit loop 4.39 - if (index < 0) { 4.40 - buf.append(htmlstr.substring(previndex)); 4.41 - break; 4.42 - } 4.43 - // If next {@docroot} tag found, append htmlstr up to start of tag 4.44 - buf.append(htmlstr.substring(previndex, index)); 4.45 - previndex = index + docroot.length(); 4.46 - if (configuration.docrootparent.length() > 0 && htmlstr.startsWith("/..", previndex)) { 4.47 + int prevEnd = 0; 4.48 + do { 4.49 + int match = docrootMatcher.start(); 4.50 + // append htmlstr up to start of next {@docroot} 4.51 + buf.append(htmlstr.substring(prevEnd, match)); 4.52 + prevEnd = docrootMatcher.end(); 4.53 + if (configuration.docrootparent.length() > 0 && htmlstr.startsWith("/..", prevEnd)) { 4.54 // Insert the absolute link if {@docRoot} is followed by "/..". 4.55 buf.append(configuration.docrootparent); 4.56 - previndex += 3; 4.57 + prevEnd += 3; 4.58 } else { 4.59 // Insert relative path where {@docRoot} was located 4.60 buf.append(pathToRoot.isEmpty() ? "." : pathToRoot.getPath()); 4.61 } 4.62 // Append slash if next character is not a slash 4.63 - if (previndex < htmlstr.length() && htmlstr.charAt(previndex) != '/') { 4.64 + if (prevEnd < htmlstr.length() && htmlstr.charAt(prevEnd) != '/') { 4.65 buf.append('/'); 4.66 } 4.67 - } 4.68 + } while (docrootMatcher.find()); 4.69 + buf.append(htmlstr.substring(prevEnd)); 4.70 return buf.toString(); 4.71 } 4.72 + //where: 4.73 + // Note: {@docRoot} is not case sensitive when passed in w/command line option: 4.74 + private static final Pattern docrootPattern = 4.75 + Pattern.compile(Pattern.quote("{@docroot}"), Pattern.CASE_INSENSITIVE); 4.76 4.77 /** 4.78 * Get the script to show or hide the All classes link. 4.79 @@ -1689,13 +1687,13 @@ 4.80 } 4.81 4.82 //Redirect all relative links. 4.83 - int end, begin = text.toLowerCase().indexOf("<a"); 4.84 + int end, begin = StringUtils.indexOfIgnoreCase(text, "<a"); 4.85 if(begin >= 0){ 4.86 StringBuilder textBuff = new StringBuilder(text); 4.87 4.88 while(begin >=0){ 4.89 if (textBuff.length() > begin + 2 && ! Character.isWhitespace(textBuff.charAt(begin+2))) { 4.90 - begin = textBuff.toString().toLowerCase().indexOf("<a", begin + 1); 4.91 + begin = StringUtils.indexOfIgnoreCase(textBuff.toString(), "<a", begin + 1); 4.92 continue; 4.93 } 4.94 4.95 @@ -1722,15 +1720,16 @@ 4.96 } 4.97 } 4.98 String relativeLink = textBuff.substring(begin, end); 4.99 - if (!(relativeLink.toLowerCase().startsWith("mailto:") || 4.100 - relativeLink.toLowerCase().startsWith("http:") || 4.101 - relativeLink.toLowerCase().startsWith("https:") || 4.102 - relativeLink.toLowerCase().startsWith("file:"))) { 4.103 + String relativeLinkLowerCase = StringUtils.toLowerCase(relativeLink); 4.104 + if (!(relativeLinkLowerCase.startsWith("mailto:") || 4.105 + relativeLinkLowerCase.startsWith("http:") || 4.106 + relativeLinkLowerCase.startsWith("https:") || 4.107 + relativeLinkLowerCase.startsWith("file:"))) { 4.108 relativeLink = "{@"+(new DocRootTaglet()).getName() + "}/" 4.109 + redirectPathFromRoot.resolve(relativeLink).getPath(); 4.110 textBuff.replace(begin, end, relativeLink); 4.111 } 4.112 - begin = textBuff.toString().toLowerCase().indexOf("<a", begin + 1); 4.113 + begin = StringUtils.indexOfIgnoreCase(textBuff.toString(), "<a", begin + 1); 4.114 } 4.115 return textBuff.toString(); 4.116 } 4.117 @@ -1771,7 +1770,7 @@ 4.118 break main; 4.119 ch = text.charAt(currPos); 4.120 } 4.121 - if (ch == '>' && blockTags.contains(text.substring(tagPos, currPos).toLowerCase())) { 4.122 + if (ch == '>' && blockTags.contains(StringUtils.toLowerCase(text.substring(tagPos, currPos)))) { 4.123 result.append(text, startPos, lessThanPos); 4.124 startPos = currPos + 1; 4.125 }
5.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java Wed Jun 18 13:32:11 2014 -0700 5.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java Thu Jun 26 08:46:07 2014 -0700 5.3 @@ -1,5 +1,5 @@ 5.4 /* 5.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 5.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 5.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.8 * 5.9 * This code is free software; you can redistribute it and/or modify it 5.10 @@ -31,6 +31,7 @@ 5.11 import com.sun.tools.doclets.formats.html.markup.*; 5.12 import com.sun.tools.doclets.internal.toolkit.*; 5.13 import com.sun.tools.doclets.internal.toolkit.util.*; 5.14 +import com.sun.tools.javac.util.StringUtils; 5.15 5.16 /** 5.17 * Writes method documentation in HTML format. 5.18 @@ -331,24 +332,6 @@ 5.19 } 5.20 5.21 /** 5.22 - * Parse the <Code> tag and return the text. 5.23 - */ 5.24 - protected String parseCodeTag(String tag){ 5.25 - if(tag == null){ 5.26 - return ""; 5.27 - } 5.28 - 5.29 - String lc = tag.toLowerCase(); 5.30 - int begin = lc.indexOf("<code>"); 5.31 - int end = lc.indexOf("</code>"); 5.32 - if(begin == -1 || end == -1 || end <= begin){ 5.33 - return tag; 5.34 - } else { 5.35 - return tag.substring(begin + 6, end); 5.36 - } 5.37 - } 5.38 - 5.39 - /** 5.40 * {@inheritDoc} 5.41 */ 5.42 protected static void addImplementsInfo(HtmlDocletWriter writer,
6.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlAttr.java Wed Jun 18 13:32:11 2014 -0700 6.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlAttr.java Thu Jun 26 08:46:07 2014 -0700 6.3 @@ -25,6 +25,8 @@ 6.4 6.5 package com.sun.tools.doclets.formats.html.markup; 6.6 6.7 +import com.sun.tools.javac.util.StringUtils; 6.8 + 6.9 /** 6.10 * Enum representing HTML tag attributes. 6.11 * 6.12 @@ -64,7 +66,7 @@ 6.13 private final String value; 6.14 6.15 HtmlAttr() { 6.16 - this.value = name().toLowerCase(); 6.17 + this.value = StringUtils.toLowerCase(name()); 6.18 } 6.19 6.20 HtmlAttr(String name) {
7.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTag.java Wed Jun 18 13:32:11 2014 -0700 7.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTag.java Thu Jun 26 08:46:07 2014 -0700 7.3 @@ -25,7 +25,7 @@ 7.4 7.5 package com.sun.tools.doclets.formats.html.markup; 7.6 7.7 -import java.util.Locale; 7.8 +import com.sun.tools.javac.util.StringUtils; 7.9 7.10 /** 7.11 * Enum representing HTML tags. 7.12 @@ -117,7 +117,7 @@ 7.13 HtmlTag(BlockType blockType, EndTag endTag ) { 7.14 this.blockType = blockType; 7.15 this.endTag = endTag; 7.16 - this.value = name().toLowerCase(Locale.US); 7.17 + this.value = StringUtils.toLowerCase(name()); 7.18 } 7.19 7.20 /**
8.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java Wed Jun 18 13:32:11 2014 -0700 8.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java Thu Jun 26 08:46:07 2014 -0700 8.3 @@ -29,6 +29,7 @@ 8.4 import java.util.*; 8.5 import java.util.regex.Matcher; 8.6 import java.util.regex.Pattern; 8.7 +import javax.tools.JavaFileManager; 8.8 8.9 import com.sun.javadoc.*; 8.10 import com.sun.tools.javac.sym.Profiles; 8.11 @@ -36,7 +37,7 @@ 8.12 import com.sun.tools.doclets.internal.toolkit.builders.BuilderFactory; 8.13 import com.sun.tools.doclets.internal.toolkit.taglets.*; 8.14 import com.sun.tools.doclets.internal.toolkit.util.*; 8.15 -import javax.tools.JavaFileManager; 8.16 +import com.sun.tools.javac.util.StringUtils; 8.17 8.18 /** 8.19 * Configure the output based on the options. Doclets should sub-class 8.20 @@ -337,7 +338,7 @@ 8.21 * Negative value means error occurred. 8.22 */ 8.23 public int optionLength(String option) { 8.24 - option = option.toLowerCase(); 8.25 + option = StringUtils.toLowerCase(option); 8.26 if (option.equals("-author") || 8.27 option.equals("-docfilessubdirs") || 8.28 option.equals("-javafx") || 8.29 @@ -454,7 +455,7 @@ 8.30 // the output directory has already been created: so do that first. 8.31 for (int oi = 0; oi < options.length; ++oi) { 8.32 String[] os = options[oi]; 8.33 - String opt = os[0].toLowerCase(); 8.34 + String opt = StringUtils.toLowerCase(os[0]); 8.35 if (opt.equals("-d")) { 8.36 destDirName = addTrailingFileSep(os[1]); 8.37 docFileDestDirName = destDirName; 8.38 @@ -465,7 +466,7 @@ 8.39 8.40 for (int oi = 0; oi < options.length; ++oi) { 8.41 String[] os = options[oi]; 8.42 - String opt = os[0].toLowerCase(); 8.43 + String opt = StringUtils.toLowerCase(os[0]); 8.44 if (opt.equals("-docfilessubdirs")) { 8.45 copydocfilesubdirs = true; 8.46 } else if (opt.equals("-docencoding")) { 8.47 @@ -708,7 +709,7 @@ 8.48 String encoding = ""; 8.49 for (int oi = 0; oi < options.length; oi++) { 8.50 String[] os = options[oi]; 8.51 - String opt = os[0].toLowerCase(); 8.52 + String opt = StringUtils.toLowerCase(os[0]); 8.53 if (opt.equals("-docencoding")) { 8.54 docencodingfound = true; 8.55 if (!checkOutputFileEncoding(os[1], reporter)) {
9.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java Wed Jun 18 13:32:11 2014 -0700 9.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java Thu Jun 26 08:46:07 2014 -0700 9.3 @@ -384,13 +384,13 @@ 9.4 commentTextBuilder.append( 9.5 MessageFormat.format( 9.6 configuration.getText("doclet.PropertySetterWithName"), 9.7 - Util.propertyNameFromMethodName(member.name()))); 9.8 + Util.propertyNameFromMethodName(configuration, member.name()))); 9.9 } 9.10 if (isGetter) { 9.11 commentTextBuilder.append( 9.12 MessageFormat.format( 9.13 configuration.getText("doclet.PropertyGetterWithName"), 9.14 - Util.propertyNameFromMethodName(member.name()))); 9.15 + Util.propertyNameFromMethodName(configuration, member.name()))); 9.16 } 9.17 if (propertyDoc.commentText() != null 9.18 && !propertyDoc.commentText().isEmpty()) {
10.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java Wed Jun 18 13:32:11 2014 -0700 10.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java Thu Jun 26 08:46:07 2014 -0700 10.3 @@ -31,6 +31,7 @@ 10.4 import com.sun.javadoc.*; 10.5 import com.sun.tools.doclets.internal.toolkit.*; 10.6 import com.sun.tools.doclets.internal.toolkit.util.*; 10.7 +import com.sun.tools.javac.util.StringUtils; 10.8 10.9 /** 10.10 * Builds the serialized form. 10.11 @@ -567,7 +568,7 @@ 10.12 } 10.13 Tag[] serial = doc.tags("serial"); 10.14 if (serial.length > 0) { 10.15 - String serialtext = serial[0].text().toLowerCase(); 10.16 + String serialtext = StringUtils.toLowerCase(serial[0].text()); 10.17 if (serialtext.indexOf("exclude") >= 0) { 10.18 return false; 10.19 } else if (serialtext.indexOf("include") >= 0) {
11.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SimpleTaglet.java Wed Jun 18 13:32:11 2014 -0700 11.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SimpleTaglet.java Thu Jun 26 08:46:07 2014 -0700 11.3 @@ -28,6 +28,7 @@ 11.4 import com.sun.javadoc.*; 11.5 import com.sun.tools.doclets.internal.toolkit.Content; 11.6 import com.sun.tools.doclets.internal.toolkit.util.DocFinder; 11.7 +import com.sun.tools.javac.util.StringUtils; 11.8 11.9 /** 11.10 * A simple single argument custom tag. 11.11 @@ -110,7 +111,7 @@ 11.12 public SimpleTaglet(String tagName, String header, String locations) { 11.13 this.tagName = tagName; 11.14 this.header = header; 11.15 - locations = locations.toLowerCase(); 11.16 + locations = StringUtils.toLowerCase(locations); 11.17 if (locations.indexOf(ALL) != -1 && locations.indexOf(EXCLUDED) == -1) { 11.18 this.locations = PACKAGE + TYPE + FIELD + METHOD + CONSTRUCTOR + OVERVIEW; 11.19 } else {
12.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java Wed Jun 18 13:32:11 2014 -0700 12.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java Thu Jun 26 08:46:07 2014 -0700 12.3 @@ -35,6 +35,7 @@ 12.4 12.5 import com.sun.javadoc.*; 12.6 import com.sun.tools.doclets.internal.toolkit.util.*; 12.7 +import com.sun.tools.javac.util.StringUtils; 12.8 12.9 /** 12.10 * Manages the<code>Taglet</code>s used by doclets. 12.11 @@ -304,7 +305,7 @@ 12.12 return; 12.13 } 12.14 Taglet tag = customTags.get(tagName); 12.15 - locations = locations.toLowerCase(); 12.16 + locations = StringUtils.toLowerCase(locations); 12.17 if (tag == null || header != null) { 12.18 customTags.remove(tagName); 12.19 customTags.put(tagName, new SimpleTaglet(tagName, header, locations)); 12.20 @@ -375,7 +376,7 @@ 12.21 name = name.substring(1, name.length()); 12.22 } 12.23 if (! (standardTags.contains(name) || customTags.containsKey(name))) { 12.24 - if (standardTagsLowercase.contains(name.toLowerCase())) { 12.25 + if (standardTagsLowercase.contains(StringUtils.toLowerCase(name))) { 12.26 message.warning(tags[i].position(), "doclet.UnknownTagLowercase", tags[i].name()); 12.27 continue; 12.28 } else { 12.29 @@ -708,7 +709,7 @@ 12.30 private void initStandardTagsLowercase() { 12.31 Iterator<String> it = standardTags.iterator(); 12.32 while (it.hasNext()) { 12.33 - standardTagsLowercase.add(it.next().toLowerCase()); 12.34 + standardTagsLowercase.add(StringUtils.toLowerCase(it.next())); 12.35 } 12.36 } 12.37
13.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java Wed Jun 18 13:32:11 2014 -0700 13.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java Thu Jun 26 08:46:07 2014 -0700 13.3 @@ -28,11 +28,12 @@ 13.4 import java.io.*; 13.5 import java.lang.annotation.ElementType; 13.6 import java.util.*; 13.7 +import javax.tools.StandardLocation; 13.8 13.9 import com.sun.javadoc.*; 13.10 import com.sun.javadoc.AnnotationDesc.ElementValuePair; 13.11 import com.sun.tools.doclets.internal.toolkit.*; 13.12 -import javax.tools.StandardLocation; 13.13 +import com.sun.tools.javac.util.StringUtils; 13.14 13.15 /** 13.16 * Utilities Class for Doclets. 13.17 @@ -253,8 +254,8 @@ 13.18 */ 13.19 private static class TypeComparator implements Comparator<Type> { 13.20 public int compare(Type type1, Type type2) { 13.21 - return type1.qualifiedTypeName().toLowerCase().compareTo( 13.22 - type2.qualifiedTypeName().toLowerCase()); 13.23 + return type1.qualifiedTypeName().compareToIgnoreCase( 13.24 + type2.qualifiedTypeName()); 13.25 } 13.26 } 13.27 13.28 @@ -589,7 +590,7 @@ 13.29 typeName = "doclet.Enum"; 13.30 } 13.31 return config.getText( 13.32 - lowerCaseOnly ? typeName.toLowerCase() : typeName); 13.33 + lowerCaseOnly ? StringUtils.toLowerCase(typeName) : typeName); 13.34 } 13.35 13.36 /** 13.37 @@ -724,7 +725,7 @@ 13.38 * @param name name of the getter or setter method. 13.39 * @return the name of the property of the given setter of getter. 13.40 */ 13.41 - public static String propertyNameFromMethodName(String name) { 13.42 + public static String propertyNameFromMethodName(Configuration configuration, String name) { 13.43 String propertyName = null; 13.44 if (name.startsWith("get") || name.startsWith("set")) { 13.45 propertyName = name.substring(3); 13.46 @@ -734,7 +735,7 @@ 13.47 if ((propertyName == null) || propertyName.isEmpty()){ 13.48 return ""; 13.49 } 13.50 - return propertyName.substring(0, 1).toLowerCase() 13.51 + return propertyName.substring(0, 1).toLowerCase(configuration.getLocale()) 13.52 + propertyName.substring(1); 13.53 } 13.54
14.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java Wed Jun 18 13:32:11 2014 -0700 14.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java Thu Jun 26 08:46:07 2014 -0700 14.3 @@ -702,7 +702,7 @@ 14.4 private boolean isPropertyGetterOrSetter(MethodDoc[] members, 14.5 MethodDoc methodDoc) { 14.6 boolean found = false; 14.7 - String propertyName = Util.propertyNameFromMethodName(methodDoc.name()); 14.8 + String propertyName = Util.propertyNameFromMethodName(configuration, methodDoc.name()); 14.9 if (!propertyName.isEmpty()) { 14.10 String propertyMethodName = propertyName + "Property"; 14.11 for (MethodDoc member: members) {
15.1 --- a/src/share/classes/com/sun/tools/doclint/Checker.java Wed Jun 18 13:32:11 2014 -0700 15.2 +++ b/src/share/classes/com/sun/tools/doclint/Checker.java Thu Jun 26 08:46:07 2014 -0700 15.3 @@ -80,6 +80,7 @@ 15.4 import com.sun.source.util.TreePath; 15.5 import com.sun.tools.doclint.HtmlTag.AttrKind; 15.6 import com.sun.tools.javac.tree.DocPretty; 15.7 +import com.sun.tools.javac.util.StringUtils; 15.8 import static com.sun.tools.doclint.Messages.Group.*; 15.9 15.10 15.11 @@ -243,7 +244,7 @@ 15.12 markEnclosingTag(Flag.HAS_TEXT); 15.13 String name = tree.getName().toString(); 15.14 if (name.startsWith("#")) { 15.15 - int v = name.toLowerCase().startsWith("#x") 15.16 + int v = StringUtils.toLowerCase(name).startsWith("#x") 15.17 ? Integer.parseInt(name.substring(2), 16) 15.18 : Integer.parseInt(name.substring(1), 10); 15.19 if (!Entity.isValid(v)) {
16.1 --- a/src/share/classes/com/sun/tools/doclint/Env.java Wed Jun 18 13:32:11 2014 -0700 16.2 +++ b/src/share/classes/com/sun/tools/doclint/Env.java Thu Jun 26 08:46:07 2014 -0700 16.3 @@ -44,6 +44,7 @@ 16.4 import com.sun.source.util.TreePath; 16.5 import com.sun.tools.javac.model.JavacTypes; 16.6 import com.sun.tools.javac.tree.JCTree; 16.7 +import com.sun.tools.javac.util.StringUtils; 16.8 16.9 /** 16.10 * Utility container for current execution environment, 16.11 @@ -66,7 +67,7 @@ 16.12 16.13 static boolean accepts(String opt) { 16.14 for (AccessKind g: values()) 16.15 - if (opt.equals(g.name().toLowerCase())) return true; 16.16 + if (opt.equals(StringUtils.toLowerCase(g.name()))) return true; 16.17 return false; 16.18 } 16.19
17.1 --- a/src/share/classes/com/sun/tools/doclint/HtmlTag.java Wed Jun 18 13:32:11 2014 -0700 17.2 +++ b/src/share/classes/com/sun/tools/doclint/HtmlTag.java Thu Jun 26 08:46:07 2014 -0700 17.3 @@ -36,6 +36,7 @@ 17.4 import javax.lang.model.element.Name; 17.5 17.6 import static com.sun.tools.doclint.HtmlTag.Attr.*; 17.7 +import com.sun.tools.javac.util.StringUtils; 17.8 17.9 /** 17.10 * Enum representing HTML tags. 17.11 @@ -352,7 +353,7 @@ 17.12 WIDTH; 17.13 17.14 public String getText() { 17.15 - return toLowerCase(name()); 17.16 + return StringUtils.toLowerCase(name()); 17.17 } 17.18 17.19 static final Map<String,Attr> index = new HashMap<String,Attr>(); 17.20 @@ -431,11 +432,11 @@ 17.21 } 17.22 17.23 public String getText() { 17.24 - return toLowerCase(name()); 17.25 + return StringUtils.toLowerCase(name()); 17.26 } 17.27 17.28 public Attr getAttr(Name attrName) { 17.29 - return Attr.index.get(toLowerCase(attrName.toString())); 17.30 + return Attr.index.get(StringUtils.toLowerCase(attrName.toString())); 17.31 } 17.32 17.33 public AttrKind getAttrKind(Name attrName) { 17.34 @@ -457,10 +458,7 @@ 17.35 } 17.36 17.37 static HtmlTag get(Name tagName) { 17.38 - return index.get(toLowerCase(tagName.toString())); 17.39 + return index.get(StringUtils.toLowerCase(tagName.toString())); 17.40 } 17.41 17.42 - private static String toLowerCase(String s) { 17.43 - return s.toLowerCase(Locale.US); 17.44 - } 17.45 }
18.1 --- a/src/share/classes/com/sun/tools/doclint/Messages.java Wed Jun 18 13:32:11 2014 -0700 18.2 +++ b/src/share/classes/com/sun/tools/doclint/Messages.java Thu Jun 26 08:46:07 2014 -0700 18.3 @@ -1,5 +1,5 @@ 18.4 /* 18.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 18.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 18.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 18.8 * 18.9 * This code is free software; you can redistribute it and/or modify it 18.10 @@ -42,6 +42,7 @@ 18.11 import com.sun.source.doctree.DocTree; 18.12 import com.sun.source.tree.Tree; 18.13 import com.sun.tools.doclint.Env.AccessKind; 18.14 +import com.sun.tools.javac.util.StringUtils; 18.15 18.16 /** 18.17 * Message reporting for DocLint. 18.18 @@ -67,7 +68,7 @@ 18.19 SYNTAX, 18.20 REFERENCE; 18.21 18.22 - String optName() { return name().toLowerCase(); } 18.23 + String optName() { return StringUtils.toLowerCase(name()); } 18.24 String notOptName() { return "-" + optName(); } 18.25 18.26 static boolean accepts(String opt) { 18.27 @@ -158,7 +159,7 @@ 18.28 18.29 static boolean isValidOptions(String opts) { 18.30 for (String opt: opts.split(",")) { 18.31 - if (!isValidOption(opt.trim().toLowerCase())) 18.32 + if (!isValidOption(StringUtils.toLowerCase(opt.trim()))) 18.33 return false; 18.34 } 18.35 return true; 18.36 @@ -203,7 +204,7 @@ 18.37 setOption(ALL, Env.AccessKind.PRIVATE); 18.38 else { 18.39 for (String opt: opts.split(",")) 18.40 - setOption(opt.trim().toLowerCase()); 18.41 + setOption(StringUtils.toLowerCase(opt.trim())); 18.42 } 18.43 } 18.44 18.45 @@ -215,7 +216,7 @@ 18.46 18.47 int sep = arg.indexOf("/"); 18.48 if (sep > 0) { 18.49 - Env.AccessKind ak = Env.AccessKind.valueOf(arg.substring(sep + 1).toUpperCase()); 18.50 + Env.AccessKind ak = Env.AccessKind.valueOf(StringUtils.toUpperCase(arg.substring(sep + 1))); 18.51 setOption(arg.substring(0, sep), ak); 18.52 } else { 18.53 setOption(arg, null); 18.54 @@ -290,7 +291,7 @@ 18.55 out.println("By diagnostic kind..."); 18.56 Table dkindTable = new Table(); 18.57 for (Diagnostic.Kind k : Diagnostic.Kind.values()) { 18.58 - dkindTable.put(k.toString().toLowerCase(), dkindCounts[k.ordinal()]); 18.59 + dkindTable.put(StringUtils.toLowerCase(k.toString()), dkindCounts[k.ordinal()]); 18.60 } 18.61 dkindTable.print(out); 18.62 out.println();
19.1 --- a/src/share/classes/com/sun/tools/javac/code/Flags.java Wed Jun 18 13:32:11 2014 -0700 19.2 +++ b/src/share/classes/com/sun/tools/javac/code/Flags.java Thu Jun 26 08:46:07 2014 -0700 19.3 @@ -1,5 +1,5 @@ 19.4 /* 19.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 19.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 19.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 19.8 * 19.9 * This code is free software; you can redistribute it and/or modify it 19.10 @@ -33,6 +33,7 @@ 19.11 import javax.lang.model.element.Modifier; 19.12 19.13 import com.sun.tools.javac.util.Assert; 19.14 +import com.sun.tools.javac.util.StringUtils; 19.15 19.16 /** Access flags and other modifiers for Java classes and members. 19.17 * 19.18 @@ -275,6 +276,11 @@ 19.19 */ 19.20 public static final long LAMBDA_METHOD = 1L<<49; 19.21 19.22 + /** 19.23 + * Flag to control recursion in TransTypes 19.24 + */ 19.25 + public static final long TYPE_TRANSLATED = 1L<<50; 19.26 + 19.27 /** Modifier masks. 19.28 */ 19.29 public static final int 19.30 @@ -294,7 +300,8 @@ 19.31 ModifierFlags = ((long)StandardFlags & ~INTERFACE) | DEFAULT, 19.32 InterfaceMethodMask = ABSTRACT | STATIC | PUBLIC | STRICTFP | DEFAULT, 19.33 AnnotationTypeElementMask = ABSTRACT | PUBLIC, 19.34 - LocalVarFlags = FINAL | PARAMETER; 19.35 + LocalVarFlags = FINAL | PARAMETER, 19.36 + ReceiverParamFlags = PARAMETER; 19.37 19.38 19.39 public static Set<Modifier> asModifierSet(long flags) { 19.40 @@ -384,11 +391,12 @@ 19.41 BAD_OVERRIDE(Flags.BAD_OVERRIDE), 19.42 SIGNATURE_POLYMORPHIC(Flags.SIGNATURE_POLYMORPHIC), 19.43 THROWS(Flags.THROWS), 19.44 - LAMBDA_METHOD(Flags.LAMBDA_METHOD); 19.45 + LAMBDA_METHOD(Flags.LAMBDA_METHOD), 19.46 + TYPE_TRANSLATED(Flags.TYPE_TRANSLATED); 19.47 19.48 Flag(long flag) { 19.49 this.value = flag; 19.50 - this.lowercaseName = name().toLowerCase(); 19.51 + this.lowercaseName = StringUtils.toLowerCase(name()); 19.52 } 19.53 19.54 @Override
20.1 --- a/src/share/classes/com/sun/tools/javac/code/Symbol.java Wed Jun 18 13:32:11 2014 -0700 20.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java Thu Jun 26 08:46:07 2014 -0700 20.3 @@ -779,42 +779,41 @@ 20.4 20.5 @Override 20.6 public List<Attribute.Compound> getAnnotationMirrors() { 20.7 - return onlyTypeVariableAnnotations(owner.getRawTypeAttributes()); 20.8 - } 20.9 - 20.10 - private List<Attribute.Compound> onlyTypeVariableAnnotations( 20.11 - List<Attribute.TypeCompound> candidates) { 20.12 - // Declaration annotations on TypeParameters are stored in type attributes 20.13 + // Declaration annotations on type variables are stored in type attributes 20.14 + // on the owner of the TypeVariableSymbol 20.15 + List<Attribute.TypeCompound> candidates = owner.getRawTypeAttributes(); 20.16 + int index = owner.getTypeParameters().indexOf(this); 20.17 List<Attribute.Compound> res = List.nil(); 20.18 for (Attribute.TypeCompound a : candidates) { 20.19 - if (a.position.type == TargetType.CLASS_TYPE_PARAMETER || 20.20 - a.position.type == TargetType.METHOD_TYPE_PARAMETER) 20.21 + if (isCurrentSymbolsAnnotation(a, index)) 20.22 res = res.prepend(a); 20.23 } 20.24 20.25 - return res = res.reverse(); 20.26 + return res.reverse(); 20.27 } 20.28 20.29 - 20.30 - 20.31 // Helper to getAnnotation[s] 20.32 @Override 20.33 public <A extends Annotation> Attribute.Compound getAttribute(Class<A> annoType) { 20.34 - 20.35 String name = annoType.getName(); 20.36 20.37 // Declaration annotations on type variables are stored in type attributes 20.38 // on the owner of the TypeVariableSymbol 20.39 List<Attribute.TypeCompound> candidates = owner.getRawTypeAttributes(); 20.40 + int index = owner.getTypeParameters().indexOf(this); 20.41 for (Attribute.TypeCompound anno : candidates) 20.42 - if (anno.position.type == TargetType.CLASS_TYPE_PARAMETER || 20.43 - anno.position.type == TargetType.METHOD_TYPE_PARAMETER) 20.44 - if (name.contentEquals(anno.type.tsym.flatName())) 20.45 - return anno; 20.46 + if (isCurrentSymbolsAnnotation(anno, index) && 20.47 + name.contentEquals(anno.type.tsym.flatName())) 20.48 + return anno; 20.49 20.50 return null; 20.51 } 20.52 - 20.53 + //where: 20.54 + boolean isCurrentSymbolsAnnotation(Attribute.TypeCompound anno, int index) { 20.55 + return (anno.position.type == TargetType.CLASS_TYPE_PARAMETER || 20.56 + anno.position.type == TargetType.METHOD_TYPE_PARAMETER) && 20.57 + anno.position.parameter_index == index; 20.58 + } 20.59 20.60 20.61 @Override
21.1 --- a/src/share/classes/com/sun/tools/javac/code/Type.java Wed Jun 18 13:32:11 2014 -0700 21.2 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java Thu Jun 26 08:46:07 2014 -0700 21.3 @@ -72,13 +72,28 @@ 21.4 public abstract class Type extends AnnoConstruct implements TypeMirror { 21.5 21.6 /** Constant type: no type at all. */ 21.7 - public static final JCNoType noType = new JCNoType(); 21.8 + public static final JCNoType noType = new JCNoType() { 21.9 + @Override 21.10 + public String toString() { 21.11 + return "none"; 21.12 + } 21.13 + }; 21.14 21.15 /** Constant type: special type to be used during recovery of deferred expressions. */ 21.16 - public static final JCNoType recoveryType = new JCNoType(); 21.17 + public static final JCNoType recoveryType = new JCNoType(){ 21.18 + @Override 21.19 + public String toString() { 21.20 + return "recovery"; 21.21 + } 21.22 + }; 21.23 21.24 /** Constant type: special type to be used for marking stuck trees. */ 21.25 - public static final JCNoType stuckType = new JCNoType(); 21.26 + public static final JCNoType stuckType = new JCNoType() { 21.27 + @Override 21.28 + public String toString() { 21.29 + return "stuck"; 21.30 + } 21.31 + }; 21.32 21.33 /** If this switch is turned on, the names of type variables 21.34 * and anonymous classes are printed with hashcodes appended. 21.35 @@ -1643,9 +1658,6 @@ 21.36 //only change bounds if request comes from substBounds 21.37 super.addBound(ib, bound, types, update); 21.38 } 21.39 - else if (bound.hasTag(UNDETVAR) && !((UndetVar) bound).isCaptured()) { 21.40 - ((UndetVar) bound).addBound(ib.complement(), this, types, false); 21.41 - } 21.42 } 21.43 21.44 @Override
22.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java Wed Jun 18 13:32:11 2014 -0700 22.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Thu Jun 26 08:46:07 2014 -0700 22.3 @@ -135,7 +135,7 @@ 22.4 else 22.5 return wildUpperBound(w.type); 22.6 } 22.7 - else return t; 22.8 + else return t.unannotatedType(); 22.9 } 22.10 22.11 /** 22.12 @@ -147,7 +147,7 @@ 22.13 TypeVar v = (TypeVar) t.unannotatedType(); 22.14 return v.isCaptured() ? cvarUpperBound(v.bound) : v; 22.15 } 22.16 - else return t; 22.17 + else return t.unannotatedType(); 22.18 } 22.19 22.20 /** 22.21 @@ -156,10 +156,10 @@ 22.22 */ 22.23 public Type wildLowerBound(Type t) { 22.24 if (t.hasTag(WILDCARD)) { 22.25 - WildcardType w = (WildcardType) t; 22.26 + WildcardType w = (WildcardType) t.unannotatedType(); 22.27 return w.isExtendsBound() ? syms.botType : wildLowerBound(w.type); 22.28 } 22.29 - else return t; 22.30 + else return t.unannotatedType(); 22.31 } 22.32 22.33 /** 22.34 @@ -167,10 +167,11 @@ 22.35 * @param t a type 22.36 */ 22.37 public Type cvarLowerBound(Type t) { 22.38 - if (t.hasTag(TYPEVAR) && ((TypeVar) t).isCaptured()) { 22.39 - return cvarLowerBound(t.getLowerBound()); 22.40 + if (t.hasTag(TYPEVAR)) { 22.41 + TypeVar v = (TypeVar) t.unannotatedType(); 22.42 + return v.isCaptured() ? cvarLowerBound(v.getLowerBound()) : v; 22.43 } 22.44 - else return t; 22.45 + else return t.unannotatedType(); 22.46 } 22.47 // </editor-fold> 22.48 22.49 @@ -628,7 +629,7 @@ 22.50 * (ii) perform functional interface bridge calculation. 22.51 */ 22.52 public ClassSymbol makeFunctionalInterfaceClass(Env<AttrContext> env, Name name, List<Type> targets, long cflags) { 22.53 - if (targets.isEmpty() || !isFunctionalInterface(targets.head)) { 22.54 + if (targets.isEmpty()) { 22.55 return null; 22.56 } 22.57 Symbol descSym = findDescriptorSymbol(targets.head.tsym); 22.58 @@ -1221,14 +1222,35 @@ 22.59 TypeRelation isSameTypeLoose = new LooseSameTypeVisitor(); 22.60 22.61 private class LooseSameTypeVisitor extends SameTypeVisitor { 22.62 + 22.63 + /** cache of the type-variable pairs being (recursively) tested. */ 22.64 + private Set<TypePair> cache = new HashSet<>(); 22.65 + 22.66 @Override 22.67 boolean sameTypeVars(TypeVar tv1, TypeVar tv2) { 22.68 - return tv1.tsym == tv2.tsym && visit(tv1.getUpperBound(), tv2.getUpperBound()); 22.69 + return tv1.tsym == tv2.tsym && checkSameBounds(tv1, tv2); 22.70 } 22.71 @Override 22.72 protected boolean containsTypes(List<Type> ts1, List<Type> ts2) { 22.73 return containsTypeEquivalent(ts1, ts2); 22.74 } 22.75 + 22.76 + /** 22.77 + * Since type-variable bounds can be recursive, we need to protect against 22.78 + * infinite loops - where the same bounds are checked over and over recursively. 22.79 + */ 22.80 + private boolean checkSameBounds(TypeVar tv1, TypeVar tv2) { 22.81 + TypePair p = new TypePair(tv1, tv2, true); 22.82 + if (cache.add(p)) { 22.83 + try { 22.84 + return visit(tv1.getUpperBound(), tv2.getUpperBound()); 22.85 + } finally { 22.86 + cache.remove(p); 22.87 + } 22.88 + } else { 22.89 + return false; 22.90 + } 22.91 + } 22.92 }; 22.93 22.94 /** 22.95 @@ -1375,7 +1397,7 @@ 22.96 // debugContainsType(t, s); 22.97 return isSameWildcard(t, s) 22.98 || isCaptureOf(s, t) 22.99 - || ((t.isExtendsBound() || isSubtypeNoCapture(wildLowerBound(t), wildLowerBound(s))) && 22.100 + || ((t.isExtendsBound() || isSubtypeNoCapture(wildLowerBound(t), cvarLowerBound(wildLowerBound(s)))) && 22.101 // TODO: JDK-8039214, cvarUpperBound call here is incorrect 22.102 (t.isSuperBound() || isSubtypeNoCapture(cvarUpperBound(wildUpperBound(s)), wildUpperBound(t)))); 22.103 } 22.104 @@ -2278,7 +2300,7 @@ 22.105 public Type visitType(Type t, Void ignored) { 22.106 // A note on wildcards: there is no good way to 22.107 // determine a supertype for a super bounded wildcard. 22.108 - return null; 22.109 + return Type.noType; 22.110 } 22.111 22.112 @Override 22.113 @@ -2445,7 +2467,7 @@ 22.114 return false; 22.115 return 22.116 t.isRaw() || 22.117 - supertype(t) != null && isDerivedRaw(supertype(t)) || 22.118 + supertype(t) != Type.noType && isDerivedRaw(supertype(t)) || 22.119 isDerivedRaw(interfaces(t)); 22.120 } 22.121 22.122 @@ -3376,9 +3398,16 @@ 22.123 class TypePair { 22.124 final Type t1; 22.125 final Type t2; 22.126 + boolean strict; 22.127 + 22.128 TypePair(Type t1, Type t2) { 22.129 + this(t1, t2, false); 22.130 + } 22.131 + 22.132 + TypePair(Type t1, Type t2, boolean strict) { 22.133 this.t1 = t1; 22.134 this.t2 = t2; 22.135 + this.strict = strict; 22.136 } 22.137 @Override 22.138 public int hashCode() { 22.139 @@ -3389,8 +3418,8 @@ 22.140 if (!(obj instanceof TypePair)) 22.141 return false; 22.142 TypePair typePair = (TypePair)obj; 22.143 - return isSameType(t1, typePair.t1) 22.144 - && isSameType(t2, typePair.t2); 22.145 + return isSameType(t1, typePair.t1, strict) 22.146 + && isSameType(t2, typePair.t2, strict); 22.147 } 22.148 } 22.149 Set<TypePair> mergeCache = new HashSet<TypePair>(); 22.150 @@ -4670,7 +4699,7 @@ 22.151 assembleClassSig(rawOuter 22.152 ? types.erasure(outer) 22.153 : outer); 22.154 - append('.'); 22.155 + append(rawOuter ? '$' : '.'); 22.156 Assert.check(c.flatname.startsWith(c.owner.enclClass().flatname)); 22.157 append(rawOuter 22.158 ? c.flatname.subName(c.owner.enclClass().flatname.getByteLength() + 1, c.flatname.getByteLength())
23.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Wed Jun 18 13:32:11 2014 -0700 23.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Thu Jun 26 08:46:07 2014 -0700 23.3 @@ -94,6 +94,7 @@ 23.4 final Annotate annotate; 23.5 final TypeAnnotations typeAnnotations; 23.6 final DeferredLintHandler deferredLintHandler; 23.7 + final TypeEnvs typeEnvs; 23.8 23.9 public static Attr instance(Context context) { 23.10 Attr instance = context.get(attrKey); 23.11 @@ -123,6 +124,7 @@ 23.12 annotate = Annotate.instance(context); 23.13 typeAnnotations = TypeAnnotations.instance(context); 23.14 deferredLintHandler = DeferredLintHandler.instance(context); 23.15 + typeEnvs = TypeEnvs.instance(context); 23.16 23.17 Options options = Options.instance(context); 23.18 23.19 @@ -138,6 +140,7 @@ 23.20 allowTypeAnnos = source.allowTypeAnnotations(); 23.21 allowLambda = source.allowLambda(); 23.22 allowDefaultMethods = source.allowDefaultMethods(); 23.23 + allowStaticInterfaceMethods = source.allowStaticInterfaceMethods(); 23.24 sourceName = source.name; 23.25 relax = (options.isSet("-retrofit") || 23.26 options.isSet("-relax")); 23.27 @@ -195,6 +198,10 @@ 23.28 */ 23.29 boolean allowDefaultMethods; 23.30 23.31 + /** Switch: static interface methods enabled? 23.32 + */ 23.33 + boolean allowStaticInterfaceMethods; 23.34 + 23.35 /** Switch: allow references to surrounding object from anonymous 23.36 * objects during constructor call? 23.37 */ 23.38 @@ -427,7 +434,7 @@ 23.39 } 23.40 23.41 public Type attribType(JCTree node, TypeSymbol sym) { 23.42 - Env<AttrContext> env = enter.typeEnvs.get(sym); 23.43 + Env<AttrContext> env = typeEnvs.get(sym); 23.44 Env<AttrContext> localEnv = env.dup(node, env.info.dup()); 23.45 return attribTree(node, localEnv, unknownTypeInfo); 23.46 } 23.47 @@ -2056,7 +2063,7 @@ 23.48 tree.constructor = constructor.baseSymbol(); 23.49 23.50 final TypeSymbol csym = clazztype.tsym; 23.51 - ResultInfo diamondResult = new ResultInfo(MTH, newMethodTemplate(resultInfo.pt, argtypes, typeargtypes), new Check.NestedCheckContext(resultInfo.checkContext) { 23.52 + ResultInfo diamondResult = new ResultInfo(pkind, newMethodTemplate(resultInfo.pt, argtypes, typeargtypes), new Check.NestedCheckContext(resultInfo.checkContext) { 23.53 @Override 23.54 public void report(DiagnosticPosition _unused, JCDiagnostic details) { 23.55 enclosingContext.report(tree.clazz, 23.56 @@ -2961,10 +2968,19 @@ 23.57 if (checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK && 23.58 pt != Type.recoveryType) { 23.59 //check that functional interface class is well-formed 23.60 - ClassSymbol csym = types.makeFunctionalInterfaceClass(env, 23.61 - names.empty, List.of(fExpr.targets.head), ABSTRACT); 23.62 - if (csym != null) { 23.63 - chk.checkImplementations(env.tree, csym, csym); 23.64 + try { 23.65 + /* Types.makeFunctionalInterfaceClass() may throw an exception 23.66 + * when it's executed post-inference. See the listener code 23.67 + * above. 23.68 + */ 23.69 + ClassSymbol csym = types.makeFunctionalInterfaceClass(env, 23.70 + names.empty, List.of(fExpr.targets.head), ABSTRACT); 23.71 + if (csym != null) { 23.72 + chk.checkImplementations(env.tree, csym, csym); 23.73 + } 23.74 + } catch (Types.FunctionDescriptorLookupError ex) { 23.75 + JCDiagnostic cause = ex.getDiagnostic(); 23.76 + resultInfo.checkContext.report(env.tree, cause); 23.77 } 23.78 } 23.79 } 23.80 @@ -3323,6 +3339,10 @@ 23.81 tree.pos(), site, sym.name, true); 23.82 } 23.83 } 23.84 + if (!allowStaticInterfaceMethods && sitesym.isInterface() && 23.85 + sym.isStatic() && sym.kind == MTH) { 23.86 + log.error(tree.pos(), "static.intf.method.invoke.not.supported.in.source", sourceName); 23.87 + } 23.88 } else if (sym.kind != ERR && (sym.flags() & STATIC) != 0 && sym.name != names._class) { 23.89 // If the qualified item is not a type and the selected item is static, report 23.90 // a warning. Make allowance for the class of an array type e.g. Object[].class) 23.91 @@ -4042,7 +4062,7 @@ 23.92 // ... and attribute the bound class 23.93 c.flags_field |= UNATTRIBUTED; 23.94 Env<AttrContext> cenv = enter.classEnv(cd, env); 23.95 - enter.typeEnvs.put(c, cenv); 23.96 + typeEnvs.put(c, cenv); 23.97 attribClass(c); 23.98 return owntype; 23.99 } 23.100 @@ -4192,9 +4212,9 @@ 23.101 c.flags_field &= ~UNATTRIBUTED; 23.102 23.103 // Get environment current at the point of class definition. 23.104 - Env<AttrContext> env = enter.typeEnvs.get(c); 23.105 - 23.106 - // The info.lint field in the envs stored in enter.typeEnvs is deliberately uninitialized, 23.107 + Env<AttrContext> env = typeEnvs.get(c); 23.108 + 23.109 + // The info.lint field in the envs stored in typeEnvs is deliberately uninitialized, 23.110 // because the annotations were not available at the time the env was created. Therefore, 23.111 // we look up the environment chain for the first enclosing environment for which the 23.112 // lint value is set. Typically, this is the parent env, but might be further if there
24.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Wed Jun 18 13:32:11 2014 -0700 24.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Thu Jun 26 08:46:07 2014 -0700 24.3 @@ -1038,7 +1038,9 @@ 24.4 24.5 switch (sym.kind) { 24.6 case VAR: 24.7 - if (sym.owner.kind != TYP) 24.8 + if (TreeInfo.isReceiverParam(tree)) 24.9 + mask = ReceiverParamFlags; 24.10 + else if (sym.owner.kind != TYP) 24.11 mask = LocalVarFlags; 24.12 else if ((sym.owner.flags_field & INTERFACE) != 0) 24.13 mask = implicit = InterfaceVarFlags; 24.14 @@ -1813,6 +1815,11 @@ 24.15 Type t1, 24.16 Type t2, 24.17 Type site) { 24.18 + if ((site.tsym.flags() & COMPOUND) != 0) { 24.19 + // special case for intersections: need to eliminate wildcards in supertypes 24.20 + t1 = types.capture(t1); 24.21 + t2 = types.capture(t2); 24.22 + } 24.23 return firstIncompatibility(pos, t1, t2, site) == null; 24.24 } 24.25 24.26 @@ -2672,7 +2679,7 @@ 24.27 checkClassBounds(pos, seensofar, it); 24.28 } 24.29 Type st = types.supertype(type); 24.30 - if (st != null) checkClassBounds(pos, seensofar, st); 24.31 + if (st != Type.noType) checkClassBounds(pos, seensofar, st); 24.32 } 24.33 24.34 /** Enter interface into into set.
25.1 --- a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Wed Jun 18 13:32:11 2014 -0700 25.2 +++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Thu Jun 26 08:46:07 2014 -0700 25.3 @@ -77,6 +77,7 @@ 25.4 final Types types; 25.5 final Flow flow; 25.6 final Names names; 25.7 + final TypeEnvs typeEnvs; 25.8 25.9 public static DeferredAttr instance(Context context) { 25.10 DeferredAttr instance = context.get(deferredAttrKey); 25.11 @@ -100,6 +101,7 @@ 25.12 flow = Flow.instance(context); 25.13 names = Names.instance(context); 25.14 stuckTree = make.Ident(names.empty).setType(Type.stuckType); 25.15 + typeEnvs = TypeEnvs.instance(context); 25.16 emptyDeferredAttrContext = 25.17 new DeferredAttrContext(AttrMode.CHECK, null, MethodResolutionPhase.BOX, infer.emptyContext, null, null) { 25.18 @Override 25.19 @@ -400,7 +402,7 @@ 25.20 //it is possible that nested expressions inside argument expression 25.21 //are left unchecked - in such cases there's nothing to clean up. 25.22 if (csym == null) return; 25.23 - enter.typeEnvs.remove(csym); 25.24 + typeEnvs.remove(csym); 25.25 chk.compiled.remove(csym.flatname); 25.26 syms.classes.remove(csym.flatname); 25.27 super.visitClassDef(tree); 25.28 @@ -928,7 +930,7 @@ 25.29 25.30 LambdaReturnScanner() { 25.31 super(EnumSet.of(BLOCK, CASE, CATCH, DOLOOP, FOREACHLOOP, 25.32 - FORLOOP, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP)); 25.33 + FORLOOP, IF, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP)); 25.34 } 25.35 } 25.36 25.37 @@ -1218,25 +1220,102 @@ 25.38 } 25.39 25.40 //slow path 25.41 + Symbol sym = quicklyResolveMethod(env, tree); 25.42 + 25.43 + if (sym == null) { 25.44 + result = ArgumentExpressionKind.POLY; 25.45 + return; 25.46 + } 25.47 + 25.48 + result = analyzeCandidateMethods(sym, ArgumentExpressionKind.PRIMITIVE, 25.49 + argumentKindAnalyzer); 25.50 + } 25.51 + //where 25.52 + private boolean isSimpleReceiver(JCTree rec) { 25.53 + switch (rec.getTag()) { 25.54 + case IDENT: 25.55 + return true; 25.56 + case SELECT: 25.57 + return isSimpleReceiver(((JCFieldAccess)rec).selected); 25.58 + case TYPEAPPLY: 25.59 + case TYPEARRAY: 25.60 + return true; 25.61 + case ANNOTATED_TYPE: 25.62 + return isSimpleReceiver(((JCAnnotatedType)rec).underlyingType); 25.63 + case APPLY: 25.64 + return true; 25.65 + default: 25.66 + return false; 25.67 + } 25.68 + } 25.69 + private ArgumentExpressionKind reduce(ArgumentExpressionKind kind) { 25.70 + return argumentKindAnalyzer.reduce(result, kind); 25.71 + } 25.72 + MethodAnalyzer<ArgumentExpressionKind> argumentKindAnalyzer = 25.73 + new MethodAnalyzer<ArgumentExpressionKind>() { 25.74 + @Override 25.75 + public ArgumentExpressionKind process(MethodSymbol ms) { 25.76 + return ArgumentExpressionKind.methodKind(ms, types); 25.77 + } 25.78 + @Override 25.79 + public ArgumentExpressionKind reduce(ArgumentExpressionKind kind1, 25.80 + ArgumentExpressionKind kind2) { 25.81 + switch (kind1) { 25.82 + case PRIMITIVE: return kind2; 25.83 + case NO_POLY: return kind2.isPoly() ? kind2 : kind1; 25.84 + case POLY: return kind1; 25.85 + default: 25.86 + Assert.error(); 25.87 + return null; 25.88 + } 25.89 + } 25.90 + @Override 25.91 + public boolean shouldStop(ArgumentExpressionKind result) { 25.92 + return result.isPoly(); 25.93 + } 25.94 + }; 25.95 + 25.96 + @Override 25.97 + public void visitLiteral(JCLiteral tree) { 25.98 + Type litType = attr.litType(tree.typetag); 25.99 + result = ArgumentExpressionKind.standaloneKind(litType, types); 25.100 + } 25.101 + 25.102 + @Override 25.103 + void skip(JCTree tree) { 25.104 + result = ArgumentExpressionKind.NO_POLY; 25.105 + } 25.106 + 25.107 + private Symbol quicklyResolveMethod(Env<AttrContext> env, final JCMethodInvocation tree) { 25.108 final JCExpression rec = tree.meth.hasTag(SELECT) ? 25.109 ((JCFieldAccess)tree.meth).selected : 25.110 null; 25.111 25.112 if (rec != null && !isSimpleReceiver(rec)) { 25.113 - //give up if receiver is too complex (to cut down analysis time) 25.114 - result = ArgumentExpressionKind.POLY; 25.115 - return; 25.116 + return null; 25.117 } 25.118 25.119 - Type site = rec != null ? 25.120 - attribSpeculative(rec, env, attr.unknownTypeExprInfo).type : 25.121 - env.enclClass.sym.type; 25.122 + Type site; 25.123 25.124 - while (site.hasTag(TYPEVAR)) { 25.125 - site = site.getUpperBound(); 25.126 + if (rec != null) { 25.127 + if (rec.hasTag(APPLY)) { 25.128 + Symbol recSym = quicklyResolveMethod(env, (JCMethodInvocation) rec); 25.129 + if (recSym == null) 25.130 + return null; 25.131 + Symbol resolvedReturnType = 25.132 + analyzeCandidateMethods(recSym, syms.errSymbol, returnSymbolAnalyzer); 25.133 + if (resolvedReturnType == null) 25.134 + return null; 25.135 + site = resolvedReturnType.type; 25.136 + } else { 25.137 + site = attribSpeculative(rec, env, attr.unknownTypeExprInfo).type; 25.138 + } 25.139 + } else { 25.140 + site = env.enclClass.sym.type; 25.141 } 25.142 25.143 List<Type> args = rs.dummyArgs(tree.args.length()); 25.144 + Name name = TreeInfo.name(tree.meth); 25.145 25.146 Resolve.LookupHelper lh = rs.new LookupHelper(name, site, args, List.<Type>nil(), MethodResolutionPhase.VARARITY) { 25.147 @Override 25.148 @@ -1251,61 +1330,60 @@ 25.149 } 25.150 }; 25.151 25.152 - Symbol sym = rs.lookupMethod(env, tree, site.tsym, rs.arityMethodCheck, lh); 25.153 + return rs.lookupMethod(env, tree, site.tsym, rs.arityMethodCheck, lh); 25.154 + } 25.155 + //where: 25.156 + MethodAnalyzer<Symbol> returnSymbolAnalyzer = new MethodAnalyzer<Symbol>() { 25.157 + @Override 25.158 + public Symbol process(MethodSymbol ms) { 25.159 + ArgumentExpressionKind kind = ArgumentExpressionKind.methodKind(ms, types); 25.160 + return kind != ArgumentExpressionKind.POLY ? ms.getReturnType().tsym : null; 25.161 + } 25.162 + @Override 25.163 + public Symbol reduce(Symbol s1, Symbol s2) { 25.164 + return s1 == syms.errSymbol ? s2 : s1 == s2 ? s1 : null; 25.165 + } 25.166 + @Override 25.167 + public boolean shouldStop(Symbol result) { 25.168 + return result == null; 25.169 + } 25.170 + }; 25.171 25.172 - if (sym.kind == Kinds.AMBIGUOUS) { 25.173 - Resolve.AmbiguityError err = (Resolve.AmbiguityError)sym.baseSymbol(); 25.174 - result = ArgumentExpressionKind.PRIMITIVE; 25.175 - for (Symbol s : err.ambiguousSyms) { 25.176 - if (result.isPoly()) break; 25.177 - if (s.kind == Kinds.MTH) { 25.178 - result = reduce(ArgumentExpressionKind.methodKind(s, types)); 25.179 + /** 25.180 + * Process the result of Resolve.lookupMethod. If sym is a method symbol, the result of 25.181 + * MethodAnalyzer.process is returned. If sym is an ambiguous symbol, all the candidate 25.182 + * methods are inspected one by one, using MethodAnalyzer.process. The outcomes are 25.183 + * reduced using MethodAnalyzer.reduce (using defaultValue as the first value over which 25.184 + * the reduction runs). MethodAnalyzer.shouldStop can be used to stop the inspection early. 25.185 + */ 25.186 + <E> E analyzeCandidateMethods(Symbol sym, E defaultValue, MethodAnalyzer<E> analyzer) { 25.187 + switch (sym.kind) { 25.188 + case Kinds.MTH: 25.189 + return analyzer.process((MethodSymbol) sym); 25.190 + case Kinds.AMBIGUOUS: 25.191 + Resolve.AmbiguityError err = (Resolve.AmbiguityError)sym.baseSymbol(); 25.192 + E res = defaultValue; 25.193 + for (Symbol s : err.ambiguousSyms) { 25.194 + if (s.kind == Kinds.MTH) { 25.195 + res = analyzer.reduce(res, analyzer.process((MethodSymbol) s)); 25.196 + if (analyzer.shouldStop(res)) 25.197 + return res; 25.198 + } 25.199 } 25.200 - } 25.201 - } else { 25.202 - result = (sym.kind == Kinds.MTH) ? 25.203 - ArgumentExpressionKind.methodKind(sym, types) : 25.204 - ArgumentExpressionKind.NO_POLY; 25.205 + return res; 25.206 + default: 25.207 + return defaultValue; 25.208 } 25.209 } 25.210 - //where 25.211 - private boolean isSimpleReceiver(JCTree rec) { 25.212 - switch (rec.getTag()) { 25.213 - case IDENT: 25.214 - return true; 25.215 - case SELECT: 25.216 - return isSimpleReceiver(((JCFieldAccess)rec).selected); 25.217 - case TYPEAPPLY: 25.218 - case TYPEARRAY: 25.219 - return true; 25.220 - case ANNOTATED_TYPE: 25.221 - return isSimpleReceiver(((JCAnnotatedType)rec).underlyingType); 25.222 - default: 25.223 - return false; 25.224 - } 25.225 - } 25.226 - private ArgumentExpressionKind reduce(ArgumentExpressionKind kind) { 25.227 - switch (result) { 25.228 - case PRIMITIVE: return kind; 25.229 - case NO_POLY: return kind.isPoly() ? kind : result; 25.230 - case POLY: return result; 25.231 - default: 25.232 - Assert.error(); 25.233 - return null; 25.234 - } 25.235 - } 25.236 + } 25.237 25.238 - @Override 25.239 - public void visitLiteral(JCLiteral tree) { 25.240 - Type litType = attr.litType(tree.typetag); 25.241 - result = ArgumentExpressionKind.standaloneKind(litType, types); 25.242 - } 25.243 + /** Analyzer for methods - used by analyzeCandidateMethods. */ 25.244 + interface MethodAnalyzer<E> { 25.245 + E process(MethodSymbol ms); 25.246 + E reduce(E e1, E e2); 25.247 + boolean shouldStop(E result); 25.248 + } 25.249 25.250 - @Override 25.251 - void skip(JCTree tree) { 25.252 - result = ArgumentExpressionKind.NO_POLY; 25.253 - } 25.254 - } 25.255 //where 25.256 private EnumSet<JCTree.Tag> deferredCheckerTags = 25.257 EnumSet.of(LAMBDA, REFERENCE, PARENS, TYPECAST,
26.1 --- a/src/share/classes/com/sun/tools/javac/comp/Enter.java Wed Jun 18 13:32:11 2014 -0700 26.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Enter.java Thu Jun 26 08:46:07 2014 -0700 26.3 @@ -105,6 +105,7 @@ 26.4 Names names; 26.5 JavaFileManager fileManager; 26.6 PkgInfo pkginfoOpt; 26.7 + TypeEnvs typeEnvs; 26.8 26.9 private final Todo todo; 26.10 26.11 @@ -142,14 +143,9 @@ 26.12 26.13 Options options = Options.instance(context); 26.14 pkginfoOpt = PkgInfo.get(options); 26.15 + typeEnvs = TypeEnvs.instance(context); 26.16 } 26.17 26.18 - /** A hashtable mapping classes and packages to the environments current 26.19 - * at the points of their definitions. 26.20 - */ 26.21 - Map<TypeSymbol,Env<AttrContext>> typeEnvs = 26.22 - new HashMap<TypeSymbol,Env<AttrContext>>(); 26.23 - 26.24 /** Accessor for typeEnvs 26.25 */ 26.26 public Env<AttrContext> getEnv(TypeSymbol sym) {
27.1 --- a/src/share/classes/com/sun/tools/javac/comp/Flow.java Wed Jun 18 13:32:11 2014 -0700 27.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java Thu Jun 26 08:46:07 2014 -0700 27.3 @@ -232,7 +232,8 @@ 27.4 } 27.5 } 27.6 27.7 - public List<Type> analyzeLambdaThrownTypes(Env<AttrContext> env, JCLambda that, TreeMaker make) { 27.8 + public List<Type> analyzeLambdaThrownTypes(final Env<AttrContext> env, 27.9 + JCLambda that, TreeMaker make) { 27.10 //we need to disable diagnostics temporarily; the problem is that if 27.11 //a lambda expression contains e.g. an unreachable statement, an error 27.12 //message will be reported and will cause compilation to skip the flow analyis 27.13 @@ -240,7 +241,13 @@ 27.14 //related errors, which will allow for more errors to be detected 27.15 Log.DiagnosticHandler diagHandler = new Log.DiscardDiagnosticHandler(log); 27.16 try { 27.17 - new AssignAnalyzer(log, syms, lint, names, enforceThisDotInit).analyzeTree(env); 27.18 + new AssignAnalyzer(log, syms, lint, names, enforceThisDotInit) { 27.19 + @Override 27.20 + protected boolean trackable(VarSymbol sym) { 27.21 + return !env.info.scope.includes(sym) && 27.22 + sym.owner.kind == MTH; 27.23 + } 27.24 + }.analyzeTree(env); 27.25 LambdaFlowAnalyzer flowAnalyzer = new LambdaFlowAnalyzer(); 27.26 flowAnalyzer.analyzeTree(env, that, make); 27.27 return flowAnalyzer.inferredThrownTypes;
28.1 --- a/src/share/classes/com/sun/tools/javac/comp/Lower.java Wed Jun 18 13:32:11 2014 -0700 28.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java Thu Jun 26 08:46:07 2014 -0700 28.3 @@ -82,6 +82,7 @@ 28.4 private ConstFold cfolder; 28.5 private Target target; 28.6 private Source source; 28.7 + private final TypeEnvs typeEnvs; 28.8 private boolean allowEnums; 28.9 private final Name dollarAssertionsDisabled; 28.10 private final Name classDollar; 28.11 @@ -103,6 +104,7 @@ 28.12 cfolder = ConstFold.instance(context); 28.13 target = Target.instance(context); 28.14 source = Source.instance(context); 28.15 + typeEnvs = TypeEnvs.instance(context); 28.16 allowEnums = source.allowEnums(); 28.17 dollarAssertionsDisabled = names. 28.18 fromString(target.syntheticNameChar() + "assertionsDisabled"); 28.19 @@ -2452,10 +2454,16 @@ 28.20 } 28.21 28.22 public void visitClassDef(JCClassDecl tree) { 28.23 + Env<AttrContext> prevEnv = attrEnv; 28.24 ClassSymbol currentClassPrev = currentClass; 28.25 MethodSymbol currentMethodSymPrev = currentMethodSym; 28.26 + 28.27 currentClass = tree.sym; 28.28 currentMethodSym = null; 28.29 + attrEnv = typeEnvs.remove(currentClass); 28.30 + if (attrEnv == null) 28.31 + attrEnv = prevEnv; 28.32 + 28.33 classdefs.put(currentClass, tree); 28.34 28.35 proxies = proxies.dup(currentClass); 28.36 @@ -2527,6 +2535,7 @@ 28.37 // Append translated tree to `translated' queue. 28.38 translated.append(tree); 28.39 28.40 + attrEnv = prevEnv; 28.41 currentClass = currentClassPrev; 28.42 currentMethodSym = currentMethodSymPrev; 28.43
29.1 --- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Wed Jun 18 13:32:11 2014 -0700 29.2 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Thu Jun 26 08:46:07 2014 -0700 29.3 @@ -86,6 +86,7 @@ 29.4 private final Target target; 29.5 private final DeferredLintHandler deferredLintHandler; 29.6 private final Lint lint; 29.7 + private final TypeEnvs typeEnvs; 29.8 29.9 public static MemberEnter instance(Context context) { 29.10 MemberEnter instance = context.get(memberEnterKey); 29.11 @@ -113,6 +114,7 @@ 29.12 target = Target.instance(context); 29.13 deferredLintHandler = DeferredLintHandler.instance(context); 29.14 lint = Lint.instance(context); 29.15 + typeEnvs = TypeEnvs.instance(context); 29.16 allowTypeAnnos = source.allowTypeAnnotations(); 29.17 allowRepeatedAnnos = source.allowRepeatedAnnotations(); 29.18 } 29.19 @@ -652,22 +654,8 @@ 29.20 attr.attribIdentAsEnumType(localEnv, (JCIdent)tree.vartype); 29.21 } else { 29.22 attr.attribType(tree.vartype, localEnv); 29.23 - if (tree.nameexpr != null) { 29.24 - attr.attribExpr(tree.nameexpr, localEnv); 29.25 - MethodSymbol m = localEnv.enclMethod.sym; 29.26 - if (m.isConstructor()) { 29.27 - Type outertype = m.owner.owner.type; 29.28 - if (outertype.hasTag(TypeTag.CLASS)) { 29.29 - checkType(tree.vartype, outertype, "incorrect.constructor.receiver.type"); 29.30 - checkType(tree.nameexpr, outertype, "incorrect.constructor.receiver.name"); 29.31 - } else { 29.32 - log.error(tree, "receiver.parameter.not.applicable.constructor.toplevel.class"); 29.33 - } 29.34 - } else { 29.35 - checkType(tree.vartype, m.owner.type, "incorrect.receiver.type"); 29.36 - checkType(tree.nameexpr, m.owner.type, "incorrect.receiver.name"); 29.37 - } 29.38 - } 29.39 + if (TreeInfo.isReceiverParam(tree)) 29.40 + checkReceiver(tree, localEnv); 29.41 } 29.42 } finally { 29.43 deferredLintHandler.setPos(prevLintPos); 29.44 @@ -714,6 +702,26 @@ 29.45 log.error(tree, diag, type, tree.type); 29.46 } 29.47 } 29.48 + void checkReceiver(JCVariableDecl tree, Env<AttrContext> localEnv) { 29.49 + attr.attribExpr(tree.nameexpr, localEnv); 29.50 + MethodSymbol m = localEnv.enclMethod.sym; 29.51 + if (m.isConstructor()) { 29.52 + Type outertype = m.owner.owner.type; 29.53 + if (outertype.hasTag(TypeTag.METHOD)) { 29.54 + // we have a local inner class 29.55 + outertype = m.owner.owner.owner.type; 29.56 + } 29.57 + if (outertype.hasTag(TypeTag.CLASS)) { 29.58 + checkType(tree.vartype, outertype, "incorrect.constructor.receiver.type"); 29.59 + checkType(tree.nameexpr, outertype, "incorrect.constructor.receiver.name"); 29.60 + } else { 29.61 + log.error(tree, "receiver.parameter.not.applicable.constructor.toplevel.class"); 29.62 + } 29.63 + } else { 29.64 + checkType(tree.vartype, m.owner.type, "incorrect.receiver.type"); 29.65 + checkType(tree.nameexpr, m.owner.type, "incorrect.receiver.name"); 29.66 + } 29.67 + } 29.68 29.69 public boolean needsLazyConstValue(JCTree tree) { 29.70 InitTreeVisitor initTreeVisitor = new InitTreeVisitor(); 29.71 @@ -1018,7 +1026,7 @@ 29.72 29.73 ClassSymbol c = (ClassSymbol)sym; 29.74 ClassType ct = (ClassType)c.type; 29.75 - Env<AttrContext> env = enter.typeEnvs.get(c); 29.76 + Env<AttrContext> env = typeEnvs.get(c); 29.77 JCClassDecl tree = (JCClassDecl)env.tree; 29.78 boolean wasFirst = isFirst; 29.79 isFirst = false;
30.1 --- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Wed Jun 18 13:32:11 2014 -0700 30.2 +++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Thu Jun 26 08:46:07 2014 -0700 30.3 @@ -967,10 +967,11 @@ 30.4 translateClass((ClassSymbol)st.tsym); 30.5 } 30.6 30.7 - Env<AttrContext> myEnv = enter.typeEnvs.remove(c); 30.8 - if (myEnv == null) { 30.9 + Env<AttrContext> myEnv = enter.getEnv(c); 30.10 + if (myEnv == null || (c.flags_field & TYPE_TRANSLATED) != 0) { 30.11 return; 30.12 } 30.13 + c.flags_field |= TYPE_TRANSLATED; 30.14 30.15 /* The two assertions below are set for early detection of any attempt 30.16 * to translate a class that:
31.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 31.2 +++ b/src/share/classes/com/sun/tools/javac/comp/TypeEnvs.java Thu Jun 26 08:46:07 2014 -0700 31.3 @@ -0,0 +1,63 @@ 31.4 +/* 31.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 31.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 31.7 + * 31.8 + * This code is free software; you can redistribute it and/or modify it 31.9 + * under the terms of the GNU General Public License version 2 only, as 31.10 + * published by the Free Software Foundation. Oracle designates this 31.11 + * particular file as subject to the "Classpath" exception as provided 31.12 + * by Oracle in the LICENSE file that accompanied this code. 31.13 + * 31.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 31.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 31.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 31.17 + * version 2 for more details (a copy is included in the LICENSE file that 31.18 + * accompanied this code). 31.19 + * 31.20 + * You should have received a copy of the GNU General Public License version 31.21 + * 2 along with this work; if not, write to the Free Software Foundation, 31.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 31.23 + * 31.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 31.25 + * or visit www.oracle.com if you need additional information or have any 31.26 + * questions. 31.27 + */ 31.28 + 31.29 +package com.sun.tools.javac.comp; 31.30 + 31.31 +import java.util.Collection; 31.32 +import java.util.HashMap; 31.33 +import com.sun.tools.javac.code.Symbol.TypeSymbol; 31.34 +import com.sun.tools.javac.util.Context; 31.35 + 31.36 +/** This class contains the type environments used by Enter, MemberEnter, 31.37 + * Attr, DeferredAttr, and Lower. 31.38 + * 31.39 + * <p><b>This is NOT part of any supported API. 31.40 + * If you write code that depends on this, you do so at your own risk. 31.41 + * This code and its internal interfaces are subject to change or 31.42 + * deletion without notice.</b> 31.43 + */ 31.44 +class TypeEnvs { 31.45 + private static final long serialVersionUID = 571524752489954631L; 31.46 + 31.47 + protected static final Context.Key<TypeEnvs> typeEnvsKey = new Context.Key<>(); 31.48 + public static TypeEnvs instance(Context context) { 31.49 + TypeEnvs instance = context.get(typeEnvsKey); 31.50 + if (instance == null) 31.51 + instance = new TypeEnvs(context); 31.52 + return instance; 31.53 + } 31.54 + 31.55 + private HashMap<TypeSymbol,Env<AttrContext>> map; 31.56 + protected TypeEnvs(Context context) { 31.57 + map = new HashMap<>(); 31.58 + context.put(typeEnvsKey, this); 31.59 + } 31.60 + 31.61 + Env<AttrContext> get(TypeSymbol sym) { return map.get(sym); } 31.62 + Env<AttrContext> put(TypeSymbol sym, Env<AttrContext> env) { return map.put(sym, env); } 31.63 + Env<AttrContext> remove(TypeSymbol sym) { return map.remove(sym); } 31.64 + Collection<Env<AttrContext>> values() { return map.values(); } 31.65 + void clear() { map.clear(); } 31.66 +}
32.1 --- a/src/share/classes/com/sun/tools/javac/file/Locations.java Wed Jun 18 13:32:11 2014 -0700 32.2 +++ b/src/share/classes/com/sun/tools/javac/file/Locations.java Thu Jun 26 08:46:07 2014 -0700 32.3 @@ -1,5 +1,5 @@ 32.4 /* 32.5 - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 32.6 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. 32.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 32.8 * 32.9 * This code is free software; you can redistribute it and/or modify it 32.10 @@ -51,6 +51,7 @@ 32.11 import com.sun.tools.javac.util.ListBuffer; 32.12 import com.sun.tools.javac.util.Log; 32.13 import com.sun.tools.javac.util.Options; 32.14 +import com.sun.tools.javac.util.StringUtils; 32.15 32.16 import javax.tools.JavaFileManager; 32.17 import javax.tools.StandardJavaFileManager; 32.18 @@ -717,7 +718,7 @@ 32.19 32.20 /** Is this the name of an archive file? */ 32.21 private boolean isArchive(File file) { 32.22 - String n = file.getName().toLowerCase(); 32.23 + String n = StringUtils.toLowerCase(file.getName()); 32.24 return fsInfo.isFile(file) 32.25 && (n.endsWith(".jar") || n.endsWith(".zip")); 32.26 }
33.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Code.java Wed Jun 18 13:32:11 2014 -0700 33.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java Thu Jun 26 08:46:07 2014 -0700 33.3 @@ -1925,6 +1925,13 @@ 33.4 return aliveRanges.isEmpty() ? null : aliveRanges.get(aliveRanges.size() - 1); 33.5 } 33.6 33.7 + void removeLastRange() { 33.8 + Range lastRange = lastRange(); 33.9 + if (lastRange != null) { 33.10 + aliveRanges.remove(lastRange); 33.11 + } 33.12 + } 33.13 + 33.14 @Override 33.15 public String toString() { 33.16 if (aliveRanges == null) { 33.17 @@ -1955,9 +1962,7 @@ 33.18 } 33.19 } 33.20 } else { 33.21 - if (!aliveRanges.isEmpty()) { 33.22 - aliveRanges.remove(aliveRanges.size() - 1); 33.23 - } 33.24 + removeLastRange(); 33.25 } 33.26 } 33.27 33.28 @@ -1965,16 +1970,14 @@ 33.29 if (aliveRanges.isEmpty()) { 33.30 return false; 33.31 } 33.32 - Range range = lastRange(); 33.33 - return range.length == Character.MAX_VALUE; 33.34 + return lastRange().length == Character.MAX_VALUE; 33.35 } 33.36 33.37 public boolean isLastRangeInitialized() { 33.38 if (aliveRanges.isEmpty()) { 33.39 return false; 33.40 } 33.41 - Range range = lastRange(); 33.42 - return range.start_pc != Character.MAX_VALUE; 33.43 + return lastRange().start_pc != Character.MAX_VALUE; 33.44 } 33.45 33.46 public Range getWidestRange() { 33.47 @@ -2095,7 +2098,7 @@ 33.48 v.closeRange(length); 33.49 putVar(v); 33.50 } else { 33.51 - v.lastRange().start_pc = Character.MAX_VALUE; 33.52 + v.removeLastRange(); 33.53 } 33.54 } 33.55 }
34.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java Wed Jun 18 13:32:11 2014 -0700 34.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java Thu Jun 26 08:46:07 2014 -0700 34.3 @@ -1811,8 +1811,7 @@ 34.4 genStat(tree.thenpart, env, CRT_STATEMENT | CRT_FLOW_TARGET); 34.5 thenExit = code.branch(goto_); 34.6 if (varDebugInfo && lvtRanges.containsKey(code.meth, tree.thenpart)) { 34.7 - code.closeAliveRanges(tree.thenpart, 34.8 - thenExit != null && tree.elsepart == null ? thenExit.pc : code.cp); 34.9 + code.closeAliveRanges(tree.thenpart, code.cp); 34.10 } 34.11 } 34.12 if (elseChain != null) {
35.1 --- a/src/share/classes/com/sun/tools/javac/main/Option.java Wed Jun 18 13:32:11 2014 -0700 35.2 +++ b/src/share/classes/com/sun/tools/javac/main/Option.java Thu Jun 26 08:46:07 2014 -0700 35.3 @@ -47,6 +47,7 @@ 35.4 import com.sun.tools.javac.util.Log.PrefixKind; 35.5 import com.sun.tools.javac.util.Log.WriterKind; 35.6 import com.sun.tools.javac.util.Options; 35.7 +import com.sun.tools.javac.util.StringUtils; 35.8 import static com.sun.tools.javac.main.Option.ChoiceKind.*; 35.9 import static com.sun.tools.javac.main.Option.OptionGroup.*; 35.10 import static com.sun.tools.javac.main.Option.OptionKind.*; 35.11 @@ -713,7 +714,7 @@ 35.12 String v = options.get(XPKGINFO); 35.13 return (v == null 35.14 ? PkgInfo.LEGACY 35.15 - : PkgInfo.valueOf(v.toUpperCase())); 35.16 + : PkgInfo.valueOf(StringUtils.toUpperCase(v))); 35.17 } 35.18 } 35.19
36.1 --- a/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Wed Jun 18 13:32:11 2014 -0700 36.2 +++ b/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Thu Jun 26 08:46:07 2014 -0700 36.3 @@ -57,6 +57,7 @@ 36.4 import com.sun.tools.javac.util.Names; 36.5 import com.sun.tools.javac.util.Options; 36.6 import com.sun.tools.javac.util.Position; 36.7 +import com.sun.tools.javac.util.StringUtils; 36.8 import static com.sun.tools.javac.util.LayoutCharacters.*; 36.9 36.10 /** 36.11 @@ -993,7 +994,7 @@ 36.12 "h1", "h2", "h3", "h4", "h5", "h6", "p", "pre")); 36.13 36.14 protected boolean isSentenceBreak(Name n) { 36.15 - return htmlBlockTags.contains(n.toString().toLowerCase()); 36.16 + return htmlBlockTags.contains(StringUtils.toLowerCase(n.toString())); 36.17 } 36.18 36.19 protected boolean isSentenceBreak(DCTree t) {
37.1 --- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Wed Jun 18 13:32:11 2014 -0700 37.2 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Thu Jun 26 08:46:07 2014 -0700 37.3 @@ -4068,15 +4068,16 @@ 37.4 */ 37.5 protected static class SimpleEndPosTable extends AbstractEndPosTable { 37.6 37.7 - private final Map<JCTree, Integer> endPosMap; 37.8 + private final IntHashTable endPosMap; 37.9 37.10 SimpleEndPosTable(JavacParser parser) { 37.11 super(parser); 37.12 - endPosMap = new HashMap<JCTree, Integer>(); 37.13 + endPosMap = new IntHashTable(); 37.14 } 37.15 37.16 public void storeEnd(JCTree tree, int endpos) { 37.17 - endPosMap.put(tree, errorEndPos > endpos ? errorEndPos : endpos); 37.18 + endPosMap.putAtIndex(tree, errorEndPos > endpos ? errorEndPos : endpos, 37.19 + endPosMap.lookup(tree)); 37.20 } 37.21 37.22 protected <T extends JCTree> T to(T t) { 37.23 @@ -4090,14 +4091,15 @@ 37.24 } 37.25 37.26 public int getEndPos(JCTree tree) { 37.27 - Integer value = endPosMap.get(tree); 37.28 - return (value == null) ? Position.NOPOS : value; 37.29 + int value = endPosMap.getFromIndex(endPosMap.lookup(tree)); 37.30 + // As long as Position.NOPOS==-1, this just returns value. 37.31 + return (value == -1) ? Position.NOPOS : value; 37.32 } 37.33 37.34 public int replaceTree(JCTree oldTree, JCTree newTree) { 37.35 - Integer pos = endPosMap.remove(oldTree); 37.36 - if (pos != null) { 37.37 - endPosMap.put(newTree, pos); 37.38 + int pos = endPosMap.remove(oldTree); 37.39 + if (pos != -1) { 37.40 + storeEnd(newTree, pos); 37.41 return pos; 37.42 } 37.43 return Position.NOPOS;
38.1 --- a/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java Wed Jun 18 13:32:11 2014 -0700 38.2 +++ b/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java Thu Jun 26 08:46:07 2014 -0700 38.3 @@ -1,5 +1,5 @@ 38.4 /* 38.5 - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 38.6 + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 38.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 38.8 * 38.9 * This code is free software; you can redistribute it and/or modify it 38.10 @@ -36,6 +36,7 @@ 38.11 import java.io.PrintWriter; 38.12 import java.io.Writer; 38.13 import java.util.*; 38.14 +import com.sun.tools.javac.util.StringUtils; 38.15 38.16 /** 38.17 * A processor which prints out elements. Used to implement the 38.18 @@ -202,7 +203,7 @@ 38.19 writer.print("@interface"); 38.20 break; 38.21 default: 38.22 - writer.print(kind.toString().toLowerCase()); 38.23 + writer.print(StringUtils.toLowerCase(kind.toString())); 38.24 } 38.25 writer.print(" "); 38.26 writer.print(e.getSimpleName());
39.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Wed Jun 18 13:32:11 2014 -0700 39.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Thu Jun 26 08:46:07 2014 -0700 39.3 @@ -2390,6 +2390,11 @@ 39.4 static interface methods are not supported in -source {0}\n\ 39.5 (use -source 8 or higher to enable static interface methods) 39.6 39.7 +# 0: string 39.8 +compiler.err.static.intf.method.invoke.not.supported.in.source=\ 39.9 + static interface method invocations are not supported in -source {0}\n\ 39.10 + (use -source 8 or higher to enable static interface method invocations) 39.11 + 39.12 ######################################## 39.13 # Diagnostics for verbose resolution 39.14 # used by Resolve (debug only)
40.1 --- a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Wed Jun 18 13:32:11 2014 -0700 40.2 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Thu Jun 26 08:46:07 2014 -0700 40.3 @@ -135,6 +135,14 @@ 40.4 } 40.5 } 40.6 40.7 + public static boolean isReceiverParam(JCTree tree) { 40.8 + if (tree.hasTag(VARDEF)) { 40.9 + return ((JCVariableDecl)tree).nameexpr != null; 40.10 + } else { 40.11 + return false; 40.12 + } 40.13 + } 40.14 + 40.15 /** Is there a constructor declaration in the given list of trees? 40.16 */ 40.17 public static boolean hasConstructors(List<JCTree> trees) {
41.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 41.2 +++ b/src/share/classes/com/sun/tools/javac/util/IntHashTable.java Thu Jun 26 08:46:07 2014 -0700 41.3 @@ -0,0 +1,198 @@ 41.4 +/* 41.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 41.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 41.7 + * 41.8 + * This code is free software; you can redistribute it and/or modify it 41.9 + * under the terms of the GNU General Public License version 2 only, as 41.10 + * published by the Free Software Foundation. Oracle designates this 41.11 + * particular file as subject to the "Classpath" exception as provided 41.12 + * by Oracle in the LICENSE file that accompanied this code. 41.13 + * 41.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 41.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 41.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 41.17 + * version 2 for more details (a copy is included in the LICENSE file that 41.18 + * accompanied this code). 41.19 + * 41.20 + * You should have received a copy of the GNU General Public License version 41.21 + * 2 along with this work; if not, write to the Free Software Foundation, 41.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 41.23 + * 41.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 41.25 + * or visit www.oracle.com if you need additional information or have any 41.26 + * questions. 41.27 + */ 41.28 + 41.29 +package com.sun.tools.javac.util; 41.30 + 41.31 +/** 41.32 + * A hash table that maps Object to int. 41.33 + * 41.34 + * This is a custom hash table optimised for the Object -> int 41.35 + * maps. This is done to avoid unnecessary object allocation in the image set. 41.36 + * 41.37 + * @author Charles Turner 41.38 + * @author Per Bothner 41.39 + */ 41.40 +public class IntHashTable { 41.41 + private static final int DEFAULT_INITIAL_SIZE = 64; 41.42 + protected Object[] objs; // the domain set 41.43 + protected int[] ints; // the image set 41.44 + protected int mask; // used to clip int's into the domain 41.45 + protected int num_bindings; // the number of mappings (including DELETED) 41.46 + private final static Object DELETED = new Object(); 41.47 + 41.48 + /** 41.49 + * Construct an Object -> int hash table. 41.50 + * 41.51 + * The default size of the hash table is 64 mappings. 41.52 + */ 41.53 + public IntHashTable() { 41.54 + objs = new Object[DEFAULT_INITIAL_SIZE]; 41.55 + ints = new int[DEFAULT_INITIAL_SIZE]; 41.56 + mask = DEFAULT_INITIAL_SIZE - 1; 41.57 + } 41.58 + 41.59 + /** 41.60 + * Construct an Object -> int hash table with a specified amount of mappings. 41.61 + * @param capacity The number of default mappings in this hash table. 41.62 + */ 41.63 + public IntHashTable(int capacity) { 41.64 + int log2Size = 4; 41.65 + while (capacity > (1 << log2Size)) { 41.66 + log2Size++; 41.67 + } 41.68 + capacity = 1 << log2Size; 41.69 + objs = new Object[capacity]; 41.70 + ints = new int[capacity]; 41.71 + mask = capacity - 1; 41.72 + } 41.73 + 41.74 + /** 41.75 + * Compute the hash code of a given object. 41.76 + * 41.77 + * @param key The object whose hash code is to be computed. 41.78 + * @return zero if the object is null, otherwise the identityHashCode 41.79 + */ 41.80 + public int hash(Object key) { 41.81 + return System.identityHashCode(key); 41.82 + } 41.83 + 41.84 + /** 41.85 + * Find either the index of a key's value, or the index of an available space. 41.86 + * 41.87 + * @param key The key to whose value you want to find. 41.88 + * @param hash The hash code of this key. 41.89 + * @return Either the index of the key's value, or an index pointing to 41.90 + * unoccupied space. 41.91 + */ 41.92 + public int lookup(Object key, int hash) { 41.93 + Object node; 41.94 + int hash1 = hash ^ (hash >>> 15); 41.95 + int hash2 = (hash ^ (hash << 6)) | 1; //ensure coprimeness 41.96 + int deleted = -1; 41.97 + for (int i = hash1 & mask;; i = (i + hash2) & mask) { 41.98 + node = objs[i]; 41.99 + if (node == key) 41.100 + return i; 41.101 + if (node == null) 41.102 + return deleted >= 0 ? deleted : i; 41.103 + if (node == DELETED && deleted < 0) 41.104 + deleted = i; 41.105 + } 41.106 + } 41.107 + 41.108 + /** 41.109 + * Lookup a given key's value in the hash table. 41.110 + * 41.111 + * @param key The key whose value you want to find. 41.112 + * @return Either the index of the key's value, or an index pointing to 41.113 + * unoccupied space. 41.114 + */ 41.115 + public int lookup(Object key) { 41.116 + return lookup(key, hash(key)); 41.117 + } 41.118 + 41.119 + /** 41.120 + * Return the value stored at the specified index in the table. 41.121 + * 41.122 + * @param index The index to inspect, as returned from {@link #lookup} 41.123 + * @return A non-negative integer if the index contains a non-null 41.124 + * value, or -1 if it does. 41.125 + */ 41.126 + public int getFromIndex(int index) { 41.127 + Object node = objs[index]; 41.128 + return node == null || node == DELETED ? -1 : ints[index]; 41.129 + } 41.130 + 41.131 + /** 41.132 + * Associates the specified key with the specified value in this map. 41.133 + * 41.134 + * @param key key with which the specified value is to be associated. 41.135 + * @param value value to be associated with the specified key. 41.136 + * @param index the index at which to place this binding, as returned 41.137 + * from {@link #lookup}. 41.138 + * @return previous value associated with specified key, or -1 if there was 41.139 + * no mapping for key. 41.140 + */ 41.141 + public int putAtIndex(Object key, int value, int index) { 41.142 + Object old = objs[index]; 41.143 + if (old == null || old == DELETED) { 41.144 + objs[index] = key; 41.145 + ints[index] = value; 41.146 + if (old != DELETED) 41.147 + num_bindings++; 41.148 + if (3 * num_bindings >= 2 * objs.length) 41.149 + rehash(); 41.150 + return -1; 41.151 + } else { // update existing mapping 41.152 + int oldValue = ints[index]; 41.153 + ints[index] = value; 41.154 + return oldValue; 41.155 + } 41.156 + } 41.157 + 41.158 + public int remove(Object key) { 41.159 + int index = lookup(key); 41.160 + Object old = objs[index]; 41.161 + if (old == null || old == DELETED) 41.162 + return -1; 41.163 + objs[index] = DELETED; 41.164 + return ints[index]; 41.165 + } 41.166 + 41.167 + /** 41.168 + * Expand the hash table when it exceeds the load factor. 41.169 + * 41.170 + * Rehash the existing objects. 41.171 + */ 41.172 + protected void rehash() { 41.173 + Object[] oldObjsTable = objs; 41.174 + int[] oldIntsTable = ints; 41.175 + int oldCapacity = oldObjsTable.length; 41.176 + int newCapacity = oldCapacity << 1; 41.177 + Object[] newObjTable = new Object[newCapacity]; 41.178 + int[] newIntTable = new int[newCapacity]; 41.179 + int newMask = newCapacity - 1; 41.180 + objs = newObjTable; 41.181 + ints = newIntTable; 41.182 + mask = newMask; 41.183 + num_bindings = 0; // this is recomputed below 41.184 + Object key; 41.185 + for (int i = oldIntsTable.length; --i >= 0;) { 41.186 + key = oldObjsTable[i]; 41.187 + if (key != null && key != DELETED) 41.188 + putAtIndex(key, oldIntsTable[i], lookup(key, hash(key))); 41.189 + } 41.190 + } 41.191 + 41.192 + /** 41.193 + * Removes all mappings from this map. 41.194 + */ 41.195 + public void clear() { 41.196 + for (int i = objs.length; --i >= 0;) { 41.197 + objs[i] = null; 41.198 + } 41.199 + num_bindings = 0; 41.200 + } 41.201 +}
42.1 --- a/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java Wed Jun 18 13:32:11 2014 -0700 42.2 +++ b/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java Thu Jun 26 08:46:07 2014 -0700 42.3 @@ -355,13 +355,41 @@ 42.4 private final DiagnosticType type; 42.5 private final DiagnosticSource source; 42.6 private final DiagnosticPosition position; 42.7 - private final int line; 42.8 - private final int column; 42.9 private final String key; 42.10 protected final Object[] args; 42.11 private final Set<DiagnosticFlag> flags; 42.12 private final LintCategory lintCategory; 42.13 42.14 + /** source line position (set lazily) */ 42.15 + private SourcePosition sourcePosition; 42.16 + 42.17 + /** 42.18 + * This class is used to defer the line/column position fetch logic after diagnostic construction. 42.19 + */ 42.20 + class SourcePosition { 42.21 + 42.22 + private final int line; 42.23 + private final int column; 42.24 + 42.25 + SourcePosition() { 42.26 + int n = (position == null ? Position.NOPOS : position.getPreferredPosition()); 42.27 + if (n == Position.NOPOS || source == null) 42.28 + line = column = -1; 42.29 + else { 42.30 + line = source.getLineNumber(n); 42.31 + column = source.getColumnNumber(n, true); 42.32 + } 42.33 + } 42.34 + 42.35 + public int getLineNumber() { 42.36 + return line; 42.37 + } 42.38 + 42.39 + public int getColumnNumber() { 42.40 + return column; 42.41 + } 42.42 + } 42.43 + 42.44 /** 42.45 * Create a diagnostic object. 42.46 * @param formatter the formatter to use for the diagnostic 42.47 @@ -391,14 +419,6 @@ 42.48 this.position = pos; 42.49 this.key = key; 42.50 this.args = args; 42.51 - 42.52 - int n = (pos == null ? Position.NOPOS : pos.getPreferredPosition()); 42.53 - if (n == Position.NOPOS || source == null) 42.54 - line = column = -1; 42.55 - else { 42.56 - line = source.getLineNumber(n); 42.57 - column = source.getColumnNumber(n, true); 42.58 - } 42.59 } 42.60 42.61 /** 42.62 @@ -495,7 +515,10 @@ 42.63 * @return the line number within the source referred to by this diagnostic 42.64 */ 42.65 public long getLineNumber() { 42.66 - return line; 42.67 + if (sourcePosition == null) { 42.68 + sourcePosition = new SourcePosition(); 42.69 + } 42.70 + return sourcePosition.getLineNumber(); 42.71 } 42.72 42.73 /** 42.74 @@ -503,7 +526,10 @@ 42.75 * @return the column number within the line of source referred to by this diagnostic 42.76 */ 42.77 public long getColumnNumber() { 42.78 - return column; 42.79 + if (sourcePosition == null) { 42.80 + sourcePosition = new SourcePosition(); 42.81 + } 42.82 + return sourcePosition.getColumnNumber(); 42.83 } 42.84 42.85 /**
43.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 43.2 +++ b/src/share/classes/com/sun/tools/javac/util/StringUtils.java Thu Jun 26 08:46:07 2014 -0700 43.3 @@ -0,0 +1,70 @@ 43.4 +/* 43.5 + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. 43.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 43.7 + * 43.8 + * This code is free software; you can redistribute it and/or modify it 43.9 + * under the terms of the GNU General Public License version 2 only, as 43.10 + * published by the Free Software Foundation. Oracle designates this 43.11 + * particular file as subject to the "Classpath" exception as provided 43.12 + * by Oracle in the LICENSE file that accompanied this code. 43.13 + * 43.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 43.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 43.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 43.17 + * version 2 for more details (a copy is included in the LICENSE file that 43.18 + * accompanied this code). 43.19 + * 43.20 + * You should have received a copy of the GNU General Public License version 43.21 + * 2 along with this work; if not, write to the Free Software Foundation, 43.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 43.23 + * 43.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 43.25 + * or visit www.oracle.com if you need additional information or have any 43.26 + * questions. 43.27 + */ 43.28 + 43.29 +package com.sun.tools.javac.util; 43.30 + 43.31 +import java.util.Locale; 43.32 +import java.util.regex.Matcher; 43.33 +import java.util.regex.Pattern; 43.34 + 43.35 +/** A collection of utilities for String manipulation. 43.36 + * 43.37 + * <p><b>This is NOT part of any supported API. 43.38 + * If you write code that depends on this, you do so at your own risk. 43.39 + * This code and its internal interfaces are subject to change or 43.40 + * deletion without notice.</b> 43.41 + */ 43.42 +public class StringUtils { 43.43 + 43.44 + /**Converts the given String to lower case using the {@link Locale#US US Locale}. The result 43.45 + * is independent of the default Locale in the current JVM instance. 43.46 + */ 43.47 + public static String toLowerCase(String source) { 43.48 + return source.toLowerCase(Locale.US); 43.49 + } 43.50 + 43.51 + /**Converts the given String to upper case using the {@link Locale#US US Locale}. The result 43.52 + * is independent of the default Locale in the current JVM instance. 43.53 + */ 43.54 + public static String toUpperCase(String source) { 43.55 + return source.toUpperCase(Locale.US); 43.56 + } 43.57 + 43.58 + /**Case insensitive version of {@link String#indexOf(java.lang.String)}. Equivalent to 43.59 + * {@code text.indexOf(str)}, except the matching is case insensitive. 43.60 + */ 43.61 + public static int indexOfIgnoreCase(String text, String str) { 43.62 + return indexOfIgnoreCase(text, str, 0); 43.63 + } 43.64 + 43.65 + /**Case insensitive version of {@link String#indexOf(java.lang.String, int)}. Equivalent to 43.66 + * {@code text.indexOf(str, startIndex)}, except the matching is case insensitive. 43.67 + */ 43.68 + public static int indexOfIgnoreCase(String text, String str, int startIndex) { 43.69 + Matcher m = Pattern.compile(Pattern.quote(str), Pattern.CASE_INSENSITIVE).matcher(text); 43.70 + return m.find(startIndex) ? m.start() : -1; 43.71 + } 43.72 + 43.73 +}
44.1 --- a/src/share/classes/com/sun/tools/javap/AttributeWriter.java Wed Jun 18 13:32:11 2014 -0700 44.2 +++ b/src/share/classes/com/sun/tools/javap/AttributeWriter.java Thu Jun 26 08:46:07 2014 -0700 44.3 @@ -62,6 +62,7 @@ 44.4 import com.sun.tools.classfile.Synthetic_attribute; 44.5 44.6 import static com.sun.tools.classfile.AccessFlags.*; 44.7 +import com.sun.tools.javac.util.StringUtils; 44.8 44.9 /* 44.10 * A writer for writing Attributes as text. 44.11 @@ -690,14 +691,14 @@ 44.12 } 44.13 44.14 static String toHex(int i) { 44.15 - return Integer.toString(i, 16).toUpperCase(); 44.16 + return StringUtils.toUpperCase(Integer.toString(i, 16)); 44.17 } 44.18 44.19 static String toHex(int i, int w) { 44.20 - String s = Integer.toHexString(i).toUpperCase(); 44.21 + String s = StringUtils.toUpperCase(Integer.toHexString(i)); 44.22 while (s.length() < w) 44.23 s = "0" + s; 44.24 - return s.toUpperCase(); 44.25 + return StringUtils.toUpperCase(s); 44.26 } 44.27 44.28 private AnnotationWriter annotationWriter;
45.1 --- a/src/share/classes/com/sun/tools/javap/TypeAnnotationWriter.java Wed Jun 18 13:32:11 2014 -0700 45.2 +++ b/src/share/classes/com/sun/tools/javap/TypeAnnotationWriter.java Thu Jun 26 08:46:07 2014 -0700 45.3 @@ -37,6 +37,7 @@ 45.4 import java.util.HashMap; 45.5 import java.util.List; 45.6 import java.util.Map; 45.7 +import com.sun.tools.javac.util.StringUtils; 45.8 45.9 /** 45.10 * Annotate instructions with details about type annotations. 45.11 @@ -115,7 +116,7 @@ 45.12 print("@"); 45.13 annotationWriter.write(n.anno, false, true); 45.14 print(", "); 45.15 - println(n.kind.toString().toLowerCase()); 45.16 + println(StringUtils.toLowerCase(n.kind.toString())); 45.17 } 45.18 } 45.19 }
46.1 --- a/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java Wed Jun 18 13:32:11 2014 -0700 46.2 +++ b/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java Thu Jun 26 08:46:07 2014 -0700 46.3 @@ -49,6 +49,7 @@ 46.4 import com.sun.tools.javac.util.Context; 46.5 import com.sun.tools.javac.util.Log; 46.6 import com.sun.tools.javac.util.BaseFileManager; 46.7 +import com.sun.tools.javac.util.StringUtils; 46.8 import com.sun.tools.sjavac.comp.Dependencies; 46.9 import com.sun.tools.sjavac.comp.JavaCompilerWithDeps; 46.10 import com.sun.tools.sjavac.comp.SmartFileManager; 46.11 @@ -256,7 +257,7 @@ 46.12 // Load visible sources 46.13 Set<URI> visibleSources = new HashSet<URI>(); 46.14 boolean fix_drive_letter_case = 46.15 - System.getProperty("os.name").toLowerCase().startsWith("windows"); 46.16 + StringUtils.toLowerCase(System.getProperty("os.name")).startsWith("windows"); 46.17 for (;;) { 46.18 String l = in.readLine(); 46.19 if (l == null)
47.1 --- a/test/com/sun/javadoc/testRelativeLinks/TestRelativeLinks.java Wed Jun 18 13:32:11 2014 -0700 47.2 +++ b/test/com/sun/javadoc/testRelativeLinks/TestRelativeLinks.java Thu Jun 26 08:46:07 2014 -0700 47.3 @@ -23,7 +23,7 @@ 47.4 47.5 /* 47.6 * @test 47.7 - * @bug 4460354 8014636 47.8 + * @bug 4460354 8014636 8043186 47.9 * @summary Test to make sure that relative paths are redirected in the 47.10 * output so that they are not broken. 47.11 * @author jamieh
48.1 --- a/test/com/sun/javadoc/testRelativeLinks/pkg/C.java Wed Jun 18 13:32:11 2014 -0700 48.2 +++ b/test/com/sun/javadoc/testRelativeLinks/pkg/C.java Thu Jun 26 08:46:07 2014 -0700 48.3 @@ -1,5 +1,5 @@ 48.4 /* 48.5 - * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. 48.6 + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. 48.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 48.8 * 48.9 * This code is free software; you can redistribute it and/or modify it 48.10 @@ -30,7 +30,7 @@ 48.11 public class C { 48.12 48.13 /** 48.14 - * Here is a relative link in a field: 48.15 + * Here is a relative link in a field:\u0130 48.16 * <a href="relative-field-link.html">relative field link</a>. 48.17 */ 48.18 public C field = null;
49.1 --- a/test/com/sun/javadoc/testTopOption/TestTopOption.java Wed Jun 18 13:32:11 2014 -0700 49.2 +++ b/test/com/sun/javadoc/testTopOption/TestTopOption.java Thu Jun 26 08:46:07 2014 -0700 49.3 @@ -23,7 +23,7 @@ 49.4 49.5 /* 49.6 * @test 49.7 - * @bug 6227616 49.8 + * @bug 6227616 8043186 49.9 * @summary Test the new -top option. 49.10 * @author jamieh 49.11 * @library ../lib/ 49.12 @@ -39,7 +39,7 @@ 49.13 49.14 //Javadoc arguments. 49.15 private static final String[] ARGS = new String[] { 49.16 - "-overview", "SRC_DIR + FS + overview.html", "-use", "-top", "TOP TEXT", "-d", BUG_ID, "-sourcepath", 49.17 + "-overview", SRC_DIR + FS + "overview.html", "-use", "-top", "\u0130{@docroot}TOP TEXT", "-d", BUG_ID, "-sourcepath", 49.18 SRC_DIR, "pkg" 49.19 }; 49.20
50.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 50.2 +++ b/test/tools/javac/NoStringToLower.java Thu Jun 26 08:46:07 2014 -0700 50.3 @@ -0,0 +1,136 @@ 50.4 +/* 50.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 50.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 50.7 + * 50.8 + * This code is free software; you can redistribute it and/or modify it 50.9 + * under the terms of the GNU General Public License version 2 only, as 50.10 + * published by the Free Software Foundation. 50.11 + * 50.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 50.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 50.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 50.15 + * version 2 for more details (a copy is included in the LICENSE file that 50.16 + * accompanied this code). 50.17 + * 50.18 + * You should have received a copy of the GNU General Public License version 50.19 + * 2 along with this work; if not, write to the Free Software Foundation, 50.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 50.21 + * 50.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 50.23 + * or visit www.oracle.com if you need additional information or have any 50.24 + * questions. 50.25 + */ 50.26 + 50.27 +/* 50.28 + * @test 50.29 + * @bug 8029800 50.30 + * @summary String.toLowerCase()/toUpperCase is generally dangerous, check it is not used in langtools 50.31 + */ 50.32 + 50.33 +import java.io.*; 50.34 +import java.util.*; 50.35 +import javax.tools.*; 50.36 +import com.sun.tools.classfile.*; 50.37 +import com.sun.tools.classfile.ConstantPool.CONSTANT_Methodref_info; 50.38 + 50.39 +public class NoStringToLower { 50.40 + public static void main(String... args) throws Exception { 50.41 + NoStringToLower c = new NoStringToLower(); 50.42 + if (c.run(args)) 50.43 + return; 50.44 + 50.45 + if (is_jtreg()) 50.46 + throw new Exception(c.errors + " errors occurred"); 50.47 + else 50.48 + System.exit(1); 50.49 + } 50.50 + 50.51 + static boolean is_jtreg() { 50.52 + return (System.getProperty("test.src") != null); 50.53 + } 50.54 + 50.55 + /** 50.56 + * Main entry point. 50.57 + */ 50.58 + boolean run(String... args) throws Exception { 50.59 + JavaCompiler c = ToolProvider.getSystemJavaCompiler(); 50.60 + JavaFileManager fm = c.getStandardFileManager(null, null, null); 50.61 + JavaFileManager.Location javacLoc = findJavacLocation(fm); 50.62 + String[] pkgs = { 50.63 + "javax.annotation.processing", 50.64 + "javax.lang.model", 50.65 + "javax.tools", 50.66 + "com.sun.source", 50.67 + "com.sun.tools.classfile", 50.68 + "com.sun.tools.doclet", 50.69 + "com.sun.tools.doclint", 50.70 + "com.sun.tools.javac", 50.71 + "com.sun.tools.javadoc", 50.72 + "com.sun.tools.javah", 50.73 + "com.sun.tools.javap", 50.74 + "com.sun.tools.jdeps", 50.75 + "com.sun.tools.sjavac" 50.76 + }; 50.77 + for (String pkg: pkgs) { 50.78 + for (JavaFileObject fo: fm.list(javacLoc, 50.79 + pkg, EnumSet.of(JavaFileObject.Kind.CLASS), true)) { 50.80 + scan(fo); 50.81 + } 50.82 + } 50.83 + 50.84 + return (errors == 0); 50.85 + } 50.86 + 50.87 + // depending on how the test is run, javac may be on bootclasspath or classpath 50.88 + JavaFileManager.Location findJavacLocation(JavaFileManager fm) { 50.89 + JavaFileManager.Location[] locns = 50.90 + { StandardLocation.PLATFORM_CLASS_PATH, StandardLocation.CLASS_PATH }; 50.91 + try { 50.92 + for (JavaFileManager.Location l: locns) { 50.93 + JavaFileObject fo = fm.getJavaFileForInput(l, 50.94 + "com.sun.tools.javac.Main", JavaFileObject.Kind.CLASS); 50.95 + if (fo != null) 50.96 + return l; 50.97 + } 50.98 + } catch (IOException e) { 50.99 + throw new Error(e); 50.100 + } 50.101 + throw new IllegalStateException("Cannot find javac"); 50.102 + } 50.103 + 50.104 + /** 50.105 + * Verify there are no references to String.toLowerCase() in a class file. 50.106 + */ 50.107 + void scan(JavaFileObject fo) throws IOException { 50.108 + InputStream in = fo.openInputStream(); 50.109 + try { 50.110 + ClassFile cf = ClassFile.read(in); 50.111 + for (ConstantPool.CPInfo cpinfo: cf.constant_pool.entries()) { 50.112 + if (cpinfo.getTag() == ConstantPool.CONSTANT_Methodref) { 50.113 + CONSTANT_Methodref_info ref = (CONSTANT_Methodref_info) cpinfo; 50.114 + String methodDesc = ref.getClassInfo().getName() + "." + ref.getNameAndTypeInfo().getName() + ":" + ref.getNameAndTypeInfo().getType(); 50.115 + 50.116 + if ("java/lang/String.toLowerCase:()Ljava/lang/String;".equals(methodDesc)) { 50.117 + error("found reference to String.toLowerCase() in: " + fo.getName()); 50.118 + } 50.119 + if ("java/lang/String.toUpperCase:()Ljava/lang/String;".equals(methodDesc)) { 50.120 + error("found reference to String.toLowerCase() in: " + fo.getName()); 50.121 + } 50.122 + } 50.123 + } 50.124 + } catch (ConstantPoolException ignore) { 50.125 + } finally { 50.126 + in.close(); 50.127 + } 50.128 + } 50.129 + 50.130 + /** 50.131 + * Report an error. 50.132 + */ 50.133 + void error(String msg) { 50.134 + System.err.println("Error: " + msg); 50.135 + errors++; 50.136 + } 50.137 + 50.138 + int errors; 50.139 +}
51.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 51.2 +++ b/test/tools/javac/T8038975/AccessTest.java Thu Jun 26 08:46:07 2014 -0700 51.3 @@ -0,0 +1,39 @@ 51.4 +/* 51.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 51.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 51.7 + * 51.8 + * This code is free software; you can redistribute it and/or modify it 51.9 + * under the terms of the GNU General Public License version 2 only, as 51.10 + * published by the Free Software Foundation. 51.11 + * 51.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 51.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 51.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 51.15 + * version 2 for more details (a copy is included in the LICENSE file that 51.16 + * accompanied this code). 51.17 + * 51.18 + * You should have received a copy of the GNU General Public License version 51.19 + * 2 along with this work; if not, write to the Free Software Foundation, 51.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 51.21 + * 51.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 51.23 + * or visit www.oracle.com if you need additional information or have any 51.24 + * questions. 51.25 + */ 51.26 + 51.27 +/* 51.28 + * @test 51.29 + * @bug 8038975 51.30 + * @summary Access control in enhanced for 51.31 + * @compile AccessTest.java 51.32 + */ 51.33 + 51.34 +import a.*; 51.35 +public class AccessTest { 51.36 + private static class Impl extends B { 51.37 + public void method(Inner inner) { 51.38 + for (A a : inner) 51.39 + System.out.println(a); 51.40 + } 51.41 + } 51.42 +}
52.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 52.2 +++ b/test/tools/javac/T8038975/a/A.java Thu Jun 26 08:46:07 2014 -0700 52.3 @@ -0,0 +1,25 @@ 52.4 +/* 52.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 52.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 52.7 + * 52.8 + * This code is free software; you can redistribute it and/or modify it 52.9 + * under the terms of the GNU General Public License version 2 only, as 52.10 + * published by the Free Software Foundation. 52.11 + * 52.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 52.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 52.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 52.15 + * version 2 for more details (a copy is included in the LICENSE file that 52.16 + * accompanied this code). 52.17 + * 52.18 + * You should have received a copy of the GNU General Public License version 52.19 + * 2 along with this work; if not, write to the Free Software Foundation, 52.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 52.21 + * 52.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 52.23 + * or visit www.oracle.com if you need additional information or have any 52.24 + * questions. 52.25 + */ 52.26 + 52.27 +package a; 52.28 +public class A { }
53.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 53.2 +++ b/test/tools/javac/T8038975/a/B.java Thu Jun 26 08:46:07 2014 -0700 53.3 @@ -0,0 +1,27 @@ 53.4 +/* 53.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 53.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 53.7 + * 53.8 + * This code is free software; you can redistribute it and/or modify it 53.9 + * under the terms of the GNU General Public License version 2 only, as 53.10 + * published by the Free Software Foundation. 53.11 + * 53.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 53.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 53.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 53.15 + * version 2 for more details (a copy is included in the LICENSE file that 53.16 + * accompanied this code). 53.17 + * 53.18 + * You should have received a copy of the GNU General Public License version 53.19 + * 2 along with this work; if not, write to the Free Software Foundation, 53.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 53.21 + * 53.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 53.23 + * or visit www.oracle.com if you need additional information or have any 53.24 + * questions. 53.25 + */ 53.26 + 53.27 +package a; 53.28 +public class B { 53.29 + protected abstract class Inner implements Iterable<A> { } 53.30 +}
54.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 54.2 +++ b/test/tools/javac/annotations/FinalReceiverTest.java Thu Jun 26 08:46:07 2014 -0700 54.3 @@ -0,0 +1,14 @@ 54.4 +/* 54.5 + * @test /nodynamiccopyright/ 54.6 + * @bug 8027886 54.7 + * @summary Receiver parameters must not be final 54.8 + * @compile/fail/ref=FinalReceiverTest.out -XDrawDiagnostics FinalReceiverTest.java 54.9 + */ 54.10 + 54.11 +class FinalReceiverTest { 54.12 + void m() { 54.13 + class Inner { 54.14 + Inner(final FinalReceiverTest FinalReceiverTest.this) {} 54.15 + } 54.16 + } 54.17 +}
55.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 55.2 +++ b/test/tools/javac/annotations/FinalReceiverTest.out Thu Jun 26 08:46:07 2014 -0700 55.3 @@ -0,0 +1,2 @@ 55.4 +FinalReceiverTest.java:11:43: compiler.err.mod.not.allowed.here: final 55.5 +1 error
56.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 56.2 +++ b/test/tools/javac/annotations/LocalInnerReceiverTest.java Thu Jun 26 08:46:07 2014 -0700 56.3 @@ -0,0 +1,37 @@ 56.4 +/* 56.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 56.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 56.7 + * 56.8 + * This code is free software; you can redistribute it and/or modify it 56.9 + * under the terms of the GNU General Public License version 2 only, as 56.10 + * published by the Free Software Foundation. 56.11 + * 56.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 56.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 56.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 56.15 + * version 2 for more details (a copy is included in the LICENSE file that 56.16 + * accompanied this code). 56.17 + * 56.18 + * You should have received a copy of the GNU General Public License version 56.19 + * 2 along with this work; if not, write to the Free Software Foundation, 56.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 56.21 + * 56.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 56.23 + * or visit www.oracle.com if you need additional information or have any 56.24 + * questions. 56.25 + */ 56.26 + 56.27 +/* 56.28 + * @test 56.29 + * @bug 8029042 56.30 + * @summary Receiver parameter not supported on local class constructor 56.31 + * @compile LocalInnerReceiverTest.java 56.32 + */ 56.33 + 56.34 +class LocalInnerReceiverTest { 56.35 + void m() { 56.36 + class Inner { 56.37 + Inner(LocalInnerReceiverTest LocalInnerReceiverTest.this) {} 56.38 + } 56.39 + } 56.40 +}
57.1 --- a/test/tools/javac/annotations/typeAnnotations/newlocations/Receivers.java Wed Jun 18 13:32:11 2014 -0700 57.2 +++ b/test/tools/javac/annotations/typeAnnotations/newlocations/Receivers.java Thu Jun 26 08:46:07 2014 -0700 57.3 @@ -54,14 +54,6 @@ 57.4 <T extends Runnable> void accept(@B("m") WithValue this, T r) throws Exception { } 57.5 } 57.6 57.7 -class WithFinal { 57.8 - void plain(final @B("m") WithFinal this) { } 57.9 - <T> void generic(final @B("m") WithFinal this) { } 57.10 - void withException(final @B("m") WithFinal this) throws Exception { } 57.11 - String nonVoid(final @B("m") WithFinal this) { return null; } 57.12 - <T extends Runnable> void accept(final @B("m") WithFinal this, T r) throws Exception { } 57.13 -} 57.14 - 57.15 class WithBody { 57.16 Object f; 57.17
58.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 58.2 +++ b/test/tools/javac/defaultMethods/static/StaticInvoke.java Thu Jun 26 08:46:07 2014 -0700 58.3 @@ -0,0 +1,15 @@ 58.4 +/* @test /nodynamiccopyright/ 58.5 + * @bug 8037385 58.6 + * @summary Must not allow static interface method invocation in legacy code 58.7 + * @compile -source 8 -Xlint:-options StaticInvoke.java 58.8 + * @compile/fail/ref=StaticInvoke7.out -source 7 -Xlint:-options -XDrawDiagnostics StaticInvoke.java 58.9 + * @compile/fail/ref=StaticInvoke6.out -source 6 -Xlint:-options -XDrawDiagnostics StaticInvoke.java 58.10 + */ 58.11 +import java.util.stream.Stream; 58.12 + 58.13 +class StaticInvoke { 58.14 + void test() { 58.15 + Stream.empty(); 58.16 + java.util.stream.Stream.empty(); 58.17 + } 58.18 +}
59.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 59.2 +++ b/test/tools/javac/defaultMethods/static/StaticInvoke6.out Thu Jun 26 08:46:07 2014 -0700 59.3 @@ -0,0 +1,3 @@ 59.4 +StaticInvoke.java:12:15: compiler.err.static.intf.method.invoke.not.supported.in.source: 1.6 59.5 +StaticInvoke.java:13:32: compiler.err.static.intf.method.invoke.not.supported.in.source: 1.6 59.6 +2 errors
60.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 60.2 +++ b/test/tools/javac/defaultMethods/static/StaticInvoke7.out Thu Jun 26 08:46:07 2014 -0700 60.3 @@ -0,0 +1,3 @@ 60.4 +StaticInvoke.java:12:15: compiler.err.static.intf.method.invoke.not.supported.in.source: 1.7 60.5 +StaticInvoke.java:13:32: compiler.err.static.intf.method.invoke.not.supported.in.source: 1.7 60.6 +2 errors
61.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 61.2 +++ b/test/tools/javac/diags/examples/StaticIntfMethodInvokeNotSupported.java Thu Jun 26 08:46:07 2014 -0700 61.3 @@ -0,0 +1,32 @@ 61.4 +/* 61.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 61.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 61.7 + * 61.8 + * This code is free software; you can redistribute it and/or modify it 61.9 + * under the terms of the GNU General Public License version 2 only, as 61.10 + * published by the Free Software Foundation. 61.11 + * 61.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 61.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 61.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 61.15 + * version 2 for more details (a copy is included in the LICENSE file that 61.16 + * accompanied this code). 61.17 + * 61.18 + * You should have received a copy of the GNU General Public License version 61.19 + * 2 along with this work; if not, write to the Free Software Foundation, 61.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 61.21 + * 61.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 61.23 + * or visit www.oracle.com if you need additional information or have any 61.24 + * questions. 61.25 + */ 61.26 + 61.27 +// key: compiler.err.static.intf.method.invoke.not.supported.in.source 61.28 +// options: -source 7 -Xlint:-options 61.29 +import java.util.stream.Stream; 61.30 + 61.31 +class StaticIntfMethodInvokeNotSupported { 61.32 + void test() { 61.33 + Stream.empty(); 61.34 + } 61.35 +}
62.1 --- a/test/tools/javac/flow/LVTHarness.java Wed Jun 18 13:32:11 2014 -0700 62.2 +++ b/test/tools/javac/flow/LVTHarness.java Thu Jun 26 08:46:07 2014 -0700 62.3 @@ -1,5 +1,5 @@ 62.4 /* 62.5 - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 62.6 + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. 62.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 62.8 * 62.9 * This code is free software; you can redistribute it and/or modify it 62.10 @@ -23,8 +23,8 @@ 62.11 62.12 /* 62.13 * @test 62.14 - * @bug 7047734 8027660 62.15 - * @summary The LVT is not generated correctly during some try/catch scenarios; 62.16 + * @bug 7047734 8027660 8037937 62.17 + * @summary The LVT is not generated correctly during some try/catch scenarios 62.18 * javac crash while creating LVT entry for a local variable defined in 62.19 * an inner block 62.20 * @library /tools/javac/lib 62.21 @@ -120,7 +120,7 @@ 62.22 for (Map.Entry<ElementKey, AliveRanges> entry : aliveRangeMap.entrySet()) { 62.23 if (!seenAliveRanges.contains(entry.getKey())) { 62.24 error("Redundant @AliveRanges annotation on method " + 62.25 - entry.getKey().elem); 62.26 + entry.getKey().elem + " with key " + entry.getKey()); 62.27 } 62.28 } 62.29 } 62.30 @@ -134,7 +134,7 @@ 62.31 for (Method method : classFile.methods) { 62.32 for (ElementKey elementKey: aliveRangeMap.keySet()) { 62.33 String methodDesc = method.getName(constantPool) + 62.34 - method.descriptor.getParameterTypes(constantPool); 62.35 + method.descriptor.getParameterTypes(constantPool).replace(" ", ""); 62.36 if (methodDesc.equals(elementKey.elem.toString())) { 62.37 checkMethod(constantPool, method, aliveRangeMap.get(elementKey)); 62.38 seenAliveRanges.add(elementKey);
63.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 63.2 +++ b/test/tools/javac/flow/T8042741/A.java Thu Jun 26 08:46:07 2014 -0700 63.3 @@ -0,0 +1,37 @@ 63.4 +/* 63.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 63.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 63.7 + * 63.8 + * This code is free software; you can redistribute it and/or modify it 63.9 + * under the terms of the GNU General Public License version 2 only, as 63.10 + * published by the Free Software Foundation. 63.11 + * 63.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 63.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 63.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 63.15 + * version 2 for more details (a copy is included in the LICENSE file that 63.16 + * accompanied this code). 63.17 + * 63.18 + * You should have received a copy of the GNU General Public License version 63.19 + * 2 along with this work; if not, write to the Free Software Foundation, 63.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 63.21 + * 63.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 63.23 + * or visit www.oracle.com if you need additional information or have any 63.24 + * questions. 63.25 + */ 63.26 + 63.27 +// str must be at absolute position greater than that of lambda 63.28 +// expression in PositionTest.java 63.29 +// padding..........................................................padding 63.30 +// padding..........................................................padding 63.31 +// padding..........................................................padding 63.32 +// padding..........................................................padding 63.33 +// padding..........................................................padding 63.34 + 63.35 +public class A { 63.36 + public final String str; 63.37 + { 63.38 + str = ""; 63.39 + } 63.40 +}
64.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 64.2 +++ b/test/tools/javac/flow/T8042741/PositionTest.java Thu Jun 26 08:46:07 2014 -0700 64.3 @@ -0,0 +1,62 @@ 64.4 +/* 64.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 64.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 64.7 + * 64.8 + * This code is free software; you can redistribute it and/or modify it 64.9 + * under the terms of the GNU General Public License version 2 only, as 64.10 + * published by the Free Software Foundation. 64.11 + * 64.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 64.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 64.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 64.15 + * version 2 for more details (a copy is included in the LICENSE file that 64.16 + * accompanied this code). 64.17 + * 64.18 + * You should have received a copy of the GNU General Public License version 64.19 + * 2 along with this work; if not, write to the Free Software Foundation, 64.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 64.21 + * 64.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 64.23 + * or visit www.oracle.com if you need additional information or have any 64.24 + * questions. 64.25 + */ 64.26 + 64.27 +/* @test 64.28 + * @bug 8042741 64.29 + * @summary Java 8 compiler throws NullPointerException depending location in source file 64.30 + * @compile A.java PositionTest.java 64.31 + */ 64.32 + 64.33 +public class PositionTest extends A { 64.34 + <E extends Exception> void test(SAM<E> r) throws E { 64.35 + test(() -> { System.err.println(str); }); 64.36 + } 64.37 + interface SAM<E extends Exception> { 64.38 + public void run() throws E; 64.39 + } 64.40 + void f() { 64.41 + try { 64.42 + test(() -> { 64.43 + test(() -> { 64.44 + try { 64.45 + test(() -> { System.err.println(str); }); 64.46 + System.err.println(str); 64.47 + } catch (Exception e) {} 64.48 + System.err.println(str); 64.49 + }); 64.50 + System.err.println(str); 64.51 + }); 64.52 + } catch (Exception e) { } 64.53 + } 64.54 + void g() throws Exception { 64.55 + test(() -> { 64.56 + try { 64.57 + try { 64.58 + test(() -> { System.err.println(str); }); 64.59 + } catch (Exception e) {} 64.60 + System.err.println(str); 64.61 + } catch (Exception e) {} 64.62 + System.err.println(str); 64.63 + }); 64.64 + } 64.65 +}
65.1 --- a/test/tools/javac/flow/tests/TestCaseIfElse.java Wed Jun 18 13:32:11 2014 -0700 65.2 +++ b/test/tools/javac/flow/tests/TestCaseIfElse.java Thu Jun 26 08:46:07 2014 -0700 65.3 @@ -33,7 +33,7 @@ 65.4 65.5 @AliveRange(varName="o", bytecodeStart=10, bytecodeLength=8) 65.6 @AliveRange(varName="o", bytecodeStart=21, bytecodeLength=9) 65.7 - void m2(String[] args) { 65.8 + void m2() { 65.9 Object o; 65.10 int i = 5; 65.11 if (i != 5) { 65.12 @@ -45,4 +45,19 @@ 65.13 } 65.14 o = "finish"; 65.15 } 65.16 + 65.17 + @AliveRange(varName="o", bytecodeStart=11, bytecodeLength=3) 65.18 + @AliveRange(varName="o", bytecodeStart=17, bytecodeLength=2) 65.19 + Object m3(boolean cond1, boolean cond2) { 65.20 + Object o; 65.21 + if (cond1) { 65.22 + if (cond2) { 65.23 + o = "then"; 65.24 + } else { 65.25 + o = "else"; 65.26 + return null; 65.27 + } 65.28 + } 65.29 + return null; 65.30 + } 65.31 }
66.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 66.2 +++ b/test/tools/javac/generics/diamond/T8041713/DiamondPlusUnexistingMethodRefCrashTest.java Thu Jun 26 08:46:07 2014 -0700 66.3 @@ -0,0 +1,11 @@ 66.4 +/* 66.5 + * @test /nodynamiccopyright/ 66.6 + * @bug 8041713 66.7 + * @summary Type inference of non-existent method references crashes the compiler 66.8 + * @compile/fail/ref=DiamondPlusUnexistingMethodRefCrashTest.out -XDrawDiagnostics DiamondPlusUnexistingMethodRefCrashTest.java 66.9 + */ 66.10 + 66.11 +public class DiamondPlusUnexistingMethodRefCrashTest<T> { 66.12 + DiamondPlusUnexistingMethodRefCrashTest<String> m = 66.13 + new DiamondPlusUnexistingMethodRefCrashTest<>(DiamondPlusUnexistingMethodRefCrashTest::doNotExists); 66.14 +}
67.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 67.2 +++ b/test/tools/javac/generics/diamond/T8041713/DiamondPlusUnexistingMethodRefCrashTest.out Thu Jun 26 08:46:07 2014 -0700 67.3 @@ -0,0 +1,2 @@ 67.4 +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)) 67.5 +1 error
68.1 --- a/test/tools/javac/generics/inference/7086586/T7086586.out Wed Jun 18 13:32:11 2014 -0700 68.2 +++ b/test/tools/javac/generics/inference/7086586/T7086586.out Thu Jun 26 08:46:07 2014 -0700 68.3 @@ -1,5 +1,5 @@ 68.4 -T7086586.java:14:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.captureof: 1, ?, java.lang.String) 68.5 -T7086586.java:15:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.captureof: 1, ?, java.lang.Number) 68.6 -T7086586.java:16:31: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.captureof: 1, ?, java.lang.Exception) 68.7 -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) 68.8 +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>)) 68.9 +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>)) 68.10 +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>)) 68.11 +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>)) 68.12 4 errors
69.1 --- a/test/tools/javac/generics/inference/7086586/T7086586b.java Wed Jun 18 13:32:11 2014 -0700 69.2 +++ b/test/tools/javac/generics/inference/7086586/T7086586b.java Thu Jun 26 08:46:07 2014 -0700 69.3 @@ -23,10 +23,9 @@ 69.4 69.5 /* 69.6 * @test 69.7 - * @bug 7086586 8033718 69.8 + * @bug 7086586 69.9 * 69.10 - * @summary Inference producing null type argument; inference ignores capture 69.11 - * variable as upper bound 69.12 + * @summary Inference producing null type argument 69.13 */ 69.14 import java.util.List; 69.15 69.16 @@ -41,8 +40,8 @@ 69.17 assertionCount++; 69.18 } 69.19 69.20 - <T> void m(List<? super T> dummy) { assertTrue(true); } 69.21 - <T> void m(Object dummy) { assertTrue(false); } 69.22 + <T> void m(List<? super T> dummy) { assertTrue(false); } 69.23 + <T> void m(Object dummy) { assertTrue(true); } 69.24 69.25 void test(List<?> l) { 69.26 m(l);
70.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 70.2 +++ b/test/tools/javac/generics/inference/8043725/T8043725.java Thu Jun 26 08:46:07 2014 -0700 70.3 @@ -0,0 +1,36 @@ 70.4 +/* 70.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 70.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 70.7 + * 70.8 + * This code is free software; you can redistribute it and/or modify it 70.9 + * under the terms of the GNU General Public License version 2 only, as 70.10 + * published by the Free Software Foundation. 70.11 + * 70.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 70.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 70.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 70.15 + * version 2 for more details (a copy is included in the LICENSE file that 70.16 + * accompanied this code). 70.17 + * 70.18 + * You should have received a copy of the GNU General Public License version 70.19 + * 2 along with this work; if not, write to the Free Software Foundation, 70.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 70.21 + * 70.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 70.23 + * or visit www.oracle.com if you need additional information or have any 70.24 + * questions. 70.25 + */ 70.26 + 70.27 +/** 70.28 + * @test 70.29 + * @bug 8043725 70.30 + * @summary javac fails with StackOverflowException 70.31 + * @compile T8043725.java 70.32 + */ 70.33 +class T8043725 { 70.34 + <T extends Comparable<T>> T m(T v) { 70.35 + //this will generate two upper bounds, T and Comparable<T'> respectively 70.36 + //causing infinite recursion in lub (because of JLS 18.3.1). 70.37 + return m(v); 70.38 + } 70.39 +}
71.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 71.2 +++ b/test/tools/javac/generics/inference/NestedWildcards.java Thu Jun 26 08:46:07 2014 -0700 71.3 @@ -0,0 +1,44 @@ 71.4 +/* 71.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 71.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 71.7 + * 71.8 + * This code is free software; you can redistribute it and/or modify it 71.9 + * under the terms of the GNU General Public License version 2 only, as 71.10 + * published by the Free Software Foundation. 71.11 + * 71.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 71.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 71.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 71.15 + * version 2 for more details (a copy is included in the LICENSE file that 71.16 + * accompanied this code). 71.17 + * 71.18 + * You should have received a copy of the GNU General Public License version 71.19 + * 2 along with this work; if not, write to the Free Software Foundation, 71.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 71.21 + * 71.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 71.23 + * or visit www.oracle.com if you need additional information or have any 71.24 + * questions. 71.25 + */ 71.26 + 71.27 +/* 71.28 + * @test 71.29 + * @bug 8039214 71.30 + * @summary Nested generic methods that work on wildcard-parameterized types 71.31 + * @compile NestedWildcards.java 71.32 + */ 71.33 + 71.34 +public class NestedWildcards { 71.35 + 71.36 + public static void test(Box<String> b) { 71.37 + foo(bar(b)); 71.38 + } 71.39 + private static <X> Box<? extends X> foo(Box<? extends X> ts) { 71.40 + return null; 71.41 + } 71.42 + public static <Y> Box<? extends Y> bar(Box<? extends Y> language) { 71.43 + return null; 71.44 + } 71.45 + 71.46 + interface Box<T> {} 71.47 +}
72.1 --- a/test/tools/javac/generics/wildcards/7034495/T7034495.out Wed Jun 18 13:32:11 2014 -0700 72.2 +++ b/test/tools/javac/generics/wildcards/7034495/T7034495.out Thu Jun 26 08:46:07 2014 -0700 72.3 @@ -1,2 +1,2 @@ 72.4 -T7034495.java:40:17: compiler.err.types.incompatible.diff.ret: T7034495.B<?>, T7034495.A<?>, foo() 72.5 +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() 72.6 1 error
73.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 73.2 +++ b/test/tools/javac/generics/wildcards/T8015101.java Thu Jun 26 08:46:07 2014 -0700 73.3 @@ -0,0 +1,44 @@ 73.4 +/* 73.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 73.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 73.7 + * 73.8 + * This code is free software; you can redistribute it and/or modify it 73.9 + * under the terms of the GNU General Public License version 2 only, as 73.10 + * published by the Free Software Foundation. 73.11 + * 73.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 73.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 73.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 73.15 + * version 2 for more details (a copy is included in the LICENSE file that 73.16 + * accompanied this code). 73.17 + * 73.18 + * You should have received a copy of the GNU General Public License version 73.19 + * 2 along with this work; if not, write to the Free Software Foundation, 73.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 73.21 + * 73.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 73.23 + * or visit www.oracle.com if you need additional information or have any 73.24 + * questions. 73.25 + */ 73.26 + 73.27 +/* 73.28 + * @test 73.29 + * @bug 8015101 73.30 + * @summary Mishandling of wildcards in intersection member method check 73.31 + * @compile T8015101.java 73.32 + */ 73.33 +class T8015101 { 73.34 + 73.35 + public static class Bug<X extends Child<?, ?> & Runnable> { 73.36 + } 73.37 + 73.38 + interface Parent<C> { 73.39 + public C get(); 73.40 + } 73.41 + 73.42 + interface Child<C, S extends C> extends Parent<C> { 73.43 + @Override 73.44 + public S get(); 73.45 + } 73.46 + 73.47 + }
74.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 74.2 +++ b/test/tools/javac/generics/wildcards/T8034147.java Thu Jun 26 08:46:07 2014 -0700 74.3 @@ -0,0 +1,35 @@ 74.4 +/* 74.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 74.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 74.7 + * 74.8 + * This code is free software; you can redistribute it and/or modify it 74.9 + * under the terms of the GNU General Public License version 2 only, as 74.10 + * published by the Free Software Foundation. 74.11 + * 74.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 74.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 74.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 74.15 + * version 2 for more details (a copy is included in the LICENSE file that 74.16 + * accompanied this code). 74.17 + * 74.18 + * You should have received a copy of the GNU General Public License version 74.19 + * 2 along with this work; if not, write to the Free Software Foundation, 74.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 74.21 + * 74.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 74.23 + * or visit www.oracle.com if you need additional information or have any 74.24 + * questions. 74.25 + */ 74.26 + 74.27 +/* 74.28 + * @test 74.29 + * @bug 8034147 74.30 + * @summary javac crashes with a NullPointerException during bounds checking 74.31 + * @compile T8034147.java 74.32 + */ 74.33 + 74.34 +class T8034147 { 74.35 + static class One<X extends Two<? super X>> {} 74.36 + static class Two<Y extends Three<? extends Y>> implements Three<Y> {} 74.37 + interface Three<Z> {} 74.38 +}
75.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 75.2 +++ b/test/tools/javac/lambda/T8031967.java Thu Jun 26 08:46:07 2014 -0700 75.3 @@ -0,0 +1,137 @@ 75.4 +/* 75.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 75.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 75.7 + * 75.8 + * This code is free software; you can redistribute it and/or modify it 75.9 + * under the terms of the GNU General Public License version 2 only, as 75.10 + * published by the Free Software Foundation. 75.11 + * 75.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 75.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 75.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 75.15 + * version 2 for more details (a copy is included in the LICENSE file that 75.16 + * accompanied this code). 75.17 + * 75.18 + * You should have received a copy of the GNU General Public License version 75.19 + * 2 along with this work; if not, write to the Free Software Foundation, 75.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 75.21 + * 75.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 75.23 + * or visit www.oracle.com if you need additional information or have any 75.24 + * questions. 75.25 + */ 75.26 + 75.27 +/* 75.28 + * @test 75.29 + * @bug 8031967 75.30 + * @summary Ensure javac can handle very deeply nested chain of method invocations occurring as 75.31 + * a parameter to other method invocations. 75.32 + * @run main T8031967 75.33 + */ 75.34 + 75.35 +import java.io.IOException; 75.36 +import java.net.URI; 75.37 +import java.util.Arrays; 75.38 +import java.util.List; 75.39 + 75.40 +import javax.tools.DiagnosticListener; 75.41 +import javax.tools.JavaCompiler; 75.42 +import javax.tools.JavaFileObject; 75.43 +import javax.tools.SimpleJavaFileObject; 75.44 +import javax.tools.ToolProvider; 75.45 + 75.46 +import com.sun.source.util.JavacTask; 75.47 + 75.48 +public class T8031967 { 75.49 + 75.50 + public static void main(String... args) throws IOException { 75.51 + new T8031967().run(); 75.52 + } 75.53 + 75.54 + final int depth = 50; 75.55 + 75.56 + private void run() throws IOException { 75.57 + runTestCase(true); 75.58 + runTestCase(false); 75.59 + } 75.60 + 75.61 + private void runTestCase(boolean withErrors) throws IOException { 75.62 + StringBuilder code = new StringBuilder(); 75.63 + 75.64 + code.append("public class Test {\n" + 75.65 + " private void test() {\n" + 75.66 + " GroupLayout l = new GroupLayout();\n" + 75.67 + " l.setHorizontalGroup(\n"); 75.68 + 75.69 + gen(code, depth); 75.70 + code.append(" );\n" + 75.71 + " }\n"); 75.72 + if (!withErrors) { 75.73 + code.append(" class GroupLayout {\n" + 75.74 + " ParallelGroup createParallelGroup() {return null;}\n" + 75.75 + " ParallelGroup createParallelGroup(int i) {return null;}\n" + 75.76 + " ParallelGroup createParallelGroup(int i, int j) {return null;}\n" + 75.77 + " void setHorizontalGroup(Group g) { }\n" + 75.78 + " }\n" + 75.79 + " \n" + 75.80 + " class Group {\n" + 75.81 + " Group addGroup(Group g) { return this; }\n" + 75.82 + " Group addGroup(int i, Group g) { return this; }\n" + 75.83 + " Group addGap(int i) { return this; }\n" + 75.84 + " Group addGap(long l) { return this; }\n" + 75.85 + " Group addGap(int i, int j) { return this; }\n" + 75.86 + " Group addComponent(Object c) { return this; }\n" + 75.87 + " Group addComponent(int i, Object c) { return this; }\n" + 75.88 + " }\n" + 75.89 + " class ParallelGroup extends Group {\n" + 75.90 + " Group addGroup(Group g) { return this; }\n" + 75.91 + " Group addGroup(int i, Group g) { return this; }\n" + 75.92 + " Group addGap(int i) { return this; }\n" + 75.93 + " Group addGap(int i, int j) { return this; }\n" + 75.94 + " Group addComponent(Object c) { return this; }\n" + 75.95 + " Group addComponent(int i, Object c) { return this; }\n" + 75.96 + " }\n"); 75.97 + } 75.98 + 75.99 + code.append("}\n"); 75.100 + 75.101 + JavaSource source = new JavaSource(code.toString()); 75.102 + List<JavaSource> sourceList = Arrays.asList(source); 75.103 + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); 75.104 + DiagnosticListener<JavaFileObject> noErrors = (diagnostic) -> { 75.105 + throw new IllegalStateException("Should not produce errors: " + diagnostic); 75.106 + }; 75.107 + JavacTask task = (JavacTask) compiler.getTask(null, null, withErrors ? null : noErrors, 75.108 + null, null, sourceList); 75.109 + 75.110 + task.analyze(); 75.111 + } 75.112 + 75.113 + private void gen(StringBuilder code, int depth) { 75.114 + code.append("l.createParallelGroup()\n"); 75.115 + if (depth > 0) { 75.116 + code.append(".addGroup(\n"); 75.117 + gen(code, depth - 1); 75.118 + code.append(")"); 75.119 + } 75.120 + 75.121 + code.append(".addGap(1)\n" + 75.122 + ".addComponent(new Object())\n" + 75.123 + ".addGap(1)\n" + 75.124 + ".addComponent(new Object())"); 75.125 + } 75.126 + 75.127 + class JavaSource extends SimpleJavaFileObject { 75.128 + 75.129 + final String code; 75.130 + public JavaSource(String code) { 75.131 + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); 75.132 + this.code = code; 75.133 + } 75.134 + 75.135 + @Override 75.136 + public CharSequence getCharContent(boolean ignoreEncodingErrors) { 75.137 + return code; 75.138 + } 75.139 + } 75.140 +}
76.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 76.2 +++ b/test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.java Thu Jun 26 08:46:07 2014 -0700 76.3 @@ -0,0 +1,24 @@ 76.4 +/* 76.5 + * @test /nodynamiccopyright/ 76.6 + * @bug 8038182 76.7 + * @summary javac crash with FunctionDescriptorLookupError for invalid functional interface 76.8 + * @compile/fail/ref=CrashFunctionDescriptorExceptionTest.out -XDrawDiagnostics CrashFunctionDescriptorExceptionTest.java 76.9 + */ 76.10 + 76.11 +class CrashFunctionDescriptorExceptionTest { 76.12 + 76.13 + @SuppressWarnings("unchecked") 76.14 + void m () { 76.15 + bar((B b) -> {}); 76.16 + } 76.17 + 76.18 + <E extends A<E>> void bar(I<E> i) {} 76.19 + 76.20 + class A<E> {} 76.21 + 76.22 + class B<E> extends A<E> {} 76.23 + 76.24 + interface I<E extends A<E>> { 76.25 + void foo(E e); 76.26 + } 76.27 +}
77.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 77.2 +++ b/test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.out Thu Jun 26 08:46:07 2014 -0700 77.3 @@ -0,0 +1,2 @@ 77.4 +CrashFunctionDescriptorExceptionTest.java:12:13: compiler.err.prob.found.req: (compiler.misc.no.suitable.functional.intf.inst: CrashFunctionDescriptorExceptionTest.I<CrashFunctionDescriptorExceptionTest.B>) 77.5 +1 error
78.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 78.2 +++ b/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.java Thu Jun 26 08:46:07 2014 -0700 78.3 @@ -0,0 +1,33 @@ 78.4 +/* 78.5 + * @test /nodynamiccopyright/ 78.6 + * @bug 8042759 78.7 + * @summary Lambda returning implicitly-typed lambdas considered pertinent to applicability 78.8 + * @compile/fail/ref=ImplicitLambdaConsideredForApplicabilityTest.out -XDrawDiagnostics ImplicitLambdaConsideredForApplicabilityTest.java 78.9 + */ 78.10 + 78.11 +abstract class ImplicitLambdaConsideredForApplicabilityTest { 78.12 + interface A { 78.13 + B m(int a, int b); 78.14 + } 78.15 + 78.16 + interface C { 78.17 + String m(int a, int b); 78.18 + } 78.19 + 78.20 + interface B { 78.21 + int m(int c); 78.22 + } 78.23 + 78.24 + abstract void foo(A a); 78.25 + 78.26 + abstract void foo(C c); 78.27 + 78.28 + void bar() { 78.29 + foo((int a, int b) -> { 78.30 + if(a < b) 78.31 + return c -> 0; 78.32 + else 78.33 + return c -> 0; 78.34 + }); 78.35 + } 78.36 +}
79.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 79.2 +++ b/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.out Thu Jun 26 08:46:07 2014 -0700 79.3 @@ -0,0 +1,2 @@ 79.4 +ImplicitLambdaConsideredForApplicabilityTest.java:26:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(ImplicitLambdaConsideredForApplicabilityTest.A), ImplicitLambdaConsideredForApplicabilityTest, kindname.method, foo(ImplicitLambdaConsideredForApplicabilityTest.C), ImplicitLambdaConsideredForApplicabilityTest 79.5 +1 error
80.1 --- a/test/tools/javac/processing/model/element/TestTypeParameterAnnotations.java Wed Jun 18 13:32:11 2014 -0700 80.2 +++ b/test/tools/javac/processing/model/element/TestTypeParameterAnnotations.java Thu Jun 26 08:46:07 2014 -0700 80.3 @@ -1,5 +1,5 @@ 80.4 /* 80.5 - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 80.6 + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. 80.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 80.8 * 80.9 * This code is free software; you can redistribute it and/or modify it 80.10 @@ -23,7 +23,7 @@ 80.11 80.12 /* 80.13 * @test 80.14 - * @bug 8011027 80.15 + * @bug 8011027 8046916 80.16 * @library /tools/javac/lib 80.17 * @build JavacTestingAbstractProcessor TestTypeParameterAnnotations 80.18 * @compile -processor TestTypeParameterAnnotations -proc:only TestTypeParameterAnnotations.java 80.19 @@ -33,10 +33,16 @@ 80.20 import java.lang.annotation.*; 80.21 import javax.annotation.processing.*; 80.22 import javax.lang.model.element.*; 80.23 -import javax.lang.model.util.*; 80.24 import javax.tools.*; 80.25 80.26 -public class TestTypeParameterAnnotations<@Foo @Bar @Baz T> extends JavacTestingAbstractProcessor { 80.27 +@ExpectedTypeParameterAnnotations(typeParameterName="T1", 80.28 + annotations={"Foo1", "Bar1", "Baz1"}) 80.29 +@ExpectedTypeParameterAnnotations(typeParameterName="T2", annotations={}) 80.30 +@ExpectedTypeParameterAnnotations(typeParameterName="T3", 80.31 + annotations={"Foo2", "Bar2", "Baz2"}) 80.32 +@ExpectedTypeParameterAnnotations(typeParameterName="T4", annotations={}) 80.33 +public class TestTypeParameterAnnotations<@Foo1 @Bar1 @Baz1 T1, T2, @Foo2 @Bar2 @Baz2 T3, T4> extends 80.34 + JavacTestingAbstractProcessor { 80.35 int round = 0; 80.36 80.37 public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { 80.38 @@ -74,82 +80,69 @@ 80.39 int check(Element e, List<? extends TypeParameterElement> typarams) { 80.40 if (typarams.isEmpty()) 80.41 return 0; 80.42 - if (typarams.size() != 1) 80.43 - return 0; 80.44 80.45 - for (TypeParameterElement tpe: typarams) { 80.46 - boolean b1 = checkAnnotationMirrors(tpe, tpe.getAnnotationMirrors()); 80.47 - boolean b2 = checkAnnotationMirrors(tpe, elements.getAllAnnotationMirrors(tpe)); 80.48 - boolean b3 = checkGetAnnotation(tpe); 80.49 - boolean b4 = checkGetAnnotations(tpe); 80.50 - return b1 && b2 && b3 && b4 ? 1 : 0; 80.51 + for (TypeParameterElement tpe : typarams) { 80.52 + ExpectedTypeParameterAnnotations expected = null; 80.53 + for (ExpectedTypeParameterAnnotations a : e.getAnnotationsByType(ExpectedTypeParameterAnnotations.class)) { 80.54 + if (tpe.getSimpleName().contentEquals(a.typeParameterName())) { 80.55 + expected = a; 80.56 + break; 80.57 + } 80.58 + } 80.59 + if (expected == null) { 80.60 + throw new IllegalStateException("Does not have expected values annotation."); 80.61 + } 80.62 + checkAnnotationMirrors(tpe, tpe.getAnnotationMirrors(), expected); 80.63 + checkAnnotationMirrors(tpe, elements.getAllAnnotationMirrors(tpe), expected); 80.64 + checkGetAnnotation(tpe, expected); 80.65 + checkGetAnnotations(tpe, expected); 80.66 } 80.67 - return 0; 80.68 + 80.69 + return typarams.size(); 80.70 } 80.71 80.72 - boolean checkAnnotationMirrors(TypeParameterElement tpe, List<? extends AnnotationMirror> l) { 80.73 - if (l.size() != 3) { 80.74 - error("To few annotations, got " + l.size() + 80.75 - ", should be 3", tpe); 80.76 - return false; 80.77 + void checkAnnotationMirrors(TypeParameterElement tpe, List<? extends AnnotationMirror> l, ExpectedTypeParameterAnnotations expected) { 80.78 + String[] expectedAnnotations = expected.annotations(); 80.79 + 80.80 + if (l.size() != expectedAnnotations.length) { 80.81 + error("Incorrect number of annotations, got " + l.size() + 80.82 + ", should be " + expectedAnnotations.length, tpe); 80.83 + return ; 80.84 } 80.85 80.86 - AnnotationMirror m = l.get(0); 80.87 - if (!m.getAnnotationType().asElement().equals(elements.getTypeElement("Foo"))) { 80.88 - error("Wrong type of annotation, was expecting @Foo", m.getAnnotationType().asElement()); 80.89 - return false; 80.90 + for (int i = 0; i < expectedAnnotations.length; i++) { 80.91 + AnnotationMirror m = l.get(i); 80.92 + if (!m.getAnnotationType().asElement().equals(elements.getTypeElement(expectedAnnotations[i]))) { 80.93 + error("Wrong type of annotation, was expecting @Foo", m.getAnnotationType().asElement()); 80.94 + return ; 80.95 + } 80.96 } 80.97 - m = l.get(1); 80.98 - if (!m.getAnnotationType().asElement().equals(elements.getTypeElement("Bar"))) { 80.99 - error("Wrong type of annotation, was expecting @Bar", m.getAnnotationType().asElement()); 80.100 - return false; 80.101 - } 80.102 - m = l.get(2); 80.103 - if (!m.getAnnotationType().asElement().equals(elements.getTypeElement("Baz"))) { 80.104 - error("Wrong type of annotation, was expecting @Baz", m.getAnnotationType().asElement()); 80.105 - return false; 80.106 - } 80.107 - return true; 80.108 } 80.109 80.110 - boolean checkGetAnnotation(TypeParameterElement tpe) { 80.111 - Foo f = tpe.getAnnotation(Foo.class); 80.112 - if (f == null) 80.113 - error("Expecting @Foo to be present in getAnnotation()", tpe); 80.114 + void checkGetAnnotation(TypeParameterElement tpe, ExpectedTypeParameterAnnotations expected) { 80.115 + List<String> expectedAnnotations = Arrays.asList(expected.annotations()); 80.116 80.117 - Bar b = tpe.getAnnotation(Bar.class); 80.118 - if (b == null) 80.119 - error("Expecting @Bar to be present in getAnnotation()", tpe); 80.120 + for (Class<? extends Annotation> c : ALL_ANNOTATIONS) { 80.121 + Object a = tpe.getAnnotation(c); 80.122 80.123 - Baz z = tpe.getAnnotation(Baz.class); 80.124 - if (z == null) 80.125 - error("Expecting @Baz to be present in getAnnotation()", tpe); 80.126 - 80.127 - return f != null && 80.128 - b != null && 80.129 - z != null; 80.130 + if (a != null ^ expectedAnnotations.indexOf(c.getName()) != (-1)) { 80.131 + error("Unexpected behavior for " + c.getName(), tpe); 80.132 + return ; 80.133 + } 80.134 + } 80.135 } 80.136 80.137 - boolean checkGetAnnotations(TypeParameterElement tpe) { 80.138 - Foo[] f = tpe.getAnnotationsByType(Foo.class); 80.139 - if (f.length != 1) { 80.140 - error("Expecting 1 @Foo to be present in getAnnotationsByType()", tpe); 80.141 - return false; 80.142 + void checkGetAnnotations(TypeParameterElement tpe, ExpectedTypeParameterAnnotations expected) { 80.143 + List<String> expectedAnnotations = Arrays.asList(expected.annotations()); 80.144 + 80.145 + for (Class<? extends Annotation> c : ALL_ANNOTATIONS) { 80.146 + Object[] a = tpe.getAnnotationsByType(c); 80.147 + 80.148 + if (a.length > 0 ^ expectedAnnotations.indexOf(c.getName()) != (-1)) { 80.149 + error("Unexpected behavior for " + c.getName(), tpe); 80.150 + return ; 80.151 + } 80.152 } 80.153 - 80.154 - Bar[] b = tpe.getAnnotationsByType(Bar.class); 80.155 - if (b.length != 1) { 80.156 - error("Expecting 1 @Bar to be present in getAnnotationsByType()", tpe); 80.157 - return false; 80.158 - } 80.159 - 80.160 - Baz[] z = tpe.getAnnotationsByType(Baz.class); 80.161 - if (z.length != 1) { 80.162 - error("Expecting 1 @Baz to be present in getAnnotationsByType()", tpe); 80.163 - return false; 80.164 - } 80.165 - 80.166 - return true; 80.167 } 80.168 80.169 void note(String msg) { 80.170 @@ -168,23 +161,71 @@ 80.171 messager.printMessage(Diagnostic.Kind.ERROR, msg); 80.172 } 80.173 80.174 + Class<? extends Annotation>[] ALL_ANNOTATIONS = new Class[] { 80.175 + Foo1.class, Bar1.class, Baz1.class, 80.176 + Foo2.class, Bar2.class, Baz2.class, 80.177 + }; 80.178 + 80.179 // additional generic elements to test 80.180 - <@Foo @Bar @Baz X> X m(X x) { return x; } 80.181 + @ExpectedTypeParameterAnnotations(typeParameterName="W", 80.182 + annotations={"Foo1", "Bar1", "Baz1"}) 80.183 + @ExpectedTypeParameterAnnotations(typeParameterName="X", annotations={}) 80.184 + @ExpectedTypeParameterAnnotations(typeParameterName="Y", 80.185 + annotations={"Foo2", "Bar2", "Baz2"}) 80.186 + @ExpectedTypeParameterAnnotations(typeParameterName="Z", annotations={}) 80.187 + <@Foo1 @Bar1 @Baz1 W, X, @Foo2 @Bar2 @Baz2 Y, Z> X m(X x) { return x; } 80.188 80.189 - interface Intf<@Foo @Bar @Baz X> { X m() ; } 80.190 + @ExpectedTypeParameterAnnotations(typeParameterName="W", 80.191 + annotations={"Foo1", "Bar1", "Baz1"}) 80.192 + @ExpectedTypeParameterAnnotations(typeParameterName="X", annotations={}) 80.193 + @ExpectedTypeParameterAnnotations(typeParameterName="Y", 80.194 + annotations={"Foo2", "Bar2", "Baz2"}) 80.195 + @ExpectedTypeParameterAnnotations(typeParameterName="Z", annotations={}) 80.196 + interface Intf<@Foo1 @Bar1 @Baz1 W, X, @Foo2 @Bar2 @Baz2 Y, Z> { X m() ; } 80.197 80.198 - class Class<@Foo @Bar @Baz X> { 80.199 - <@Foo @Bar @Baz Y> Class() { } 80.200 + @ExpectedTypeParameterAnnotations(typeParameterName="W", 80.201 + annotations={"Foo1", "Bar1", "Baz1"}) 80.202 + @ExpectedTypeParameterAnnotations(typeParameterName="X", annotations={}) 80.203 + @ExpectedTypeParameterAnnotations(typeParameterName="Y", 80.204 + annotations={"Foo2", "Bar2", "Baz2"}) 80.205 + @ExpectedTypeParameterAnnotations(typeParameterName="Z", annotations={}) 80.206 + class Clazz<@Foo1 @Bar1 @Baz1 W, X, @Foo2 @Bar2 @Baz2 Y, Z> { 80.207 + @ExpectedTypeParameterAnnotations(typeParameterName="W", 80.208 + annotations={"Foo1", "Bar1", "Baz1"}) 80.209 + @ExpectedTypeParameterAnnotations(typeParameterName="X", annotations={}) 80.210 + @ExpectedTypeParameterAnnotations(typeParameterName="Y", 80.211 + annotations={"Foo2", "Bar2", "Baz2"}) 80.212 + @ExpectedTypeParameterAnnotations(typeParameterName="Z", annotations={}) 80.213 + <@Foo1 @Bar1 @Baz1 W, X, @Foo2 @Bar2 @Baz2 Y, Z> Clazz() { } 80.214 } 80.215 80.216 - final int expect = 5; // top level class, plus preceding examples 80.217 + final int expect = 5 * 4; // top level class, plus preceding examples, 4 type variables each 80.218 } 80.219 80.220 @Target(ElementType.TYPE_PARAMETER) 80.221 -@interface Foo {} 80.222 +@interface Foo1 {} 80.223 80.224 @Target(ElementType.TYPE_PARAMETER) 80.225 -@interface Bar {} 80.226 +@interface Bar1 {} 80.227 80.228 @Target(ElementType.TYPE_PARAMETER) 80.229 -@interface Baz {} 80.230 +@interface Baz1 {} 80.231 + 80.232 +@Target(ElementType.TYPE_PARAMETER) 80.233 +@interface Foo2 {} 80.234 + 80.235 +@Target(ElementType.TYPE_PARAMETER) 80.236 +@interface Bar2 {} 80.237 + 80.238 +@Target(ElementType.TYPE_PARAMETER) 80.239 +@interface Baz2 {} 80.240 + 80.241 +@Repeatable(ExpectedTypeParameterAnnotationsCollection.class) 80.242 +@interface ExpectedTypeParameterAnnotations { 80.243 + public String typeParameterName(); 80.244 + public String[] annotations(); 80.245 +} 80.246 + 80.247 +@interface ExpectedTypeParameterAnnotationsCollection { 80.248 + public ExpectedTypeParameterAnnotations[] value(); 80.249 +}
81.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 81.2 +++ b/test/tools/javac/types/BadSigTest.java Thu Jun 26 08:46:07 2014 -0700 81.3 @@ -0,0 +1,40 @@ 81.4 +/* 81.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 81.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 81.7 + * 81.8 + * This code is free software; you can redistribute it and/or modify it 81.9 + * under the terms of the GNU General Public License version 2 only, as 81.10 + * published by the Free Software Foundation. 81.11 + * 81.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 81.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 81.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 81.15 + * version 2 for more details (a copy is included in the LICENSE file that 81.16 + * accompanied this code). 81.17 + * 81.18 + * You should have received a copy of the GNU General Public License version 81.19 + * 2 along with this work; if not, write to the Free Software Foundation, 81.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 81.21 + * 81.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 81.23 + * or visit www.oracle.com if you need additional information or have any 81.24 + * questions. 81.25 + */ 81.26 + 81.27 +/* 81.28 + * @test 81.29 + * @bug 8037934 81.30 + * @summary Javac generates invalid signatures for local types 81.31 + * @run main BadSigTest 81.32 + */ 81.33 + 81.34 +public class BadSigTest<Outer> { 81.35 + void m(){ 81.36 + class Local1{} 81.37 + class Local2 extends Local1{} 81.38 + Local2.class.getTypeParameters(); 81.39 + } 81.40 + public static void main(String[] args) { 81.41 + new BadSigTest().m(); 81.42 + } 81.43 +}
82.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 82.2 +++ b/test/tools/javac/util/StringUtilsTest.java Thu Jun 26 08:46:07 2014 -0700 82.3 @@ -0,0 +1,68 @@ 82.4 +/* 82.5 + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. 82.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 82.7 + * 82.8 + * This code is free software; you can redistribute it and/or modify it 82.9 + * under the terms of the GNU General Public License version 2 only, as 82.10 + * published by the Free Software Foundation. 82.11 + * 82.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 82.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 82.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 82.15 + * version 2 for more details (a copy is included in the LICENSE file that 82.16 + * accompanied this code). 82.17 + * 82.18 + * You should have received a copy of the GNU General Public License version 82.19 + * 2 along with this work; if not, write to the Free Software Foundation, 82.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 82.21 + * 82.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 82.23 + * or visit www.oracle.com if you need additional information or have any 82.24 + * questions. 82.25 + */ 82.26 + 82.27 +/** 82.28 + * @test 82.29 + * @bug 8029800 8043186 82.30 + * @summary Unit test StringUtils 82.31 + * @run main StringUtilsTest 82.32 + */ 82.33 + 82.34 +import java.util.Locale; 82.35 +import java.util.Objects; 82.36 +import com.sun.tools.javac.util.StringUtils; 82.37 + 82.38 +public class StringUtilsTest { 82.39 + public static void main(String... args) throws Exception { 82.40 + new StringUtilsTest().run(); 82.41 + } 82.42 + 82.43 + void run() throws Exception { 82.44 + Locale.setDefault(new Locale("tr", "TR")); 82.45 + 82.46 + //verify the properties of the default locale: 82.47 + assertEquals("\u0131", "I".toLowerCase()); 82.48 + assertEquals("\u0130", "i".toUpperCase()); 82.49 + 82.50 + //verify the StringUtils.toLowerCase/toUpperCase do what they should: 82.51 + assertEquals("i", StringUtils.toLowerCase("I")); 82.52 + assertEquals("I", StringUtils.toUpperCase("i")); 82.53 + 82.54 + //verify StringUtils.caseInsensitiveIndexOf works: 82.55 + assertEquals(2, StringUtils.indexOfIgnoreCase(" lookFor", "lookfor")); 82.56 + assertEquals(11, StringUtils.indexOfIgnoreCase(" lookFor LOOKfor", "lookfor", 11)); 82.57 + assertEquals(2, StringUtils.indexOfIgnoreCase("\u0130\u0130lookFor", "lookfor")); 82.58 + } 82.59 + 82.60 + void assertEquals(String expected, String actual) { 82.61 + if (!Objects.equals(expected, actual)) { 82.62 + throw new IllegalStateException("expected=" + expected + "; actual=" + actual); 82.63 + } 82.64 + } 82.65 + 82.66 + void assertEquals(int expected, int actual) { 82.67 + if (expected != actual) { 82.68 + throw new IllegalStateException("expected=" + expected + "; actual=" + actual); 82.69 + } 82.70 + } 82.71 +}