This commit is contained in:
Lana Steuck 2015-02-05 15:44:57 -08:00
commit 3a5a821349
10 changed files with 154 additions and 37 deletions
langtools
make/tools/propertiesparser/gen
src/jdk.compiler/share/classes/com/sun/tools/javac
test/tools

@ -192,8 +192,8 @@ public class ClassGenerator {
*/
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;
}

@ -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 @@ public class Types {
* 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
*/

@ -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 class TransTypes extends TreeTranslator {
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 @@ public class TransTypes extends TreeTranslator {
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

@ -2145,7 +2145,8 @@ public class Gen extends JCTree.Visitor {
// 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));
}
}

@ -477,7 +477,7 @@ java.rmi.dgc.*: compact2
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.server.*: proprietary compact2
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

@ -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<Date> list = new ArrayList<>();
list.add(new Date());
List<Foo> cList = (List<Foo>) (List<?>) list;
Date date = (Date) cList.get(0);
CheckNoClassCastException.result += "ListFailDone";
}
}
class MapFail {
static interface Foo {
}
public static void main(String[] args) {
Map<String,Date> aMap = new HashMap<>();
aMap.put("test",new Date());
Map<String,Foo> m = (Map<String,Foo>) (Map<?,?>) aMap;
Date q = (Date) m.get("test");
CheckNoClassCastException.result += "MapFailDone";
}
}

@ -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 @@ public class DoubleCastTest {
m1((byte[])m());
m1((byte[])os[0]);
m1((byte[])this.x);
m1((byte[])((byte []) (o = null)));
}
}

@ -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
*/

@ -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<X>, (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<X>, (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

@ -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");
}
}