提交 81924db8 编写于 作者: L lana

Merge

# #
# 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. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
...@@ -1589,9 +1589,16 @@ public class Types { ...@@ -1589,9 +1589,16 @@ public class Types {
* type parameters in t are deleted. * type parameters in t are deleted.
*/ */
public Type erasure(Type t) { public Type erasure(Type t) {
return erasure(t, false); return eraseNotNeeded(t)? t : erasure(t, false);
} }
//where //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) { private Type erasure(Type t, boolean recurse) {
if (t.tag <= lastBaseTag) if (t.tag <= lastBaseTag)
return t; /* fast special case */ return t; /* fast special case */
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
...@@ -3499,7 +3499,6 @@ public class Lower extends TreeTranslator { ...@@ -3499,7 +3499,6 @@ public class Lower extends TreeTranslator {
JCExpression expression = oneCase.getExpression(); JCExpression expression = oneCase.getExpression();
if (expression != null) { // expression for a "default" case is null if (expression != null) { // expression for a "default" case is null
expression = TreeInfo.skipParens(expression);
String labelExpr = (String) expression.type.constValue(); String labelExpr = (String) expression.type.constValue();
Integer mapping = caseLabelToPosition.put(labelExpr, casePosition); Integer mapping = caseLabelToPosition.put(labelExpr, casePosition);
Assert.checkNull(mapping); Assert.checkNull(mapping);
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
...@@ -188,7 +188,7 @@ public class ClassReader implements Completer { ...@@ -188,7 +188,7 @@ public class ClassReader implements Completer {
/** The current input pointer. /** The current input pointer.
*/ */
int bp; protected int bp;
/** The objects of the constant pool. /** The objects of the constant pool.
*/ */
...@@ -890,13 +890,13 @@ public class ClassReader implements Completer { ...@@ -890,13 +890,13 @@ public class ClassReader implements Completer {
protected enum AttributeKind { CLASS, MEMBER }; protected enum AttributeKind { CLASS, MEMBER };
protected abstract class AttributeReader { 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.name = name;
this.version = version; this.version = version;
this.kinds = kinds; this.kinds = kinds;
} }
boolean accepts(AttributeKind kind) { protected boolean accepts(AttributeKind kind) {
if (kinds.contains(kind)) { if (kinds.contains(kind)) {
if (majorVersion > version.major || (majorVersion == version.major && minorVersion >= version.minor)) if (majorVersion > version.major || (majorVersion == version.major && minorVersion >= version.minor))
return true; return true;
...@@ -915,11 +915,11 @@ public class ClassReader implements Completer { ...@@ -915,11 +915,11 @@ public class ClassReader implements Completer {
return false; return false;
} }
abstract void read(Symbol sym, int attrLen); protected abstract void read(Symbol sym, int attrLen);
final Name name; protected final Name name;
final ClassFile.Version version; protected final ClassFile.Version version;
final Set<AttributeKind> kinds; protected final Set<AttributeKind> kinds;
} }
protected Set<AttributeKind> CLASS_ATTRIBUTE = protected Set<AttributeKind> CLASS_ATTRIBUTE =
...@@ -936,7 +936,7 @@ public class ClassReader implements Completer { ...@@ -936,7 +936,7 @@ public class ClassReader implements Completer {
// v45.3 attributes // v45.3 attributes
new AttributeReader(names.Code, V45_3, MEMBER_ATTRIBUTE) { new AttributeReader(names.Code, V45_3, MEMBER_ATTRIBUTE) {
void read(Symbol sym, int attrLen) { protected void read(Symbol sym, int attrLen) {
if (readAllOfClassFile || saveParameterNames) if (readAllOfClassFile || saveParameterNames)
((MethodSymbol)sym).code = readCode(sym); ((MethodSymbol)sym).code = readCode(sym);
else else
...@@ -945,7 +945,7 @@ public class ClassReader implements Completer { ...@@ -945,7 +945,7 @@ public class ClassReader implements Completer {
}, },
new AttributeReader(names.ConstantValue, V45_3, MEMBER_ATTRIBUTE) { 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()); Object v = readPool(nextChar());
// Ignore ConstantValue attribute if field not final. // Ignore ConstantValue attribute if field not final.
if ((sym.flags() & FINAL) != 0) if ((sym.flags() & FINAL) != 0)
...@@ -954,13 +954,13 @@ public class ClassReader implements Completer { ...@@ -954,13 +954,13 @@ public class ClassReader implements Completer {
}, },
new AttributeReader(names.Deprecated, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) { 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; sym.flags_field |= DEPRECATED;
} }
}, },
new AttributeReader(names.Exceptions, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) { 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(); int nexceptions = nextChar();
List<Type> thrown = List.nil(); List<Type> thrown = List.nil();
for (int j = 0; j < nexceptions; j++) for (int j = 0; j < nexceptions; j++)
...@@ -971,14 +971,14 @@ public class ClassReader implements Completer { ...@@ -971,14 +971,14 @@ public class ClassReader implements Completer {
}, },
new AttributeReader(names.InnerClasses, V45_3, CLASS_ATTRIBUTE) { 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; ClassSymbol c = (ClassSymbol) sym;
readInnerClasses(c); readInnerClasses(c);
} }
}, },
new AttributeReader(names.LocalVariableTable, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) { 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; int newbp = bp + attrLen;
if (saveParameterNames) { if (saveParameterNames) {
// Pick up parameter names from the variable table. // Pick up parameter names from the variable table.
...@@ -1014,7 +1014,7 @@ public class ClassReader implements Completer { ...@@ -1014,7 +1014,7 @@ public class ClassReader implements Completer {
}, },
new AttributeReader(names.SourceFile, V45_3, CLASS_ATTRIBUTE) { 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; ClassSymbol c = (ClassSymbol) sym;
Name n = readName(nextChar()); Name n = readName(nextChar());
c.sourcefile = new SourceFileObject(n, c.flatname); c.sourcefile = new SourceFileObject(n, c.flatname);
...@@ -1022,7 +1022,7 @@ public class ClassReader implements Completer { ...@@ -1022,7 +1022,7 @@ public class ClassReader implements Completer {
}, },
new AttributeReader(names.Synthetic, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) { 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 // bridge methods are visible when generics not enabled
if (allowGenerics || (sym.flags_field & BRIDGE) == 0) if (allowGenerics || (sym.flags_field & BRIDGE) == 0)
sym.flags_field |= SYNTHETIC; sym.flags_field |= SYNTHETIC;
...@@ -1032,7 +1032,7 @@ public class ClassReader implements Completer { ...@@ -1032,7 +1032,7 @@ public class ClassReader implements Completer {
// standard v49 attributes // standard v49 attributes
new AttributeReader(names.EnclosingMethod, V49, CLASS_ATTRIBUTE) { new AttributeReader(names.EnclosingMethod, V49, CLASS_ATTRIBUTE) {
void read(Symbol sym, int attrLen) { protected void read(Symbol sym, int attrLen) {
int newbp = bp + attrLen; int newbp = bp + attrLen;
readEnclosingMethodAttr(sym); readEnclosingMethodAttr(sym);
bp = newbp; bp = newbp;
...@@ -1041,11 +1041,11 @@ public class ClassReader implements Completer { ...@@ -1041,11 +1041,11 @@ public class ClassReader implements Completer {
new AttributeReader(names.Signature, V49, CLASS_OR_MEMBER_ATTRIBUTE) { new AttributeReader(names.Signature, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
@Override @Override
boolean accepts(AttributeKind kind) { protected boolean accepts(AttributeKind kind) {
return super.accepts(kind) && allowGenerics; return super.accepts(kind) && allowGenerics;
} }
void read(Symbol sym, int attrLen) { protected void read(Symbol sym, int attrLen) {
if (sym.kind == TYP) { if (sym.kind == TYP) {
ClassSymbol c = (ClassSymbol) sym; ClassSymbol c = (ClassSymbol) sym;
readingClassAttr = true; readingClassAttr = true;
...@@ -1074,31 +1074,31 @@ public class ClassReader implements Completer { ...@@ -1074,31 +1074,31 @@ public class ClassReader implements Completer {
// v49 annotation attributes // v49 annotation attributes
new AttributeReader(names.AnnotationDefault, V49, CLASS_OR_MEMBER_ATTRIBUTE) { new AttributeReader(names.AnnotationDefault, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
void read(Symbol sym, int attrLen) { protected void read(Symbol sym, int attrLen) {
attachAnnotationDefault(sym); attachAnnotationDefault(sym);
} }
}, },
new AttributeReader(names.RuntimeInvisibleAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) { new AttributeReader(names.RuntimeInvisibleAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
void read(Symbol sym, int attrLen) { protected void read(Symbol sym, int attrLen) {
attachAnnotations(sym); attachAnnotations(sym);
} }
}, },
new AttributeReader(names.RuntimeInvisibleParameterAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) { new AttributeReader(names.RuntimeInvisibleParameterAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
void read(Symbol sym, int attrLen) { protected void read(Symbol sym, int attrLen) {
attachParameterAnnotations(sym); attachParameterAnnotations(sym);
} }
}, },
new AttributeReader(names.RuntimeVisibleAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) { new AttributeReader(names.RuntimeVisibleAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
void read(Symbol sym, int attrLen) { protected void read(Symbol sym, int attrLen) {
attachAnnotations(sym); attachAnnotations(sym);
} }
}, },
new AttributeReader(names.RuntimeVisibleParameterAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) { new AttributeReader(names.RuntimeVisibleParameterAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
void read(Symbol sym, int attrLen) { protected void read(Symbol sym, int attrLen) {
attachParameterAnnotations(sym); attachParameterAnnotations(sym);
} }
}, },
...@@ -1106,14 +1106,14 @@ public class ClassReader implements Completer { ...@@ -1106,14 +1106,14 @@ public class ClassReader implements Completer {
// additional "legacy" v49 attributes, superceded by flags // additional "legacy" v49 attributes, superceded by flags
new AttributeReader(names.Annotation, V49, CLASS_OR_MEMBER_ATTRIBUTE) { new AttributeReader(names.Annotation, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
void read(Symbol sym, int attrLen) { protected void read(Symbol sym, int attrLen) {
if (allowAnnotations) if (allowAnnotations)
sym.flags_field |= ANNOTATION; sym.flags_field |= ANNOTATION;
} }
}, },
new AttributeReader(names.Bridge, V49, MEMBER_ATTRIBUTE) { new AttributeReader(names.Bridge, V49, MEMBER_ATTRIBUTE) {
void read(Symbol sym, int attrLen) { protected void read(Symbol sym, int attrLen) {
sym.flags_field |= BRIDGE; sym.flags_field |= BRIDGE;
if (!allowGenerics) if (!allowGenerics)
sym.flags_field &= ~SYNTHETIC; sym.flags_field &= ~SYNTHETIC;
...@@ -1121,13 +1121,13 @@ public class ClassReader implements Completer { ...@@ -1121,13 +1121,13 @@ public class ClassReader implements Completer {
}, },
new AttributeReader(names.Enum, V49, CLASS_OR_MEMBER_ATTRIBUTE) { 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; sym.flags_field |= ENUM;
} }
}, },
new AttributeReader(names.Varargs, V49, CLASS_OR_MEMBER_ATTRIBUTE) { new AttributeReader(names.Varargs, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
void read(Symbol sym, int attrLen) { protected void read(Symbol sym, int attrLen) {
if (allowVarargs) if (allowVarargs)
sym.flags_field |= VARARGS; sym.flags_field |= VARARGS;
} }
...@@ -1153,7 +1153,7 @@ public class ClassReader implements Completer { ...@@ -1153,7 +1153,7 @@ public class ClassReader implements Completer {
void readEnclosingMethodAttr(Symbol sym) { protected void readEnclosingMethodAttr(Symbol sym) {
// sym is a nested class with an "Enclosing Method" attribute // sym is a nested class with an "Enclosing Method" attribute
// remove sym from it's current owners scope and place it in // remove sym from it's current owners scope and place it in
// the scope specified by the attribute // the scope specified by the attribute
......
...@@ -164,7 +164,7 @@ public class ClassWriter extends ClassFile { ...@@ -164,7 +164,7 @@ public class ClassWriter extends ClassFile {
/** Construct a class writer, given an options table. /** Construct a class writer, given an options table.
*/ */
private ClassWriter(Context context) { protected ClassWriter(Context context) {
context.put(classWriterKey, this); context.put(classWriterKey, this);
log = Log.instance(context); log = Log.instance(context);
...@@ -601,12 +601,20 @@ public class ClassWriter extends ClassFile { ...@@ -601,12 +601,20 @@ public class ClassWriter extends ClassFile {
* Returns the number of attributes written (0 or 1). * Returns the number of attributes written (0 or 1).
*/ */
int writeEnclosingMethodAttribute(ClassSymbol c) { int writeEnclosingMethodAttribute(ClassSymbol c) {
if (!target.hasEnclosingMethodAttribute() || if (!target.hasEnclosingMethodAttribute())
c.owner.kind != MTH && // neither a local class 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 c.name != names.empty) // nor anonymous
return 0; return 0;
int alenIdx = writeAttr(names.EnclosingMethod); int alenIdx = writeAttr(attributeName);
ClassSymbol enclClass = c.owner.enclClass(); ClassSymbol enclClass = c.owner.enclClass();
MethodSymbol enclMethod = MethodSymbol enclMethod =
(c.owner.type == null // local to init block (c.owner.type == null // local to init block
...@@ -1569,6 +1577,7 @@ public class ClassWriter extends ClassFile { ...@@ -1569,6 +1577,7 @@ public class ClassWriter extends ClassFile {
acount += writeFlagAttrs(c.flags()); acount += writeFlagAttrs(c.flags());
acount += writeJavaAnnotations(c.getAnnotationMirrors()); acount += writeJavaAnnotations(c.getAnnotationMirrors());
acount += writeEnclosingMethodAttribute(c); acount += writeEnclosingMethodAttribute(c);
acount += writeExtraClassAttributes(c);
poolbuf.appendInt(JAVA_MAGIC); poolbuf.appendInt(JAVA_MAGIC);
poolbuf.appendChar(target.minorVersion); poolbuf.appendChar(target.minorVersion);
...@@ -1588,6 +1597,14 @@ public class ClassWriter extends ClassFile { ...@@ -1588,6 +1597,14 @@ public class ClassWriter extends ClassFile {
pool = c.pool = null; // to conserve space 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 adjustFlags(final long flags) {
int result = (int)flags; int result = (int)flags;
if ((flags & SYNTHETIC) != 0 && !target.useSyntheticFlag()) if ((flags & SYNTHETIC) != 0 && !target.useSyntheticFlag())
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
# #
# 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. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
......
/*
* 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;
}
}
}
/*
* 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;
}
}
}
/*
* 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;
}
}
}
/*
* 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;
}
}
}
/*
* 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;
}
}
}
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
# #
# 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. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -47,6 +47,7 @@ public class T6348499 { ...@@ -47,6 +47,7 @@ public class T6348499 {
public static void main(String... args) { public static void main(String... args) {
String testSrc = System.getProperty("test.src", "."); String testSrc = System.getProperty("test.src", ".");
String testClasses = System.getProperty("test.classes"); String testClasses = System.getProperty("test.classes");
String testClassPath = System.getProperty("test.class.path", testClasses);
String A_java = new File(testSrc, "A.java").getPath(); String A_java = new File(testSrc, "A.java").getPath();
JavacTool tool = JavacTool.create(); JavacTool tool = JavacTool.create();
MyDiagListener dl = new MyDiagListener(); MyDiagListener dl = new MyDiagListener();
...@@ -55,7 +56,7 @@ public class T6348499 { ...@@ -55,7 +56,7 @@ public class T6348499 {
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "A.java"))); fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "A.java")));
Iterable<String> opts = Arrays.asList("-proc:only", Iterable<String> opts = Arrays.asList("-proc:only",
"-processor", "A", "-processor", "A",
"-processorpath", testClasses); "-processorpath", testClassPath);
StringWriter out = new StringWriter(); StringWriter out = new StringWriter();
JavacTask task = tool.getTask(out, fm, dl, opts, null, files); JavacTask task = tool.getTask(out, fm, dl, opts, null, files);
task.call(); task.call();
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -43,20 +43,20 @@ public class T6414633 { ...@@ -43,20 +43,20 @@ public class T6414633 {
public static void main(String... args) { public static void main(String... args) {
String testSrc = System.getProperty("test.src", "."); String testSrc = System.getProperty("test.src", ".");
String testClasses = System.getProperty("test.classes", "."); String testClasses = System.getProperty("test.classes", ".");
String testClassPath = System.getProperty("test.class.path", testClasses);
JavacTool tool = JavacTool.create(); JavacTool tool = JavacTool.create();
MyDiagListener dl = new MyDiagListener(); MyDiagListener dl = new MyDiagListener();
StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null); StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
try { try {
fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(new File(testClasses))); fm.setLocation(StandardLocation.CLASS_PATH, pathToFiles(testClassPath));
} catch (IOException e) { } catch (IOException e) {
throw new AssertionError(e); throw new AssertionError(e);
} }
Iterable<? extends JavaFileObject> files = Iterable<? extends JavaFileObject> files =
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, A.class.getName()+".java"))); fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, A.class.getName()+".java")));
String[] opts = { "-proc:only", String[] opts = { "-proc:only",
"-processor", A.class.getName(), "-processor", A.class.getName() };
"-classpath", testClasses + System.getProperty("path.separator") + "../../lib" };
JavacTask task = tool.getTask(null, fm, dl, Arrays.asList(opts), null, files); JavacTask task = tool.getTask(null, fm, dl, Arrays.asList(opts), null, files);
task.call(); task.call();
...@@ -65,6 +65,15 @@ public class T6414633 { ...@@ -65,6 +65,15 @@ public class T6414633 {
throw new AssertionError(dl.diags + " diagnostics reported"); 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> private static class MyDiagListener implements DiagnosticListener<JavaFileObject>
{ {
public void report(Diagnostic d) { public void report(Diagnostic d) {
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -156,7 +156,9 @@ public class T6920317 { ...@@ -156,7 +156,9 @@ public class T6920317 {
String expect = null; String expect = null;
opts.add("-processorpath"); 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");
opts.add(Processor.class.getName()); opts.add(Processor.class.getName());
opts.add("-proc:only"); opts.add("-proc:only");
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -38,7 +38,8 @@ import java.util.*; ...@@ -38,7 +38,8 @@ import java.util.*;
public class TestWithXstdout { public class TestWithXstdout {
public static void main(String... args) throws Exception { public static void main(String... args) throws Exception {
File testSrc = new File(System.getProperty("test.src")); 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"); File stdout = new File("stdout.out");
run_javac("-XDrawDiagnostics", run_javac("-XDrawDiagnostics",
"-XprintProcessorInfo", "-XprintProcessorInfo",
...@@ -46,7 +47,7 @@ public class TestWithXstdout { ...@@ -46,7 +47,7 @@ public class TestWithXstdout {
"-proc:only", "-proc:only",
"-processor", "Test", "-processor", "Test",
"-Xstdout", stdout.getPath(), "-Xstdout", stdout.getPath(),
"-classpath", testClasses.getPath(), "-classpath", testClassPath,
new File(testSrc, "Test.java").getPath()); new File(testSrc, "Test.java").getPath());
boolean ok = compare(stdout, new File(testSrc, "Test.out")); boolean ok = compare(stdout, new File(testSrc, "Test.out"));
if (!ok) if (!ok)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册