Mon, 16 Jun 2014 11:19:22 -0700
Merge
1.1 --- a/src/share/classes/com/sun/tools/classfile/Instruction.java Wed Jun 11 09:31:26 2014 -0700 1.2 +++ b/src/share/classes/com/sun/tools/classfile/Instruction.java Mon Jun 16 11:19:22 2014 -0700 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -25,6 +25,8 @@ 1.11 1.12 package com.sun.tools.classfile; 1.13 1.14 +import java.util.Locale; 1.15 + 1.16 /** 1.17 * See JVMS, chapter 6. 1.18 * 1.19 @@ -211,7 +213,7 @@ 1.20 if (opcode == null) 1.21 return "bytecode " + getUnsignedByte(0); 1.22 else 1.23 - return opcode.toString().toLowerCase(); 1.24 + return opcode.toString().toLowerCase(Locale.US); 1.25 } 1.26 1.27 /** Get the length, in bytes, of this instruction, including the opcode
2.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java Wed Jun 11 09:31:26 2014 -0700 2.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java Mon Jun 16 11:19:22 2014 -0700 2.3 @@ -37,6 +37,7 @@ 2.4 import com.sun.tools.doclint.DocLint; 2.5 import com.sun.tools.javac.file.JavacFileManager; 2.6 import com.sun.tools.javac.util.Context; 2.7 +import com.sun.tools.javac.util.StringUtils; 2.8 import com.sun.tools.javadoc.RootDocImpl; 2.9 2.10 /** 2.11 @@ -237,7 +238,7 @@ 2.12 public void setSpecificDocletOptions(String[][] options) { 2.13 for (int oi = 0; oi < options.length; ++oi) { 2.14 String[] os = options[oi]; 2.15 - String opt = os[0].toLowerCase(); 2.16 + String opt = StringUtils.toLowerCase(os[0]); 2.17 if (opt.equals("-footer")) { 2.18 footer = os[1]; 2.19 } else if (opt.equals("-header")) { 2.20 @@ -325,7 +326,7 @@ 2.21 return result; 2.22 } 2.23 // otherwise look for the options we have added 2.24 - option = option.toLowerCase(); 2.25 + option = StringUtils.toLowerCase(option); 2.26 if (option.equals("-nodeprecatedlist") || 2.27 option.equals("-noindex") || 2.28 option.equals("-notree") || 2.29 @@ -389,7 +390,7 @@ 2.30 // otherwise look at our options 2.31 for (int oi = 0; oi < options.length; ++oi) { 2.32 String[] os = options[oi]; 2.33 - String opt = os[0].toLowerCase(); 2.34 + String opt = StringUtils.toLowerCase(os[0]); 2.35 if (opt.equals("-helpfile")) { 2.36 if (nohelp == true) { 2.37 reporter.printError(getText("doclet.Option_conflict",
3.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Wed Jun 11 09:31:26 2014 -0700 3.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Mon Jun 16 11:19:22 2014 -0700 3.3 @@ -28,12 +28,15 @@ 3.4 import java.io.*; 3.5 import java.text.SimpleDateFormat; 3.6 import java.util.*; 3.7 +import java.util.regex.Matcher; 3.8 +import java.util.regex.Pattern; 3.9 3.10 import com.sun.javadoc.*; 3.11 import com.sun.tools.doclets.formats.html.markup.*; 3.12 import com.sun.tools.doclets.internal.toolkit.*; 3.13 import com.sun.tools.doclets.internal.toolkit.taglets.*; 3.14 import com.sun.tools.doclets.internal.toolkit.util.*; 3.15 +import com.sun.tools.javac.util.StringUtils; 3.16 3.17 /** 3.18 * Class for the Html Format Code Generation specific to JavaDoc. 3.19 @@ -138,42 +141,37 @@ 3.20 if (index < 0) { 3.21 return htmlstr; 3.22 } 3.23 - String lowerHtml = htmlstr.toLowerCase(); 3.24 - // Return index of first occurrence of {@docroot} 3.25 - // Note: {@docRoot} is not case sensitive when passed in w/command line option 3.26 - index = lowerHtml.indexOf("{@docroot}", index); 3.27 - if (index < 0) { 3.28 + Matcher docrootMatcher = docrootPattern.matcher(htmlstr); 3.29 + if (!docrootMatcher.find()) { 3.30 return htmlstr; 3.31 } 3.32 StringBuilder buf = new StringBuilder(); 3.33 - int previndex = 0; 3.34 - while (true) { 3.35 - final String docroot = "{@docroot}"; 3.36 - // Search for lowercase version of {@docRoot} 3.37 - index = lowerHtml.indexOf(docroot, previndex); 3.38 - // If next {@docRoot} tag not found, append rest of htmlstr and exit loop 3.39 - if (index < 0) { 3.40 - buf.append(htmlstr.substring(previndex)); 3.41 - break; 3.42 - } 3.43 - // If next {@docroot} tag found, append htmlstr up to start of tag 3.44 - buf.append(htmlstr.substring(previndex, index)); 3.45 - previndex = index + docroot.length(); 3.46 - if (configuration.docrootparent.length() > 0 && htmlstr.startsWith("/..", previndex)) { 3.47 + int prevEnd = 0; 3.48 + do { 3.49 + int match = docrootMatcher.start(); 3.50 + // append htmlstr up to start of next {@docroot} 3.51 + buf.append(htmlstr.substring(prevEnd, match)); 3.52 + prevEnd = docrootMatcher.end(); 3.53 + if (configuration.docrootparent.length() > 0 && htmlstr.startsWith("/..", prevEnd)) { 3.54 // Insert the absolute link if {@docRoot} is followed by "/..". 3.55 buf.append(configuration.docrootparent); 3.56 - previndex += 3; 3.57 + prevEnd += 3; 3.58 } else { 3.59 // Insert relative path where {@docRoot} was located 3.60 buf.append(pathToRoot.isEmpty() ? "." : pathToRoot.getPath()); 3.61 } 3.62 // Append slash if next character is not a slash 3.63 - if (previndex < htmlstr.length() && htmlstr.charAt(previndex) != '/') { 3.64 + if (prevEnd < htmlstr.length() && htmlstr.charAt(prevEnd) != '/') { 3.65 buf.append('/'); 3.66 } 3.67 - } 3.68 + } while (docrootMatcher.find()); 3.69 + buf.append(htmlstr.substring(prevEnd)); 3.70 return buf.toString(); 3.71 } 3.72 + //where: 3.73 + // Note: {@docRoot} is not case sensitive when passed in w/command line option: 3.74 + private static final Pattern docrootPattern = 3.75 + Pattern.compile(Pattern.quote("{@docroot}"), Pattern.CASE_INSENSITIVE); 3.76 3.77 /** 3.78 * Get the script to show or hide the All classes link. 3.79 @@ -1689,13 +1687,13 @@ 3.80 } 3.81 3.82 //Redirect all relative links. 3.83 - int end, begin = text.toLowerCase().indexOf("<a"); 3.84 + int end, begin = StringUtils.indexOfIgnoreCase(text, "<a"); 3.85 if(begin >= 0){ 3.86 StringBuilder textBuff = new StringBuilder(text); 3.87 3.88 while(begin >=0){ 3.89 if (textBuff.length() > begin + 2 && ! Character.isWhitespace(textBuff.charAt(begin+2))) { 3.90 - begin = textBuff.toString().toLowerCase().indexOf("<a", begin + 1); 3.91 + begin = StringUtils.indexOfIgnoreCase(textBuff.toString(), "<a", begin + 1); 3.92 continue; 3.93 } 3.94 3.95 @@ -1722,15 +1720,16 @@ 3.96 } 3.97 } 3.98 String relativeLink = textBuff.substring(begin, end); 3.99 - if (!(relativeLink.toLowerCase().startsWith("mailto:") || 3.100 - relativeLink.toLowerCase().startsWith("http:") || 3.101 - relativeLink.toLowerCase().startsWith("https:") || 3.102 - relativeLink.toLowerCase().startsWith("file:"))) { 3.103 + String relativeLinkLowerCase = StringUtils.toLowerCase(relativeLink); 3.104 + if (!(relativeLinkLowerCase.startsWith("mailto:") || 3.105 + relativeLinkLowerCase.startsWith("http:") || 3.106 + relativeLinkLowerCase.startsWith("https:") || 3.107 + relativeLinkLowerCase.startsWith("file:"))) { 3.108 relativeLink = "{@"+(new DocRootTaglet()).getName() + "}/" 3.109 + redirectPathFromRoot.resolve(relativeLink).getPath(); 3.110 textBuff.replace(begin, end, relativeLink); 3.111 } 3.112 - begin = textBuff.toString().toLowerCase().indexOf("<a", begin + 1); 3.113 + begin = StringUtils.indexOfIgnoreCase(textBuff.toString(), "<a", begin + 1); 3.114 } 3.115 return textBuff.toString(); 3.116 } 3.117 @@ -1771,7 +1770,7 @@ 3.118 break main; 3.119 ch = text.charAt(currPos); 3.120 } 3.121 - if (ch == '>' && blockTags.contains(text.substring(tagPos, currPos).toLowerCase())) { 3.122 + if (ch == '>' && blockTags.contains(StringUtils.toLowerCase(text.substring(tagPos, currPos)))) { 3.123 result.append(text, startPos, lessThanPos); 3.124 startPos = currPos + 1; 3.125 }
4.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java Wed Jun 11 09:31:26 2014 -0700 4.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java Mon Jun 16 11:19:22 2014 -0700 4.3 @@ -1,5 +1,5 @@ 4.4 /* 4.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 4.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 4.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.8 * 4.9 * This code is free software; you can redistribute it and/or modify it 4.10 @@ -31,6 +31,7 @@ 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.util.*; 4.14 +import com.sun.tools.javac.util.StringUtils; 4.15 4.16 /** 4.17 * Writes method documentation in HTML format. 4.18 @@ -331,24 +332,6 @@ 4.19 } 4.20 4.21 /** 4.22 - * Parse the <Code> tag and return the text. 4.23 - */ 4.24 - protected String parseCodeTag(String tag){ 4.25 - if(tag == null){ 4.26 - return ""; 4.27 - } 4.28 - 4.29 - String lc = tag.toLowerCase(); 4.30 - int begin = lc.indexOf("<code>"); 4.31 - int end = lc.indexOf("</code>"); 4.32 - if(begin == -1 || end == -1 || end <= begin){ 4.33 - return tag; 4.34 - } else { 4.35 - return tag.substring(begin + 6, end); 4.36 - } 4.37 - } 4.38 - 4.39 - /** 4.40 * {@inheritDoc} 4.41 */ 4.42 protected static void addImplementsInfo(HtmlDocletWriter writer,
5.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlAttr.java Wed Jun 11 09:31:26 2014 -0700 5.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlAttr.java Mon Jun 16 11:19:22 2014 -0700 5.3 @@ -25,6 +25,8 @@ 5.4 5.5 package com.sun.tools.doclets.formats.html.markup; 5.6 5.7 +import com.sun.tools.javac.util.StringUtils; 5.8 + 5.9 /** 5.10 * Enum representing HTML tag attributes. 5.11 * 5.12 @@ -64,7 +66,7 @@ 5.13 private final String value; 5.14 5.15 HtmlAttr() { 5.16 - this.value = name().toLowerCase(); 5.17 + this.value = StringUtils.toLowerCase(name()); 5.18 } 5.19 5.20 HtmlAttr(String name) {
6.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTag.java Wed Jun 11 09:31:26 2014 -0700 6.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTag.java Mon Jun 16 11:19:22 2014 -0700 6.3 @@ -25,7 +25,7 @@ 6.4 6.5 package com.sun.tools.doclets.formats.html.markup; 6.6 6.7 -import java.util.Locale; 6.8 +import com.sun.tools.javac.util.StringUtils; 6.9 6.10 /** 6.11 * Enum representing HTML tags. 6.12 @@ -117,7 +117,7 @@ 6.13 HtmlTag(BlockType blockType, EndTag endTag ) { 6.14 this.blockType = blockType; 6.15 this.endTag = endTag; 6.16 - this.value = name().toLowerCase(Locale.US); 6.17 + this.value = StringUtils.toLowerCase(name()); 6.18 } 6.19 6.20 /**
7.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java Wed Jun 11 09:31:26 2014 -0700 7.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java Mon Jun 16 11:19:22 2014 -0700 7.3 @@ -29,6 +29,7 @@ 7.4 import java.util.*; 7.5 import java.util.regex.Matcher; 7.6 import java.util.regex.Pattern; 7.7 +import javax.tools.JavaFileManager; 7.8 7.9 import com.sun.javadoc.*; 7.10 import com.sun.tools.javac.sym.Profiles; 7.11 @@ -36,7 +37,7 @@ 7.12 import com.sun.tools.doclets.internal.toolkit.builders.BuilderFactory; 7.13 import com.sun.tools.doclets.internal.toolkit.taglets.*; 7.14 import com.sun.tools.doclets.internal.toolkit.util.*; 7.15 -import javax.tools.JavaFileManager; 7.16 +import com.sun.tools.javac.util.StringUtils; 7.17 7.18 /** 7.19 * Configure the output based on the options. Doclets should sub-class 7.20 @@ -337,7 +338,7 @@ 7.21 * Negative value means error occurred. 7.22 */ 7.23 public int optionLength(String option) { 7.24 - option = option.toLowerCase(); 7.25 + option = StringUtils.toLowerCase(option); 7.26 if (option.equals("-author") || 7.27 option.equals("-docfilessubdirs") || 7.28 option.equals("-javafx") || 7.29 @@ -454,7 +455,7 @@ 7.30 // the output directory has already been created: so do that first. 7.31 for (int oi = 0; oi < options.length; ++oi) { 7.32 String[] os = options[oi]; 7.33 - String opt = os[0].toLowerCase(); 7.34 + String opt = StringUtils.toLowerCase(os[0]); 7.35 if (opt.equals("-d")) { 7.36 destDirName = addTrailingFileSep(os[1]); 7.37 docFileDestDirName = destDirName; 7.38 @@ -465,7 +466,7 @@ 7.39 7.40 for (int oi = 0; oi < options.length; ++oi) { 7.41 String[] os = options[oi]; 7.42 - String opt = os[0].toLowerCase(); 7.43 + String opt = StringUtils.toLowerCase(os[0]); 7.44 if (opt.equals("-docfilessubdirs")) { 7.45 copydocfilesubdirs = true; 7.46 } else if (opt.equals("-docencoding")) { 7.47 @@ -708,7 +709,7 @@ 7.48 String encoding = ""; 7.49 for (int oi = 0; oi < options.length; oi++) { 7.50 String[] os = options[oi]; 7.51 - String opt = os[0].toLowerCase(); 7.52 + String opt = StringUtils.toLowerCase(os[0]); 7.53 if (opt.equals("-docencoding")) { 7.54 docencodingfound = true; 7.55 if (!checkOutputFileEncoding(os[1], reporter)) {
8.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java Wed Jun 11 09:31:26 2014 -0700 8.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java Mon Jun 16 11:19:22 2014 -0700 8.3 @@ -384,13 +384,13 @@ 8.4 commentTextBuilder.append( 8.5 MessageFormat.format( 8.6 configuration.getText("doclet.PropertySetterWithName"), 8.7 - Util.propertyNameFromMethodName(member.name()))); 8.8 + Util.propertyNameFromMethodName(configuration, member.name()))); 8.9 } 8.10 if (isGetter) { 8.11 commentTextBuilder.append( 8.12 MessageFormat.format( 8.13 configuration.getText("doclet.PropertyGetterWithName"), 8.14 - Util.propertyNameFromMethodName(member.name()))); 8.15 + Util.propertyNameFromMethodName(configuration, member.name()))); 8.16 } 8.17 if (propertyDoc.commentText() != null 8.18 && !propertyDoc.commentText().isEmpty()) {
9.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java Wed Jun 11 09:31:26 2014 -0700 9.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java Mon Jun 16 11:19:22 2014 -0700 9.3 @@ -31,6 +31,7 @@ 9.4 import com.sun.javadoc.*; 9.5 import com.sun.tools.doclets.internal.toolkit.*; 9.6 import com.sun.tools.doclets.internal.toolkit.util.*; 9.7 +import com.sun.tools.javac.util.StringUtils; 9.8 9.9 /** 9.10 * Builds the serialized form. 9.11 @@ -567,7 +568,7 @@ 9.12 } 9.13 Tag[] serial = doc.tags("serial"); 9.14 if (serial.length > 0) { 9.15 - String serialtext = serial[0].text().toLowerCase(); 9.16 + String serialtext = StringUtils.toLowerCase(serial[0].text()); 9.17 if (serialtext.indexOf("exclude") >= 0) { 9.18 return false; 9.19 } else if (serialtext.indexOf("include") >= 0) {
10.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SimpleTaglet.java Wed Jun 11 09:31:26 2014 -0700 10.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SimpleTaglet.java Mon Jun 16 11:19:22 2014 -0700 10.3 @@ -28,6 +28,7 @@ 10.4 import com.sun.javadoc.*; 10.5 import com.sun.tools.doclets.internal.toolkit.Content; 10.6 import com.sun.tools.doclets.internal.toolkit.util.DocFinder; 10.7 +import com.sun.tools.javac.util.StringUtils; 10.8 10.9 /** 10.10 * A simple single argument custom tag. 10.11 @@ -110,7 +111,7 @@ 10.12 public SimpleTaglet(String tagName, String header, String locations) { 10.13 this.tagName = tagName; 10.14 this.header = header; 10.15 - locations = locations.toLowerCase(); 10.16 + locations = StringUtils.toLowerCase(locations); 10.17 if (locations.indexOf(ALL) != -1 && locations.indexOf(EXCLUDED) == -1) { 10.18 this.locations = PACKAGE + TYPE + FIELD + METHOD + CONSTRUCTOR + OVERVIEW; 10.19 } else {
11.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java Wed Jun 11 09:31:26 2014 -0700 11.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java Mon Jun 16 11:19:22 2014 -0700 11.3 @@ -35,6 +35,7 @@ 11.4 11.5 import com.sun.javadoc.*; 11.6 import com.sun.tools.doclets.internal.toolkit.util.*; 11.7 +import com.sun.tools.javac.util.StringUtils; 11.8 11.9 /** 11.10 * Manages the<code>Taglet</code>s used by doclets. 11.11 @@ -304,7 +305,7 @@ 11.12 return; 11.13 } 11.14 Taglet tag = customTags.get(tagName); 11.15 - locations = locations.toLowerCase(); 11.16 + locations = StringUtils.toLowerCase(locations); 11.17 if (tag == null || header != null) { 11.18 customTags.remove(tagName); 11.19 customTags.put(tagName, new SimpleTaglet(tagName, header, locations)); 11.20 @@ -375,7 +376,7 @@ 11.21 name = name.substring(1, name.length()); 11.22 } 11.23 if (! (standardTags.contains(name) || customTags.containsKey(name))) { 11.24 - if (standardTagsLowercase.contains(name.toLowerCase())) { 11.25 + if (standardTagsLowercase.contains(StringUtils.toLowerCase(name))) { 11.26 message.warning(tags[i].position(), "doclet.UnknownTagLowercase", tags[i].name()); 11.27 continue; 11.28 } else { 11.29 @@ -708,7 +709,7 @@ 11.30 private void initStandardTagsLowercase() { 11.31 Iterator<String> it = standardTags.iterator(); 11.32 while (it.hasNext()) { 11.33 - standardTagsLowercase.add(it.next().toLowerCase()); 11.34 + standardTagsLowercase.add(StringUtils.toLowerCase(it.next())); 11.35 } 11.36 } 11.37
12.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java Wed Jun 11 09:31:26 2014 -0700 12.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java Mon Jun 16 11:19:22 2014 -0700 12.3 @@ -28,11 +28,12 @@ 12.4 import java.io.*; 12.5 import java.lang.annotation.ElementType; 12.6 import java.util.*; 12.7 +import javax.tools.StandardLocation; 12.8 12.9 import com.sun.javadoc.*; 12.10 import com.sun.javadoc.AnnotationDesc.ElementValuePair; 12.11 import com.sun.tools.doclets.internal.toolkit.*; 12.12 -import javax.tools.StandardLocation; 12.13 +import com.sun.tools.javac.util.StringUtils; 12.14 12.15 /** 12.16 * Utilities Class for Doclets. 12.17 @@ -253,8 +254,8 @@ 12.18 */ 12.19 private static class TypeComparator implements Comparator<Type> { 12.20 public int compare(Type type1, Type type2) { 12.21 - return type1.qualifiedTypeName().toLowerCase().compareTo( 12.22 - type2.qualifiedTypeName().toLowerCase()); 12.23 + return type1.qualifiedTypeName().compareToIgnoreCase( 12.24 + type2.qualifiedTypeName()); 12.25 } 12.26 } 12.27 12.28 @@ -589,7 +590,7 @@ 12.29 typeName = "doclet.Enum"; 12.30 } 12.31 return config.getText( 12.32 - lowerCaseOnly ? typeName.toLowerCase() : typeName); 12.33 + lowerCaseOnly ? StringUtils.toLowerCase(typeName) : typeName); 12.34 } 12.35 12.36 /** 12.37 @@ -724,7 +725,7 @@ 12.38 * @param name name of the getter or setter method. 12.39 * @return the name of the property of the given setter of getter. 12.40 */ 12.41 - public static String propertyNameFromMethodName(String name) { 12.42 + public static String propertyNameFromMethodName(Configuration configuration, String name) { 12.43 String propertyName = null; 12.44 if (name.startsWith("get") || name.startsWith("set")) { 12.45 propertyName = name.substring(3); 12.46 @@ -734,7 +735,7 @@ 12.47 if ((propertyName == null) || propertyName.isEmpty()){ 12.48 return ""; 12.49 } 12.50 - return propertyName.substring(0, 1).toLowerCase() 12.51 + return propertyName.substring(0, 1).toLowerCase(configuration.getLocale()) 12.52 + propertyName.substring(1); 12.53 } 12.54
13.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java Wed Jun 11 09:31:26 2014 -0700 13.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java Mon Jun 16 11:19:22 2014 -0700 13.3 @@ -702,7 +702,7 @@ 13.4 private boolean isPropertyGetterOrSetter(MethodDoc[] members, 13.5 MethodDoc methodDoc) { 13.6 boolean found = false; 13.7 - String propertyName = Util.propertyNameFromMethodName(methodDoc.name()); 13.8 + String propertyName = Util.propertyNameFromMethodName(configuration, methodDoc.name()); 13.9 if (!propertyName.isEmpty()) { 13.10 String propertyMethodName = propertyName + "Property"; 13.11 for (MethodDoc member: members) {
14.1 --- a/src/share/classes/com/sun/tools/doclint/Checker.java Wed Jun 11 09:31:26 2014 -0700 14.2 +++ b/src/share/classes/com/sun/tools/doclint/Checker.java Mon Jun 16 11:19:22 2014 -0700 14.3 @@ -80,6 +80,7 @@ 14.4 import com.sun.source.util.TreePath; 14.5 import com.sun.tools.doclint.HtmlTag.AttrKind; 14.6 import com.sun.tools.javac.tree.DocPretty; 14.7 +import com.sun.tools.javac.util.StringUtils; 14.8 import static com.sun.tools.doclint.Messages.Group.*; 14.9 14.10 14.11 @@ -243,7 +244,7 @@ 14.12 markEnclosingTag(Flag.HAS_TEXT); 14.13 String name = tree.getName().toString(); 14.14 if (name.startsWith("#")) { 14.15 - int v = name.toLowerCase().startsWith("#x") 14.16 + int v = StringUtils.toLowerCase(name).startsWith("#x") 14.17 ? Integer.parseInt(name.substring(2), 16) 14.18 : Integer.parseInt(name.substring(1), 10); 14.19 if (!Entity.isValid(v)) {
15.1 --- a/src/share/classes/com/sun/tools/doclint/Env.java Wed Jun 11 09:31:26 2014 -0700 15.2 +++ b/src/share/classes/com/sun/tools/doclint/Env.java Mon Jun 16 11:19:22 2014 -0700 15.3 @@ -44,6 +44,7 @@ 15.4 import com.sun.source.util.TreePath; 15.5 import com.sun.tools.javac.model.JavacTypes; 15.6 import com.sun.tools.javac.tree.JCTree; 15.7 +import com.sun.tools.javac.util.StringUtils; 15.8 15.9 /** 15.10 * Utility container for current execution environment, 15.11 @@ -66,7 +67,7 @@ 15.12 15.13 static boolean accepts(String opt) { 15.14 for (AccessKind g: values()) 15.15 - if (opt.equals(g.name().toLowerCase())) return true; 15.16 + if (opt.equals(StringUtils.toLowerCase(g.name()))) return true; 15.17 return false; 15.18 } 15.19
16.1 --- a/src/share/classes/com/sun/tools/doclint/HtmlTag.java Wed Jun 11 09:31:26 2014 -0700 16.2 +++ b/src/share/classes/com/sun/tools/doclint/HtmlTag.java Mon Jun 16 11:19:22 2014 -0700 16.3 @@ -36,6 +36,7 @@ 16.4 import javax.lang.model.element.Name; 16.5 16.6 import static com.sun.tools.doclint.HtmlTag.Attr.*; 16.7 +import com.sun.tools.javac.util.StringUtils; 16.8 16.9 /** 16.10 * Enum representing HTML tags. 16.11 @@ -352,7 +353,7 @@ 16.12 WIDTH; 16.13 16.14 public String getText() { 16.15 - return toLowerCase(name()); 16.16 + return StringUtils.toLowerCase(name()); 16.17 } 16.18 16.19 static final Map<String,Attr> index = new HashMap<String,Attr>(); 16.20 @@ -431,11 +432,11 @@ 16.21 } 16.22 16.23 public String getText() { 16.24 - return toLowerCase(name()); 16.25 + return StringUtils.toLowerCase(name()); 16.26 } 16.27 16.28 public Attr getAttr(Name attrName) { 16.29 - return Attr.index.get(toLowerCase(attrName.toString())); 16.30 + return Attr.index.get(StringUtils.toLowerCase(attrName.toString())); 16.31 } 16.32 16.33 public AttrKind getAttrKind(Name attrName) { 16.34 @@ -457,10 +458,7 @@ 16.35 } 16.36 16.37 static HtmlTag get(Name tagName) { 16.38 - return index.get(toLowerCase(tagName.toString())); 16.39 + return index.get(StringUtils.toLowerCase(tagName.toString())); 16.40 } 16.41 16.42 - private static String toLowerCase(String s) { 16.43 - return s.toLowerCase(Locale.US); 16.44 - } 16.45 }
17.1 --- a/src/share/classes/com/sun/tools/doclint/Messages.java Wed Jun 11 09:31:26 2014 -0700 17.2 +++ b/src/share/classes/com/sun/tools/doclint/Messages.java Mon Jun 16 11:19:22 2014 -0700 17.3 @@ -1,5 +1,5 @@ 17.4 /* 17.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 17.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 17.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 17.8 * 17.9 * This code is free software; you can redistribute it and/or modify it 17.10 @@ -42,6 +42,7 @@ 17.11 import com.sun.source.doctree.DocTree; 17.12 import com.sun.source.tree.Tree; 17.13 import com.sun.tools.doclint.Env.AccessKind; 17.14 +import com.sun.tools.javac.util.StringUtils; 17.15 17.16 /** 17.17 * Message reporting for DocLint. 17.18 @@ -67,7 +68,7 @@ 17.19 SYNTAX, 17.20 REFERENCE; 17.21 17.22 - String optName() { return name().toLowerCase(); } 17.23 + String optName() { return StringUtils.toLowerCase(name()); } 17.24 String notOptName() { return "-" + optName(); } 17.25 17.26 static boolean accepts(String opt) { 17.27 @@ -158,7 +159,7 @@ 17.28 17.29 static boolean isValidOptions(String opts) { 17.30 for (String opt: opts.split(",")) { 17.31 - if (!isValidOption(opt.trim().toLowerCase())) 17.32 + if (!isValidOption(StringUtils.toLowerCase(opt.trim()))) 17.33 return false; 17.34 } 17.35 return true; 17.36 @@ -203,7 +204,7 @@ 17.37 setOption(ALL, Env.AccessKind.PRIVATE); 17.38 else { 17.39 for (String opt: opts.split(",")) 17.40 - setOption(opt.trim().toLowerCase()); 17.41 + setOption(StringUtils.toLowerCase(opt.trim())); 17.42 } 17.43 } 17.44 17.45 @@ -215,7 +216,7 @@ 17.46 17.47 int sep = arg.indexOf("/"); 17.48 if (sep > 0) { 17.49 - Env.AccessKind ak = Env.AccessKind.valueOf(arg.substring(sep + 1).toUpperCase()); 17.50 + Env.AccessKind ak = Env.AccessKind.valueOf(StringUtils.toUpperCase(arg.substring(sep + 1))); 17.51 setOption(arg.substring(0, sep), ak); 17.52 } else { 17.53 setOption(arg, null); 17.54 @@ -290,7 +291,7 @@ 17.55 out.println("By diagnostic kind..."); 17.56 Table dkindTable = new Table(); 17.57 for (Diagnostic.Kind k : Diagnostic.Kind.values()) { 17.58 - dkindTable.put(k.toString().toLowerCase(), dkindCounts[k.ordinal()]); 17.59 + dkindTable.put(StringUtils.toLowerCase(k.toString()), dkindCounts[k.ordinal()]); 17.60 } 17.61 dkindTable.print(out); 17.62 out.println();
18.1 --- a/src/share/classes/com/sun/tools/javac/code/Flags.java Wed Jun 11 09:31:26 2014 -0700 18.2 +++ b/src/share/classes/com/sun/tools/javac/code/Flags.java Mon Jun 16 11:19:22 2014 -0700 18.3 @@ -1,5 +1,5 @@ 18.4 /* 18.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 18.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 18.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 18.8 * 18.9 * This code is free software; you can redistribute it and/or modify it 18.10 @@ -33,6 +33,7 @@ 18.11 import javax.lang.model.element.Modifier; 18.12 18.13 import com.sun.tools.javac.util.Assert; 18.14 +import com.sun.tools.javac.util.StringUtils; 18.15 18.16 /** Access flags and other modifiers for Java classes and members. 18.17 * 18.18 @@ -388,7 +389,7 @@ 18.19 18.20 Flag(long flag) { 18.21 this.value = flag; 18.22 - this.lowercaseName = name().toLowerCase(); 18.23 + this.lowercaseName = StringUtils.toLowerCase(name()); 18.24 } 18.25 18.26 @Override
19.1 --- a/src/share/classes/com/sun/tools/javac/code/Type.java Wed Jun 11 09:31:26 2014 -0700 19.2 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java Mon Jun 16 11:19:22 2014 -0700 19.3 @@ -72,13 +72,28 @@ 19.4 public abstract class Type extends AnnoConstruct implements TypeMirror { 19.5 19.6 /** Constant type: no type at all. */ 19.7 - public static final JCNoType noType = new JCNoType(); 19.8 + public static final JCNoType noType = new JCNoType() { 19.9 + @Override 19.10 + public String toString() { 19.11 + return "none"; 19.12 + } 19.13 + }; 19.14 19.15 /** Constant type: special type to be used during recovery of deferred expressions. */ 19.16 - public static final JCNoType recoveryType = new JCNoType(); 19.17 + public static final JCNoType recoveryType = new JCNoType(){ 19.18 + @Override 19.19 + public String toString() { 19.20 + return "recovery"; 19.21 + } 19.22 + }; 19.23 19.24 /** Constant type: special type to be used for marking stuck trees. */ 19.25 - public static final JCNoType stuckType = new JCNoType(); 19.26 + public static final JCNoType stuckType = new JCNoType() { 19.27 + @Override 19.28 + public String toString() { 19.29 + return "stuck"; 19.30 + } 19.31 + }; 19.32 19.33 /** If this switch is turned on, the names of type variables 19.34 * and anonymous classes are printed with hashcodes appended. 19.35 @@ -1643,9 +1658,6 @@ 19.36 //only change bounds if request comes from substBounds 19.37 super.addBound(ib, bound, types, update); 19.38 } 19.39 - else if (bound.hasTag(UNDETVAR) && !((UndetVar) bound).isCaptured()) { 19.40 - ((UndetVar) bound).addBound(ib.complement(), this, types, false); 19.41 - } 19.42 } 19.43 19.44 @Override
20.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java Wed Jun 11 09:31:26 2014 -0700 20.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Mon Jun 16 11:19:22 2014 -0700 20.3 @@ -1221,14 +1221,35 @@ 20.4 TypeRelation isSameTypeLoose = new LooseSameTypeVisitor(); 20.5 20.6 private class LooseSameTypeVisitor extends SameTypeVisitor { 20.7 + 20.8 + /** cache of the type-variable pairs being (recursively) tested. */ 20.9 + private Set<TypePair> cache = new HashSet<>(); 20.10 + 20.11 @Override 20.12 boolean sameTypeVars(TypeVar tv1, TypeVar tv2) { 20.13 - return tv1.tsym == tv2.tsym && visit(tv1.getUpperBound(), tv2.getUpperBound()); 20.14 + return tv1.tsym == tv2.tsym && checkSameBounds(tv1, tv2); 20.15 } 20.16 @Override 20.17 protected boolean containsTypes(List<Type> ts1, List<Type> ts2) { 20.18 return containsTypeEquivalent(ts1, ts2); 20.19 } 20.20 + 20.21 + /** 20.22 + * Since type-variable bounds can be recursive, we need to protect against 20.23 + * infinite loops - where the same bounds are checked over and over recursively. 20.24 + */ 20.25 + private boolean checkSameBounds(TypeVar tv1, TypeVar tv2) { 20.26 + TypePair p = new TypePair(tv1, tv2, true); 20.27 + if (cache.add(p)) { 20.28 + try { 20.29 + return visit(tv1.getUpperBound(), tv2.getUpperBound()); 20.30 + } finally { 20.31 + cache.remove(p); 20.32 + } 20.33 + } else { 20.34 + return false; 20.35 + } 20.36 + } 20.37 }; 20.38 20.39 /** 20.40 @@ -1375,7 +1396,7 @@ 20.41 // debugContainsType(t, s); 20.42 return isSameWildcard(t, s) 20.43 || isCaptureOf(s, t) 20.44 - || ((t.isExtendsBound() || isSubtypeNoCapture(wildLowerBound(t), wildLowerBound(s))) && 20.45 + || ((t.isExtendsBound() || isSubtypeNoCapture(wildLowerBound(t), cvarLowerBound(wildLowerBound(s)))) && 20.46 // TODO: JDK-8039214, cvarUpperBound call here is incorrect 20.47 (t.isSuperBound() || isSubtypeNoCapture(cvarUpperBound(wildUpperBound(s)), wildUpperBound(t)))); 20.48 } 20.49 @@ -3376,9 +3397,16 @@ 20.50 class TypePair { 20.51 final Type t1; 20.52 final Type t2; 20.53 + boolean strict; 20.54 + 20.55 TypePair(Type t1, Type t2) { 20.56 + this(t1, t2, false); 20.57 + } 20.58 + 20.59 + TypePair(Type t1, Type t2, boolean strict) { 20.60 this.t1 = t1; 20.61 this.t2 = t2; 20.62 + this.strict = strict; 20.63 } 20.64 @Override 20.65 public int hashCode() { 20.66 @@ -3389,8 +3417,8 @@ 20.67 if (!(obj instanceof TypePair)) 20.68 return false; 20.69 TypePair typePair = (TypePair)obj; 20.70 - return isSameType(t1, typePair.t1) 20.71 - && isSameType(t2, typePair.t2); 20.72 + return isSameType(t1, typePair.t1, strict) 20.73 + && isSameType(t2, typePair.t2, strict); 20.74 } 20.75 } 20.76 Set<TypePair> mergeCache = new HashSet<TypePair>(); 20.77 @@ -4670,7 +4698,7 @@ 20.78 assembleClassSig(rawOuter 20.79 ? types.erasure(outer) 20.80 : outer); 20.81 - append('.'); 20.82 + append(rawOuter ? '$' : '.'); 20.83 Assert.check(c.flatname.startsWith(c.owner.enclClass().flatname)); 20.84 append(rawOuter 20.85 ? c.flatname.subName(c.owner.enclClass().flatname.getByteLength() + 1, c.flatname.getByteLength())
21.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Wed Jun 11 09:31:26 2014 -0700 21.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Mon Jun 16 11:19:22 2014 -0700 21.3 @@ -138,6 +138,7 @@ 21.4 allowTypeAnnos = source.allowTypeAnnotations(); 21.5 allowLambda = source.allowLambda(); 21.6 allowDefaultMethods = source.allowDefaultMethods(); 21.7 + allowStaticInterfaceMethods = source.allowStaticInterfaceMethods(); 21.8 sourceName = source.name; 21.9 relax = (options.isSet("-retrofit") || 21.10 options.isSet("-relax")); 21.11 @@ -195,6 +196,10 @@ 21.12 */ 21.13 boolean allowDefaultMethods; 21.14 21.15 + /** Switch: static interface methods enabled? 21.16 + */ 21.17 + boolean allowStaticInterfaceMethods; 21.18 + 21.19 /** Switch: allow references to surrounding object from anonymous 21.20 * objects during constructor call? 21.21 */ 21.22 @@ -2056,7 +2061,7 @@ 21.23 tree.constructor = constructor.baseSymbol(); 21.24 21.25 final TypeSymbol csym = clazztype.tsym; 21.26 - ResultInfo diamondResult = new ResultInfo(MTH, newMethodTemplate(resultInfo.pt, argtypes, typeargtypes), new Check.NestedCheckContext(resultInfo.checkContext) { 21.27 + ResultInfo diamondResult = new ResultInfo(pkind, newMethodTemplate(resultInfo.pt, argtypes, typeargtypes), new Check.NestedCheckContext(resultInfo.checkContext) { 21.28 @Override 21.29 public void report(DiagnosticPosition _unused, JCDiagnostic details) { 21.30 enclosingContext.report(tree.clazz, 21.31 @@ -3323,6 +3328,10 @@ 21.32 tree.pos(), site, sym.name, true); 21.33 } 21.34 } 21.35 + if (!allowStaticInterfaceMethods && sitesym.isInterface() && 21.36 + sym.isStatic() && sym.kind == MTH) { 21.37 + log.error(tree.pos(), "static.intf.method.invoke.not.supported.in.source", sourceName); 21.38 + } 21.39 } else if (sym.kind != ERR && (sym.flags() & STATIC) != 0 && sym.name != names._class) { 21.40 // If the qualified item is not a type and the selected item is static, report 21.41 // a warning. Make allowance for the class of an array type e.g. Object[].class)
22.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Wed Jun 11 09:31:26 2014 -0700 22.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Mon Jun 16 11:19:22 2014 -0700 22.3 @@ -1813,6 +1813,11 @@ 22.4 Type t1, 22.5 Type t2, 22.6 Type site) { 22.7 + if ((site.tsym.flags() & COMPOUND) != 0) { 22.8 + // special case for intersections: need to eliminate wildcards in supertypes 22.9 + t1 = types.capture(t1); 22.10 + t2 = types.capture(t2); 22.11 + } 22.12 return firstIncompatibility(pos, t1, t2, site) == null; 22.13 } 22.14
23.1 --- a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Wed Jun 11 09:31:26 2014 -0700 23.2 +++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Mon Jun 16 11:19:22 2014 -0700 23.3 @@ -1218,25 +1218,102 @@ 23.4 } 23.5 23.6 //slow path 23.7 + Symbol sym = quicklyResolveMethod(env, tree); 23.8 + 23.9 + if (sym == null) { 23.10 + result = ArgumentExpressionKind.POLY; 23.11 + return; 23.12 + } 23.13 + 23.14 + result = analyzeCandidateMethods(sym, ArgumentExpressionKind.PRIMITIVE, 23.15 + argumentKindAnalyzer); 23.16 + } 23.17 + //where 23.18 + private boolean isSimpleReceiver(JCTree rec) { 23.19 + switch (rec.getTag()) { 23.20 + case IDENT: 23.21 + return true; 23.22 + case SELECT: 23.23 + return isSimpleReceiver(((JCFieldAccess)rec).selected); 23.24 + case TYPEAPPLY: 23.25 + case TYPEARRAY: 23.26 + return true; 23.27 + case ANNOTATED_TYPE: 23.28 + return isSimpleReceiver(((JCAnnotatedType)rec).underlyingType); 23.29 + case APPLY: 23.30 + return true; 23.31 + default: 23.32 + return false; 23.33 + } 23.34 + } 23.35 + private ArgumentExpressionKind reduce(ArgumentExpressionKind kind) { 23.36 + return argumentKindAnalyzer.reduce(result, kind); 23.37 + } 23.38 + MethodAnalyzer<ArgumentExpressionKind> argumentKindAnalyzer = 23.39 + new MethodAnalyzer<ArgumentExpressionKind>() { 23.40 + @Override 23.41 + public ArgumentExpressionKind process(MethodSymbol ms) { 23.42 + return ArgumentExpressionKind.methodKind(ms, types); 23.43 + } 23.44 + @Override 23.45 + public ArgumentExpressionKind reduce(ArgumentExpressionKind kind1, 23.46 + ArgumentExpressionKind kind2) { 23.47 + switch (kind1) { 23.48 + case PRIMITIVE: return kind2; 23.49 + case NO_POLY: return kind2.isPoly() ? kind2 : kind1; 23.50 + case POLY: return kind1; 23.51 + default: 23.52 + Assert.error(); 23.53 + return null; 23.54 + } 23.55 + } 23.56 + @Override 23.57 + public boolean shouldStop(ArgumentExpressionKind result) { 23.58 + return result.isPoly(); 23.59 + } 23.60 + }; 23.61 + 23.62 + @Override 23.63 + public void visitLiteral(JCLiteral tree) { 23.64 + Type litType = attr.litType(tree.typetag); 23.65 + result = ArgumentExpressionKind.standaloneKind(litType, types); 23.66 + } 23.67 + 23.68 + @Override 23.69 + void skip(JCTree tree) { 23.70 + result = ArgumentExpressionKind.NO_POLY; 23.71 + } 23.72 + 23.73 + private Symbol quicklyResolveMethod(Env<AttrContext> env, final JCMethodInvocation tree) { 23.74 final JCExpression rec = tree.meth.hasTag(SELECT) ? 23.75 ((JCFieldAccess)tree.meth).selected : 23.76 null; 23.77 23.78 if (rec != null && !isSimpleReceiver(rec)) { 23.79 - //give up if receiver is too complex (to cut down analysis time) 23.80 - result = ArgumentExpressionKind.POLY; 23.81 - return; 23.82 + return null; 23.83 } 23.84 23.85 - Type site = rec != null ? 23.86 - attribSpeculative(rec, env, attr.unknownTypeExprInfo).type : 23.87 - env.enclClass.sym.type; 23.88 + Type site; 23.89 23.90 - while (site.hasTag(TYPEVAR)) { 23.91 - site = site.getUpperBound(); 23.92 + if (rec != null) { 23.93 + if (rec.hasTag(APPLY)) { 23.94 + Symbol recSym = quicklyResolveMethod(env, (JCMethodInvocation) rec); 23.95 + if (recSym == null) 23.96 + return null; 23.97 + Symbol resolvedReturnType = 23.98 + analyzeCandidateMethods(recSym, syms.errSymbol, returnSymbolAnalyzer); 23.99 + if (resolvedReturnType == null) 23.100 + return null; 23.101 + site = resolvedReturnType.type; 23.102 + } else { 23.103 + site = attribSpeculative(rec, env, attr.unknownTypeExprInfo).type; 23.104 + } 23.105 + } else { 23.106 + site = env.enclClass.sym.type; 23.107 } 23.108 23.109 List<Type> args = rs.dummyArgs(tree.args.length()); 23.110 + Name name = TreeInfo.name(tree.meth); 23.111 23.112 Resolve.LookupHelper lh = rs.new LookupHelper(name, site, args, List.<Type>nil(), MethodResolutionPhase.VARARITY) { 23.113 @Override 23.114 @@ -1251,61 +1328,60 @@ 23.115 } 23.116 }; 23.117 23.118 - Symbol sym = rs.lookupMethod(env, tree, site.tsym, rs.arityMethodCheck, lh); 23.119 + return rs.lookupMethod(env, tree, site.tsym, rs.arityMethodCheck, lh); 23.120 + } 23.121 + //where: 23.122 + MethodAnalyzer<Symbol> returnSymbolAnalyzer = new MethodAnalyzer<Symbol>() { 23.123 + @Override 23.124 + public Symbol process(MethodSymbol ms) { 23.125 + ArgumentExpressionKind kind = ArgumentExpressionKind.methodKind(ms, types); 23.126 + return kind != ArgumentExpressionKind.POLY ? ms.getReturnType().tsym : null; 23.127 + } 23.128 + @Override 23.129 + public Symbol reduce(Symbol s1, Symbol s2) { 23.130 + return s1 == syms.errSymbol ? s2 : s1 == s2 ? s1 : null; 23.131 + } 23.132 + @Override 23.133 + public boolean shouldStop(Symbol result) { 23.134 + return result == null; 23.135 + } 23.136 + }; 23.137 23.138 - if (sym.kind == Kinds.AMBIGUOUS) { 23.139 - Resolve.AmbiguityError err = (Resolve.AmbiguityError)sym.baseSymbol(); 23.140 - result = ArgumentExpressionKind.PRIMITIVE; 23.141 - for (Symbol s : err.ambiguousSyms) { 23.142 - if (result.isPoly()) break; 23.143 - if (s.kind == Kinds.MTH) { 23.144 - result = reduce(ArgumentExpressionKind.methodKind(s, types)); 23.145 + /** 23.146 + * Process the result of Resolve.lookupMethod. If sym is a method symbol, the result of 23.147 + * MethodAnalyzer.process is returned. If sym is an ambiguous symbol, all the candidate 23.148 + * methods are inspected one by one, using MethodAnalyzer.process. The outcomes are 23.149 + * reduced using MethodAnalyzer.reduce (using defaultValue as the first value over which 23.150 + * the reduction runs). MethodAnalyzer.shouldStop can be used to stop the inspection early. 23.151 + */ 23.152 + <E> E analyzeCandidateMethods(Symbol sym, E defaultValue, MethodAnalyzer<E> analyzer) { 23.153 + switch (sym.kind) { 23.154 + case Kinds.MTH: 23.155 + return analyzer.process((MethodSymbol) sym); 23.156 + case Kinds.AMBIGUOUS: 23.157 + Resolve.AmbiguityError err = (Resolve.AmbiguityError)sym.baseSymbol(); 23.158 + E res = defaultValue; 23.159 + for (Symbol s : err.ambiguousSyms) { 23.160 + if (s.kind == Kinds.MTH) { 23.161 + res = analyzer.reduce(res, analyzer.process((MethodSymbol) s)); 23.162 + if (analyzer.shouldStop(res)) 23.163 + return res; 23.164 + } 23.165 } 23.166 - } 23.167 - } else { 23.168 - result = (sym.kind == Kinds.MTH) ? 23.169 - ArgumentExpressionKind.methodKind(sym, types) : 23.170 - ArgumentExpressionKind.NO_POLY; 23.171 + return res; 23.172 + default: 23.173 + return defaultValue; 23.174 } 23.175 } 23.176 - //where 23.177 - private boolean isSimpleReceiver(JCTree rec) { 23.178 - switch (rec.getTag()) { 23.179 - case IDENT: 23.180 - return true; 23.181 - case SELECT: 23.182 - return isSimpleReceiver(((JCFieldAccess)rec).selected); 23.183 - case TYPEAPPLY: 23.184 - case TYPEARRAY: 23.185 - return true; 23.186 - case ANNOTATED_TYPE: 23.187 - return isSimpleReceiver(((JCAnnotatedType)rec).underlyingType); 23.188 - default: 23.189 - return false; 23.190 - } 23.191 - } 23.192 - private ArgumentExpressionKind reduce(ArgumentExpressionKind kind) { 23.193 - switch (result) { 23.194 - case PRIMITIVE: return kind; 23.195 - case NO_POLY: return kind.isPoly() ? kind : result; 23.196 - case POLY: return result; 23.197 - default: 23.198 - Assert.error(); 23.199 - return null; 23.200 - } 23.201 - } 23.202 + } 23.203 23.204 - @Override 23.205 - public void visitLiteral(JCLiteral tree) { 23.206 - Type litType = attr.litType(tree.typetag); 23.207 - result = ArgumentExpressionKind.standaloneKind(litType, types); 23.208 - } 23.209 + /** Analyzer for methods - used by analyzeCandidateMethods. */ 23.210 + interface MethodAnalyzer<E> { 23.211 + E process(MethodSymbol ms); 23.212 + E reduce(E e1, E e2); 23.213 + boolean shouldStop(E result); 23.214 + } 23.215 23.216 - @Override 23.217 - void skip(JCTree tree) { 23.218 - result = ArgumentExpressionKind.NO_POLY; 23.219 - } 23.220 - } 23.221 //where 23.222 private EnumSet<JCTree.Tag> deferredCheckerTags = 23.223 EnumSet.of(LAMBDA, REFERENCE, PARENS, TYPECAST,
24.1 --- a/src/share/classes/com/sun/tools/javac/comp/Flow.java Wed Jun 11 09:31:26 2014 -0700 24.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java Mon Jun 16 11:19:22 2014 -0700 24.3 @@ -232,7 +232,8 @@ 24.4 } 24.5 } 24.6 24.7 - public List<Type> analyzeLambdaThrownTypes(Env<AttrContext> env, JCLambda that, TreeMaker make) { 24.8 + public List<Type> analyzeLambdaThrownTypes(final Env<AttrContext> env, 24.9 + JCLambda that, TreeMaker make) { 24.10 //we need to disable diagnostics temporarily; the problem is that if 24.11 //a lambda expression contains e.g. an unreachable statement, an error 24.12 //message will be reported and will cause compilation to skip the flow analyis 24.13 @@ -240,7 +241,13 @@ 24.14 //related errors, which will allow for more errors to be detected 24.15 Log.DiagnosticHandler diagHandler = new Log.DiscardDiagnosticHandler(log); 24.16 try { 24.17 - new AssignAnalyzer(log, syms, lint, names, enforceThisDotInit).analyzeTree(env); 24.18 + new AssignAnalyzer(log, syms, lint, names, enforceThisDotInit) { 24.19 + @Override 24.20 + protected boolean trackable(VarSymbol sym) { 24.21 + return !env.info.scope.includes(sym) && 24.22 + sym.owner.kind == MTH; 24.23 + } 24.24 + }.analyzeTree(env); 24.25 LambdaFlowAnalyzer flowAnalyzer = new LambdaFlowAnalyzer(); 24.26 flowAnalyzer.analyzeTree(env, that, make); 24.27 return flowAnalyzer.inferredThrownTypes;
25.1 --- a/src/share/classes/com/sun/tools/javac/file/Locations.java Wed Jun 11 09:31:26 2014 -0700 25.2 +++ b/src/share/classes/com/sun/tools/javac/file/Locations.java Mon Jun 16 11:19:22 2014 -0700 25.3 @@ -1,5 +1,5 @@ 25.4 /* 25.5 - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 25.6 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. 25.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 25.8 * 25.9 * This code is free software; you can redistribute it and/or modify it 25.10 @@ -51,6 +51,7 @@ 25.11 import com.sun.tools.javac.util.ListBuffer; 25.12 import com.sun.tools.javac.util.Log; 25.13 import com.sun.tools.javac.util.Options; 25.14 +import com.sun.tools.javac.util.StringUtils; 25.15 25.16 import javax.tools.JavaFileManager; 25.17 import javax.tools.StandardJavaFileManager; 25.18 @@ -717,7 +718,7 @@ 25.19 25.20 /** Is this the name of an archive file? */ 25.21 private boolean isArchive(File file) { 25.22 - String n = file.getName().toLowerCase(); 25.23 + String n = StringUtils.toLowerCase(file.getName()); 25.24 return fsInfo.isFile(file) 25.25 && (n.endsWith(".jar") || n.endsWith(".zip")); 25.26 }
26.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Code.java Wed Jun 11 09:31:26 2014 -0700 26.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java Mon Jun 16 11:19:22 2014 -0700 26.3 @@ -1925,6 +1925,13 @@ 26.4 return aliveRanges.isEmpty() ? null : aliveRanges.get(aliveRanges.size() - 1); 26.5 } 26.6 26.7 + void removeLastRange() { 26.8 + Range lastRange = lastRange(); 26.9 + if (lastRange != null) { 26.10 + aliveRanges.remove(lastRange); 26.11 + } 26.12 + } 26.13 + 26.14 @Override 26.15 public String toString() { 26.16 if (aliveRanges == null) { 26.17 @@ -1955,9 +1962,7 @@ 26.18 } 26.19 } 26.20 } else { 26.21 - if (!aliveRanges.isEmpty()) { 26.22 - aliveRanges.remove(aliveRanges.size() - 1); 26.23 - } 26.24 + removeLastRange(); 26.25 } 26.26 } 26.27 26.28 @@ -1965,16 +1970,14 @@ 26.29 if (aliveRanges.isEmpty()) { 26.30 return false; 26.31 } 26.32 - Range range = lastRange(); 26.33 - return range.length == Character.MAX_VALUE; 26.34 + return lastRange().length == Character.MAX_VALUE; 26.35 } 26.36 26.37 public boolean isLastRangeInitialized() { 26.38 if (aliveRanges.isEmpty()) { 26.39 return false; 26.40 } 26.41 - Range range = lastRange(); 26.42 - return range.start_pc != Character.MAX_VALUE; 26.43 + return lastRange().start_pc != Character.MAX_VALUE; 26.44 } 26.45 26.46 public Range getWidestRange() { 26.47 @@ -2095,7 +2098,7 @@ 26.48 v.closeRange(length); 26.49 putVar(v); 26.50 } else { 26.51 - v.lastRange().start_pc = Character.MAX_VALUE; 26.52 + v.removeLastRange(); 26.53 } 26.54 } 26.55 }
27.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java Wed Jun 11 09:31:26 2014 -0700 27.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java Mon Jun 16 11:19:22 2014 -0700 27.3 @@ -1811,8 +1811,7 @@ 27.4 genStat(tree.thenpart, env, CRT_STATEMENT | CRT_FLOW_TARGET); 27.5 thenExit = code.branch(goto_); 27.6 if (varDebugInfo && lvtRanges.containsKey(code.meth, tree.thenpart)) { 27.7 - code.closeAliveRanges(tree.thenpart, 27.8 - thenExit != null && tree.elsepart == null ? thenExit.pc : code.cp); 27.9 + code.closeAliveRanges(tree.thenpart, code.cp); 27.10 } 27.11 } 27.12 if (elseChain != null) {
28.1 --- a/src/share/classes/com/sun/tools/javac/main/Option.java Wed Jun 11 09:31:26 2014 -0700 28.2 +++ b/src/share/classes/com/sun/tools/javac/main/Option.java Mon Jun 16 11:19:22 2014 -0700 28.3 @@ -47,6 +47,7 @@ 28.4 import com.sun.tools.javac.util.Log.PrefixKind; 28.5 import com.sun.tools.javac.util.Log.WriterKind; 28.6 import com.sun.tools.javac.util.Options; 28.7 +import com.sun.tools.javac.util.StringUtils; 28.8 import static com.sun.tools.javac.main.Option.ChoiceKind.*; 28.9 import static com.sun.tools.javac.main.Option.OptionGroup.*; 28.10 import static com.sun.tools.javac.main.Option.OptionKind.*; 28.11 @@ -713,7 +714,7 @@ 28.12 String v = options.get(XPKGINFO); 28.13 return (v == null 28.14 ? PkgInfo.LEGACY 28.15 - : PkgInfo.valueOf(v.toUpperCase())); 28.16 + : PkgInfo.valueOf(StringUtils.toUpperCase(v))); 28.17 } 28.18 } 28.19
29.1 --- a/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Wed Jun 11 09:31:26 2014 -0700 29.2 +++ b/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Mon Jun 16 11:19:22 2014 -0700 29.3 @@ -57,6 +57,7 @@ 29.4 import com.sun.tools.javac.util.Names; 29.5 import com.sun.tools.javac.util.Options; 29.6 import com.sun.tools.javac.util.Position; 29.7 +import com.sun.tools.javac.util.StringUtils; 29.8 import static com.sun.tools.javac.util.LayoutCharacters.*; 29.9 29.10 /** 29.11 @@ -993,7 +994,7 @@ 29.12 "h1", "h2", "h3", "h4", "h5", "h6", "p", "pre")); 29.13 29.14 protected boolean isSentenceBreak(Name n) { 29.15 - return htmlBlockTags.contains(n.toString().toLowerCase()); 29.16 + return htmlBlockTags.contains(StringUtils.toLowerCase(n.toString())); 29.17 } 29.18 29.19 protected boolean isSentenceBreak(DCTree t) {
30.1 --- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Wed Jun 11 09:31:26 2014 -0700 30.2 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Mon Jun 16 11:19:22 2014 -0700 30.3 @@ -4068,15 +4068,16 @@ 30.4 */ 30.5 protected static class SimpleEndPosTable extends AbstractEndPosTable { 30.6 30.7 - private final Map<JCTree, Integer> endPosMap; 30.8 + private final IntHashTable endPosMap; 30.9 30.10 SimpleEndPosTable(JavacParser parser) { 30.11 super(parser); 30.12 - endPosMap = new HashMap<JCTree, Integer>(); 30.13 + endPosMap = new IntHashTable(); 30.14 } 30.15 30.16 public void storeEnd(JCTree tree, int endpos) { 30.17 - endPosMap.put(tree, errorEndPos > endpos ? errorEndPos : endpos); 30.18 + endPosMap.putAtIndex(tree, errorEndPos > endpos ? errorEndPos : endpos, 30.19 + endPosMap.lookup(tree)); 30.20 } 30.21 30.22 protected <T extends JCTree> T to(T t) { 30.23 @@ -4090,14 +4091,15 @@ 30.24 } 30.25 30.26 public int getEndPos(JCTree tree) { 30.27 - Integer value = endPosMap.get(tree); 30.28 - return (value == null) ? Position.NOPOS : value; 30.29 + int value = endPosMap.getFromIndex(endPosMap.lookup(tree)); 30.30 + // As long as Position.NOPOS==-1, this just returns value. 30.31 + return (value == -1) ? Position.NOPOS : value; 30.32 } 30.33 30.34 public int replaceTree(JCTree oldTree, JCTree newTree) { 30.35 - Integer pos = endPosMap.remove(oldTree); 30.36 - if (pos != null) { 30.37 - endPosMap.put(newTree, pos); 30.38 + int pos = endPosMap.remove(oldTree); 30.39 + if (pos != -1) { 30.40 + storeEnd(newTree, pos); 30.41 return pos; 30.42 } 30.43 return Position.NOPOS;
31.1 --- a/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java Wed Jun 11 09:31:26 2014 -0700 31.2 +++ b/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java Mon Jun 16 11:19:22 2014 -0700 31.3 @@ -1,5 +1,5 @@ 31.4 /* 31.5 - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 31.6 + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 31.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 31.8 * 31.9 * This code is free software; you can redistribute it and/or modify it 31.10 @@ -36,6 +36,7 @@ 31.11 import java.io.PrintWriter; 31.12 import java.io.Writer; 31.13 import java.util.*; 31.14 +import com.sun.tools.javac.util.StringUtils; 31.15 31.16 /** 31.17 * A processor which prints out elements. Used to implement the 31.18 @@ -202,7 +203,7 @@ 31.19 writer.print("@interface"); 31.20 break; 31.21 default: 31.22 - writer.print(kind.toString().toLowerCase()); 31.23 + writer.print(StringUtils.toLowerCase(kind.toString())); 31.24 } 31.25 writer.print(" "); 31.26 writer.print(e.getSimpleName());
32.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Wed Jun 11 09:31:26 2014 -0700 32.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Mon Jun 16 11:19:22 2014 -0700 32.3 @@ -2390,6 +2390,11 @@ 32.4 static interface methods are not supported in -source {0}\n\ 32.5 (use -source 8 or higher to enable static interface methods) 32.6 32.7 +# 0: string 32.8 +compiler.err.static.intf.method.invoke.not.supported.in.source=\ 32.9 + static interface method invocations are not supported in -source {0}\n\ 32.10 + (use -source 8 or higher to enable static interface method invocations) 32.11 + 32.12 ######################################## 32.13 # Diagnostics for verbose resolution 32.14 # used by Resolve (debug only)
33.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 33.2 +++ b/src/share/classes/com/sun/tools/javac/util/IntHashTable.java Mon Jun 16 11:19:22 2014 -0700 33.3 @@ -0,0 +1,198 @@ 33.4 +/* 33.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 33.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 33.7 + * 33.8 + * This code is free software; you can redistribute it and/or modify it 33.9 + * under the terms of the GNU General Public License version 2 only, as 33.10 + * published by the Free Software Foundation. Oracle designates this 33.11 + * particular file as subject to the "Classpath" exception as provided 33.12 + * by Oracle in the LICENSE file that accompanied this code. 33.13 + * 33.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 33.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 33.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 33.17 + * version 2 for more details (a copy is included in the LICENSE file that 33.18 + * accompanied this code). 33.19 + * 33.20 + * You should have received a copy of the GNU General Public License version 33.21 + * 2 along with this work; if not, write to the Free Software Foundation, 33.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 33.23 + * 33.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 33.25 + * or visit www.oracle.com if you need additional information or have any 33.26 + * questions. 33.27 + */ 33.28 + 33.29 +package com.sun.tools.javac.util; 33.30 + 33.31 +/** 33.32 + * A hash table that maps Object to int. 33.33 + * 33.34 + * This is a custom hash table optimised for the Object -> int 33.35 + * maps. This is done to avoid unnecessary object allocation in the image set. 33.36 + * 33.37 + * @author Charles Turner 33.38 + * @author Per Bothner 33.39 + */ 33.40 +public class IntHashTable { 33.41 + private static final int DEFAULT_INITIAL_SIZE = 64; 33.42 + protected Object[] objs; // the domain set 33.43 + protected int[] ints; // the image set 33.44 + protected int mask; // used to clip int's into the domain 33.45 + protected int num_bindings; // the number of mappings (including DELETED) 33.46 + private final static Object DELETED = new Object(); 33.47 + 33.48 + /** 33.49 + * Construct an Object -> int hash table. 33.50 + * 33.51 + * The default size of the hash table is 64 mappings. 33.52 + */ 33.53 + public IntHashTable() { 33.54 + objs = new Object[DEFAULT_INITIAL_SIZE]; 33.55 + ints = new int[DEFAULT_INITIAL_SIZE]; 33.56 + mask = DEFAULT_INITIAL_SIZE - 1; 33.57 + } 33.58 + 33.59 + /** 33.60 + * Construct an Object -> int hash table with a specified amount of mappings. 33.61 + * @param capacity The number of default mappings in this hash table. 33.62 + */ 33.63 + public IntHashTable(int capacity) { 33.64 + int log2Size = 4; 33.65 + while (capacity > (1 << log2Size)) { 33.66 + log2Size++; 33.67 + } 33.68 + capacity = 1 << log2Size; 33.69 + objs = new Object[capacity]; 33.70 + ints = new int[capacity]; 33.71 + mask = capacity - 1; 33.72 + } 33.73 + 33.74 + /** 33.75 + * Compute the hash code of a given object. 33.76 + * 33.77 + * @param key The object whose hash code is to be computed. 33.78 + * @return zero if the object is null, otherwise the identityHashCode 33.79 + */ 33.80 + public int hash(Object key) { 33.81 + return System.identityHashCode(key); 33.82 + } 33.83 + 33.84 + /** 33.85 + * Find either the index of a key's value, or the index of an available space. 33.86 + * 33.87 + * @param key The key to whose value you want to find. 33.88 + * @param hash The hash code of this key. 33.89 + * @return Either the index of the key's value, or an index pointing to 33.90 + * unoccupied space. 33.91 + */ 33.92 + public int lookup(Object key, int hash) { 33.93 + Object node; 33.94 + int hash1 = hash ^ (hash >>> 15); 33.95 + int hash2 = (hash ^ (hash << 6)) | 1; //ensure coprimeness 33.96 + int deleted = -1; 33.97 + for (int i = hash1 & mask;; i = (i + hash2) & mask) { 33.98 + node = objs[i]; 33.99 + if (node == key) 33.100 + return i; 33.101 + if (node == null) 33.102 + return deleted >= 0 ? deleted : i; 33.103 + if (node == DELETED && deleted < 0) 33.104 + deleted = i; 33.105 + } 33.106 + } 33.107 + 33.108 + /** 33.109 + * Lookup a given key's value in the hash table. 33.110 + * 33.111 + * @param key The key whose value you want to find. 33.112 + * @return Either the index of the key's value, or an index pointing to 33.113 + * unoccupied space. 33.114 + */ 33.115 + public int lookup(Object key) { 33.116 + return lookup(key, hash(key)); 33.117 + } 33.118 + 33.119 + /** 33.120 + * Return the value stored at the specified index in the table. 33.121 + * 33.122 + * @param index The index to inspect, as returned from {@link #lookup} 33.123 + * @return A non-negative integer if the index contains a non-null 33.124 + * value, or -1 if it does. 33.125 + */ 33.126 + public int getFromIndex(int index) { 33.127 + Object node = objs[index]; 33.128 + return node == null || node == DELETED ? -1 : ints[index]; 33.129 + } 33.130 + 33.131 + /** 33.132 + * Associates the specified key with the specified value in this map. 33.133 + * 33.134 + * @param key key with which the specified value is to be associated. 33.135 + * @param value value to be associated with the specified key. 33.136 + * @param index the index at which to place this binding, as returned 33.137 + * from {@link #lookup}. 33.138 + * @return previous value associated with specified key, or -1 if there was 33.139 + * no mapping for key. 33.140 + */ 33.141 + public int putAtIndex(Object key, int value, int index) { 33.142 + Object old = objs[index]; 33.143 + if (old == null || old == DELETED) { 33.144 + objs[index] = key; 33.145 + ints[index] = value; 33.146 + if (old != DELETED) 33.147 + num_bindings++; 33.148 + if (3 * num_bindings >= 2 * objs.length) 33.149 + rehash(); 33.150 + return -1; 33.151 + } else { // update existing mapping 33.152 + int oldValue = ints[index]; 33.153 + ints[index] = value; 33.154 + return oldValue; 33.155 + } 33.156 + } 33.157 + 33.158 + public int remove(Object key) { 33.159 + int index = lookup(key); 33.160 + Object old = objs[index]; 33.161 + if (old == null || old == DELETED) 33.162 + return -1; 33.163 + objs[index] = DELETED; 33.164 + return ints[index]; 33.165 + } 33.166 + 33.167 + /** 33.168 + * Expand the hash table when it exceeds the load factor. 33.169 + * 33.170 + * Rehash the existing objects. 33.171 + */ 33.172 + protected void rehash() { 33.173 + Object[] oldObjsTable = objs; 33.174 + int[] oldIntsTable = ints; 33.175 + int oldCapacity = oldObjsTable.length; 33.176 + int newCapacity = oldCapacity << 1; 33.177 + Object[] newObjTable = new Object[newCapacity]; 33.178 + int[] newIntTable = new int[newCapacity]; 33.179 + int newMask = newCapacity - 1; 33.180 + objs = newObjTable; 33.181 + ints = newIntTable; 33.182 + mask = newMask; 33.183 + num_bindings = 0; // this is recomputed below 33.184 + Object key; 33.185 + for (int i = oldIntsTable.length; --i >= 0;) { 33.186 + key = oldObjsTable[i]; 33.187 + if (key != null && key != DELETED) 33.188 + putAtIndex(key, oldIntsTable[i], lookup(key, hash(key))); 33.189 + } 33.190 + } 33.191 + 33.192 + /** 33.193 + * Removes all mappings from this map. 33.194 + */ 33.195 + public void clear() { 33.196 + for (int i = objs.length; --i >= 0;) { 33.197 + objs[i] = null; 33.198 + } 33.199 + num_bindings = 0; 33.200 + } 33.201 +}
34.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 34.2 +++ b/src/share/classes/com/sun/tools/javac/util/StringUtils.java Mon Jun 16 11:19:22 2014 -0700 34.3 @@ -0,0 +1,70 @@ 34.4 +/* 34.5 + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. 34.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 34.7 + * 34.8 + * This code is free software; you can redistribute it and/or modify it 34.9 + * under the terms of the GNU General Public License version 2 only, as 34.10 + * published by the Free Software Foundation. Oracle designates this 34.11 + * particular file as subject to the "Classpath" exception as provided 34.12 + * by Oracle in the LICENSE file that accompanied this code. 34.13 + * 34.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 34.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 34.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 34.17 + * version 2 for more details (a copy is included in the LICENSE file that 34.18 + * accompanied this code). 34.19 + * 34.20 + * You should have received a copy of the GNU General Public License version 34.21 + * 2 along with this work; if not, write to the Free Software Foundation, 34.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 34.23 + * 34.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 34.25 + * or visit www.oracle.com if you need additional information or have any 34.26 + * questions. 34.27 + */ 34.28 + 34.29 +package com.sun.tools.javac.util; 34.30 + 34.31 +import java.util.Locale; 34.32 +import java.util.regex.Matcher; 34.33 +import java.util.regex.Pattern; 34.34 + 34.35 +/** A collection of utilities for String manipulation. 34.36 + * 34.37 + * <p><b>This is NOT part of any supported API. 34.38 + * If you write code that depends on this, you do so at your own risk. 34.39 + * This code and its internal interfaces are subject to change or 34.40 + * deletion without notice.</b> 34.41 + */ 34.42 +public class StringUtils { 34.43 + 34.44 + /**Converts the given String to lower case using the {@link Locale#US US Locale}. The result 34.45 + * is independent of the default Locale in the current JVM instance. 34.46 + */ 34.47 + public static String toLowerCase(String source) { 34.48 + return source.toLowerCase(Locale.US); 34.49 + } 34.50 + 34.51 + /**Converts the given String to upper case using the {@link Locale#US US Locale}. The result 34.52 + * is independent of the default Locale in the current JVM instance. 34.53 + */ 34.54 + public static String toUpperCase(String source) { 34.55 + return source.toUpperCase(Locale.US); 34.56 + } 34.57 + 34.58 + /**Case insensitive version of {@link String#indexOf(java.lang.String)}. Equivalent to 34.59 + * {@code text.indexOf(str)}, except the matching is case insensitive. 34.60 + */ 34.61 + public static int indexOfIgnoreCase(String text, String str) { 34.62 + return indexOfIgnoreCase(text, str, 0); 34.63 + } 34.64 + 34.65 + /**Case insensitive version of {@link String#indexOf(java.lang.String, int)}. Equivalent to 34.66 + * {@code text.indexOf(str, startIndex)}, except the matching is case insensitive. 34.67 + */ 34.68 + public static int indexOfIgnoreCase(String text, String str, int startIndex) { 34.69 + Matcher m = Pattern.compile(Pattern.quote(str), Pattern.CASE_INSENSITIVE).matcher(text); 34.70 + return m.find(startIndex) ? m.start() : -1; 34.71 + } 34.72 + 34.73 +}
35.1 --- a/src/share/classes/com/sun/tools/javap/AttributeWriter.java Wed Jun 11 09:31:26 2014 -0700 35.2 +++ b/src/share/classes/com/sun/tools/javap/AttributeWriter.java Mon Jun 16 11:19:22 2014 -0700 35.3 @@ -62,6 +62,7 @@ 35.4 import com.sun.tools.classfile.Synthetic_attribute; 35.5 35.6 import static com.sun.tools.classfile.AccessFlags.*; 35.7 +import com.sun.tools.javac.util.StringUtils; 35.8 35.9 /* 35.10 * A writer for writing Attributes as text. 35.11 @@ -690,14 +691,14 @@ 35.12 } 35.13 35.14 static String toHex(int i) { 35.15 - return Integer.toString(i, 16).toUpperCase(); 35.16 + return StringUtils.toUpperCase(Integer.toString(i, 16)); 35.17 } 35.18 35.19 static String toHex(int i, int w) { 35.20 - String s = Integer.toHexString(i).toUpperCase(); 35.21 + String s = StringUtils.toUpperCase(Integer.toHexString(i)); 35.22 while (s.length() < w) 35.23 s = "0" + s; 35.24 - return s.toUpperCase(); 35.25 + return StringUtils.toUpperCase(s); 35.26 } 35.27 35.28 private AnnotationWriter annotationWriter;
36.1 --- a/src/share/classes/com/sun/tools/javap/TypeAnnotationWriter.java Wed Jun 11 09:31:26 2014 -0700 36.2 +++ b/src/share/classes/com/sun/tools/javap/TypeAnnotationWriter.java Mon Jun 16 11:19:22 2014 -0700 36.3 @@ -37,6 +37,7 @@ 36.4 import java.util.HashMap; 36.5 import java.util.List; 36.6 import java.util.Map; 36.7 +import com.sun.tools.javac.util.StringUtils; 36.8 36.9 /** 36.10 * Annotate instructions with details about type annotations. 36.11 @@ -115,7 +116,7 @@ 36.12 print("@"); 36.13 annotationWriter.write(n.anno, false, true); 36.14 print(", "); 36.15 - println(n.kind.toString().toLowerCase()); 36.16 + println(StringUtils.toLowerCase(n.kind.toString())); 36.17 } 36.18 } 36.19 }
37.1 --- a/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java Wed Jun 11 09:31:26 2014 -0700 37.2 +++ b/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java Mon Jun 16 11:19:22 2014 -0700 37.3 @@ -49,6 +49,7 @@ 37.4 import com.sun.tools.javac.util.Context; 37.5 import com.sun.tools.javac.util.Log; 37.6 import com.sun.tools.javac.util.BaseFileManager; 37.7 +import com.sun.tools.javac.util.StringUtils; 37.8 import com.sun.tools.sjavac.comp.Dependencies; 37.9 import com.sun.tools.sjavac.comp.JavaCompilerWithDeps; 37.10 import com.sun.tools.sjavac.comp.SmartFileManager; 37.11 @@ -256,7 +257,7 @@ 37.12 // Load visible sources 37.13 Set<URI> visibleSources = new HashSet<URI>(); 37.14 boolean fix_drive_letter_case = 37.15 - System.getProperty("os.name").toLowerCase().startsWith("windows"); 37.16 + StringUtils.toLowerCase(System.getProperty("os.name")).startsWith("windows"); 37.17 for (;;) { 37.18 String l = in.readLine(); 37.19 if (l == null)
38.1 --- a/test/com/sun/javadoc/testRelativeLinks/TestRelativeLinks.java Wed Jun 11 09:31:26 2014 -0700 38.2 +++ b/test/com/sun/javadoc/testRelativeLinks/TestRelativeLinks.java Mon Jun 16 11:19:22 2014 -0700 38.3 @@ -23,7 +23,7 @@ 38.4 38.5 /* 38.6 * @test 38.7 - * @bug 4460354 8014636 38.8 + * @bug 4460354 8014636 8043186 38.9 * @summary Test to make sure that relative paths are redirected in the 38.10 * output so that they are not broken. 38.11 * @author jamieh
39.1 --- a/test/com/sun/javadoc/testRelativeLinks/pkg/C.java Wed Jun 11 09:31:26 2014 -0700 39.2 +++ b/test/com/sun/javadoc/testRelativeLinks/pkg/C.java Mon Jun 16 11:19:22 2014 -0700 39.3 @@ -1,5 +1,5 @@ 39.4 /* 39.5 - * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. 39.6 + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. 39.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 39.8 * 39.9 * This code is free software; you can redistribute it and/or modify it 39.10 @@ -30,7 +30,7 @@ 39.11 public class C { 39.12 39.13 /** 39.14 - * Here is a relative link in a field: 39.15 + * Here is a relative link in a field:\u0130 39.16 * <a href="relative-field-link.html">relative field link</a>. 39.17 */ 39.18 public C field = null;
40.1 --- a/test/com/sun/javadoc/testTopOption/TestTopOption.java Wed Jun 11 09:31:26 2014 -0700 40.2 +++ b/test/com/sun/javadoc/testTopOption/TestTopOption.java Mon Jun 16 11:19:22 2014 -0700 40.3 @@ -23,7 +23,7 @@ 40.4 40.5 /* 40.6 * @test 40.7 - * @bug 6227616 40.8 + * @bug 6227616 8043186 40.9 * @summary Test the new -top option. 40.10 * @author jamieh 40.11 * @library ../lib/ 40.12 @@ -39,7 +39,7 @@ 40.13 40.14 //Javadoc arguments. 40.15 private static final String[] ARGS = new String[] { 40.16 - "-overview", "SRC_DIR + FS + overview.html", "-use", "-top", "TOP TEXT", "-d", BUG_ID, "-sourcepath", 40.17 + "-overview", SRC_DIR + FS + "overview.html", "-use", "-top", "\u0130{@docroot}TOP TEXT", "-d", BUG_ID, "-sourcepath", 40.18 SRC_DIR, "pkg" 40.19 }; 40.20
41.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 41.2 +++ b/test/tools/javac/NoStringToLower.java Mon Jun 16 11:19:22 2014 -0700 41.3 @@ -0,0 +1,136 @@ 41.4 +/* 41.5 + * Copyright (c) 2013, 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. 41.11 + * 41.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 41.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 41.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 41.15 + * version 2 for more details (a copy is included in the LICENSE file that 41.16 + * accompanied this code). 41.17 + * 41.18 + * You should have received a copy of the GNU General Public License version 41.19 + * 2 along with this work; if not, write to the Free Software Foundation, 41.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 41.21 + * 41.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 41.23 + * or visit www.oracle.com if you need additional information or have any 41.24 + * questions. 41.25 + */ 41.26 + 41.27 +/* 41.28 + * @test 41.29 + * @bug 8029800 41.30 + * @summary String.toLowerCase()/toUpperCase is generally dangerous, check it is not used in langtools 41.31 + */ 41.32 + 41.33 +import java.io.*; 41.34 +import java.util.*; 41.35 +import javax.tools.*; 41.36 +import com.sun.tools.classfile.*; 41.37 +import com.sun.tools.classfile.ConstantPool.CONSTANT_Methodref_info; 41.38 + 41.39 +public class NoStringToLower { 41.40 + public static void main(String... args) throws Exception { 41.41 + NoStringToLower c = new NoStringToLower(); 41.42 + if (c.run(args)) 41.43 + return; 41.44 + 41.45 + if (is_jtreg()) 41.46 + throw new Exception(c.errors + " errors occurred"); 41.47 + else 41.48 + System.exit(1); 41.49 + } 41.50 + 41.51 + static boolean is_jtreg() { 41.52 + return (System.getProperty("test.src") != null); 41.53 + } 41.54 + 41.55 + /** 41.56 + * Main entry point. 41.57 + */ 41.58 + boolean run(String... args) throws Exception { 41.59 + JavaCompiler c = ToolProvider.getSystemJavaCompiler(); 41.60 + JavaFileManager fm = c.getStandardFileManager(null, null, null); 41.61 + JavaFileManager.Location javacLoc = findJavacLocation(fm); 41.62 + String[] pkgs = { 41.63 + "javax.annotation.processing", 41.64 + "javax.lang.model", 41.65 + "javax.tools", 41.66 + "com.sun.source", 41.67 + "com.sun.tools.classfile", 41.68 + "com.sun.tools.doclet", 41.69 + "com.sun.tools.doclint", 41.70 + "com.sun.tools.javac", 41.71 + "com.sun.tools.javadoc", 41.72 + "com.sun.tools.javah", 41.73 + "com.sun.tools.javap", 41.74 + "com.sun.tools.jdeps", 41.75 + "com.sun.tools.sjavac" 41.76 + }; 41.77 + for (String pkg: pkgs) { 41.78 + for (JavaFileObject fo: fm.list(javacLoc, 41.79 + pkg, EnumSet.of(JavaFileObject.Kind.CLASS), true)) { 41.80 + scan(fo); 41.81 + } 41.82 + } 41.83 + 41.84 + return (errors == 0); 41.85 + } 41.86 + 41.87 + // depending on how the test is run, javac may be on bootclasspath or classpath 41.88 + JavaFileManager.Location findJavacLocation(JavaFileManager fm) { 41.89 + JavaFileManager.Location[] locns = 41.90 + { StandardLocation.PLATFORM_CLASS_PATH, StandardLocation.CLASS_PATH }; 41.91 + try { 41.92 + for (JavaFileManager.Location l: locns) { 41.93 + JavaFileObject fo = fm.getJavaFileForInput(l, 41.94 + "com.sun.tools.javac.Main", JavaFileObject.Kind.CLASS); 41.95 + if (fo != null) 41.96 + return l; 41.97 + } 41.98 + } catch (IOException e) { 41.99 + throw new Error(e); 41.100 + } 41.101 + throw new IllegalStateException("Cannot find javac"); 41.102 + } 41.103 + 41.104 + /** 41.105 + * Verify there are no references to String.toLowerCase() in a class file. 41.106 + */ 41.107 + void scan(JavaFileObject fo) throws IOException { 41.108 + InputStream in = fo.openInputStream(); 41.109 + try { 41.110 + ClassFile cf = ClassFile.read(in); 41.111 + for (ConstantPool.CPInfo cpinfo: cf.constant_pool.entries()) { 41.112 + if (cpinfo.getTag() == ConstantPool.CONSTANT_Methodref) { 41.113 + CONSTANT_Methodref_info ref = (CONSTANT_Methodref_info) cpinfo; 41.114 + String methodDesc = ref.getClassInfo().getName() + "." + ref.getNameAndTypeInfo().getName() + ":" + ref.getNameAndTypeInfo().getType(); 41.115 + 41.116 + if ("java/lang/String.toLowerCase:()Ljava/lang/String;".equals(methodDesc)) { 41.117 + error("found reference to String.toLowerCase() in: " + fo.getName()); 41.118 + } 41.119 + if ("java/lang/String.toUpperCase:()Ljava/lang/String;".equals(methodDesc)) { 41.120 + error("found reference to String.toLowerCase() in: " + fo.getName()); 41.121 + } 41.122 + } 41.123 + } 41.124 + } catch (ConstantPoolException ignore) { 41.125 + } finally { 41.126 + in.close(); 41.127 + } 41.128 + } 41.129 + 41.130 + /** 41.131 + * Report an error. 41.132 + */ 41.133 + void error(String msg) { 41.134 + System.err.println("Error: " + msg); 41.135 + errors++; 41.136 + } 41.137 + 41.138 + int errors; 41.139 +}
42.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 42.2 +++ b/test/tools/javac/diags/examples/StaticIntfMethodInvokeNotSupported.java Mon Jun 16 11:19:22 2014 -0700 42.3 @@ -0,0 +1,32 @@ 42.4 +/* 42.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 42.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 42.7 + * 42.8 + * This code is free software; you can redistribute it and/or modify it 42.9 + * under the terms of the GNU General Public License version 2 only, as 42.10 + * published by the Free Software Foundation. 42.11 + * 42.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 42.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 42.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 42.15 + * version 2 for more details (a copy is included in the LICENSE file that 42.16 + * accompanied this code). 42.17 + * 42.18 + * You should have received a copy of the GNU General Public License version 42.19 + * 2 along with this work; if not, write to the Free Software Foundation, 42.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 42.21 + * 42.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 42.23 + * or visit www.oracle.com if you need additional information or have any 42.24 + * questions. 42.25 + */ 42.26 + 42.27 +// key: compiler.err.static.intf.method.invoke.not.supported.in.source 42.28 +// options: -source 7 -Xlint:-options 42.29 +import java.util.stream.Stream; 42.30 + 42.31 +class StaticIntfMethodInvokeNotSupported { 42.32 + void test() { 42.33 + Stream.empty(); 42.34 + } 42.35 +}
43.1 --- a/test/tools/javac/flow/LVTHarness.java Wed Jun 11 09:31:26 2014 -0700 43.2 +++ b/test/tools/javac/flow/LVTHarness.java Mon Jun 16 11:19:22 2014 -0700 43.3 @@ -1,5 +1,5 @@ 43.4 /* 43.5 - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 43.6 + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. 43.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 43.8 * 43.9 * This code is free software; you can redistribute it and/or modify it 43.10 @@ -23,8 +23,8 @@ 43.11 43.12 /* 43.13 * @test 43.14 - * @bug 7047734 8027660 43.15 - * @summary The LVT is not generated correctly during some try/catch scenarios; 43.16 + * @bug 7047734 8027660 8037937 43.17 + * @summary The LVT is not generated correctly during some try/catch scenarios 43.18 * javac crash while creating LVT entry for a local variable defined in 43.19 * an inner block 43.20 * @library /tools/javac/lib 43.21 @@ -120,7 +120,7 @@ 43.22 for (Map.Entry<ElementKey, AliveRanges> entry : aliveRangeMap.entrySet()) { 43.23 if (!seenAliveRanges.contains(entry.getKey())) { 43.24 error("Redundant @AliveRanges annotation on method " + 43.25 - entry.getKey().elem); 43.26 + entry.getKey().elem + " with key " + entry.getKey()); 43.27 } 43.28 } 43.29 } 43.30 @@ -134,7 +134,7 @@ 43.31 for (Method method : classFile.methods) { 43.32 for (ElementKey elementKey: aliveRangeMap.keySet()) { 43.33 String methodDesc = method.getName(constantPool) + 43.34 - method.descriptor.getParameterTypes(constantPool); 43.35 + method.descriptor.getParameterTypes(constantPool).replace(" ", ""); 43.36 if (methodDesc.equals(elementKey.elem.toString())) { 43.37 checkMethod(constantPool, method, aliveRangeMap.get(elementKey)); 43.38 seenAliveRanges.add(elementKey);
44.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 44.2 +++ b/test/tools/javac/flow/T8042741/A.java Mon Jun 16 11:19:22 2014 -0700 44.3 @@ -0,0 +1,37 @@ 44.4 +/* 44.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 44.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 44.7 + * 44.8 + * This code is free software; you can redistribute it and/or modify it 44.9 + * under the terms of the GNU General Public License version 2 only, as 44.10 + * published by the Free Software Foundation. 44.11 + * 44.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 44.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 44.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 44.15 + * version 2 for more details (a copy is included in the LICENSE file that 44.16 + * accompanied this code). 44.17 + * 44.18 + * You should have received a copy of the GNU General Public License version 44.19 + * 2 along with this work; if not, write to the Free Software Foundation, 44.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 44.21 + * 44.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 44.23 + * or visit www.oracle.com if you need additional information or have any 44.24 + * questions. 44.25 + */ 44.26 + 44.27 +// str must be at absolute position greater than that of lambda 44.28 +// expression in PositionTest.java 44.29 +// padding..........................................................padding 44.30 +// padding..........................................................padding 44.31 +// padding..........................................................padding 44.32 +// padding..........................................................padding 44.33 +// padding..........................................................padding 44.34 + 44.35 +public class A { 44.36 + public final String str; 44.37 + { 44.38 + str = ""; 44.39 + } 44.40 +}
45.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 45.2 +++ b/test/tools/javac/flow/T8042741/PositionTest.java Mon Jun 16 11:19:22 2014 -0700 45.3 @@ -0,0 +1,62 @@ 45.4 +/* 45.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 45.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 45.7 + * 45.8 + * This code is free software; you can redistribute it and/or modify it 45.9 + * under the terms of the GNU General Public License version 2 only, as 45.10 + * published by the Free Software Foundation. 45.11 + * 45.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 45.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 45.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 45.15 + * version 2 for more details (a copy is included in the LICENSE file that 45.16 + * accompanied this code). 45.17 + * 45.18 + * You should have received a copy of the GNU General Public License version 45.19 + * 2 along with this work; if not, write to the Free Software Foundation, 45.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 45.21 + * 45.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 45.23 + * or visit www.oracle.com if you need additional information or have any 45.24 + * questions. 45.25 + */ 45.26 + 45.27 +/* @test 45.28 + * @bug 8042741 45.29 + * @summary Java 8 compiler throws NullPointerException depending location in source file 45.30 + * @compile A.java PositionTest.java 45.31 + */ 45.32 + 45.33 +public class PositionTest extends A { 45.34 + <E extends Exception> void test(SAM<E> r) throws E { 45.35 + test(() -> { System.err.println(str); }); 45.36 + } 45.37 + interface SAM<E extends Exception> { 45.38 + public void run() throws E; 45.39 + } 45.40 + void f() { 45.41 + try { 45.42 + test(() -> { 45.43 + test(() -> { 45.44 + try { 45.45 + test(() -> { System.err.println(str); }); 45.46 + System.err.println(str); 45.47 + } catch (Exception e) {} 45.48 + System.err.println(str); 45.49 + }); 45.50 + System.err.println(str); 45.51 + }); 45.52 + } catch (Exception e) { } 45.53 + } 45.54 + void g() throws Exception { 45.55 + test(() -> { 45.56 + try { 45.57 + try { 45.58 + test(() -> { System.err.println(str); }); 45.59 + } catch (Exception e) {} 45.60 + System.err.println(str); 45.61 + } catch (Exception e) {} 45.62 + System.err.println(str); 45.63 + }); 45.64 + } 45.65 +}
46.1 --- a/test/tools/javac/flow/tests/TestCaseIfElse.java Wed Jun 11 09:31:26 2014 -0700 46.2 +++ b/test/tools/javac/flow/tests/TestCaseIfElse.java Mon Jun 16 11:19:22 2014 -0700 46.3 @@ -33,7 +33,7 @@ 46.4 46.5 @AliveRange(varName="o", bytecodeStart=10, bytecodeLength=8) 46.6 @AliveRange(varName="o", bytecodeStart=21, bytecodeLength=9) 46.7 - void m2(String[] args) { 46.8 + void m2() { 46.9 Object o; 46.10 int i = 5; 46.11 if (i != 5) { 46.12 @@ -45,4 +45,19 @@ 46.13 } 46.14 o = "finish"; 46.15 } 46.16 + 46.17 + @AliveRange(varName="o", bytecodeStart=11, bytecodeLength=3) 46.18 + @AliveRange(varName="o", bytecodeStart=17, bytecodeLength=2) 46.19 + Object m3(boolean cond1, boolean cond2) { 46.20 + Object o; 46.21 + if (cond1) { 46.22 + if (cond2) { 46.23 + o = "then"; 46.24 + } else { 46.25 + o = "else"; 46.26 + return null; 46.27 + } 46.28 + } 46.29 + return null; 46.30 + } 46.31 }
47.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 47.2 +++ b/test/tools/javac/generics/diamond/T8041713/DiamondPlusUnexistingMethodRefCrashTest.java Mon Jun 16 11:19:22 2014 -0700 47.3 @@ -0,0 +1,11 @@ 47.4 +/* 47.5 + * @test /nodynamiccopyright/ 47.6 + * @bug 8041713 47.7 + * @summary Type inference of non-existent method references crashes the compiler 47.8 + * @compile/fail/ref=DiamondPlusUnexistingMethodRefCrashTest.out -XDrawDiagnostics DiamondPlusUnexistingMethodRefCrashTest.java 47.9 + */ 47.10 + 47.11 +public class DiamondPlusUnexistingMethodRefCrashTest<T> { 47.12 + DiamondPlusUnexistingMethodRefCrashTest<String> m = 47.13 + new DiamondPlusUnexistingMethodRefCrashTest<>(DiamondPlusUnexistingMethodRefCrashTest::doNotExists); 47.14 +}
48.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 48.2 +++ b/test/tools/javac/generics/diamond/T8041713/DiamondPlusUnexistingMethodRefCrashTest.out Mon Jun 16 11:19:22 2014 -0700 48.3 @@ -0,0 +1,2 @@ 48.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)) 48.5 +1 error
49.1 --- a/test/tools/javac/generics/inference/7086586/T7086586.out Wed Jun 11 09:31:26 2014 -0700 49.2 +++ b/test/tools/javac/generics/inference/7086586/T7086586.out Mon Jun 16 11:19:22 2014 -0700 49.3 @@ -1,5 +1,5 @@ 49.4 -T7086586.java:14:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.captureof: 1, ?, java.lang.String) 49.5 -T7086586.java:15:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.captureof: 1, ?, java.lang.Number) 49.6 -T7086586.java:16:31: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.captureof: 1, ?, java.lang.Exception) 49.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) 49.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>)) 49.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>)) 49.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>)) 49.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>)) 49.12 4 errors
50.1 --- a/test/tools/javac/generics/inference/7086586/T7086586b.java Wed Jun 11 09:31:26 2014 -0700 50.2 +++ b/test/tools/javac/generics/inference/7086586/T7086586b.java Mon Jun 16 11:19:22 2014 -0700 50.3 @@ -23,10 +23,9 @@ 50.4 50.5 /* 50.6 * @test 50.7 - * @bug 7086586 8033718 50.8 + * @bug 7086586 50.9 * 50.10 - * @summary Inference producing null type argument; inference ignores capture 50.11 - * variable as upper bound 50.12 + * @summary Inference producing null type argument 50.13 */ 50.14 import java.util.List; 50.15 50.16 @@ -41,8 +40,8 @@ 50.17 assertionCount++; 50.18 } 50.19 50.20 - <T> void m(List<? super T> dummy) { assertTrue(true); } 50.21 - <T> void m(Object dummy) { assertTrue(false); } 50.22 + <T> void m(List<? super T> dummy) { assertTrue(false); } 50.23 + <T> void m(Object dummy) { assertTrue(true); } 50.24 50.25 void test(List<?> l) { 50.26 m(l);
51.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 51.2 +++ b/test/tools/javac/generics/inference/8043725/T8043725.java Mon Jun 16 11:19:22 2014 -0700 51.3 @@ -0,0 +1,36 @@ 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 8043725 51.30 + * @summary javac fails with StackOverflowException 51.31 + * @compile T8043725.java 51.32 + */ 51.33 +class T8043725 { 51.34 + <T extends Comparable<T>> T m(T v) { 51.35 + //this will generate two upper bounds, T and Comparable<T'> respectively 51.36 + //causing infinite recursion in lub (because of JLS 18.3.1). 51.37 + return m(v); 51.38 + } 51.39 +}
52.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 52.2 +++ b/test/tools/javac/generics/inference/NestedWildcards.java Mon Jun 16 11:19:22 2014 -0700 52.3 @@ -0,0 +1,44 @@ 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 +/* 52.28 + * @test 52.29 + * @bug 8039214 52.30 + * @summary Nested generic methods that work on wildcard-parameterized types 52.31 + * @compile NestedWildcards.java 52.32 + */ 52.33 + 52.34 +public class NestedWildcards { 52.35 + 52.36 + public static void test(Box<String> b) { 52.37 + foo(bar(b)); 52.38 + } 52.39 + private static <X> Box<? extends X> foo(Box<? extends X> ts) { 52.40 + return null; 52.41 + } 52.42 + public static <Y> Box<? extends Y> bar(Box<? extends Y> language) { 52.43 + return null; 52.44 + } 52.45 + 52.46 + interface Box<T> {} 52.47 +}
53.1 --- a/test/tools/javac/generics/wildcards/7034495/T7034495.out Wed Jun 11 09:31:26 2014 -0700 53.2 +++ b/test/tools/javac/generics/wildcards/7034495/T7034495.out Mon Jun 16 11:19:22 2014 -0700 53.3 @@ -1,2 +1,2 @@ 53.4 -T7034495.java:40:17: compiler.err.types.incompatible.diff.ret: T7034495.B<?>, T7034495.A<?>, foo() 53.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() 53.6 1 error
54.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 54.2 +++ b/test/tools/javac/generics/wildcards/T8015101.java Mon Jun 16 11:19:22 2014 -0700 54.3 @@ -0,0 +1,44 @@ 54.4 +/* 54.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 54.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 54.7 + * 54.8 + * This code is free software; you can redistribute it and/or modify it 54.9 + * under the terms of the GNU General Public License version 2 only, as 54.10 + * published by the Free Software Foundation. 54.11 + * 54.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 54.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 54.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 54.15 + * version 2 for more details (a copy is included in the LICENSE file that 54.16 + * accompanied this code). 54.17 + * 54.18 + * You should have received a copy of the GNU General Public License version 54.19 + * 2 along with this work; if not, write to the Free Software Foundation, 54.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 54.21 + * 54.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 54.23 + * or visit www.oracle.com if you need additional information or have any 54.24 + * questions. 54.25 + */ 54.26 + 54.27 +/* 54.28 + * @test 54.29 + * @bug 8015101 54.30 + * @summary Mishandling of wildcards in intersection member method check 54.31 + * @compile T8015101.java 54.32 + */ 54.33 +class T8015101 { 54.34 + 54.35 + public static class Bug<X extends Child<?, ?> & Runnable> { 54.36 + } 54.37 + 54.38 + interface Parent<C> { 54.39 + public C get(); 54.40 + } 54.41 + 54.42 + interface Child<C, S extends C> extends Parent<C> { 54.43 + @Override 54.44 + public S get(); 54.45 + } 54.46 + 54.47 + }
55.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 55.2 +++ b/test/tools/javac/lambda/T8031967.java Mon Jun 16 11:19:22 2014 -0700 55.3 @@ -0,0 +1,137 @@ 55.4 +/* 55.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 55.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 55.7 + * 55.8 + * This code is free software; you can redistribute it and/or modify it 55.9 + * under the terms of the GNU General Public License version 2 only, as 55.10 + * published by the Free Software Foundation. 55.11 + * 55.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 55.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 55.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 55.15 + * version 2 for more details (a copy is included in the LICENSE file that 55.16 + * accompanied this code). 55.17 + * 55.18 + * You should have received a copy of the GNU General Public License version 55.19 + * 2 along with this work; if not, write to the Free Software Foundation, 55.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 55.21 + * 55.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 55.23 + * or visit www.oracle.com if you need additional information or have any 55.24 + * questions. 55.25 + */ 55.26 + 55.27 +/* 55.28 + * @test 55.29 + * @bug 8031967 55.30 + * @summary Ensure javac can handle very deeply nested chain of method invocations occurring as 55.31 + * a parameter to other method invocations. 55.32 + * @run main T8031967 55.33 + */ 55.34 + 55.35 +import java.io.IOException; 55.36 +import java.net.URI; 55.37 +import java.util.Arrays; 55.38 +import java.util.List; 55.39 + 55.40 +import javax.tools.DiagnosticListener; 55.41 +import javax.tools.JavaCompiler; 55.42 +import javax.tools.JavaFileObject; 55.43 +import javax.tools.SimpleJavaFileObject; 55.44 +import javax.tools.ToolProvider; 55.45 + 55.46 +import com.sun.source.util.JavacTask; 55.47 + 55.48 +public class T8031967 { 55.49 + 55.50 + public static void main(String... args) throws IOException { 55.51 + new T8031967().run(); 55.52 + } 55.53 + 55.54 + final int depth = 50; 55.55 + 55.56 + private void run() throws IOException { 55.57 + runTestCase(true); 55.58 + runTestCase(false); 55.59 + } 55.60 + 55.61 + private void runTestCase(boolean withErrors) throws IOException { 55.62 + StringBuilder code = new StringBuilder(); 55.63 + 55.64 + code.append("public class Test {\n" + 55.65 + " private void test() {\n" + 55.66 + " GroupLayout l = new GroupLayout();\n" + 55.67 + " l.setHorizontalGroup(\n"); 55.68 + 55.69 + gen(code, depth); 55.70 + code.append(" );\n" + 55.71 + " }\n"); 55.72 + if (!withErrors) { 55.73 + code.append(" class GroupLayout {\n" + 55.74 + " ParallelGroup createParallelGroup() {return null;}\n" + 55.75 + " ParallelGroup createParallelGroup(int i) {return null;}\n" + 55.76 + " ParallelGroup createParallelGroup(int i, int j) {return null;}\n" + 55.77 + " void setHorizontalGroup(Group g) { }\n" + 55.78 + " }\n" + 55.79 + " \n" + 55.80 + " class Group {\n" + 55.81 + " Group addGroup(Group g) { return this; }\n" + 55.82 + " Group addGroup(int i, Group g) { return this; }\n" + 55.83 + " Group addGap(int i) { return this; }\n" + 55.84 + " Group addGap(long l) { return this; }\n" + 55.85 + " Group addGap(int i, int j) { return this; }\n" + 55.86 + " Group addComponent(Object c) { return this; }\n" + 55.87 + " Group addComponent(int i, Object c) { return this; }\n" + 55.88 + " }\n" + 55.89 + " class ParallelGroup extends Group {\n" + 55.90 + " Group addGroup(Group g) { return this; }\n" + 55.91 + " Group addGroup(int i, Group g) { return this; }\n" + 55.92 + " Group addGap(int i) { return this; }\n" + 55.93 + " Group addGap(int i, int j) { return this; }\n" + 55.94 + " Group addComponent(Object c) { return this; }\n" + 55.95 + " Group addComponent(int i, Object c) { return this; }\n" + 55.96 + " }\n"); 55.97 + } 55.98 + 55.99 + code.append("}\n"); 55.100 + 55.101 + JavaSource source = new JavaSource(code.toString()); 55.102 + List<JavaSource> sourceList = Arrays.asList(source); 55.103 + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); 55.104 + DiagnosticListener<JavaFileObject> noErrors = (diagnostic) -> { 55.105 + throw new IllegalStateException("Should not produce errors: " + diagnostic); 55.106 + }; 55.107 + JavacTask task = (JavacTask) compiler.getTask(null, null, withErrors ? null : noErrors, 55.108 + null, null, sourceList); 55.109 + 55.110 + task.analyze(); 55.111 + } 55.112 + 55.113 + private void gen(StringBuilder code, int depth) { 55.114 + code.append("l.createParallelGroup()\n"); 55.115 + if (depth > 0) { 55.116 + code.append(".addGroup(\n"); 55.117 + gen(code, depth - 1); 55.118 + code.append(")"); 55.119 + } 55.120 + 55.121 + code.append(".addGap(1)\n" + 55.122 + ".addComponent(new Object())\n" + 55.123 + ".addGap(1)\n" + 55.124 + ".addComponent(new Object())"); 55.125 + } 55.126 + 55.127 + class JavaSource extends SimpleJavaFileObject { 55.128 + 55.129 + final String code; 55.130 + public JavaSource(String code) { 55.131 + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); 55.132 + this.code = code; 55.133 + } 55.134 + 55.135 + @Override 55.136 + public CharSequence getCharContent(boolean ignoreEncodingErrors) { 55.137 + return code; 55.138 + } 55.139 + } 55.140 +}
56.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 56.2 +++ b/test/tools/javac/types/BadSigTest.java Mon Jun 16 11:19:22 2014 -0700 56.3 @@ -0,0 +1,40 @@ 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 8037934 56.30 + * @summary Javac generates invalid signatures for local types 56.31 + * @run main BadSigTest 56.32 + */ 56.33 + 56.34 +public class BadSigTest<Outer> { 56.35 + void m(){ 56.36 + class Local1{} 56.37 + class Local2 extends Local1{} 56.38 + Local2.class.getTypeParameters(); 56.39 + } 56.40 + public static void main(String[] args) { 56.41 + new BadSigTest().m(); 56.42 + } 56.43 +}
57.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 57.2 +++ b/test/tools/javac/util/StringUtilsTest.java Mon Jun 16 11:19:22 2014 -0700 57.3 @@ -0,0 +1,68 @@ 57.4 +/* 57.5 + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. 57.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 57.7 + * 57.8 + * This code is free software; you can redistribute it and/or modify it 57.9 + * under the terms of the GNU General Public License version 2 only, as 57.10 + * published by the Free Software Foundation. 57.11 + * 57.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 57.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 57.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 57.15 + * version 2 for more details (a copy is included in the LICENSE file that 57.16 + * accompanied this code). 57.17 + * 57.18 + * You should have received a copy of the GNU General Public License version 57.19 + * 2 along with this work; if not, write to the Free Software Foundation, 57.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 57.21 + * 57.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 57.23 + * or visit www.oracle.com if you need additional information or have any 57.24 + * questions. 57.25 + */ 57.26 + 57.27 +/** 57.28 + * @test 57.29 + * @bug 8029800 8043186 57.30 + * @summary Unit test StringUtils 57.31 + * @run main StringUtilsTest 57.32 + */ 57.33 + 57.34 +import java.util.Locale; 57.35 +import java.util.Objects; 57.36 +import com.sun.tools.javac.util.StringUtils; 57.37 + 57.38 +public class StringUtilsTest { 57.39 + public static void main(String... args) throws Exception { 57.40 + new StringUtilsTest().run(); 57.41 + } 57.42 + 57.43 + void run() throws Exception { 57.44 + Locale.setDefault(new Locale("tr", "TR")); 57.45 + 57.46 + //verify the properties of the default locale: 57.47 + assertEquals("\u0131", "I".toLowerCase()); 57.48 + assertEquals("\u0130", "i".toUpperCase()); 57.49 + 57.50 + //verify the StringUtils.toLowerCase/toUpperCase do what they should: 57.51 + assertEquals("i", StringUtils.toLowerCase("I")); 57.52 + assertEquals("I", StringUtils.toUpperCase("i")); 57.53 + 57.54 + //verify StringUtils.caseInsensitiveIndexOf works: 57.55 + assertEquals(2, StringUtils.indexOfIgnoreCase(" lookFor", "lookfor")); 57.56 + assertEquals(11, StringUtils.indexOfIgnoreCase(" lookFor LOOKfor", "lookfor", 11)); 57.57 + assertEquals(2, StringUtils.indexOfIgnoreCase("\u0130\u0130lookFor", "lookfor")); 57.58 + } 57.59 + 57.60 + void assertEquals(String expected, String actual) { 57.61 + if (!Objects.equals(expected, actual)) { 57.62 + throw new IllegalStateException("expected=" + expected + "; actual=" + actual); 57.63 + } 57.64 + } 57.65 + 57.66 + void assertEquals(int expected, int actual) { 57.67 + if (expected != actual) { 57.68 + throw new IllegalStateException("expected=" + expected + "; actual=" + actual); 57.69 + } 57.70 + } 57.71 +}