# HG changeset patch # User lana # Date 1423179897 28800 # Node ID 1ba2a6b0fd9f7b3453772389e5b3ce1d699cac2e # Parent 772d7d253a11484faf8c599583ee9232c0e66a25# Parent 6752a23c7fecf0a34b3b54342467f4aa1c400ead Merge diff -r 772d7d253a11 -r 1ba2a6b0fd9f langtools/make/tools/propertiesparser/gen/ClassGenerator.java --- a/langtools/make/tools/propertiesparser/gen/ClassGenerator.java Thu Feb 05 11:43:37 2015 -0800 +++ b/langtools/make/tools/propertiesparser/gen/ClassGenerator.java Thu Feb 05 15:44:57 2015 -0800 @@ -192,8 +192,8 @@ */ String packageName(File file) { String path = file.getAbsolutePath(); - int begin = path.indexOf("com" + File.separatorChar); - String packagePath = path.substring(begin, path.lastIndexOf(File.separatorChar)); + int begin = path.lastIndexOf(File.separatorChar + "com" + File.separatorChar); + String packagePath = path.substring(begin + 1, path.lastIndexOf(File.separatorChar)); String packageName = packagePath.replace(File.separatorChar, '.'); return packageName; } diff -r 772d7d253a11 -r 1ba2a6b0fd9f langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java Thu Feb 05 11:43:37 2015 -0800 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java Thu Feb 05 15:44:57 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2015, 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 @@ -1931,6 +1931,11 @@ * Return the (most specific) base type of t that starts with the * given symbol. If none exists, return null. * + * Caveat Emptor: Since javac represents the class of all arrays with a singleton + * symbol Symtab.arrayClass, which by being a singleton cannot hold any discriminant, + * this method could yield surprising answers when invoked on arrays. For example when + * invoked with t being byte [] and sym being t.sym itself, asSuper would answer null. + * * @param t a type * @param sym a symbol */ diff -r 772d7d253a11 -r 1ba2a6b0fd9f langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java Thu Feb 05 11:43:37 2015 -0800 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java Thu Feb 05 15:44:57 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, 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 @@ -720,7 +720,7 @@ public void visitParens(JCParens tree) { tree.expr = translate(tree.expr, pt); - tree.type = erasure(tree.type); + tree.type = erasure(tree.expr.type); result = tree; } @@ -755,7 +755,7 @@ tree.clazz = translate(tree.clazz, null); Type originalTarget = tree.type; tree.type = erasure(tree.type); - JCExpression newExpression = translate(tree.expr, erasure(tree.expr.type)); + JCExpression newExpression = translate(tree.expr, tree.type); if (newExpression != tree.expr) { JCTypeCast typeCast = newExpression.hasTag(Tag.TYPECAST) ? (JCTypeCast) newExpression diff -r 772d7d253a11 -r 1ba2a6b0fd9f langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java Thu Feb 05 11:43:37 2015 -0800 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java Thu Feb 05 15:44:57 2015 -0800 @@ -2145,7 +2145,8 @@ // For basic types, the coerce(...) in genExpr(...) will do // the conversion. if (!tree.clazz.type.isPrimitive() && - types.asSuper(tree.expr.type, tree.clazz.type.tsym) == null) { + !types.isSameType(tree.expr.type, tree.clazz.type) && + types.asSuper(tree.expr.type, tree.clazz.type.tsym) == null) { code.emitop2(checkcast, makeRef(tree.pos(), tree.clazz.type)); } } diff -r 772d7d253a11 -r 1ba2a6b0fd9f langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/ct.properties --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/ct.properties Thu Feb 05 11:43:37 2015 -0800 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/ct.properties Thu Feb 05 15:44:57 2015 -0800 @@ -477,7 +477,7 @@ java.rmi.registry.*: compact2 java.rmi.server.*: compact2 java.security.*: compact1 -java.security.acl.*: compact3 +java.security.acl.*: compact1 java.security.cert.*: compact1 java.security.interfaces.*: compact1 java.security.spec.*: compact1 @@ -687,7 +687,7 @@ sun.rmi.transport.*: proprietary compact2 sun.rmi.transport.proxy.*: proprietary compact2 sun.rmi.transport.tcp.*: proprietary compact2 -sun.security.acl.*: proprietary compact3 +sun.security.acl.*: proprietary compact1 sun.security.action.*: proprietary compact1 sun.security.jca.*: proprietary compact1 sun.security.jgss.*: proprietary compact3 diff -r 772d7d253a11 -r 1ba2a6b0fd9f langtools/test/tools/javac/CheckNoClassCastException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/CheckNoClassCastException.java Thu Feb 05 15:44:57 2015 -0800 @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2015, 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 8069265 + * @summary ClassCastException when compiled with JDK 9b08+, JDK8 compiles OK. + * @run main CheckNoClassCastException + */ +import java.util.*; + +public class CheckNoClassCastException { + static String result = ""; + public static void main(String[] args) { + ListFail.main(null); + MapFail.main(null); + if (!result.equals("ListFailDoneMapFailDone")) + throw new AssertionError("Incorrect result"); + } +} + +class ListFail { + static interface Foo { + } + + public static void main(String[] args) { + List list = new ArrayList<>(); + list.add(new Date()); + + List cList = (List) (List) list; + Date date = (Date) cList.get(0); + CheckNoClassCastException.result += "ListFailDone"; + } +} + + +class MapFail { + static interface Foo { + } + + public static void main(String[] args) { + Map aMap = new HashMap<>(); + aMap.put("test",new Date()); + + Map m = (Map) (Map) aMap; + Date q = (Date) m.get("test"); + CheckNoClassCastException.result += "MapFailDone"; + } +} diff -r 772d7d253a11 -r 1ba2a6b0fd9f langtools/test/tools/javac/T7053059/DoubleCastTest.java --- a/langtools/test/tools/javac/T7053059/DoubleCastTest.java Thu Feb 05 11:43:37 2015 -0800 +++ b/langtools/test/tools/javac/T7053059/DoubleCastTest.java Thu Feb 05 15:44:57 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, 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 @@ -47,6 +47,7 @@ m1((byte[])m()); m1((byte[])os[0]); m1((byte[])this.x); + m1((byte[])((byte []) (o = null))); } } diff -r 772d7d253a11 -r 1ba2a6b0fd9f langtools/test/tools/javac/lambda/MethodReference55.java --- a/langtools/test/tools/javac/lambda/MethodReference55.java Thu Feb 05 11:43:37 2015 -0800 +++ b/langtools/test/tools/javac/lambda/MethodReference55.java Thu Feb 05 15:44:57 2015 -0800 @@ -1,29 +1,6 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8004101 + * @test /nodynamiccopyright/ + * @bug 8004101 8072445 * @summary Add checks for method reference well-formedness * @compile/fail/ref=MethodReference55.out -XDrawDiagnostics MethodReference55.java */ diff -r 772d7d253a11 -r 1ba2a6b0fd9f langtools/test/tools/javac/lambda/MethodReference55.out --- a/langtools/test/tools/javac/lambda/MethodReference55.out Thu Feb 05 11:43:37 2015 -0800 +++ b/langtools/test/tools/javac/lambda/MethodReference55.out Thu Feb 05 15:44:57 2015 -0800 @@ -1,3 +1,3 @@ -MethodReference55.java:36:11: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.bad.static.method.in.bound.lookup: kindname.method, m(java.lang.Object))) -MethodReference55.java:39:9: compiler.err.cant.apply.symbol: kindname.method, g, MethodReference55.V, @1384, kindname.class, MethodReference55, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.bad.static.method.in.bound.lookup: kindname.method, m(java.lang.Object)))) +MethodReference55.java:13:11: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.bad.static.method.in.bound.lookup: kindname.method, m(java.lang.Object))) +MethodReference55.java:16:9: compiler.err.cant.apply.symbol: kindname.method, g, MethodReference55.V, @361, kindname.class, MethodReference55, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.bad.static.method.in.bound.lookup: kindname.method, m(java.lang.Object)))) 2 errors diff -r 772d7d253a11 -r 1ba2a6b0fd9f langtools/test/tools/sjavac/ParallelCompilations.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/sjavac/ParallelCompilations.java Thu Feb 05 15:44:57 2015 -0800 @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2015, 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 + * @summary Test to check that -j option works with more than one value + * @bug 8071629 + * @author sogoel + * @library /tools/lib + * @build Wrapper ToolBox + * @run main Wrapper ParallelCompilations + */ + +import java.io.*; +import java.nio.file.*; +import com.sun.tools.sjavac.Main; + +class ParallelCompilations extends SJavacTester { + public static void main(String[] args) throws Exception { + new ParallelCompilations().run(); + } + + public void run() throws Exception { + ToolBox tb = new ToolBox(); + final String SERVER_ARG = "--server:" + + "portfile=testportfile," + + "background=false"; + + // Generate 10 files + for (int i = 0; i < 10; i++) { + String fileName = "Test" + i; + String content = "package foo"+ i + ";\n" + + "public class "+ fileName + "{\n" + + " public static void main(String[] args) {}\n" + + "\n}"; + Path srcDir = Paths.get("src"); + tb.writeJavaFiles(srcDir,content); + } + //Method will throw an exception if compilation fails + compile("src", "-d", "classes", "-j", "10", SERVER_ARG, "--log=debug"); + } +}