OpenJDK / amber / amber
changeset 27127:f71cda53d7a6
Merge
author | lana |
---|---|
date | Thu, 16 Oct 2014 14:15:23 -0700 |
parents | b74a3d555835 6c718c5086b3 |
children | d1480cb49283 |
files | langtools/test/tools/javac/7129225/NegTest.ref langtools/test/tools/javac/7129225/TestImportStar.ref |
diffstat | 31 files changed, 339 insertions(+), 312 deletions(-) [+] |
line wrap: on
line diff
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java Thu Oct 16 12:02:08 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java Thu Oct 16 14:15:23 2014 -0700 @@ -1889,7 +1889,12 @@ * Mapping to take element type of an arraytype */ private Mapping elemTypeFun = new Mapping ("elemTypeFun") { - public Type apply(Type t) { return elemtype(t); } + public Type apply(Type t) { + while (t.hasTag(TYPEVAR)) { + t = t.getUpperBound(); + } + return elemtype(t); + } }; /** @@ -3531,40 +3536,46 @@ } /** - * Return the least upper bound of pair of types. if the lub does + * Return the least upper bound of list of types. if the lub does * not exist return null. */ - public Type lub(Type t1, Type t2) { - return lub(List.of(t1, t2)); + public Type lub(List<Type> ts) { + return lub(ts.toArray(new Type[ts.length()])); } /** * Return the least upper bound (lub) of set of types. If the lub * does not exist return the type of null (bottom). */ - public Type lub(List<Type> ts) { + public Type lub(Type... ts) { + final int UNKNOWN_BOUND = 0; final int ARRAY_BOUND = 1; final int CLASS_BOUND = 2; - int boundkind = 0; - for (Type t : ts) { + + int[] kinds = new int[ts.length]; + + int boundkind = UNKNOWN_BOUND; + for (int i = 0 ; i < ts.length ; i++) { + Type t = ts[i]; switch (t.getTag()) { case CLASS: - boundkind |= CLASS_BOUND; + boundkind |= kinds[i] = CLASS_BOUND; break; case ARRAY: - boundkind |= ARRAY_BOUND; + boundkind |= kinds[i] = ARRAY_BOUND; break; case TYPEVAR: do { t = t.getUpperBound(); } while (t.hasTag(TYPEVAR)); if (t.hasTag(ARRAY)) { - boundkind |= ARRAY_BOUND; + boundkind |= kinds[i] = ARRAY_BOUND; } else { - boundkind |= CLASS_BOUND; + boundkind |= kinds[i] = CLASS_BOUND; } break; default: + kinds[i] = UNKNOWN_BOUND; if (t.isPrimitive()) return syms.errType; } @@ -3575,15 +3586,16 @@ case ARRAY_BOUND: // calculate lub(A[], B[]) - List<Type> elements = Type.map(ts, elemTypeFun); - for (Type t : elements) { - if (t.isPrimitive()) { + Type[] elements = new Type[ts.length]; + for (int i = 0 ; i < ts.length ; i++) { + Type elem = elements[i] = elemTypeFun.apply(ts[i]); + if (elem.isPrimitive()) { // if a primitive type is found, then return // arraySuperType unless all the types are the // same - Type first = ts.head; - for (Type s : ts.tail) { - if (!isSameType(first, s)) { + Type first = ts[0]; + for (int j = 1 ; j < ts.length ; j++) { + if (!isSameType(first, ts[j])) { // lub(int[], B[]) is Cloneable & Serializable return arraySuperType(); } @@ -3598,13 +3610,20 @@ case CLASS_BOUND: // calculate lub(A, B) - while (!ts.head.hasTag(CLASS) && !ts.head.hasTag(TYPEVAR)) { - ts = ts.tail; + int startIdx = 0; + for (int i = 0; i < ts.length ; i++) { + Type t = ts[i]; + if (t.hasTag(CLASS) || t.hasTag(TYPEVAR)) { + break; + } else { + startIdx++; + } } - Assert.check(!ts.isEmpty()); + Assert.check(startIdx < ts.length); //step 1 - compute erased candidate set (EC) - List<Type> cl = erasedSupertypes(ts.head); - for (Type t : ts.tail) { + List<Type> cl = erasedSupertypes(ts[startIdx]); + for (int i = startIdx + 1 ; i < ts.length ; i++) { + Type t = ts[i]; if (t.hasTag(CLASS) || t.hasTag(TYPEVAR)) cl = intersect(cl, erasedSupertypes(t)); } @@ -3613,9 +3632,9 @@ //step 3 - for each element G in MEC, compute lci(Inv(G)) List<Type> candidates = List.nil(); for (Type erasedSupertype : mec) { - List<Type> lci = List.of(asSuper(ts.head, erasedSupertype.tsym)); - for (Type t : ts) { - lci = intersect(lci, List.of(asSuper(t, erasedSupertype.tsym))); + List<Type> lci = List.of(asSuper(ts[startIdx], erasedSupertype.tsym)); + for (int i = startIdx + 1 ; i < ts.length ; i++) { + lci = intersect(lci, List.of(asSuper(ts[i], erasedSupertype.tsym))); } candidates = candidates.appendList(lci); } @@ -3626,9 +3645,9 @@ default: // calculate lub(A, B[]) List<Type> classes = List.of(arraySuperType()); - for (Type t : ts) { - if (!t.hasTag(ARRAY)) // Filter out any arrays - classes = classes.prepend(t); + for (int i = 0 ; i < ts.length ; i++) { + if (kinds[i] != ARRAY_BOUND) // Filter out any arrays + classes = classes.prepend(ts[i]); } // lub(A, B[]) is lub(A, arraySuperType) return lub(classes);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java Thu Oct 16 12:02:08 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java Thu Oct 16 14:15:23 2014 -0700 @@ -315,8 +315,10 @@ isError = true; } List<JCExpression> args = a.args; + boolean elidedValue = false; if (args.length() == 1 && !args.head.hasTag(ASSIGN)) { // special case: elided "value=" assumed + elidedValue = true; args.head = make.at(args.head.pos). Assign(make.Ident(names.value), args.head); } @@ -336,7 +338,7 @@ continue; } JCIdent left = (JCIdent)assign.lhs; - Symbol method = rs.resolveQualifiedMethod(assign.rhs.pos(), + Symbol method = rs.resolveQualifiedMethod(elidedValue ? assign.rhs.pos() : left.pos(), env, a.type, left.name,
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java Thu Oct 16 12:02:08 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java Thu Oct 16 14:15:23 2014 -0700 @@ -67,11 +67,15 @@ private Symtab syms; private TreeMaker make; private Enter enter; - private boolean allowInterfaceBridges; private Types types; private final Resolve resolve; + private final CompileStates compileStates; - private final CompileStates compileStates; + /** Switch: is complex graph inference supported? */ + private final boolean allowGraphInference; + + /** Switch: are default methods supported? */ + private final boolean allowInterfaceBridges; protected TransTypes(Context context) { context.put(transTypesKey, this); @@ -81,11 +85,12 @@ syms = Symtab.instance(context); enter = Enter.instance(context); overridden = new HashMap<>(); - Source source = Source.instance(context); - allowInterfaceBridges = source.allowDefaultMethods(); types = Types.instance(context); make = TreeMaker.instance(context); resolve = Resolve.instance(context); + Source source = Source.instance(context); + allowInterfaceBridges = source.allowDefaultMethods(); + allowGraphInference = source.allowGraphInference(); } /** A hashtable mapping bridge methods to the methods they override after @@ -654,7 +659,11 @@ tree.meth = translate(tree.meth, null); Symbol meth = TreeInfo.symbol(tree.meth); Type mt = meth.erasure(types); - List<Type> argtypes = mt.getParameterTypes(); + boolean useInstantiatedPtArgs = + allowGraphInference && !types.isSignaturePolymorphic((MethodSymbol)meth.baseSymbol()); + List<Type> argtypes = useInstantiatedPtArgs ? + tree.meth.type.getParameterTypes() : + mt.getParameterTypes(); if (meth.name == names.init && meth.owner == syms.enumSym) argtypes = argtypes.tail.tail; if (tree.varargsElement != null) @@ -675,14 +684,23 @@ public void visitNewClass(JCNewClass tree) { if (tree.encl != null) tree.encl = translate(tree.encl, erasure(tree.encl.type)); + + Type erasedConstructorType = tree.constructorType != null ? + erasure(tree.constructorType) : + null; + + List<Type> argtypes = erasedConstructorType != null && allowGraphInference ? + erasedConstructorType.getParameterTypes() : + tree.constructor.erasure(types).getParameterTypes(); + tree.clazz = translate(tree.clazz, null); if (tree.varargsElement != null) tree.varargsElement = types.erasure(tree.varargsElement); tree.args = translateArgs( - tree.args, tree.constructor.erasure(types).getParameterTypes(), tree.varargsElement); + tree.args, argtypes, tree.varargsElement); tree.def = translate(tree.def, null); - if (tree.constructorType != null) - tree.constructorType = erasure(tree.constructorType); + if (erasedConstructorType != null) + tree.constructorType = erasedConstructorType; tree.type = erasure(tree.type); result = tree; }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java Thu Oct 16 12:02:08 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java Thu Oct 16 14:15:23 2014 -0700 @@ -173,14 +173,14 @@ * Utility class to help evaluate a path option. Duplicate entries are ignored, jar class paths * can be expanded. */ - private class Path extends LinkedHashSet<File> { + private class SearchPath extends LinkedHashSet<File> { private static final long serialVersionUID = 0; private boolean expandJarClassPaths = false; private final Set<File> canonicalValues = new HashSet<>(); - public Path expandJarClassPaths(boolean x) { + public SearchPath expandJarClassPaths(boolean x) { expandJarClassPaths = x; return this; } @@ -190,12 +190,12 @@ */ private File emptyPathDefault = null; - public Path emptyPathDefault(File x) { + public SearchPath emptyPathDefault(File x) { emptyPathDefault = x; return this; } - public Path addDirectories(String dirs, boolean warn) { + public SearchPath addDirectories(String dirs, boolean warn) { boolean prev = expandJarClassPaths; expandJarClassPaths = true; try { @@ -210,7 +210,7 @@ } } - public Path addDirectories(String dirs) { + public SearchPath addDirectories(String dirs) { return addDirectories(dirs, warn); } @@ -235,18 +235,18 @@ } } - public Path addFiles(String files, boolean warn) { + public SearchPath addFiles(String files, boolean warn) { if (files != null) { addFiles(getPathEntries(files, emptyPathDefault), warn); } return this; } - public Path addFiles(String files) { + public SearchPath addFiles(String files) { return addFiles(files, warn); } - public Path addFiles(Iterable<? extends File> files, boolean warn) { + public SearchPath addFiles(Iterable<? extends File> files, boolean warn) { if (files != null) { for (File file : files) { addFile(file, warn); @@ -255,7 +255,7 @@ return this; } - public Path addFiles(Iterable<? extends File> files) { + public SearchPath addFiles(Iterable<? extends File> files) { return addFiles(files, warn); } @@ -458,7 +458,7 @@ @Override void setLocation(Iterable<? extends File> files) { - Path p; + SearchPath p; if (files == null) { p = computePath(null); } else { @@ -467,12 +467,12 @@ searchPath = Collections.unmodifiableCollection(p); } - protected Path computePath(String value) { + protected SearchPath computePath(String value) { return createPath().addFiles(value); } - protected Path createPath() { - return new Path(); + protected SearchPath createPath() { + return new SearchPath(); } } @@ -494,7 +494,7 @@ } @Override - protected Path computePath(String value) { + protected SearchPath computePath(String value) { String cp = value; // CLASSPATH environment variable when run from `javac'. @@ -517,8 +517,8 @@ } @Override - protected Path createPath() { - return new Path() + protected SearchPath createPath() { + return new SearchPath() .expandJarClassPaths(true) // Only search user jars for Class-Paths .emptyPathDefault(new File(".")); // Empty path elt ==> current directory } @@ -616,15 +616,15 @@ } else { defaultBootClassPathRtJar = null; isDefaultBootClassPath = false; - Path p = new Path().addFiles(files, false); + SearchPath p = new SearchPath().addFiles(files, false); searchPath = Collections.unmodifiableCollection(p); optionValues.clear(); } } - Path computePath() { + SearchPath computePath() { defaultBootClassPathRtJar = null; - Path path = new Path(); + SearchPath path = new SearchPath(); String bootclasspathOpt = optionValues.get(BOOTCLASSPATH); String endorseddirsOpt = optionValues.get(ENDORSEDDIRS);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/7129225/NegTest.out Thu Oct 16 14:15:23 2014 -0700 @@ -0,0 +1,2 @@ +TestImportStar.java:14:1: compiler.err.doesnt.exist: xxx +1 error
--- a/langtools/test/tools/javac/7129225/NegTest.ref Thu Oct 16 12:02:08 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -TestImportStar.java:39:1: compiler.err.doesnt.exist: xxx -1 error
--- a/langtools/test/tools/javac/7129225/TestImportStar.java Thu Oct 16 12:02:08 2014 -0700 +++ b/langtools/test/tools/javac/7129225/TestImportStar.java Thu Oct 16 14:15:23 2014 -0700 @@ -1,36 +1,11 @@ -/* - * 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 +/* @test /nodynamiccopyright/ * @bug 7129225 * @summary import xxx.* isn't handled correctly by annotation processing * @library /tools/javac/lib * @build JavacTestingAbstractProcessor - * @compile/fail/ref=NegTest.ref -XDrawDiagnostics TestImportStar.java + * @compile/fail/ref=NegTest.out -XDrawDiagnostics TestImportStar.java * @compile Anno.java AnnoProcessor.java - * @compile/fail/ref=TestImportStar.ref -XDrawDiagnostics -processor AnnoProcessor -proc:only TestImportStar.java + * @compile/fail/ref=TestImportStar.out -XDrawDiagnostics -processor AnnoProcessor -proc:only TestImportStar.java */ //The @compile/fail... verifies that the fix doesn't break the normal compilation of import xxx.*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/7129225/TestImportStar.out Thu Oct 16 14:15:23 2014 -0700 @@ -0,0 +1,4 @@ +- compiler.note.proc.messager: RUNNING - lastRound = false +TestImportStar.java:14:1: compiler.err.doesnt.exist: xxx +- compiler.note.proc.messager: RUNNING - lastRound = true +1 error
--- a/langtools/test/tools/javac/7129225/TestImportStar.ref Thu Oct 16 12:02:08 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -- compiler.note.proc.messager: RUNNING - lastRound = false -TestImportStar.java:39:1: compiler.err.doesnt.exist: xxx -- compiler.note.proc.messager: RUNNING - lastRound = true -1 error \ No newline at end of file
--- a/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_4.java Thu Oct 16 12:02:08 2014 -0700 +++ b/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_4.java Thu Oct 16 14:15:23 2014 -0700 @@ -1,34 +1,10 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test + * @test /nodynamiccopyright/ * @bug 4094658 * @summary Test enforcement of JLS 6.6.1 and 6.6.2 rules requiring that * the type to which a component member belongs be accessible in qualified * names. - * - * @compile/fail QualifiedAccess_4.java + * @compile/fail/ref=QualifiedAccess_4.out -XDrawDiagnostics QualifiedAccess_4.java */ import pack1.P1; @@ -38,8 +14,5 @@ class Foo { class Bar {} } - - // NOTE: Error localization and recovery is bad here, - // eliciting two other spurious complaints. Foo.Bar yy = x.new Foo.Bar(); // ERROR - Type in qualified 'new' must be unqualified }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/QualifiedAccess/QualifiedAccess_4.out Thu Oct 16 14:15:23 2014 -0700 @@ -0,0 +1,2 @@ +QualifiedAccess_4.java:17:28: compiler.err.expected: '(' +1 error
--- a/langtools/test/tools/javac/T4848619/T4848619a.java Thu Oct 16 12:02:08 2014 -0700 +++ b/langtools/test/tools/javac/T4848619/T4848619a.java Thu Oct 16 14:15:23 2014 -0700 @@ -1,32 +1,9 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 4848619 * @summary static final variable declared after use and self initialized * @author Peter von der Ah\u00e9 - * @compile/fail T4848619a.java + * @compile/fail/ref=T4848619a.out -XDrawDiagnostics T4848619a.java */ public class T4848619a {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/T4848619/T4848619a.out Thu Oct 16 14:15:23 2014 -0700 @@ -0,0 +1,2 @@ +T4848619a.java:11:37: compiler.err.illegal.self.ref +1 error
--- a/langtools/test/tools/javac/T4848619/T4848619b.java Thu Oct 16 12:02:08 2014 -0700 +++ b/langtools/test/tools/javac/T4848619/T4848619b.java Thu Oct 16 14:15:23 2014 -0700 @@ -1,32 +1,9 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test + * @test /nodynamiccopyright/ * @bug 4848619 * @summary static final variable declared after use and self initialized * @author Peter von der Ah\u00e9 - * @compile/fail T4848619b.java + * @compile/fail/ref=T4848619b.out -XDrawDiagnostics T4848619b.java */ public class T4848619b {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/T4848619/T4848619b.out Thu Oct 16 14:15:23 2014 -0700 @@ -0,0 +1,2 @@ +T4848619b.java:11:13: compiler.err.illegal.self.ref +1 error
--- a/langtools/test/tools/javac/annotations/neg/Recovery1.out Thu Oct 16 12:02:08 2014 -0700 +++ b/langtools/test/tools/javac/annotations/neg/Recovery1.out Thu Oct 16 14:15:23 2014 -0700 @@ -1,4 +1,4 @@ Recovery1.java:14:5: compiler.err.cant.resolve.location: kindname.class, Marker, , , (compiler.misc.location: kindname.annotation, recovery1.MyAnnotation, null) Recovery1.java:14:30: compiler.err.cant.resolve.location: kindname.class, Marker, , , (compiler.misc.location: kindname.annotation, recovery1.MyAnnotation, null) -Recovery1.java:18:43: compiler.err.cant.resolve.location.args: kindname.method, markerToo, , , (compiler.misc.location: kindname.annotation, recovery1.MyAnnotation, null) +Recovery1.java:18:33: compiler.err.cant.resolve.location.args: kindname.method, markerToo, , , (compiler.misc.location: kindname.annotation, recovery1.MyAnnotation, null) 3 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/generics/inference/8058199/T8058199.java Thu Oct 16 14:15:23 2014 -0700 @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. 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 8058199 + * @summary Code generation problem with javac skipping a checkcast instruction + */ +public class T8058199 { + + final static String SYNTHETIC_CAST_TYPE = "[Ljava.lang.String;"; + + @SuppressWarnings("unchecked") + <Z> Z[] makeArr(Z z) { return (Z[])new Object[1]; } + + <U> void check(U u) { } + + void testMethod() { + test(() -> check(makeArr(""))); + } + + void testNewDiamond() { + class Check<X> { + Check(X x) { } + } + test(()-> new Check<>(makeArr(""))); + } + + void testNewGeneric() { + class Check { + <Z> Check(Z z) { } + } + test(()-> new Check(makeArr(""))); + } + + private void test(Runnable r) { + try { + r.run(); + throw new AssertionError("Missing synthetic cast"); + } catch (ClassCastException cce) { + if (!cce.getMessage().contains(SYNTHETIC_CAST_TYPE)) { + throw new AssertionError("Bad type in synthetic cast", cce); + } + } + } + + public static void main(String[] args) { + T8058199 test = new T8058199(); + test.testMethod(); + test.testNewDiamond(); + test.testNewGeneric(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/generics/inference/8058511/T8058511a.java Thu Oct 16 14:15:23 2014 -0700 @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. 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 8058511 + * @summary StackOverflowError at com.sun.tools.javac.code.Types.lub + * @compile T8058511a.java + */ +class T8058511a { + <Z> void choose(Z z1, Z z2) { } + + void test(Class<Double> cd, Class<? extends double[]> cdarr) { + choose(cd, cdarr); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/generics/inference/8058511/T8058511b.java Thu Oct 16 14:15:23 2014 -0700 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. 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 8058511 + * @summary StackOverflowError at com.sun.tools.javac.code.Types.lub + * @compile T8058511b.java + */ +class T8058511b { + void test(Class<Double> cd, Class<? extends double[]> cdarr) { + ((false) ? cd : cdarr).toString(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/generics/inference/8058511/T8058511c.java Thu Oct 16 14:15:23 2014 -0700 @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. 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 8058511 + * @summary StackOverflowError at com.sun.tools.javac.code.Types.lub + * @compile T8058511c.java + */ +import java.util.List; + +class T8058511c { + void test(List<? extends double[]> l) { + (true ? l.get(0) : l.get(0)).toString(); + } +}
--- a/langtools/test/tools/javac/positions/TreeEndPosTest.java Thu Oct 16 12:02:08 2014 -0700 +++ b/langtools/test/tools/javac/positions/TreeEndPosTest.java Thu Oct 16 14:15:23 2014 -0700 @@ -23,7 +23,7 @@ /* * @test - * @bug 8017216 8019422 8019421 + * @bug 8017216 8019422 8019421 8054956 * @summary verify start and end positions * @run main TreeEndPosTest */ @@ -102,6 +102,7 @@ public static void main(String... args) throws IOException { testUninitializedVariable(); testMissingAnnotationValue(); + testUnresolvableAnnotationAttribute(); testFinalVariableWithDefaultConstructor(); testFinalVariableWithConstructor(); } @@ -115,6 +116,11 @@ null, "@interface Foo { }", "\"vvvv\"")); } + static void testUnresolvableAnnotationAttribute() throws IOException { + compile(JavaSource.createJavaSource("@Foo(value=\"vvvv\")", + null, "@interface Foo { }", "value")); + } + static void testFinalVariableWithDefaultConstructor() throws IOException { compile(JavaSource.createJavaSource("private static final String Foo; public void bar() { }", "private static final String Foo;"));
--- a/langtools/test/tools/javac/scope/6225935/Estatico4.java Thu Oct 16 12:02:08 2014 -0700 +++ b/langtools/test/tools/javac/scope/6225935/Estatico4.java Thu Oct 16 14:15:23 2014 -0700 @@ -1,31 +1,8 @@ /* - * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test + * @test /nodynamiccopyright/ * @bug 6214959 - * @summary Compiler fails do produce error message with ODD number of import static - * @compile/fail Estatico4.java + * @summary Compiler fails to produce error message with ODD number of import static + * @compile/fail/ref=Estatico4.out -XDrawDiagnostics Estatico4.java */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/scope/6225935/Estatico4.out Thu Oct 16 14:15:23 2014 -0700 @@ -0,0 +1,2 @@ +Estatico4.java:16:24: compiler.err.ref.ambiguous: CENTER, kindname.variable, CENTER, java.awt.FlowLayout, kindname.variable, CENTER, javax.swing.SwingConstants +1 error
--- a/langtools/test/tools/javac/scope/6225935/T6214959.java Thu Oct 16 12:02:08 2014 -0700 +++ b/langtools/test/tools/javac/scope/6225935/T6214959.java Thu Oct 16 14:15:23 2014 -0700 @@ -1,32 +1,9 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test + * @test /nodynamiccopyright/ * @bug 6214959 - * @summary Compiler fails do produce error message with ODD number of import static + * @summary Compiler fails to produce error message with ODD number of import static * @author Peter von der Ah\u00e9 - * @compile/fail T6214959.java + * @compile/fail/ref=T6214959.out -XDrawDiagnostics T6214959.java */ import static a.Star.*;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/scope/6225935/T6214959.out Thu Oct 16 14:15:23 2014 -0700 @@ -0,0 +1,2 @@ +T6214959.java:15:7: compiler.err.ref.ambiguous: y, kindname.method, y(), a.Star, kindname.method, y(), a.Ambiguous +1 error
--- a/langtools/test/tools/javac/warnings/DepAnn.java Thu Oct 16 12:02:08 2014 -0700 +++ b/langtools/test/tools/javac/warnings/DepAnn.java Thu Oct 16 14:15:23 2014 -0700 @@ -1,35 +1,7 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test + * @test /nodynamiccopyright/ * @bug 4986256 - * @compile DepAnn.java - * @compile -Xlint:dep-ann DepAnn.java - * @compile -Xlint:all DepAnn.java - * @compile -Werror DepAnn.java - * @compile/fail -Werror -Xlint:dep-ann DepAnn.java - * @compile/fail -Werror -Xlint:all,-path DepAnn.java + * @compile/ref=DepAnn.out -XDrawDiagnostics -Xlint:all DepAnn.java */ // control: this class should generate warnings
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/warnings/DepAnn.out Thu Oct 16 14:15:23 2014 -0700 @@ -0,0 +1,5 @@ +DepAnn.java:12:10: compiler.warn.missing.deprecated.annotation +DepAnn.java:9:1: compiler.warn.missing.deprecated.annotation +DepAnn.java:59:10: compiler.warn.missing.deprecated.annotation +DepAnn.java:56:1: compiler.warn.missing.deprecated.annotation +4 warnings
--- a/langtools/test/tools/javac/warnings/Finally.java Thu Oct 16 12:02:08 2014 -0700 +++ b/langtools/test/tools/javac/warnings/Finally.java Thu Oct 16 14:15:23 2014 -0700 @@ -1,35 +1,7 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test + * @test /nodynamiccopyright/ * @bug 4986256 - * @compile Finally.java - * @compile -Xlint:finally Finally.java - * @compile -Xlint:all Finally.java - * @compile -Werror Finally.java - * @compile/fail -Werror -Xlint:finally Finally.java - * @compile/fail -Werror -Xlint:all,-path Finally.java + * @compile/ref=Finally.out -XDrawDiagnostics -Xlint:all Finally.java */ // control: this class should generate a warning
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/warnings/Finally.out Thu Oct 16 14:15:23 2014 -0700 @@ -0,0 +1,2 @@ +Finally.java:16:9: compiler.warn.finally.cannot.complete +1 warning
--- a/langtools/test/tools/javac/warnings/Serial.java Thu Oct 16 12:02:08 2014 -0700 +++ b/langtools/test/tools/javac/warnings/Serial.java Thu Oct 16 14:15:23 2014 -0700 @@ -1,34 +1,7 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test + * @test /nodynamiccopyright/ * @bug 4986256 - * @compile Serial.java - * @compile -Xlint:serial Serial.java - * @compile -Xlint:all Serial.java - * @compile -Werror Serial.java - * @compile/fail -Werror -Xlint:serial Serial.java + * @compile/ref=Serial.out -XDrawDiagnostics -Xlint:all Serial.java */ import java.io.Serializable;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/warnings/Serial.out Thu Oct 16 14:15:23 2014 -0700 @@ -0,0 +1,5 @@ +Serial.java:12:12: compiler.warn.missing.SVUID: Serial.Inner +Serial.java:10:1: compiler.warn.missing.SVUID: Serial +Serial.java:51:12: compiler.warn.missing.SVUID: Serial3.Inner +Serial.java:49:1: compiler.warn.missing.SVUID: Serial3 +4 warnings