8007546: ClassCastException on JSR308 tests
8015993: jck-compiler tests are failed with java.lang.ClassCastException
Summary: Fix ClassCastExceptions arising from addition of AnnotatedType.
Reviewed-by: jjg, abuckley
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Thu Jun 20 08:45:43 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Thu Jun 20 19:01:20 2013 -0400
@@ -3206,7 +3206,7 @@
if (skind == TYP) {
Type elt = site;
while (elt.hasTag(ARRAY))
- elt = ((ArrayType)elt).elemtype;
+ elt = ((ArrayType)elt.unannotatedType()).elemtype;
if (elt.hasTag(TYPEVAR)) {
log.error(tree.pos(), "type.var.cant.be.deref");
result = types.createErrorType(tree.type);
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java Thu Jun 20 08:45:43 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java Thu Jun 20 19:01:20 2013 -0400
@@ -919,11 +919,15 @@
if (o instanceof Long) return syms.longType;
if (o instanceof Double) return syms.doubleType;
if (o instanceof ClassSymbol) return syms.classType;
- if (o instanceof Type.ArrayType) return syms.classType;
- if (o instanceof Type.MethodType) return syms.methodTypeType;
+ if (o instanceof Pool.MethodHandle) return syms.methodHandleType;
if (o instanceof UniqueType) return typeForPool(((UniqueType)o).type);
- if (o instanceof Pool.MethodHandle) return syms.methodHandleType;
- throw new AssertionError(o);
+ if (o instanceof Type) {
+ Type ty = ((Type)o).unannotatedType();
+
+ if (ty instanceof Type.ArrayType) return syms.classType;
+ if (ty instanceof Type.MethodType) return syms.methodTypeType;
+ }
+ throw new AssertionError("Invalid type of constant pool entry: " + o.getClass());
}
/** Emit an opcode with a one-byte operand field;