Mercurial > hg > icedtea8-forest > langtools
changeset 1347:e48e7e1f026b jdk8-b55
Merge
author | lana |
---|---|
date | Thu, 30 Aug 2012 20:14:48 -0700 |
parents | c47742f53f99 (current diff) 542c87b8ce7f (diff) |
children | 0f8cf3d89a7c 3f36e22c8c39 |
files | |
diffstat | 49 files changed, 310 insertions(+), 81 deletions(-) [+] |
line wrap: on
line diff
--- a/make/jprt.properties Thu Aug 30 10:27:39 2012 -0700 +++ b/make/jprt.properties Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ # -# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2006, 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
--- a/make/tools/anttasks/CompilePropertiesTask.java Thu Aug 30 10:27:39 2012 -0700 +++ b/make/tools/anttasks/CompilePropertiesTask.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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
--- a/make/tools/anttasks/GenStubsTask.java Thu Aug 30 10:27:39 2012 -0700 +++ b/make/tools/anttasks/GenStubsTask.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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
--- a/make/tools/anttasks/SelectToolTask.java Thu Aug 30 10:27:39 2012 -0700 +++ b/make/tools/anttasks/SelectToolTask.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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
--- a/make/tools/compileproperties/CompileProperties.java Thu Aug 30 10:27:39 2012 -0700 +++ b/make/tools/compileproperties/CompileProperties.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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
--- a/make/tools/genstubs/GenStubs.java Thu Aug 30 10:27:39 2012 -0700 +++ b/make/tools/genstubs/GenStubs.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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
--- a/src/share/classes/com/sun/tools/javac/code/Source.java Thu Aug 30 10:27:39 2012 -0700 +++ b/src/share/classes/com/sun/tools/javac/code/Source.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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
--- a/src/share/classes/com/sun/tools/javac/code/Type.java Thu Aug 30 10:27:39 2012 -0700 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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
--- a/src/share/classes/com/sun/tools/javac/code/Types.java Thu Aug 30 10:27:39 2012 -0700 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Thu Aug 30 20:14:48 2012 -0700 @@ -1589,9 +1589,16 @@ * type parameters in t are deleted. */ public Type erasure(Type t) { - return erasure(t, false); + return eraseNotNeeded(t)? t : erasure(t, false); } //where + private boolean eraseNotNeeded(Type t) { + // We don't want to erase primitive types and String type as that + // operation is idempotent. Also, erasing these could result in loss + // of information such as constant values attached to such types. + return (t.tag <= lastBaseTag) || (syms.stringType.tsym == t.tsym); + } + private Type erasure(Type t, boolean recurse) { if (t.tag <= lastBaseTag) return t; /* fast special case */
--- a/src/share/classes/com/sun/tools/javac/comp/AttrContext.java Thu Aug 30 10:27:39 2012 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/AttrContext.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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
--- a/src/share/classes/com/sun/tools/javac/comp/Lower.java Thu Aug 30 10:27:39 2012 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java Thu Aug 30 20:14:48 2012 -0700 @@ -3499,7 +3499,6 @@ JCExpression expression = oneCase.getExpression(); if (expression != null) { // expression for a "default" case is null - expression = TreeInfo.skipParens(expression); String labelExpr = (String) expression.type.constValue(); Integer mapping = caseLabelToPosition.put(labelExpr, casePosition); Assert.checkNull(mapping);
--- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Thu Aug 30 10:27:39 2012 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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
--- a/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java Thu Aug 30 10:27:39 2012 -0700 +++ b/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Thu Aug 30 10:27:39 2012 -0700 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Thu Aug 30 20:14:48 2012 -0700 @@ -188,7 +188,7 @@ /** The current input pointer. */ - int bp; + protected int bp; /** The objects of the constant pool. */ @@ -890,13 +890,13 @@ protected enum AttributeKind { CLASS, MEMBER }; protected abstract class AttributeReader { - AttributeReader(Name name, ClassFile.Version version, Set<AttributeKind> kinds) { + protected AttributeReader(Name name, ClassFile.Version version, Set<AttributeKind> kinds) { this.name = name; this.version = version; this.kinds = kinds; } - boolean accepts(AttributeKind kind) { + protected boolean accepts(AttributeKind kind) { if (kinds.contains(kind)) { if (majorVersion > version.major || (majorVersion == version.major && minorVersion >= version.minor)) return true; @@ -915,11 +915,11 @@ return false; } - abstract void read(Symbol sym, int attrLen); + protected abstract void read(Symbol sym, int attrLen); - final Name name; - final ClassFile.Version version; - final Set<AttributeKind> kinds; + protected final Name name; + protected final ClassFile.Version version; + protected final Set<AttributeKind> kinds; } protected Set<AttributeKind> CLASS_ATTRIBUTE = @@ -936,7 +936,7 @@ // v45.3 attributes new AttributeReader(names.Code, V45_3, MEMBER_ATTRIBUTE) { - void read(Symbol sym, int attrLen) { + protected void read(Symbol sym, int attrLen) { if (readAllOfClassFile || saveParameterNames) ((MethodSymbol)sym).code = readCode(sym); else @@ -945,7 +945,7 @@ }, new AttributeReader(names.ConstantValue, V45_3, MEMBER_ATTRIBUTE) { - void read(Symbol sym, int attrLen) { + protected void read(Symbol sym, int attrLen) { Object v = readPool(nextChar()); // Ignore ConstantValue attribute if field not final. if ((sym.flags() & FINAL) != 0) @@ -954,13 +954,13 @@ }, new AttributeReader(names.Deprecated, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) { - void read(Symbol sym, int attrLen) { + protected void read(Symbol sym, int attrLen) { sym.flags_field |= DEPRECATED; } }, new AttributeReader(names.Exceptions, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) { - void read(Symbol sym, int attrLen) { + protected void read(Symbol sym, int attrLen) { int nexceptions = nextChar(); List<Type> thrown = List.nil(); for (int j = 0; j < nexceptions; j++) @@ -971,14 +971,14 @@ }, new AttributeReader(names.InnerClasses, V45_3, CLASS_ATTRIBUTE) { - void read(Symbol sym, int attrLen) { + protected void read(Symbol sym, int attrLen) { ClassSymbol c = (ClassSymbol) sym; readInnerClasses(c); } }, new AttributeReader(names.LocalVariableTable, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) { - void read(Symbol sym, int attrLen) { + protected void read(Symbol sym, int attrLen) { int newbp = bp + attrLen; if (saveParameterNames) { // Pick up parameter names from the variable table. @@ -1014,7 +1014,7 @@ }, new AttributeReader(names.SourceFile, V45_3, CLASS_ATTRIBUTE) { - void read(Symbol sym, int attrLen) { + protected void read(Symbol sym, int attrLen) { ClassSymbol c = (ClassSymbol) sym; Name n = readName(nextChar()); c.sourcefile = new SourceFileObject(n, c.flatname); @@ -1022,7 +1022,7 @@ }, new AttributeReader(names.Synthetic, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) { - void read(Symbol sym, int attrLen) { + protected void read(Symbol sym, int attrLen) { // bridge methods are visible when generics not enabled if (allowGenerics || (sym.flags_field & BRIDGE) == 0) sym.flags_field |= SYNTHETIC; @@ -1032,7 +1032,7 @@ // standard v49 attributes new AttributeReader(names.EnclosingMethod, V49, CLASS_ATTRIBUTE) { - void read(Symbol sym, int attrLen) { + protected void read(Symbol sym, int attrLen) { int newbp = bp + attrLen; readEnclosingMethodAttr(sym); bp = newbp; @@ -1041,11 +1041,11 @@ new AttributeReader(names.Signature, V49, CLASS_OR_MEMBER_ATTRIBUTE) { @Override - boolean accepts(AttributeKind kind) { + protected boolean accepts(AttributeKind kind) { return super.accepts(kind) && allowGenerics; } - void read(Symbol sym, int attrLen) { + protected void read(Symbol sym, int attrLen) { if (sym.kind == TYP) { ClassSymbol c = (ClassSymbol) sym; readingClassAttr = true; @@ -1074,31 +1074,31 @@ // v49 annotation attributes new AttributeReader(names.AnnotationDefault, V49, CLASS_OR_MEMBER_ATTRIBUTE) { - void read(Symbol sym, int attrLen) { + protected void read(Symbol sym, int attrLen) { attachAnnotationDefault(sym); } }, new AttributeReader(names.RuntimeInvisibleAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) { - void read(Symbol sym, int attrLen) { + protected void read(Symbol sym, int attrLen) { attachAnnotations(sym); } }, new AttributeReader(names.RuntimeInvisibleParameterAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) { - void read(Symbol sym, int attrLen) { + protected void read(Symbol sym, int attrLen) { attachParameterAnnotations(sym); } }, new AttributeReader(names.RuntimeVisibleAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) { - void read(Symbol sym, int attrLen) { + protected void read(Symbol sym, int attrLen) { attachAnnotations(sym); } }, new AttributeReader(names.RuntimeVisibleParameterAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) { - void read(Symbol sym, int attrLen) { + protected void read(Symbol sym, int attrLen) { attachParameterAnnotations(sym); } }, @@ -1106,14 +1106,14 @@ // additional "legacy" v49 attributes, superceded by flags new AttributeReader(names.Annotation, V49, CLASS_OR_MEMBER_ATTRIBUTE) { - void read(Symbol sym, int attrLen) { + protected void read(Symbol sym, int attrLen) { if (allowAnnotations) sym.flags_field |= ANNOTATION; } }, new AttributeReader(names.Bridge, V49, MEMBER_ATTRIBUTE) { - void read(Symbol sym, int attrLen) { + protected void read(Symbol sym, int attrLen) { sym.flags_field |= BRIDGE; if (!allowGenerics) sym.flags_field &= ~SYNTHETIC; @@ -1121,13 +1121,13 @@ }, new AttributeReader(names.Enum, V49, CLASS_OR_MEMBER_ATTRIBUTE) { - void read(Symbol sym, int attrLen) { + protected void read(Symbol sym, int attrLen) { sym.flags_field |= ENUM; } }, new AttributeReader(names.Varargs, V49, CLASS_OR_MEMBER_ATTRIBUTE) { - void read(Symbol sym, int attrLen) { + protected void read(Symbol sym, int attrLen) { if (allowVarargs) sym.flags_field |= VARARGS; } @@ -1153,7 +1153,7 @@ - void readEnclosingMethodAttr(Symbol sym) { + protected void readEnclosingMethodAttr(Symbol sym) { // sym is a nested class with an "Enclosing Method" attribute // remove sym from it's current owners scope and place it in // the scope specified by the attribute
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Thu Aug 30 10:27:39 2012 -0700 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Thu Aug 30 20:14:48 2012 -0700 @@ -164,7 +164,7 @@ /** Construct a class writer, given an options table. */ - private ClassWriter(Context context) { + protected ClassWriter(Context context) { context.put(classWriterKey, this); log = Log.instance(context); @@ -601,12 +601,20 @@ * Returns the number of attributes written (0 or 1). */ int writeEnclosingMethodAttribute(ClassSymbol c) { - if (!target.hasEnclosingMethodAttribute() || - c.owner.kind != MTH && // neither a local class + if (!target.hasEnclosingMethodAttribute()) + return 0; + return writeEnclosingMethodAttribute(names.EnclosingMethod, c); + } + + /** Write the EnclosingMethod attribute with a specified name. + * Returns the number of attributes written (0 or 1). + */ + protected int writeEnclosingMethodAttribute(Name attributeName, ClassSymbol c) { + if (c.owner.kind != MTH && // neither a local class c.name != names.empty) // nor anonymous return 0; - int alenIdx = writeAttr(names.EnclosingMethod); + int alenIdx = writeAttr(attributeName); ClassSymbol enclClass = c.owner.enclClass(); MethodSymbol enclMethod = (c.owner.type == null // local to init block @@ -1569,6 +1577,7 @@ acount += writeFlagAttrs(c.flags()); acount += writeJavaAnnotations(c.getAnnotationMirrors()); acount += writeEnclosingMethodAttribute(c); + acount += writeExtraClassAttributes(c); poolbuf.appendInt(JAVA_MAGIC); poolbuf.appendChar(target.minorVersion); @@ -1588,6 +1597,14 @@ pool = c.pool = null; // to conserve space } + /**Allows subclasses to write additional class attributes + * + * @return the number of attributes written + */ + protected int writeExtraClassAttributes(ClassSymbol c) { + return 0; + } + int adjustFlags(final long flags) { int result = (int)flags; if ((flags & SYNTHETIC) != 0 && !target.useSyntheticFlag())
--- a/src/share/classes/com/sun/tools/javac/main/Main.java Thu Aug 30 10:27:39 2012 -0700 +++ b/src/share/classes/com/sun/tools/javac/main/Main.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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
--- a/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java Thu Aug 30 10:27:39 2012 -0700 +++ b/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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
--- a/test/tools/javac/ProtectedInnerClass/ProtectedInnerClass.sh Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/ProtectedInnerClass/ProtectedInnerClass.sh Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ # -# Copyright (c) 1998, 2009, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1998, 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/StringsInSwitch/7181320/BinOpInCaseLabel.java Thu Aug 30 20:14:48 2012 -0700 @@ -0,0 +1,38 @@ +/* + * 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 7181320 + * @summary javac NullPointerException for switch labels with cast to String expressions + * @compile BinOpInCaseLabel.java + */ + +public class BinOpInCaseLabel { + public static void main(String [] args) { + switch (args[0]) { + case "hello" + "world": + break; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/StringsInSwitch/7181320/CastInCaseLabel.java Thu Aug 30 20:14:48 2012 -0700 @@ -0,0 +1,38 @@ +/* + * 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 7181320 + * @summary javac NullPointerException for switch labels with cast to String expressions + * @compile CastInCaseLabel.java + */ + +public class CastInCaseLabel { + public static void main(String [] args) { + switch (args[0]) { + case (String)"hello": + break; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/StringsInSwitch/7181320/CondExprInCaseLabel.java Thu Aug 30 20:14:48 2012 -0700 @@ -0,0 +1,39 @@ +/* + * 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 7181320 + * @summary javac NullPointerException for switch labels with cast to String expressions + * @compile CondExprInCaseLabel.java + */ + +public class CondExprInCaseLabel { + public static void main(String [] args) { + final boolean cond = true; + switch (args[0]) { + case cond ? "hello" : "world": + break; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/StringsInSwitch/7181320/CondExprInCaseLabel1.java Thu Aug 30 20:14:48 2012 -0700 @@ -0,0 +1,39 @@ +/* + * 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 7181320 + * @summary javac NullPointerException for switch labels with cast to String expressions + * @compile CondExprInCaseLabel1.java + */ + +public class CondExprInCaseLabel1 { + public static void main(String [] args) { + final boolean cond = true; + switch (args[0]) { + case cond ? (String)"hello" : "world": + break; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/StringsInSwitch/7181320/CondExprInCaseLabel2.java Thu Aug 30 20:14:48 2012 -0700 @@ -0,0 +1,39 @@ +/* + * 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 7181320 + * @summary javac NullPointerException for switch labels with cast to String expressions + * @compile CondExprInCaseLabel2.java + */ + +public class CondExprInCaseLabel2 { + public static void main(String [] args) { + final boolean cond = true; + switch (args[0]) { + case cond ? "hello" : (String)"world": + break; + } + } +}
--- a/test/tools/javac/api/7086261/T7086261.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/api/7086261/T7086261.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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
--- a/test/tools/javac/api/T6397104.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/api/T6397104.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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
--- a/test/tools/javac/diags/CheckExamples.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/diags/CheckExamples.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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
--- a/test/tools/javac/diags/MessageInfo.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/diags/MessageInfo.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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
--- a/test/tools/javac/diags/RunExamples.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/diags/RunExamples.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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
--- a/test/tools/javac/diags/examples/ApplicableMethodFound1.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/diags/examples/ApplicableMethodFound1.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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
--- a/test/tools/javac/diags/examples/IllegalDot.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/diags/examples/IllegalDot.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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
--- a/test/tools/javac/diags/examples/InconvertibleTypes.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/diags/examples/InconvertibleTypes.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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
--- a/test/tools/javac/diags/examples/KindnameConstructor.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/diags/examples/KindnameConstructor.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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
--- a/test/tools/javac/diags/examples/NotApplicableMethodFound.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/diags/examples/NotApplicableMethodFound.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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
--- a/test/tools/javac/diags/examples/PossibleLossPrecision.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/diags/examples/PossibleLossPrecision.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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
--- a/test/tools/javac/diags/examples/ResourceNotApplicableToType.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/diags/examples/ResourceNotApplicableToType.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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
--- a/test/tools/javac/diags/examples/VarargsArgumentMismatch.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/diags/examples/VarargsArgumentMismatch.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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
--- a/test/tools/javac/diags/examples/VerboseResolveMulti1.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/diags/examples/VerboseResolveMulti1.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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
--- a/test/tools/javac/diags/examples/WhereCaptured.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/diags/examples/WhereCaptured.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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
--- a/test/tools/javac/diags/examples/WhereCaptured1.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/diags/examples/WhereCaptured1.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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
--- a/test/tools/javac/diags/examples/WhereIntersection.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/diags/examples/WhereIntersection.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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
--- a/test/tools/javac/diags/examples/WhereTypeVar.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/diags/examples/WhereTypeVar.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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
--- a/test/tools/javac/generics/typevars/T7148242.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/generics/typevars/T7148242.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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
--- a/test/tools/javac/newlines/Newlines.sh Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/newlines/Newlines.sh Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ # -# Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2002, 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
--- a/test/tools/javac/parser/T4881269.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/parser/T4881269.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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
--- a/test/tools/javac/processing/6348499/T6348499.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/processing/6348499/T6348499.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -47,6 +47,7 @@ public static void main(String... args) { String testSrc = System.getProperty("test.src", "."); String testClasses = System.getProperty("test.classes"); + String testClassPath = System.getProperty("test.class.path", testClasses); String A_java = new File(testSrc, "A.java").getPath(); JavacTool tool = JavacTool.create(); MyDiagListener dl = new MyDiagListener(); @@ -55,7 +56,7 @@ fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "A.java"))); Iterable<String> opts = Arrays.asList("-proc:only", "-processor", "A", - "-processorpath", testClasses); + "-processorpath", testClassPath); StringWriter out = new StringWriter(); JavacTask task = tool.getTask(out, fm, dl, opts, null, files); task.call();
--- a/test/tools/javac/processing/6414633/T6414633.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/processing/6414633/T6414633.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -43,20 +43,20 @@ public static void main(String... args) { String testSrc = System.getProperty("test.src", "."); String testClasses = System.getProperty("test.classes", "."); + String testClassPath = System.getProperty("test.class.path", testClasses); JavacTool tool = JavacTool.create(); MyDiagListener dl = new MyDiagListener(); StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null); try { - fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(new File(testClasses))); + fm.setLocation(StandardLocation.CLASS_PATH, pathToFiles(testClassPath)); } catch (IOException e) { throw new AssertionError(e); } Iterable<? extends JavaFileObject> files = fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, A.class.getName()+".java"))); String[] opts = { "-proc:only", - "-processor", A.class.getName(), - "-classpath", testClasses + System.getProperty("path.separator") + "../../lib" }; + "-processor", A.class.getName() }; JavacTask task = tool.getTask(null, fm, dl, Arrays.asList(opts), null, files); task.call(); @@ -65,6 +65,15 @@ throw new AssertionError(dl.diags + " diagnostics reported"); } + private static List<File> pathToFiles(String path) { + List<File> list = new ArrayList<File>(); + for (String s: path.split(File.pathSeparator)) { + if (!s.isEmpty()) + list.add(new File(s)); + } + return list; + } + private static class MyDiagListener implements DiagnosticListener<JavaFileObject> { public void report(Diagnostic d) {
--- a/test/tools/javac/processing/T6920317.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/processing/T6920317.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -156,7 +156,9 @@ String expect = null; opts.add("-processorpath"); - opts.add(System.getProperty("test.classes")); + String testClasses = System.getProperty("test.classes"); + String testClassPath = System.getProperty("test.class.path", testClasses); + opts.add(testClassPath); opts.add("-processor"); opts.add(Processor.class.getName()); opts.add("-proc:only");
--- a/test/tools/javac/processing/TestWarnErrorCount.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/processing/TestWarnErrorCount.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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
--- a/test/tools/javac/processing/options/testPrintProcessorInfo/TestWithXstdout.java Thu Aug 30 10:27:39 2012 -0700 +++ b/test/tools/javac/processing/options/testPrintProcessorInfo/TestWithXstdout.java Thu Aug 30 20:14:48 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -38,7 +38,8 @@ public class TestWithXstdout { public static void main(String... args) throws Exception { File testSrc = new File(System.getProperty("test.src")); - File testClasses = new File(System.getProperty("test.classes")); + String testClasses = System.getProperty("test.classes", "."); + String testClassPath = System.getProperty("test.class.path", testClasses); File stdout = new File("stdout.out"); run_javac("-XDrawDiagnostics", "-XprintProcessorInfo", @@ -46,7 +47,7 @@ "-proc:only", "-processor", "Test", "-Xstdout", stdout.getPath(), - "-classpath", testClasses.getPath(), + "-classpath", testClassPath, new File(testSrc, "Test.java").getPath()); boolean ok = compare(stdout, new File(testSrc, "Test.out")); if (!ok)