# HG changeset patch # User chegar # Date 1377854230 -3600 # Node ID a8f0c3583a86821f28e2400e81684a4cb34c3aab # Parent a540e2a926cf0d1856a56fb341fc623f27758076# Parent e431c9bfb171317e55095207887cbd17f6a5e139 Merge diff -r a540e2a926cf -r a8f0c3583a86 .hgtags --- a/.hgtags Fri Aug 23 22:12:54 2013 +0100 +++ b/.hgtags Fri Aug 30 10:17:10 2013 +0100 @@ -226,3 +226,4 @@ 453a305e116507847cc6577b80b4d9794bcb08bf jdk8-b102 76cfe7c61f2575ea5400845b8e80dab6f4b1d7d0 jdk8-b103 dd4a00c220c6e14d9b2ce93a2bd436a1d04f0d03 jdk8-b104 +375834b5cf086dd7ce9e49f602d81bb51d3e0fa9 jdk8-b105 diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/source/tree/NewArrayTree.java --- a/src/share/classes/com/sun/source/tree/NewArrayTree.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/source/tree/NewArrayTree.java Fri Aug 30 10:17:10 2013 +0100 @@ -25,7 +25,7 @@ package com.sun.source.tree; -import java.util.List; +import com.sun.tools.javac.util.List; /** * A tree node for an expression to create a new instance of an array. @@ -48,4 +48,6 @@ Tree getType(); List getDimensions(); List getInitializers(); + List getAnnotations(); + List> getDimAnnotations(); } diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/source/util/TreeScanner.java --- a/src/share/classes/com/sun/source/util/TreeScanner.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/source/util/TreeScanner.java Fri Aug 30 10:17:10 2013 +0100 @@ -285,6 +285,10 @@ R r = scan(node.getType(), p); r = scanAndReduce(node.getDimensions(), p, r); r = scanAndReduce(node.getInitializers(), p, r); + r = scanAndReduce(node.getAnnotations(), p, r); + for (Iterable< ? extends Tree> dimAnno : node.getDimAnnotations()) { + r = scanAndReduce(dimAnno, p, r); + } return r; } diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java --- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java Fri Aug 30 10:17:10 2013 +0100 @@ -159,10 +159,7 @@ body.addContent(div); if (configuration.showProfiles) { Content profileSummary = configuration.getResource("doclet.Profiles"); - Content profilesTableSummary = configuration.getResource("doclet.Member_Table_Summary", - configuration.getResource("doclet.Profile_Summary"), - configuration.getResource("doclet.profiles")); - addProfilesList(profileSummary, profilesTableSummary, body); + addProfilesList(profileSummary, body); } addPackagesList(packages, text, tableSummary, body); } @@ -214,10 +211,8 @@ * Do nothing. This will be overridden. * * @param profileSummary the profile summary heading - * @param profilesTableSummary the profiles table summary information * @param body the content tree to which the profiles list will be added */ - protected void addProfilesList(Content profileSummary, Content profilesTableSummary, - Content body) { + protected void addProfilesList(Content profileSummary, Content body) { } } diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java --- a/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java Fri Aug 30 10:17:10 2013 +0100 @@ -25,8 +25,16 @@ package com.sun.tools.doclets.formats.html; -import java.io.*; -import java.util.*; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; import com.sun.javadoc.*; import com.sun.tools.doclets.formats.html.markup.*; @@ -95,7 +103,7 @@ super(configuration, filename); this.classdoc = classdoc; if (mapper.classToPackageAnnotations.containsKey(classdoc.qualifiedName())) - pkgToPackageAnnotations = new HashSet(mapper.classToPackageAnnotations.get(classdoc.qualifiedName())); + pkgToPackageAnnotations = new TreeSet(mapper.classToPackageAnnotations.get(classdoc.qualifiedName())); configuration.currentcd = classdoc; this.pkgSet = new TreeSet(); this.pkgToClassTypeParameter = pkgDivide(mapper.classToClassTypeParam); diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java --- a/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java Fri Aug 30 10:17:10 2013 +0100 @@ -109,7 +109,7 @@ } } // Can't link so just write label. - link.addContent(label.toString()); + link.addContent(label); if (noLabel && !classLinkInfo.excludeTypeParameterLinks) { link.addContent(getTypeParameterLinks(linkInfo)); } diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java --- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java Fri Aug 30 10:17:10 2013 +0100 @@ -123,15 +123,20 @@ /** * {@inheritDoc} */ - protected void addProfilesList(Content profileSummary, String profilesTableSummary, - Content body) { - Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0, profilesTableSummary, - getTableCaption(profileSummary)); - table.addContent(getSummaryTableHeader(profileTableHeader, "col")); - Content tbody = new HtmlTree(HtmlTag.TBODY); - addProfilesList(tbody); - table.addContent(tbody); - Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table); + protected void addProfilesList(Content profileSummary, Content body) { + Content h2 = HtmlTree.HEADING(HtmlTag.H2, profileSummary); + Content profilesDiv = HtmlTree.DIV(h2); + Content ul = new HtmlTree(HtmlTag.UL); + String profileName; + for (int i = 1; i < configuration.profiles.getProfileCount(); i++) { + profileName = Profile.lookup(i).name; + Content profileLinkContent = getTargetProfileLink("classFrame", + new StringContent(profileName), profileName); + Content li = HtmlTree.LI(profileLinkContent); + ul.addContent(li); + } + profilesDiv.addContent(ul); + Content div = HtmlTree.DIV(HtmlStyle.contentContainer, profilesDiv); body.addContent(div); } @@ -151,31 +156,6 @@ } /** - * Adds list of profiles in the index table. Generate link to each profile. - * - * @param tbody the documentation tree to which the list will be added - */ - protected void addProfilesList(Content tbody) { - for (int i = 1; i < configuration.profiles.getProfileCount(); i++) { - String profileName = Profile.lookup(i).name; - Content profileLinkContent = getTargetProfileLink("classFrame", - new StringContent(profileName), profileName); - Content tdProfile = HtmlTree.TD(HtmlStyle.colFirst, profileLinkContent); - HtmlTree tdSummary = new HtmlTree(HtmlTag.TD); - tdSummary.addStyle(HtmlStyle.colLast); - tdSummary.addContent(getSpace()); - HtmlTree tr = HtmlTree.TR(tdProfile); - tr.addContent(tdSummary); - if (i % 2 == 0) { - tr.addStyle(HtmlStyle.altColor); - } else { - tr.addStyle(HtmlStyle.rowColor); - } - tbody.addContent(tr); - } - } - - /** * Adds list of packages in the index table. Generate link to each package. * * @param packages Packages to which link is to be generated diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTag.java --- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTag.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTag.java Fri Aug 30 10:17:10 2013 +0100 @@ -25,6 +25,8 @@ package com.sun.tools.doclets.formats.html.markup; +import java.util.Locale; + /** * Enum representing HTML tags. * @@ -115,7 +117,7 @@ HtmlTag(BlockType blockType, EndTag endTag ) { this.blockType = blockType; this.endTag = endTag; - this.value = name().toLowerCase(); + this.value = name().toLowerCase(Locale.US); } /** diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/doclets/formats/html/markup/StringContent.java --- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/StringContent.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/StringContent.java Fri Aug 30 10:17:10 2013 +0100 @@ -70,6 +70,7 @@ * DocletAbortException because it * is not supported. */ + @Override public void addContent(Content content) { throw new DocletAbortException(); } @@ -80,6 +81,7 @@ * * @param strContent string content to be added */ + @Override public void addContent(String strContent) { appendChars(strContent); } @@ -87,10 +89,12 @@ /** * {@inheritDoc} */ + @Override public boolean isEmpty() { return (stringContent.length() == 0); } + @Override public int charCount() { return RawHtml.charCount(stringContent.toString()); } @@ -98,6 +102,7 @@ /** * {@inheritDoc} */ + @Override public String toString() { return stringContent.toString(); } diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties Fri Aug 30 10:17:10 2013 +0100 @@ -176,25 +176,32 @@ doclet.0_and_1={0} and {1} #Documentation for Enums -doclet.enum_values_doc=\n\ +doclet.enum_values_doc.main=\n\ Returns an array containing the constants of this enum type, in\n\ the order they are declared. This method may be used to iterate\n\ over the constants as follows:\n\
\n\
  for ({0} c : {0}.values())\n\
      System.out.println(c);\n\
- 
\n\ - @return an array containing the constants of this enum type, in\n\ - the order they are declared + -doclet.enum_valueof_doc=\n\ +doclet.enum_values_doc.return=\n\ + an array containing the constants of this enum type, in the order they are declared + +doclet.enum_valueof_doc.main=\n\ Returns the enum constant of this type with the specified name.\n\ The string must match exactly an identifier used to declare an\n\ enum constant in this type. (Extraneous whitespace characters are \n\ - not permitted.)\n\ - \n\ - @param name the name of the enum constant to be returned.\n\ - @return the enum constant with the specified name\n\ - @throws IllegalArgumentException if this enum type has no constant\n\ - with the specified name\n\ - @throws NullPointerException if the argument is null + not permitted.) + +doclet.enum_valueof_doc.param_name=\ + the name of the enum constant to be returned. + +doclet.enum_valueof_doc.return=\ + the enum constant with the specified name + +doclet.enum_valueof_doc.throws_ila=\ + if this enum type has no constant with the specified name + +doclet.enum_valueof_doc.throws_npe=\ + if the argument is null diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java Fri Aug 30 10:17:10 2013 +0100 @@ -667,16 +667,28 @@ for (int j = 0; j < methods.length; j++) { MethodDoc currentMethod = methods[j]; if (currentMethod.name().equals("values") && - currentMethod.parameters().length == 0) { - currentMethod.setRawCommentText( - configuration.getText("doclet.enum_values_doc", classDoc.name())); + currentMethod.parameters().length == 0) { + StringBuilder sb = new StringBuilder(); + sb.append(configuration.getText("doclet.enum_values_doc.main", classDoc.name())); + sb.append("\n@return "); + sb.append(configuration.getText("doclet.enum_values_doc.return")); + currentMethod.setRawCommentText(sb.toString()); } else if (currentMethod.name().equals("valueOf") && - currentMethod.parameters().length == 1) { + currentMethod.parameters().length == 1) { Type paramType = currentMethod.parameters()[0].type(); if (paramType != null && - paramType.qualifiedTypeName().equals(String.class.getName())) { - currentMethod.setRawCommentText( - configuration.getText("doclet.enum_valueof_doc")); + paramType.qualifiedTypeName().equals(String.class.getName())) { + StringBuilder sb = new StringBuilder(); + sb.append(configuration.getText("doclet.enum_valueof_doc.main", classDoc.name())); + sb.append("\n@param name "); + sb.append(configuration.getText("doclet.enum_valueof_doc.param_name")); + sb.append("\n@return "); + sb.append(configuration.getText("doclet.enum_valueof_doc.return")); + sb.append("\n@throws IllegalArgumentException "); + sb.append(configuration.getText("doclet.enum_valueof_doc.throws_ila")); + sb.append("\n@throws NullPointerException "); + sb.append(configuration.getText("doclet.enum_valueof_doc.throws_npe")); + currentMethod.setRawCommentText(sb.toString()); } } } diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/doclint/HtmlTag.java --- a/src/share/classes/com/sun/tools/doclint/HtmlTag.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/doclint/HtmlTag.java Fri Aug 30 10:17:10 2013 +0100 @@ -30,6 +30,7 @@ import java.util.EnumMap; import java.util.EnumSet; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import javax.lang.model.element.Name; @@ -345,7 +346,7 @@ WIDTH; public String getText() { - return name().toLowerCase(); + return toLowerCase(name()); } static final Map index = new HashMap(); @@ -424,11 +425,11 @@ } public String getText() { - return name().toLowerCase(); + return toLowerCase(name()); } public Attr getAttr(Name attrName) { - return Attr.index.get(attrName.toString().toLowerCase()); + return Attr.index.get(toLowerCase(attrName.toString())); } public AttrKind getAttrKind(Name attrName) { @@ -450,6 +451,10 @@ } static HtmlTag get(Name tagName) { - return index.get(tagName.toString().toLowerCase()); + return index.get(toLowerCase(tagName.toString())); + } + + private static String toLowerCase(String s) { + return s.toLowerCase(Locale.US); } } diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/javac/code/Attribute.java --- a/src/share/classes/com/sun/tools/javac/code/Attribute.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Attribute.java Fri Aug 30 10:17:10 2013 +0100 @@ -340,6 +340,14 @@ } } + public static class UnresolvedClass extends Error { + public Type classType; + public UnresolvedClass(Type type, Type classType) { + super(type); + this.classType = classType; + } + } + /** A visitor type for dynamic dispatch on the kind of attribute value. */ public static interface Visitor { void visitConstant(Attribute.Constant value); diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/javac/code/Scope.java --- a/src/share/classes/com/sun/tools/javac/code/Scope.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Scope.java Fri Aug 30 10:17:10 2013 +0100 @@ -199,7 +199,7 @@ } public void enter(Symbol sym, Scope s) { - enter(sym, s, s); + enter(sym, s, s, false); } /** @@ -207,7 +207,7 @@ * given scope `s' accessed through `origin'. The last two * arguments are only used in import scopes. */ - public void enter(Symbol sym, Scope s, Scope origin) { + public void enter(Symbol sym, Scope s, Scope origin, boolean staticallyImported) { Assert.check(shared == 0); if (nelems * 3 >= hashMask * 2) dble(); @@ -217,7 +217,7 @@ old = sentinel; nelems++; } - Entry e = makeEntry(sym, old, elems, s, origin); + Entry e = makeEntry(sym, old, elems, s, origin, staticallyImported); table[hash] = e; elems = e; @@ -227,7 +227,7 @@ } } - Entry makeEntry(Symbol sym, Entry shadowed, Entry sibling, Scope scope, Scope origin) { + Entry makeEntry(Symbol sym, Entry shadowed, Entry sibling, Scope scope, Scope origin, boolean staticallyImported) { return new Entry(sym, shadowed, sibling, scope); } @@ -499,6 +499,10 @@ else return shadowed.next(sf); } + public boolean isStaticallyImported() { + return false; + } + public Scope getOrigin() { // The origin is only recorded for import scopes. For all // other scope entries, the "enclosing" type is available @@ -517,20 +521,19 @@ } @Override - Entry makeEntry(Symbol sym, Entry shadowed, Entry sibling, Scope scope, Scope origin) { - return new ImportEntry(sym, shadowed, sibling, scope, origin); - } - - static class ImportEntry extends Entry { - private Scope origin; + Entry makeEntry(Symbol sym, Entry shadowed, Entry sibling, Scope scope, + final Scope origin, final boolean staticallyImported) { + return new Entry(sym, shadowed, sibling, scope) { + @Override + public Scope getOrigin() { + return origin; + } - ImportEntry(Symbol sym, Entry shadowed, Entry sibling, Scope scope, Scope origin) { - super(sym, shadowed, sibling, scope); - this.origin = origin; - } - - @Override - public Scope getOrigin() { return origin; } + @Override + public boolean isStaticallyImported() { + return staticallyImported; + } + }; } } @@ -724,7 +727,7 @@ } @Override - public void enter(Symbol sym, Scope s, Scope origin) { + public void enter(Symbol sym, Scope s, Scope origin, boolean staticallyImported) { throw new UnsupportedOperationException(); } diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/javac/code/Symbol.java --- a/src/share/classes/com/sun/tools/javac/code/Symbol.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java Fri Aug 30 10:17:10 2013 +0100 @@ -463,26 +463,34 @@ return false; } - /** Check for hiding. Note that this doesn't handle multiple - * (interface) inheritance. */ private boolean hiddenIn(ClassSymbol clazz, Types types) { - if (kind == MTH && (flags() & STATIC) == 0) return false; - while (true) { - if (owner == clazz) return false; - Scope.Entry e = clazz.members().lookup(name); - while (e.scope != null) { - if (e.sym == this) return false; - if (e.sym.kind == kind && + Symbol sym = hiddenInInternal(clazz, types); + return sym != null && sym != this; + } + + private Symbol hiddenInInternal(ClassSymbol c, Types types) { + Scope.Entry e = c.members().lookup(name); + while (e.scope != null) { + if (e.sym.kind == kind && (kind != MTH || - (e.sym.flags() & STATIC) != 0 && - types.isSubSignature(e.sym.type, type))) - return true; - e = e.next(); + (e.sym.flags() & STATIC) != 0 && + types.isSubSignature(e.sym.type, type))) { + return e.sym; } - Type superType = types.supertype(clazz.type); - if (!superType.hasTag(CLASS)) return false; - clazz = (ClassSymbol)superType.tsym; + e = e.next(); } + List hiddenSyms = List.nil(); + for (Type st : types.interfaces(c.type).prepend(types.supertype(c.type))) { + if (st != null && (st.hasTag(CLASS))) { + Symbol sym = hiddenInInternal((ClassSymbol)st.tsym, types); + if (sym != null) { + hiddenSyms = hiddenSyms.prepend(hiddenInInternal((ClassSymbol)st.tsym, types)); + } + } + } + return hiddenSyms.contains(this) ? + this : + (hiddenSyms.isEmpty() ? null : hiddenSyms.head); } /** Is this symbol inherited into a given class? diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/javac/code/Type.java --- a/src/share/classes/com/sun/tools/javac/code/Type.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java Fri Aug 30 10:17:10 2013 +0100 @@ -1161,7 +1161,7 @@ } public boolean contains(Type elem) { - return elem == this || contains(argtypes, elem) || restype.contains(elem); + return elem == this || contains(argtypes, elem) || restype.contains(elem) || contains(thrown, elem); } public MethodType asMethodType() { return this; } @@ -1525,7 +1525,7 @@ } protected void addBound(InferenceBound ib, Type bound, Types types, boolean update) { - Type bound2 = toTypeVarMap.apply(bound); + Type bound2 = toTypeVarMap.apply(bound).baseType(); List prevBounds = bounds.get(ib); for (Type b : prevBounds) { //check for redundancy - use strict version of isSameType on tvars diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/javac/comp/Annotate.java --- a/src/share/classes/com/sun/tools/javac/comp/Annotate.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Annotate.java Fri Aug 30 10:17:10 2013 +0100 @@ -332,8 +332,20 @@ } if (expected.tsym == syms.classType.tsym) { Type result = attr.attribExpr(tree, env, expected); - if (result.isErroneous()) - return new Attribute.Error(expected); + if (result.isErroneous()) { + // Does it look like a class literal? + if (TreeInfo.name(tree) == names._class) { + Name n = (((JCFieldAccess) tree).selected).type.tsym.flatName(); + return new Attribute.UnresolvedClass(expected, + types.createErrorType(n, + syms.unknownSymbol, syms.classType)); + } else { + return new Attribute.Error(expected); + } + } + + // Class literals look like field accesses of a field named class + // at the tree level if (TreeInfo.name(tree) != names._class) { log.error(tree.pos(), "annotation.value.must.be.class.literal"); return new Attribute.Error(expected); diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/javac/comp/Attr.java --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Aug 30 10:17:10 2013 +0100 @@ -398,7 +398,7 @@ @Override public Symbol visitMemberSelect(MemberSelectTree node, Env env) { Symbol site = visit(node.getExpression(), env); - if (site.kind == ERR) + if (site.kind == ERR || site.kind == ABSENT_TYP) return site; Name name = (Name)node.getIdentifier(); if (site.kind == PCK) { @@ -2395,7 +2395,7 @@ ResultInfo bodyResultInfo = lambdaType.getReturnType() == Type.recoveryType ? recoveryInfo : - new LambdaResultInfo(lambdaType.getReturnType(), funcContext); + new ResultInfo(VAL, lambdaType.getReturnType(), funcContext); localEnv.info.returnResult = bodyResultInfo; Log.DeferredDiagnosticHandler lambdaDeferredHandler = new Log.DeferredDiagnosticHandler(log); @@ -2602,35 +2602,12 @@ } } - class LambdaResultInfo extends ResultInfo { - - LambdaResultInfo(Type pt, CheckContext checkContext) { - super(VAL, pt, checkContext); - } - - @Override - protected Type check(DiagnosticPosition pos, Type found) { - return super.check(pos, found.baseType()); - } - - @Override - protected ResultInfo dup(CheckContext newContext) { - return new LambdaResultInfo(pt, newContext); - } - - @Override - protected ResultInfo dup(Type newPt) { - return new LambdaResultInfo(newPt, checkContext); - } - } - /** * Lambda compatibility. Check that given return types, thrown types, parameter types * are compatible with the expected functional interface descriptor. This means that: * (i) parameter types must be identical to those of the target descriptor; (ii) return * types must be compatible with the return type of the expected descriptor; - * (iii) thrown types must be 'included' in the thrown types list of the expected - * descriptor. + * (iii) finish inference of thrown types if required. */ private void checkLambdaCompatible(JCLambda tree, Type descriptor, CheckContext checkContext, boolean speculativeAttr) { Type returnType = checkContext.inferenceContext().asFree(descriptor.getReturnType()); @@ -2652,9 +2629,7 @@ if (!speculativeAttr) { List thrownTypes = checkContext.inferenceContext().asFree(descriptor.getThrownTypes()); - if (chk.unhandled(tree.inferredThrownTypes == null ? List.nil() : tree.inferredThrownTypes, thrownTypes).nonEmpty()) { - log.error(tree, "incompatible.thrown.types.in.lambda", tree.inferredThrownTypes); - } + chk.unhandled(tree.inferredThrownTypes == null ? List.nil() : tree.inferredThrownTypes, thrownTypes); } } diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/javac/comp/Check.java --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Aug 30 10:17:10 2013 +0100 @@ -875,19 +875,23 @@ } Type owntype = mtype; List formals = owntype.getParameterTypes(); + List nonInferred = sym.type.getParameterTypes(); + if (nonInferred.length() != formals.length()) nonInferred = formals; Type last = useVarargs ? formals.last() : null; - if (sym.name == names.init && - sym.owner == syms.enumSym) - formals = formals.tail.tail; + if (sym.name == names.init && sym.owner == syms.enumSym) { + formals = formals.tail.tail; + nonInferred = nonInferred.tail.tail; + } List args = argtrees; if (args != null) { //this is null when type-checking a method reference while (formals.head != last) { JCTree arg = args.head; - Warner warn = convertWarner(arg.pos(), arg.type, formals.head); + Warner warn = convertWarner(arg.pos(), arg.type, nonInferred.head); assertConvertible(arg, arg.type, formals.head, warn); args = args.tail; formals = formals.tail; + nonInferred = nonInferred.tail; } if (useVarargs) { Type varArg = types.elemtype(last); @@ -903,17 +907,17 @@ Type varParam = owntype.getParameterTypes().last(); Type lastArg = argtypes.last(); if (types.isSubtypeUnchecked(lastArg, types.elemtype(varParam)) && - !types.isSameType(types.erasure(varParam), types.erasure(lastArg))) + !types.isSameType(types.erasure(varParam), types.erasure(lastArg))) log.warning(argtrees.last().pos(), "inexact.non-varargs.call", - types.elemtype(varParam), varParam); + types.elemtype(varParam), varParam); } } if (useVarargs) { Type argtype = owntype.getParameterTypes().last(); if (!types.isReifiable(argtype) && - (!allowSimplifiedVarargs || - sym.attribute(syms.trustMeType.tsym) == null || - !isTrustMeAllowedOnMethod(sym))) { + (!allowSimplifiedVarargs || + sym.attribute(syms.trustMeType.tsym) == null || + !isTrustMeAllowedOnMethod(sym))) { warnUnchecked(env.tree.pos(), "unchecked.generic.array.creation", argtype); @@ -929,15 +933,15 @@ return owntype; } //where - private void assertConvertible(JCTree tree, Type actual, Type formal, Warner warn) { - if (types.isConvertible(actual, formal, warn)) - return; - - if (formal.isCompound() - && types.isSubtype(actual, types.supertype(formal)) - && types.isSubtypeUnchecked(actual, types.interfaces(formal), warn)) - return; - } + private void assertConvertible(JCTree tree, Type actual, Type formal, Warner warn) { + if (types.isConvertible(actual, formal, warn)) + return; + + if (formal.isCompound() + && types.isSubtype(actual, types.supertype(formal)) + && types.isSubtypeUnchecked(actual, types.interfaces(formal), warn)) + return; + } /** * Check that type 't' is a valid instantiation of a generic class @@ -1747,7 +1751,7 @@ if (!sup.hasTag(CLASS)) return; for (Type t1 = sup; - t1.tsym.type.isParameterized(); + t1.hasTag(CLASS) && t1.tsym.type.isParameterized(); t1 = types.supertype(t1)) { for (Scope.Entry e1 = t1.tsym.members().elems; e1 != null; @@ -3329,14 +3333,15 @@ boolean isClassDecl = e.scope == s; if ((isClassDecl || sym != e.sym) && sym.kind == e.sym.kind && - sym.name != names.error) { + sym.name != names.error && + (!staticImport || !e.isStaticallyImported())) { if (!e.sym.type.isErroneous()) { String what = e.sym.toString(); if (!isClassDecl) { if (staticImport) log.error(pos, "already.defined.static.single.import", what); else - log.error(pos, "already.defined.single.import", what); + log.error(pos, "already.defined.single.import", what); } else if (sym != e.sym) log.error(pos, "already.defined.this.unit", what); diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/javac/comp/Enter.java --- a/src/share/classes/com/sun/tools/javac/comp/Enter.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Enter.java Fri Aug 30 10:17:10 2013 +0100 @@ -291,7 +291,7 @@ if (tree.packageAnnotations.nonEmpty() || pkginfoOpt == PkgInfo.ALWAYS) { if (isPkgInfo) { addEnv = true; - } else { + } else if (tree.packageAnnotations.nonEmpty()){ log.error(tree.packageAnnotations.head.pos(), "pkg.annotations.sb.in.package-info.java"); } diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/javac/comp/Flow.java --- a/src/share/classes/com/sun/tools/javac/comp/Flow.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java Fri Aug 30 10:17:10 2013 +0100 @@ -224,7 +224,7 @@ } try { new AliveAnalyzer().analyzeTree(env, that, make); - new FlowAnalyzer().analyzeTree(env, that, make); + new LambdaFlowAnalyzer().analyzeTree(env, that, make); } finally { if (!speculative) { log.popDiagnosticHandler(diagHandler); @@ -1259,12 +1259,24 @@ ListBuffer prevPending = pendingExits; try { pendingExits = ListBuffer.lb(); - caught = List.of(syms.throwableType); //inhibit exception checking + caught = tree.getDescriptorType(types).getThrownTypes(); thrown = List.nil(); scan(tree.body); - tree.inferredThrownTypes = thrown; - } - finally { + List exits = pendingExits.toList(); + pendingExits = new ListBuffer(); + while (exits.nonEmpty()) { + FlowPendingExit exit = exits.head; + exits = exits.tail; + if (exit.thrown == null) { + Assert.check(exit.tree.hasTag(RETURN)); + } else { + // uncaught throws will be reported later + pendingExits.append(exit); + } + } + + errorUncaught(); + } finally { pendingExits = prevPending; caught = prevCaught; thrown = prevThrown; @@ -1303,6 +1315,33 @@ } /** + * Specialized pass that performs inference of thrown types for lambdas. + */ + class LambdaFlowAnalyzer extends FlowAnalyzer { + @Override + public void visitLambda(JCLambda tree) { + if (tree.type != null && + tree.type.isErroneous()) { + return; + } + List prevCaught = caught; + List prevThrown = thrown; + ListBuffer prevPending = pendingExits; + try { + pendingExits = ListBuffer.lb(); + caught = List.of(syms.throwableType); + thrown = List.nil(); + scan(tree.body); + tree.inferredThrownTypes = thrown; + } finally { + pendingExits = prevPending; + caught = prevCaught; + thrown = prevThrown; + } + } + } + + /** * This pass implements (i) definite assignment analysis, which ensures that * each variable is assigned when used and (ii) definite unassignment analysis, * which ensures that no final variable is assigned more than once. This visitor diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java --- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Fri Aug 30 10:17:10 2013 +0100 @@ -473,7 +473,7 @@ //non-void to non-void conversion: // return (TYPE)BODY; JCExpression retExpr = transTypes.coerce(attrEnv, expr, restype); - return make.Block(0, List.of(make.Return(retExpr))); + return make.at(retExpr).Block(0, List.of(make.Return(retExpr))); } } diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/javac/comp/Lower.java --- a/src/share/classes/com/sun/tools/javac/comp/Lower.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java Fri Aug 30 10:17:10 2013 +0100 @@ -356,22 +356,44 @@ } } + ClassSymbol ownerToCopyFreeVarsFrom(ClassSymbol c) { + if (!c.isLocal()) { + return null; + } + Symbol currentOwner = c.owner; + while ((currentOwner.owner.kind & TYP) != 0 && currentOwner.isLocal()) { + currentOwner = currentOwner.owner; + } + if ((currentOwner.owner.kind & (VAR | MTH)) != 0 && c.isSubClass(currentOwner, types)) { + return (ClassSymbol)currentOwner; + } + return null; + } + /** Return the variables accessed from within a local class, which * are declared in the local class' owner. * (in reverse order of first access). */ List freevars(ClassSymbol c) { + List fvs = freevarCache.get(c); + if (fvs != null) { + return fvs; + } if ((c.owner.kind & (VAR | MTH)) != 0) { - List fvs = freevarCache.get(c); - if (fvs == null) { - FreeVarCollector collector = new FreeVarCollector(c); - collector.scan(classDef(c)); - fvs = collector.fvs; - freevarCache.put(c, fvs); - } + FreeVarCollector collector = new FreeVarCollector(c); + collector.scan(classDef(c)); + fvs = collector.fvs; + freevarCache.put(c, fvs); return fvs; } else { - return List.nil(); + ClassSymbol owner = ownerToCopyFreeVarsFrom(c); + if (owner != null) { + fvs = freevarCache.get(owner); + freevarCache.put(c, fvs); + return fvs; + } else { + return List.nil(); + } } } @@ -1046,7 +1068,7 @@ boolean needsPrivateAccess(Symbol sym) { if ((sym.flags() & PRIVATE) == 0 || sym.owner == currentClass) { return false; - } else if (sym.name == names.init && (sym.owner.owner.kind & (VAR | MTH)) != 0) { + } else if (sym.name == names.init && sym.owner.isLocal()) { // private constructor in local class: relax protection sym.flags_field &= ~PRIVATE; return false; @@ -2448,6 +2470,7 @@ tree.name = Convert.shortName(currentClass.flatName()); // Add this$n and free variables proxy definitions to class. + for (List l = fvdefs; l.nonEmpty(); l = l.tail) { tree.defs = tree.defs.prepend(l.head); enterSynthetic(tree.pos(), l.head.sym, currentClass.members()); @@ -2670,8 +2693,7 @@ //where private void visitMethodDefInternal(JCMethodDecl tree) { if (tree.name == names.init && - (currentClass.isInner() || - (currentClass.owner.kind & (VAR | MTH)) != 0)) { + (currentClass.isInner() || currentClass.isLocal())) { // We are seeing a constructor of an inner class. MethodSymbol m = tree.sym; @@ -2818,7 +2840,7 @@ // If created class is local, add free variables after // explicit constructor arguments. - if ((c.owner.kind & (VAR | MTH)) != 0) { + if (c.isLocal()) { tree.args = tree.args.appendList(loadFreevars(tree.pos(), freevars(c))); } @@ -2837,7 +2859,7 @@ if (tree.encl != null) { thisArg = attr.makeNullCheck(translate(tree.encl)); thisArg.type = tree.encl.type; - } else if ((c.owner.kind & (MTH | VAR)) != 0) { + } else if (c.isLocal()) { // local class thisArg = makeThis(tree.pos(), c.type.getEnclosingType().tsym); } else { @@ -2966,7 +2988,7 @@ // If we are calling a constructor of a local class, add // free variables after explicit constructor arguments. ClassSymbol c = (ClassSymbol)constructor.owner; - if ((c.owner.kind & (VAR | MTH)) != 0) { + if (c.isLocal()) { tree.args = tree.args.appendList(loadFreevars(tree.pos(), freevars(c))); } @@ -2994,7 +3016,7 @@ makeNullCheck(translate(((JCFieldAccess) tree.meth).selected)); tree.meth = make.Ident(constructor); ((JCIdent) tree.meth).name = methName; - } else if ((c.owner.kind & (MTH | VAR)) != 0 || methName == names._this){ + } else if (c.isLocal() || methName == names._this){ // local class or this() call thisArg = makeThis(tree.meth.pos(), c.type.getEnclosingType().tsym); } else { @@ -3436,7 +3458,7 @@ eType, List.nil()); VarSymbol itvar = new VarSymbol(0, names.fromString("i" + target.syntheticNameChar()), - types.erasure(iterator.type.getReturnType()), + types.erasure(types.asSuper(iterator.type.getReturnType(), syms.iteratorType.tsym)), currentMethodSym); JCStatement init = make. diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/javac/comp/MemberEnter.java --- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Fri Aug 30 10:17:10 2013 +0100 @@ -189,7 +189,7 @@ staticImportAccessible(sym, packge) && sym.isMemberOf(origin, types) && !toScope.includes(sym)) - toScope.enter(sym, fromScope, origin.members()); + toScope.enter(sym, fromScope, origin.members(), true); } } }.importFrom(tsym); @@ -217,7 +217,7 @@ staticImportAccessible(sym, packge) && !toScope.includes(sym) && sym.isMemberOf(origin, types)) { - toScope.enter(sym, fromScope, origin.members()); + toScope.enter(sym, fromScope, origin.members(), true); } } } @@ -283,7 +283,7 @@ staticImportAccessible(sym, packge) && sym.isMemberOf(origin, types) && chk.checkUniqueStaticImport(pos, sym, toScope)) - toScope.enter(sym, sym.owner.members(), origin.members()); + toScope.enter(sym, sym.owner.members(), origin.members(), true); } } }.importFrom(tsym); @@ -313,9 +313,9 @@ staticImportAccessible(sym, packge) && sym.isMemberOf(origin, types)) { found = true; - if (sym.kind == MTH || - sym.kind != TYP && chk.checkUniqueStaticImport(pos, sym, toScope)) - toScope.enter(sym, sym.owner.members(), origin.members()); + if (sym.kind != TYP) { + toScope.enter(sym, sym.owner.members(), origin.members(), true); + } } } } diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/javac/comp/Resolve.java --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Aug 30 10:17:10 2013 +0100 @@ -1344,32 +1344,23 @@ if (bestSoFar.exists()) return bestSoFar; - Scope.Entry e = env.toplevel.namedImportScope.lookup(name); - for (; e.scope != null; e = e.next()) { - sym = e.sym; - Type origin = e.getOrigin().owner.type; - if (sym.kind == VAR) { - if (e.sym.owner.type != origin) - sym = sym.clone(e.getOrigin().owner); - return isAccessible(env, origin, sym) - ? sym : new AccessError(env, origin, sym); + Symbol origin = null; + for (Scope sc : new Scope[] { env.toplevel.namedImportScope, env.toplevel.starImportScope }) { + Scope.Entry e = sc.lookup(name); + for (; e.scope != null; e = e.next()) { + sym = e.sym; + if (sym.kind != VAR) + continue; + // invariant: sym.kind == VAR + if (bestSoFar.kind < AMBIGUOUS && sym.owner != bestSoFar.owner) + return new AmbiguityError(bestSoFar, sym); + else if (bestSoFar.kind >= VAR) { + origin = e.getOrigin().owner; + bestSoFar = isAccessible(env, origin.type, sym) + ? sym : new AccessError(env, origin.type, sym); + } } - } - - Symbol origin = null; - e = env.toplevel.starImportScope.lookup(name); - for (; e.scope != null; e = e.next()) { - sym = e.sym; - if (sym.kind != VAR) - continue; - // invariant: sym.kind == VAR - if (bestSoFar.kind < AMBIGUOUS && sym.owner != bestSoFar.owner) - return new AmbiguityError(bestSoFar, sym); - else if (bestSoFar.kind >= VAR) { - origin = e.getOrigin().owner; - bestSoFar = isAccessible(env, origin.type, sym) - ? sym : new AccessError(env, origin.type, sym); - } + if (bestSoFar.exists()) break; } if (bestSoFar.kind == VAR && bestSoFar.owner.type != origin.type) return bestSoFar.clone(origin); diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/javac/main/JavaCompiler.java --- a/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Fri Aug 30 10:17:10 2013 +0100 @@ -363,6 +363,7 @@ throw new Abort(); } source = Source.instance(context); + Target target = Target.instance(context); attr = Attr.instance(context); chk = Check.instance(context); gen = Gen.instance(context); @@ -403,6 +404,8 @@ } } + checkForObsoleteOptions(target); + verboseCompilePolicy = options.isSet("verboseCompilePolicy"); if (attrParseOnly) @@ -432,6 +435,26 @@ log.setDiagnosticFormatter(RichDiagnosticFormatter.instance(context)); } + private void checkForObsoleteOptions(Target target) { + // Unless lint checking on options is disabled, check for + // obsolete source and target options. + boolean obsoleteOptionFound = false; + if (options.isUnset(XLINT_CUSTOM, "-" + LintCategory.OPTIONS.option)) { + if (source.compareTo(Source.JDK1_5) <= 0) { + log.warning(LintCategory.OPTIONS, "option.obsolete.source", source.name); + obsoleteOptionFound = true; + } + + if (target.compareTo(Target.JDK1_5) <= 0) { + log.warning(LintCategory.OPTIONS, "option.obsolete.target", source.name); + obsoleteOptionFound = true; + } + + if (obsoleteOptionFound) + log.warning(LintCategory.OPTIONS, "option.obsolete.suppression"); + } + } + /* Switches: */ diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/javac/main/Main.java --- a/src/share/classes/com/sun/tools/javac/main/Main.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/main/Main.java Fri Aug 30 10:17:10 2013 +0100 @@ -262,6 +262,11 @@ } } + if (options.get(PROFILE) != null && options.get(BOOTCLASSPATH) != null) { + error("err.profile.bootclasspath.conflict"); + return null; + } + if (this.classnames != null && classNames != null) { this.classnames.addAll(Arrays.asList(classNames)); } diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java --- a/src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java Fri Aug 30 10:17:10 2013 +0100 @@ -244,7 +244,10 @@ } public void visitError(Attribute.Error e) { - value = null; // indicates a type mismatch + if (e instanceof Attribute.UnresolvedClass) + value = new MirroredTypeExceptionProxy(((Attribute.UnresolvedClass)e).classType); + else + value = null; // indicates a type mismatch } diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/javac/resources/compiler.properties --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Fri Aug 30 10:17:10 2013 +0100 @@ -733,10 +733,6 @@ {0} # 0: list of type -compiler.err.incompatible.thrown.types.in.lambda=\ - incompatible thrown types {0} in lambda expression - -# 0: list of type compiler.err.incompatible.thrown.types.in.mref=\ incompatible thrown types {0} in method reference @@ -1444,6 +1440,17 @@ compiler.warn.source.no.bootclasspath=\ bootstrap class path not set in conjunction with -source {0} +# 0: string +compiler.warn.option.obsolete.source=\ + source value {0} is obsolete and will be removed in a future release + +# 0: string +compiler.warn.option.obsolete.target=\ + target value {0} is obsolete and will be removed in a future release + +compiler.warn.option.obsolete.suppression=\ + To suppress warnings about obsolete options, use -Xlint:-options. + # 0: name, 1: number, 2: number, 3: number, 4: number compiler.warn.future.attr=\ {0} attribute introduced in version {1}.{2} class files is ignored in version {3}.{4} class files diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/javac/resources/javac.properties --- a/src/share/classes/com/sun/tools/javac/resources/javac.properties Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/resources/javac.properties Fri Aug 30 10:17:10 2013 +0100 @@ -185,6 +185,8 @@ key in annotation processor option ''{0}'' is not a dot-separated sequence of identifiers javac.err.invalid.flag=\ invalid flag: {0} +javac.err.profile.bootclasspath.conflict=\ + profile and bootclasspath options cannot be used together javac.err.invalid.profile=\ invalid profile: {0} javac.err.invalid.target=\ diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/javac/tree/JCTree.java --- a/src/share/classes/com/sun/tools/javac/tree/JCTree.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/tree/JCTree.java Fri Aug 30 10:17:10 2013 +0100 @@ -645,7 +645,7 @@ public List targets; public Type getDescriptorType(Types types) { - return types.findDescriptorType(targets.head); + return targets.nonEmpty() ? types.findDescriptorType(targets.head) : types.createErrorType(null); } } @@ -1571,6 +1571,16 @@ public Tag getTag() { return NEWARRAY; } + + @Override + public List getAnnotations() { + return annotations; + } + + @Override + public List> getDimAnnotations() { + return dimAnnotations; + } } /** diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/javadoc/Start.java --- a/src/share/classes/com/sun/tools/javadoc/Start.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/javadoc/Start.java Fri Aug 30 10:17:10 2013 +0100 @@ -269,6 +269,8 @@ setDocletInvoker(docletClass, fileManager, argv); compOpts = Options.instance(context); + // Make sure no obsolete source/target messages are reported + compOpts.put("-Xlint:-options", "-Xlint:-options"); // Parse arguments for (int i = 0 ; i < argv.length ; i++) { diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/sjavac/JavacState.java --- a/src/share/classes/com/sun/tools/sjavac/JavacState.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/sjavac/JavacState.java Fri Aug 30 10:17:10 2013 +0100 @@ -808,7 +808,10 @@ // Create a set of filenames with full paths. for (Source s : now.sources().values()) { - calculatedSources.add(s.file().getPath()); + // Don't include link only sources when comparing sources to compile + if (!s.isLinkedOnly()) { + calculatedSources.add(s.file().getPath()); + } } // Read in the file and create another set of filenames with full paths. try { diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/com/sun/tools/sjavac/Main.java --- a/src/share/classes/com/sun/tools/sjavac/Main.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/sjavac/Main.java Fri Aug 30 10:17:10 2013 +0100 @@ -249,16 +249,19 @@ return -1; } - // Find all source files allowable for linking. + // Create a map of all source files that are available for linking. Both -src and + // -sourcepath point to such files. It is possible to specify multiple + // -sourcepath options to enable different filtering rules. If the + // filters are the same for multiple sourcepaths, they may be concatenated + // using :(;). Before sending the list of sourcepaths to javac, they are + // all concatenated. The list created here is used by the SmartFileWrapper to + // make sure only the correct sources are actually available. // We might find more modules here as well. Map sources_to_link_to = new HashMap(); - // Always reuse -src for linking as well! This means that we might - // get two -sourcepath on the commandline after the rewrite, which is - // fine. We can have as many as we like. You need to have separate -src/-sourcepath/-classpath - // if you need different filtering rules for different roots. If you have the same filtering - // rules for all sourcepath roots, you can concatenate them using :(;) as before. - rewriteOptions(args, "-src", "-sourcepath"); + findFiles(args, "-src", Util.set(".java"), sources_to_link_to, modules, current_module, true); findFiles(args, "-sourcepath", Util.set(".java"), sources_to_link_to, modules, current_module, true); + // Rewrite the -src option to make it through to the javac instances. + rewriteOptions(args, "-src", "-sourcepath"); // Find all class files allowable for linking. // And pickup knowledge of all modules found here. diff -r a540e2a926cf -r a8f0c3583a86 src/share/classes/javax/tools/JavaCompiler.java --- a/src/share/classes/javax/tools/JavaCompiler.java Fri Aug 23 22:12:54 2013 +0100 +++ b/src/share/classes/javax/tools/JavaCompiler.java Fri Aug 30 10:17:10 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -251,8 +251,8 @@ * occurred in a user supplied component. The * {@linkplain Throwable#getCause() cause} will be the error in * user code. - * @throws IllegalArgumentException if any of the given - * compilation units are of other kind than + * @throws IllegalArgumentException if any of the options are invalid, + * or if any of the given compilation units are of other kind than * {@linkplain JavaFileObject.Kind#SOURCE source} */ CompilationTask getTask(Writer out, diff -r a540e2a926cf -r a8f0c3583a86 test/com/sun/javadoc/testProfiles/TestProfiles.java --- a/test/com/sun/javadoc/testProfiles/TestProfiles.java Fri Aug 23 22:12:54 2013 +0100 +++ b/test/com/sun/javadoc/testProfiles/TestProfiles.java Fri Aug 30 10:17:10 2013 +0100 @@ -23,7 +23,7 @@ /* * @test - * @bug 8006124 8009684 + * @bug 8006124 8009684 8016921 * @summary Test javadoc support for profiles. * @author Bhavesh Patel * @library ../lib/ @@ -33,7 +33,7 @@ public class TestProfiles extends JavadocTester { //Test information. - private static final String BUG_ID = "8006124-8009684"; + private static final String BUG_ID = "8006124-8009684-8016921"; private static final String PROFILE_BUG_ID = BUG_ID + "-1"; private static final String PACKAGE_BUG_ID = BUG_ID + "-2"; //Javadoc arguments. @@ -105,6 +105,14 @@ {PROFILE_BUG_ID + FS + "index.html", "" + }, + //Test for "overview-summary.html" showing the profile list. + {PROFILE_BUG_ID + FS + "overview-summary.html", + "" } }; private static final String[][] PROFILES_NEGATED_TEST = { @@ -159,6 +167,13 @@ }, {PACKAGE_BUG_ID + FS + "pkg2" + FS + "Class1Pkg2.html", "
compact1, compact2, compact3
" + }, + {PACKAGE_BUG_ID + FS + "overview-summary.html", + "" } }; diff -r a540e2a926cf -r a8f0c3583a86 test/com/sun/javadoc/testSeeTag/TestSeeTag.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/com/sun/javadoc/testSeeTag/TestSeeTag.java Fri Aug 30 10:17:10 2013 +0100 @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8017191 + * @summary Javadoc is confused by at-link to imported classes outside of the set of generated packages + * @author jjg + * @library ../lib/ + * @build JavadocTester TestSeeTag + * @run main TestSeeTag + */ + +public class TestSeeTag extends JavadocTester { + + //Test information. + private static final String BUG_ID = "8017191"; + private static final String OUTPUT_DIR = BUG_ID; + + //Javadoc arguments. + private static final String[] ARGS = new String[] { + "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg" + }; + + //Input for string search tests. + private static final String[][] TEST = { + { OUTPUT_DIR + FS + "pkg" + FS + "Test.html", + "List" + } + }; + private static final String[][] NEGATED_TEST = { + { OUTPUT_DIR + FS + "pkg" + FS + "Test.html", + "<code>List</code>" + } + }; + + /** + * The entry point of the test. + * @param args the array of command line arguments. + */ + public static void main(String[] args) { + TestSeeTag tester = new TestSeeTag(); + run(tester, ARGS, TEST, NEGATED_TEST); + tester.printSummary(); + } + + /** + * {@inheritDoc} + */ + public String getBugId() { + return BUG_ID; + } + + /** + * {@inheritDoc} + */ + public String getBugName() { + return getClass().getName(); + } +} diff -r a540e2a926cf -r a8f0c3583a86 test/com/sun/javadoc/testSeeTag/pkg/Test.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/com/sun/javadoc/testSeeTag/pkg/Test.java Fri Aug 30 10:17:10 2013 +0100 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg; +import java.util.List; + +/** @see List */ +public class Test { } + diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/4980495/static/Test.out --- a/test/tools/javac/4980495/static/Test.out Fri Aug 23 22:12:54 2013 +0100 +++ b/test/tools/javac/4980495/static/Test.out Fri Aug 30 10:17:10 2013 +0100 @@ -1,2 +1,2 @@ -Test.java:9:1: compiler.err.already.defined.static.single.import: f +Test.java:15:9: compiler.err.ref.ambiguous: f, kindname.variable, f, p1.A1, kindname.variable, f, p2.A2 1 error diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/6758789/T6758789b.out --- a/test/tools/javac/6758789/T6758789b.out Fri Aug 23 22:12:54 2013 +0100 +++ b/test/tools/javac/6758789/T6758789b.out Fri Aug 30 10:17:10 2013 +0100 @@ -1,5 +1,5 @@ T6758789b.java:16:10: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, T6758789a.Foo, T6758789a.Foo, kindname.class, T6758789a -T6758789b.java:16:11: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6758789a.Foo, T6758789a.Foo +T6758789b.java:16:11: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6758789a.Foo, T6758789a.Foo - compiler.err.warnings.and.werror 1 error 2 warnings diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/7182350/T7182350.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/7182350/T7182350.java Fri Aug 30 10:17:10 2013 +0100 @@ -0,0 +1,14 @@ +/** + * @test /nodynamiccopyright/ + * @bug 7182350 + * @summary verify correct output of -Xlint:unchecked on methods with unchecked conversations in parameters + * @compile/ref=T7182350.out -XDrawDiagnostics -Xlint:unchecked T7182350.java + */ + +import java.util.*; + +class T7182350 { + public static void quicksort(Vector vector, Comparator compare) { + Collections.sort(vector,compare); + } +} diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/7182350/T7182350.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/7182350/T7182350.out Fri Aug 30 10:17:10 2013 +0100 @@ -0,0 +1,4 @@ +T7182350.java:12:25: compiler.warn.unchecked.meth.invocation.applied: kindname.method, sort, java.util.List,java.util.Comparator, java.util.Vector,java.util.Comparator, kindname.class, java.util.Collections +T7182350.java:12:26: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.util.Vector, java.util.List +T7182350.java:12:33: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.util.Comparator, java.util.Comparator +3 warnings diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/T8009640/CheckRejectProfileBCPOptionsIfUsedTogetherTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T8009640/CheckRejectProfileBCPOptionsIfUsedTogetherTest.java Fri Aug 30 10:17:10 2013 +0100 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8009640 + * @summary -profile does not work when -bootclasspath specified + * @library /tools/javac/lib + * @build ToolBox + * @run main CheckRejectProfileBCPOptionsIfUsedTogetherTest + */ + +import com.sun.tools.javac.util.Assert; +import java.util.ArrayList; +import java.util.List; + +public class CheckRejectProfileBCPOptionsIfUsedTogetherTest { + + private static final String TestSrc = + "public class Test {\n" + + " javax.swing.JButton b;\n" + + "}"; + + public static void main(String args[]) throws Exception { + List errOutput = new ArrayList<>(); + String testJDK = ToolBox.jdkUnderTest; + ToolBox.createJavaFileFromSource(TestSrc); + + ToolBox.AnyToolArgs javacParams = + new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL) + .appendArgs(ToolBox.javacBinary) + .appendArgs(ToolBox.testToolVMOpts) + .appendArgs("-profile", "compact1", "-bootclasspath", + testJDK + "/jre/lib/rt.jar", "Test.java") + .setErrOutput(errOutput); + + ToolBox.executeCommand(javacParams); + + Assert.check(errOutput.get(0).startsWith( + "javac: profile and bootclasspath options cannot be used together"), + "Incorrect javac error output"); + } + +} diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/T8013394/CompileErrorWithIteratorTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T8013394/CompileErrorWithIteratorTest.java Fri Aug 30 10:17:10 2013 +0100 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8013394 + * @summary compile of iterator use fails with error "defined in an inaccessible class or interface" + * @library /tools/javac/lib + * @build ToolBox + * @run main CompileErrorWithIteratorTest + */ + +public class CompileErrorWithIteratorTest { + + private static final String TestCollectionSrc = + "package pkg;\n" + + + "import java.util.Iterator;\n" + + "import java.util.NoSuchElementException;\n" + + + "public class TestCollection implements Iterable {\n" + + " public testCollectionIterator iterator() {\n" + + " return new testCollectionIterator();\n" + + " }\n" + + " class testCollectionIterator implements Iterator {\n" + + " public boolean hasNext() { return true; }\n" + + " public E next() throws NoSuchElementException\n" + + " {\n" + + " return null;\n" + + " }\n" + + " public void remove() {}\n" + + " }\n" + + "}"; + + private static final String TestSrc = + "import pkg.TestCollection;\n" + + "\n" + + "public class Test {\n" + + "\n" + + " public static void main(String[] args) {\n" + + " TestCollection tc1 = new TestCollection();\n" + + " for (String s : tc1) {\n" + + " System.out.println(s);\n" + + " }\n" + + " }\n" + + "}"; + + public static void main(String args[]) throws Exception { + new CompileErrorWithIteratorTest().run(); + } + + void run() throws Exception { + compile(); + } + + void compile() throws Exception { + ToolBox.JavaToolArgs javacParams = + new ToolBox.JavaToolArgs() + .setSources(TestCollectionSrc, TestSrc); + ToolBox.javac(javacParams); + } + +} diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/T8019486/WrongLVTForLambdaTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T8019486/WrongLVTForLambdaTest.java Fri Aug 30 10:17:10 2013 +0100 @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8019486 + * @summary javac, generates erroneous LVT for a test case with lambda code + * @library /tools/javac/lib + * @build ToolBox + * @run main WrongLVTForLambdaTest + */ + +import java.io.File; +import java.nio.file.Paths; + +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.Code_attribute; +import com.sun.tools.classfile.LineNumberTable_attribute; +import com.sun.tools.classfile.Method; +import com.sun.tools.javac.util.Assert; + +public class WrongLVTForLambdaTest { + + static final String testSource = + /* 01 */ "import java.util.List;\n" + + /* 02 */ "import java.util.Arrays;\n" + + /* 03 */ "import java.util.stream.Collectors;\n" + + /* 04 */ "\n" + + /* 05 */ "public class Foo {\n" + + /* 06 */ " void bar(int value) {\n" + + /* 07 */ " final List numbers = Arrays.asList(1, 2, 3);\n" + + /* 08 */ " final List numbersPlusOne = \n" + + /* 09 */ " numbers.stream().map(number -> number / 1).collect(Collectors.toList());\n" + + /* 10 */ " }\n" + + /* 11 */ "}"; + + static final int[][] expectedLNT = { + // {line-number, start-pc}, + {9, 0}, //number -> number / 1 + }; + + static final String methodToLookFor = "lambda$0"; + + public static void main(String[] args) throws Exception { + new WrongLVTForLambdaTest().run(); + } + + void run() throws Exception { + compileTestClass(); + checkClassFile(new File(Paths.get(System.getProperty("user.dir"), + "Foo.class").toUri()), methodToLookFor); + } + + void compileTestClass() throws Exception { + ToolBox.JavaToolArgs javacSuccessArgs = + new ToolBox.JavaToolArgs().setSources(testSource); + ToolBox.javac(javacSuccessArgs); + } + + void checkClassFile(final File cfile, String methodToFind) throws Exception { + ClassFile classFile = ClassFile.read(cfile); + boolean methodFound = false; + for (Method method : classFile.methods) { + if (method.getName(classFile.constant_pool).equals(methodToFind)) { + methodFound = true; + Code_attribute code = (Code_attribute) method.attributes.get("Code"); + LineNumberTable_attribute lnt = + (LineNumberTable_attribute) code.attributes.get("LineNumberTable"); + Assert.check(lnt.line_number_table_length == expectedLNT.length, + "The LineNumberTable found has a length different to the expected one"); + int i = 0; + for (LineNumberTable_attribute.Entry entry: lnt.line_number_table) { + Assert.check(entry.line_number == expectedLNT[i][0] && + entry.start_pc == expectedLNT[i][1], + "LNT entry at pos " + i + " differ from expected." + + "Found " + entry.line_number + ":" + entry.start_pc + + ". Expected " + expectedLNT[i][0] + ":" + expectedLNT[i][1]); + i++; + } + } + } + Assert.check(methodFound, "The seek method was not found"); + } + + void error(String msg) { + throw new AssertionError(msg); + } + +} diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/T8022053/UnverifiableInitForNestedLocalClassTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T8022053/UnverifiableInitForNestedLocalClassTest.java Fri Aug 30 10:17:10 2013 +0100 @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8022053 + * @summary 8022053: javac generates unverifiable initializer for nested subclass of local class + * @run main UnverifiableInitForNestedLocalClassTest + */ + +public class UnverifiableInitForNestedLocalClassTest { + + public static void main(final String[] args) { + test("test"); + } + + static void test(final String arg) { + final String inlined = " inlined "; + class LocalClass { + String m() { + return "LocalClass " + arg + inlined; + } + + class SubClass extends LocalClass { + @Override + String m() { + return "SubClass " + arg + inlined; + } + } + + class SubSubClass extends SubClass { + @Override + String m() { + return "SubSubClass " + arg + inlined; + } + } + + class AnotherLocal { + class AnotherSub extends LocalClass { + @Override + String m() { + return "AnotherSub " + arg + inlined; + } + } + } + } + System.out.println(new LocalClass().m()); + System.out.println(new LocalClass().new SubClass().m()); + System.out.println(new LocalClass().new SubSubClass().m()); + System.out.println(new LocalClass().new AnotherLocal().new AnotherSub().m()); + } + +} diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/TestPkgInfo.java --- a/test/tools/javac/TestPkgInfo.java Fri Aug 23 22:12:54 2013 +0100 +++ b/test/tools/javac/TestPkgInfo.java Fri Aug 30 10:17:10 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,8 +23,10 @@ /* * @test - * @bug 6960424 - * @summary new option -Xpkginfo for better control of when package-info.class is generated + * @bug 6960424 8022161 + * @summary new option -Xpkginfo for better control of when package-info.class + * is generated, also ensures no failures if package-info.java is + * not available. */ import java.io.*; @@ -43,8 +45,11 @@ public static void main(String... args) throws Exception { new TestPkgInfo().run(args); } - public void run(String... args) throws Exception { + testPositive(); + testNoExceptions(); + } + public void testPositive(String... args) throws Exception { boolean[] booleanValues = { false, true }; for (OptKind ok: OptKind.values()) { for (boolean sr: booleanValues) { @@ -65,6 +70,32 @@ throw new Exception(errors + " errors occurred"); } + /** this should throw no exceptions **/ + void testNoExceptions() throws Exception { + count++; + System.err.println("Test " + count + ": ALWAYS nofile"); + + StringBuilder sb = new StringBuilder(); + sb.append("package test; class Hello{}"); + + // test specific tmp directory + File tmpDir = new File("tmp.test" + count); + File classesDir = new File(tmpDir, "classes"); + classesDir.mkdirs(); + File javafile = new File(new File(tmpDir, "src"), "Hello.java"); + writeFile(javafile, sb.toString()); + // build up list of options and files to be compiled + List opts = new ArrayList<>(); + List files = new ArrayList<>(); + + opts.add("-d"); + opts.add(classesDir.getPath()); + opts.add("-Xpkginfo:always"); + files.add(javafile); + + compile(opts, files); + } + void test(OptKind ok, boolean sr, boolean cr, boolean rr) throws Exception { count++; System.err.println("Test " + count + ": ok:" + ok + " sr:" + sr + " cr:" + cr + " rr:" + rr); @@ -91,15 +122,15 @@ writeFile(pkginfo_java, sb.toString()); // build up list of options and files to be compiled - List opts = new ArrayList(); - List files = new ArrayList(); + List opts = new ArrayList<>(); + List files = new ArrayList<>(); opts.add("-d"); opts.add(classesDir.getPath()); if (ok.opt != null) opts.add(ok.opt); //opts.add("-verbose"); - files.add(pkginfo_java); + files.add(pkginfo_java); compile(opts, files); @@ -134,7 +165,7 @@ /** Compile files with options provided. */ void compile(List opts, List files) throws Exception { System.err.println("javac: " + opts + " " + files); - List args = new ArrayList(); + List args = new ArrayList<>(); args.addAll(opts); for (File f: files) args.add(f.getPath()); diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/defaultMethods/defaultMethodExecution/DefaultMethodRegressionTests.java --- a/test/tools/javac/defaultMethods/defaultMethodExecution/DefaultMethodRegressionTests.java Fri Aug 23 22:12:54 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @ignore 8007517: DefaultMethodRegressionTests.java fail in TL - * @bug 8003639 - * @summary convert lambda testng tests to jtreg and add them - * @run testng DefaultMethodRegressionTests - */ - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import org.testng.annotations.Test; - -import static org.testng.Assert.*; - -/** - * This set of classes/interfaces (K/I/C) is specially designed to expose a - * bug in the JVM where it did not find some overloaded methods in some - * specific situations. (fixed by hotspot changeset ffb9316fd9ed) - */ -interface K { - int bbb(Long l); -} - -interface I extends K { - default void aaa() {} - default void aab() {} - default void aac() {} - - default int bbb(Integer i) { return 22; } - default int bbb(Float f) { return 33; } - default int bbb(Long l) { return 44; } - default int bbb(Double d) { return 55; } - default int bbb(String s) { return 66; } - - default void caa() {} - default void cab() {} - default void cac() {} -} - -class C implements I {} - -public class DefaultMethodRegressionTests { - - @Test(groups = "vm") - public void testLostOverloadedMethod() { - C c = new C(); - assertEquals(c.bbb(new Integer(1)), 22); - assertEquals(c.bbb(new Float(1.1)), 33); - assertEquals(c.bbb(new Long(1L)), 44); - assertEquals(c.bbb(new Double(0.01)), 55); - assertEquals(c.bbb(new String("")), 66); - } - - // Test to ensure that the inference verifier accepts older classfiles - // with classes that implement interfaces with defaults. - @Test(groups = "vm") - public void testInferenceVerifier() { - // interface I { int m() default { return 99; } } - byte I_bytes[] = { - (byte)0xca, (byte)0xfe, (byte)0xba, (byte)0xbe, 0x00, 0x00, 0x00, 0x33, - 0x00, 0x08, 0x07, 0x00, 0x06, 0x07, 0x00, 0x07, - 0x01, 0x00, 0x03, 0x66, 0x6f, 0x6f, 0x01, 0x00, - 0x03, 0x28, 0x29, 0x49, 0x01, 0x00, 0x04, 0x43, - 0x6f, 0x64, 0x65, 0x01, 0x00, 0x01, 0x49, 0x01, - 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, - 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65, - 0x63, 0x74, 0x06, 0x00, 0x00, 0x01, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x01, - 0x00, 0x03, 0x00, 0x04, 0x00, 0x01, 0x00, 0x05, - 0x00, 0x00, 0x00, 0x0f, 0x00, 0x01, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x03, 0x10, 0x63, (byte)0xac, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00 - }; - // public class C implements I {} /* -target 1.5 */ - byte C_bytes[] = { - (byte)0xca, (byte)0xfe, (byte)0xba, (byte)0xbe, 0x00, 0x00, 0x00, 0x31, - 0x00, 0x0c, 0x0a, 0x00, 0x03, 0x00, 0x08, 0x07, - 0x00, 0x09, 0x07, 0x00, 0x0a, 0x07, 0x00, 0x0b, - 0x01, 0x00, 0x06, 0x3c, 0x69, 0x6e, 0x69, 0x74, - 0x3e, 0x01, 0x00, 0x03, 0x28, 0x29, 0x56, 0x01, - 0x00, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x0c, 0x00, - 0x05, 0x00, 0x06, 0x01, 0x00, 0x01, 0x43, 0x01, - 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, - 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65, - 0x63, 0x74, 0x01, 0x00, 0x01, 0x49, 0x00, 0x21, - 0x00, 0x02, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x05, - 0x00, 0x06, 0x00, 0x01, 0x00, 0x07, 0x00, 0x00, - 0x00, 0x11, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x05, 0x2a, (byte)0xb7, 0x00, 0x01, (byte)0xb1, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00 - }; - - ClassLoader cl = new ClassLoader() { - protected Class findClass(String name) { - if (name.equals("I")) { - return defineClass("I", I_bytes, 0, I_bytes.length); - } else if (name.equals("C")) { - return defineClass("C", C_bytes, 0, C_bytes.length); - } else { - return null; - } - } - }; - try { - Class.forName("C", true, cl); - } catch (Exception e) { - // unmodified verifier will throw VerifyError - fail("No exception should be thrown"); - } - } -} diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/diags/examples/AlreadyDefinedStaticImport/AlreadDefinedStaticImport.java --- a/test/tools/javac/diags/examples/AlreadyDefinedStaticImport/AlreadDefinedStaticImport.java Fri Aug 23 22:12:54 2013 +0100 +++ b/test/tools/javac/diags/examples/AlreadyDefinedStaticImport/AlreadDefinedStaticImport.java Fri Aug 30 10:17:10 2013 +0100 @@ -23,5 +23,5 @@ // key: compiler.err.already.defined.static.single.import -import static p.E1.A; +import p.E1.A; import static p.E2.A; diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/diags/examples/AlreadyDefinedStaticImport/p/E1.java --- a/test/tools/javac/diags/examples/AlreadyDefinedStaticImport/p/E1.java Fri Aug 23 22:12:54 2013 +0100 +++ b/test/tools/javac/diags/examples/AlreadyDefinedStaticImport/p/E1.java Fri Aug 30 10:17:10 2013 +0100 @@ -23,4 +23,6 @@ package p; -public enum E1 { A, B, C} +public class E1 { + public static class A { } +} diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/diags/examples/AlreadyDefinedStaticImport/p/E2.java --- a/test/tools/javac/diags/examples/AlreadyDefinedStaticImport/p/E2.java Fri Aug 23 22:12:54 2013 +0100 +++ b/test/tools/javac/diags/examples/AlreadyDefinedStaticImport/p/E2.java Fri Aug 30 10:17:10 2013 +0100 @@ -23,4 +23,6 @@ package p; -public enum E2 { A, B, C } +public class E2 { + public static class A { } +} diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/diags/examples/IncompatibleThrownTypesInLambda.java --- a/test/tools/javac/diags/examples/IncompatibleThrownTypesInLambda.java Fri Aug 23 22:12:54 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -// key: compiler.err.incompatible.thrown.types.in.lambda - -class IncompatibleThrownTypesInLambda { - interface SAM { - void m(); - } - - SAM s = ()-> { throw new Exception(); }; -} diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/diags/examples/ObsoleteSourceAndTarget.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/ObsoleteSourceAndTarget.java Fri Aug 30 10:17:10 2013 +0100 @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.warn.option.obsolete.source +// key: compiler.warn.option.obsolete.target +// key: compiler.warn.option.obsolete.suppression +// key: compiler.warn.source.no.bootclasspath +// options: -source 1.5 -target 1.5 + +class ObsoleteSourceAndTarget { + public static void foo() {;} +} diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/generics/7015430/T7015430_1.out --- a/test/tools/javac/generics/7015430/T7015430_1.out Fri Aug 23 22:12:54 2013 +0100 +++ b/test/tools/javac/generics/7015430/T7015430_1.out Fri Aug 30 10:17:10 2013 +0100 @@ -1,13 +1,13 @@ T7015430.java:42:14: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable, java.lang.Iterable, kindname.class, T7015430 T7015430.java:42:15: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable T7015430.java:51:41: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable, java.lang.Iterable, kindname.class, T7015430 -T7015430.java:51:42: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable +T7015430.java:51:42: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable T7015430.java:69:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, , java.lang.Iterable, java.lang.Iterable, kindname.class, T7015430 T7015430.java:69:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable T7015430.java:78:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, , java.lang.Iterable, java.lang.Iterable, kindname.class, T7015430 -T7015430.java:78:40: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable +T7015430.java:78:40: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable T7015430.java:105:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, , java.lang.Iterable, java.lang.Iterable, kindname.class, T7015430 -T7015430.java:105:41: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable +T7015430.java:105:41: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable T7015430.java:114:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, , java.lang.Iterable, java.lang.Iterable, kindname.class, T7015430 T7015430.java:114:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable T7015430.java:42:14: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/generics/7015430/T7015430_2.out --- a/test/tools/javac/generics/7015430/T7015430_2.out Fri Aug 23 22:12:54 2013 +0100 +++ b/test/tools/javac/generics/7015430/T7015430_2.out Fri Aug 30 10:17:10 2013 +0100 @@ -1,15 +1,15 @@ T7015430.java:42:14: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable, java.lang.Iterable, kindname.class, T7015430 -T7015430.java:42:15: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable +T7015430.java:42:15: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable T7015430.java:51:41: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable, java.lang.Iterable, kindname.class, T7015430 -T7015430.java:51:42: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable +T7015430.java:51:42: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable T7015430.java:69:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, , java.lang.Iterable, java.lang.Iterable, kindname.class, T7015430 -T7015430.java:69:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable +T7015430.java:69:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable T7015430.java:78:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, , java.lang.Iterable, java.lang.Iterable, kindname.class, T7015430 -T7015430.java:78:40: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable +T7015430.java:78:40: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable T7015430.java:105:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, , java.lang.Iterable, java.lang.Iterable, kindname.class, T7015430 -T7015430.java:105:41: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable +T7015430.java:105:41: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable T7015430.java:114:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, , java.lang.Iterable, java.lang.Iterable, kindname.class, T7015430 -T7015430.java:114:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable +T7015430.java:114:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable T7015430.java:130:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception 1 error 12 warnings diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/generics/7151802/T7151802.out --- a/test/tools/javac/generics/7151802/T7151802.out Fri Aug 23 22:12:54 2013 +0100 +++ b/test/tools/javac/generics/7151802/T7151802.out Fri Aug 30 10:17:10 2013 +0100 @@ -1,6 +1,6 @@ T7151802.java:14:31: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get1, Z, T7151802.Foo, kindname.class, T7151802 T7151802.java:22:30: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get3, T7151802.Foo, T7151802.Foo, kindname.class, T7151802 -T7151802.java:22:31: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7151802.Foo, T7151802.Foo +T7151802.java:22:31: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7151802.Foo, T7151802.Foo T7151802.java:30:36: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get5, compiler.misc.no.args, compiler.misc.no.args, kindname.class, T7151802 T7151802.java:38:31: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get7, T7151802.Foo, T7151802.Foo, kindname.class, T7151802 T7151802.java:38:32: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7151802.Foo, T7151802.Foo diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/generics/8016640/T8016640.java --- a/test/tools/javac/generics/8016640/T8016640.java Fri Aug 23 22:12:54 2013 +0100 +++ b/test/tools/javac/generics/8016640/T8016640.java Fri Aug 30 10:17:10 2013 +0100 @@ -1,10 +1,11 @@ /* * @test /nodynamiccopyright/ - * @bug 8016640 + * @bug 8016640 8022508 * @summary compiler hangs if the generics arity of a base class is wrong * @compile/fail/ref=T8016640.out -XDrawDiagnostics T8016640.java */ class T8016640 { static class Foo { } static class BadFoo extends Foo { } + static class SubBadFoo extends BadFoo { } } diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/generics/inference/6718364/T6718364.out --- a/test/tools/javac/generics/inference/6718364/T6718364.out Fri Aug 23 22:12:54 2013 +0100 +++ b/test/tools/javac/generics/inference/6718364/T6718364.out Fri Aug 30 10:17:10 2013 +0100 @@ -1,3 +1,3 @@ T6718364.java:13:10: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, T6718364.X,T, T6718364.X>,T6718364.X, kindname.class, T6718364 -T6718364.java:13:32: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6718364.X, T6718364.X +T6718364.java:13:32: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6718364.X, T 2 warnings diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/generics/inference/7177306/T7177306a.out --- a/test/tools/javac/generics/inference/7177306/T7177306a.out Fri Aug 23 22:12:54 2013 +0100 +++ b/test/tools/javac/generics/inference/7177306/T7177306a.out Fri Aug 30 10:17:10 2013 +0100 @@ -1,5 +1,5 @@ T7177306a.java:13:33: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, java.util.List, java.util.List, kindname.class, T7177306a -T7177306a.java:13:34: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.util.List, java.util.List +T7177306a.java:13:34: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.util.List, java.util.List T7177306a.java:13:33: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7177306a, T7177306a - compiler.err.warnings.and.werror 1 error diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/lambda/8021567/T8021567.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/8021567/T8021567.java Fri Aug 30 10:17:10 2013 +0100 @@ -0,0 +1,26 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8021567 + * @summary Javac doesn't report "java: reference to method is ambiguous" any more + * @compile/fail/ref=T8021567.out -XDrawDiagnostics T8021567.java + */ + +class T8021567 { + + interface I_int { int m(); } + + interface I_char { char m(); } + + interface I_byte { byte m(); } + + void m(I_byte b) { } + void m(I_char b) { } + void m(I_int b) { } + + void test() { + m(() -> 1); //ambiguous + m(() -> 256); //ok - only method(I_int) applicable + m(() -> { int i = 1; return i; }); //ok - only method(I_int) applicable + m(() -> { int i = 256; return i; }); //ok - only method(I_int) applicable + } +} diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/lambda/8021567/T8021567.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/8021567/T8021567.out Fri Aug 30 10:17:10 2013 +0100 @@ -0,0 +1,2 @@ +T8021567.java:21:9: compiler.err.ref.ambiguous: m, kindname.method, m(T8021567.I_byte), T8021567, kindname.method, m(T8021567.I_char), T8021567 +1 error diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/lambda/8021567/T8021567b.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/8021567/T8021567b.java Fri Aug 30 10:17:10 2013 +0100 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8021567 + * @summary Javac doesn't report "java: reference to method is ambiguous" any more + */ + +public class T8021567b { + + interface SAM { + int m(); + } + + public static void main(String argv[]) { + test(); + } + + static boolean test() { + final int i = 0; + SAM s = () -> i; + return (s.m() == 0); + } +} diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/lambda/ExceptionsInLambda.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/ExceptionsInLambda.java Fri Aug 30 10:17:10 2013 +0100 @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8015809 + * @summary Producing individual errors for uncaught undeclared exceptions inside lambda expressions, instead of one error for whole lambda + * @compile/fail/ref=ExceptionsInLambda.out -XDrawDiagnostics ExceptionsInLambda.java + */ + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.InputStream; +import java.io.Reader; + +public class ExceptionsInLambda { + + public static void main(Runnable p, File f) { + main(() -> { + StringBuilder sb = new StringBuilder(); + + Reader in = new FileReader(f); + int r; + + while ((r = in.read()) != (-1)) { + sb.append((char) r); + } + }, f); + + doOpen(() -> new FileInputStream(f)); + } + + public static InputStream doOpen(Open open) { + return open.open(); + } + + public interface Open { + public InputStream open(); + } +} diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/lambda/ExceptionsInLambda.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/ExceptionsInLambda.out Fri Aug 30 10:17:10 2013 +0100 @@ -0,0 +1,4 @@ +ExceptionsInLambda.java:43:25: compiler.err.unreported.exception.need.to.catch.or.throw: java.io.FileNotFoundException +ExceptionsInLambda.java:46:32: compiler.err.unreported.exception.need.to.catch.or.throw: java.io.IOException +ExceptionsInLambda.java:51:22: compiler.err.unreported.exception.need.to.catch.or.throw: java.io.FileNotFoundException +3 errors diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/lambda/TargetType21.out --- a/test/tools/javac/lambda/TargetType21.out Fri Aug 23 22:12:54 2013 +0100 +++ b/test/tools/javac/lambda/TargetType21.out Fri Aug 30 10:17:10 2013 +0100 @@ -1,6 +1,5 @@ TargetType21.java:28:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM2), TargetType21, kindname.method, call(TargetType21.SAM3), TargetType21 -TargetType21.java:28:14: compiler.err.incompatible.thrown.types.in.lambda: java.lang.Exception TargetType21.java:29:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM2), TargetType21, kindname.method, call(TargetType21.SAM3), TargetType21 TargetType21.java:30:13: compiler.err.prob.found.req: (compiler.misc.cyclic.inference: A) TargetType21.java:31:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM1), TargetType21, kindname.method, call(TargetType21.SAM3), TargetType21 -5 errors +4 errors diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/lambda/TargetType59.java --- a/test/tools/javac/lambda/TargetType59.java Fri Aug 23 22:12:54 2013 +0100 +++ b/test/tools/javac/lambda/TargetType59.java Fri Aug 30 10:17:10 2013 +0100 @@ -34,15 +34,15 @@ class TargetType59 { - Collector m(Supplier supplier, BiConsumer accumulator) { + Collector m(Supplier supplier, BiConsumer accumulator) { return null; } - > Collector test1(Supplier collectionFactory) { + > Collector test1(Supplier collectionFactory) { return m(collectionFactory, Collection::add); } - Collector test2(Supplier sb) { + Collector test2(Supplier sb) { return m(sb, StringBuilder::append); } } diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/lambda/TargetType62.java --- a/test/tools/javac/lambda/TargetType62.java Fri Aug 23 22:12:54 2013 +0100 +++ b/test/tools/javac/lambda/TargetType62.java Fri Aug 30 10:17:10 2013 +0100 @@ -38,8 +38,8 @@ return g(classifier, TreeMap::new, m(HashSet::new)); } - Collector m(Supplier s) { return null; } + Collector m(Supplier s) { return null; } > - Collector g(Function classifier, Supplier mapFactory, Collector downstream) { return null; } + Collector g(Function classifier, Supplier mapFactory, Collector downstream) { return null; } } diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/processing/errors/EnsureMirroredTypeException/Processor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/processing/errors/EnsureMirroredTypeException/Processor.java Fri Aug 30 10:17:10 2013 +0100 @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.lang.annotation.*; +import java.util.*; +import javax.annotation.processing.*; +import javax.lang.model.element.*; +import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.MirroredTypeException; +import javax.lang.model.type.TypeMirror; +import javax.lang.model.type.TypeKind; +import javax.tools.*; + +import com.sun.tools.javac.util.Assert; +import com.sun.tools.javac.code.Symbol; +import static com.sun.tools.javac.code.Symbol.TypeSymbol; + +public class Processor extends JavacTestingAbstractProcessor { + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + for (Element e : roundEnv.getElementsAnnotatedWith(A.class)) { + A rtg = e.getAnnotation(A.class); + + try { + rtg.a(); + Assert.check(false); //Should not reach here + } catch (MirroredTypeException ex) { + TypeMirror tm = ex.getTypeMirror(); + Assert.check(tm.getKind() == TypeKind.ERROR); + + TypeElement elm = (TypeElement)((DeclaredType)tm).asElement(); + Assert.check(elm.getQualifiedName().toString(). + endsWith("some.path.to.SomeUnknownClass$Inner")); + + TypeSymbol sym = (TypeSymbol)elm; + Assert.check(sym.name.contentEquals("some.path.to.SomeUnknownClass$Inner")); + } + } + for (Element e : roundEnv.getElementsAnnotatedWith(B.class)) { + B rtg = e.getAnnotation(B.class); + + try { + rtg.a(); + Assert.check(false); //Should not reach here + } catch (MirroredTypeException ex) { + TypeMirror tm = ex.getTypeMirror(); + Assert.check(tm.getKind() == TypeKind.ERROR); + + TypeElement elm = (TypeElement)((DeclaredType)tm).asElement(); + Assert.check(elm.getQualifiedName().toString(). + endsWith("SomeUnknownClass")); + + TypeSymbol sym = (TypeSymbol)elm; + Assert.check(sym.name.contentEquals("SomeUnknownClass")); + } + } + for (Element e : roundEnv.getElementsAnnotatedWith(C.class)) { + C rtg = e.getAnnotation(C.class); + + try { + rtg.a(); + Assert.check(false); //Should not reach here + } catch (AnnotationTypeMismatchException ex) { + ; + } + } + return true; + } + + @interface A { + Class a(); + } + @interface B { + Class a(); + } + @interface C { + Class a(); + } +} diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/processing/errors/EnsureMirroredTypeException/Source.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/processing/errors/EnsureMirroredTypeException/Source.java Fri Aug 30 10:17:10 2013 +0100 @@ -0,0 +1,17 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8019243 + * @summary AnnotationTypeMismatchException instead of MirroredTypeException + * @library /tools/javac/lib + * @build JavacTestingAbstractProcessor Processor + * @compile/fail/ref=Source.out -XDrawDiagnostics -processor Processor Source.java + */ + +@Processor.A(a=some.path.to.SomeUnknownClass$Inner.class) +class Source1{} + +@Processor.B(a=SomeUnknownClass.class) +class Source2{} + +@Processor.C(a=SomeUnknownClass.clas) // this is not a class literal +class Source3{} diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/processing/errors/EnsureMirroredTypeException/Source.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/processing/errors/EnsureMirroredTypeException/Source.out Fri Aug 30 10:17:10 2013 +0100 @@ -0,0 +1,4 @@ +Source.java:10:28: compiler.err.doesnt.exist: some.path.to +Source.java:13:16: compiler.err.cant.resolve: kindname.class, SomeUnknownClass, , +Source.java:16:16: compiler.err.cant.resolve: kindname.variable, SomeUnknownClass, , +3 errors diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/processing/errors/TestClassNames.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/processing/errors/TestClassNames.java Fri Aug 30 10:17:10 2013 +0100 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7071377 + * @summary verify if erroneous class names are rejected + * @library /tools/javac/lib + * @build TestClassNames JavacTestingAbstractProcessor CompileFail + * @run main CompileFail ERROR -processor TestClassNames TestClassNames.x.y + * @run main CompileFail ERROR -processor TestClassNames x.y.TestClassNames + * @run main CompileFail ERROR -processor NoClass NoClass.x.y + */ + +import java.util.Set; +import javax.annotation.processing.*; +import javax.lang.model.element.*; + +/** + * No-op processor; should not be run. + */ +public class TestClassNames extends JavacTestingAbstractProcessor { + public boolean process(Set annotations, + RoundEnvironment roundEnvironment) { + return true; + } +} diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/processing/model/testgetallmembers/Main.java --- a/test/tools/javac/processing/model/testgetallmembers/Main.java Fri Aug 23 22:12:54 2013 +0100 +++ b/test/tools/javac/processing/model/testgetallmembers/Main.java Fri Aug 30 10:17:10 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,6 @@ import java.io.File; import java.util.*; -import javax.lang.model.SourceVersion; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.PackageElement; @@ -60,7 +59,10 @@ static Elements elements; public static void main(String[] args) throws Exception { - + if (haveAltRt()) { + System.out.println("Warning: alt-rt.jar detected, test skipped"); + return; + } JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); fm.setLocation(CLASS_PATH, Collections.emptyList()); @@ -123,4 +125,23 @@ if (nestedClasses < 3000) throw new AssertionError("Too few nested classes in PLATFORM_CLASS_PATH ;-)"); } + /* + * If -XX:+AggressiveOpts has been used to test, the option currently + * instructs the VM to prepend alt-rt.jar onto the bootclasspath. This + * overrides the default TreeMap implemation in rt.jar causing symbol + * resolution problems (caused by inconsistent inner class), although + * alt-rt.jar is being eliminated, we have this sanity check to detect this + * case and skip the test. + */ + static boolean haveAltRt() { + String bootClassPath = System.getProperty("sun.boot.class.path"); + for (String cp : bootClassPath.split(File.pathSeparator)) { + if (cp.endsWith("alt-rt.jar")) { + System.err.println("Warning: detected alt-rt.jar in " + + "sun.boot.class.path"); + return true; + } + } + return false; + } } diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/staticImport/6537020/T6537020.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/staticImport/6537020/T6537020.java Fri Aug 30 10:17:10 2013 +0100 @@ -0,0 +1,26 @@ +/* + * @test /nodynamiccopyright/ + * @bug 6537020 + * @summary JCK tests: a compile-time error should be given in case of ambiguously imported fields (types, methods) + * + * @compile/fail/ref=T6537020.out -XDrawDiagnostics T6537020.java + */ + +package p; + +import static p.T6537020.C.s; + +class T6537020 { + + static class A { + static String s; + } + + interface B { + String s = ""; + } + + static class C extends A implements B { } + + Object o = s; +} diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/staticImport/6537020/T6537020.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/staticImport/6537020/T6537020.out Fri Aug 30 10:17:10 2013 +0100 @@ -0,0 +1,2 @@ +T6537020.java:25:16: compiler.err.ref.ambiguous: s, kindname.variable, s, p.T6537020.B, kindname.variable, s, p.T6537020.A +1 error diff -r a540e2a926cf -r a8f0c3583a86 test/tools/javac/tree/SourceTreeScannerTest.java --- a/test/tools/javac/tree/SourceTreeScannerTest.java Fri Aug 23 22:12:54 2013 +0100 +++ b/test/tools/javac/tree/SourceTreeScannerTest.java Fri Aug 30 10:17:10 2013 +0100 @@ -140,13 +140,6 @@ // not part of public API continue; } - if (JCTree.JCNewArray.class.isAssignableFrom(tree.getClass()) - && (f.getName().equals("annotations") - || f.getName().equals("dimAnnotations"))) { - // these fields are incorrectly missing from the public API - // (CR 6983297) - continue; - } try { //System.err.println("FIELD: " + f.getName()); reflectiveScan(f.get(tree)); diff -r a540e2a926cf -r a8f0c3583a86 test/tools/sjavac/SJavac.java --- a/test/tools/sjavac/SJavac.java Fri Aug 23 22:12:54 2013 +0100 +++ b/test/tools/sjavac/SJavac.java Fri Aug 30 10:17:10 2013 +0100 @@ -82,11 +82,13 @@ compileWithOverrideSource(); compileWithInvisibleSources(); compileCircularSources(); + compileExcludingDependency(); delete(gensrc); delete(gensrc2); delete(gensrc3); delete(bin); + delete(headers); } void initialCompile() throws Exception { @@ -381,6 +383,33 @@ delete(bin); } + /** + * Tests compiling class A that depends on class B without compiling class B + * @throws Exception If test fails + */ + void compileExcludingDependency() throws Exception { + System.out.println("\nVerify that excluding classes from compilation but not from linking works."); + System.out.println("---------------------------------------------------------------------------"); + + delete(gensrc); + delete(bin); + previous_bin_state = collectState(bin); + + populate(gensrc, + "alfa/A.java", + "package alfa; public class A { beta.B b; }", + "beta/B.java", + "package beta; public class B { }"); + + compile("-x", "beta", "-src", "gensrc", "-x", "alfa", "-sourcepath", "gensrc", + "-d", "bin", "--server:portfile=testserver,background=false"); + + Map new_bin_state = collectState(bin); + verifyThatFilesHaveBeenAdded(previous_bin_state, new_bin_state, + "bin/alfa/A.class", + "bin/javac_state"); + } + void removeFrom(Path dir, String... args) throws IOException { for (String filename : args) { Path p = dir.resolve(filename); @@ -405,7 +434,7 @@ } } - void delete(Path root) throws IOException { + void delete(final Path root) throws IOException { if (!Files.exists(root)) return; Files.walkFileTree(root, new SimpleFileVisitor() { @Override