1.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Wed Apr 23 11:28:09 2014 +0200 1.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Wed Apr 30 23:26:43 2014 +0100 1.3 @@ -512,14 +512,14 @@ 1.4 break; 1.5 case CONSTANT_Fieldref: { 1.6 ClassSymbol owner = readClassSymbol(getChar(index + 1)); 1.7 - NameAndType nt = (NameAndType)readPool(getChar(index + 3)); 1.8 + NameAndType nt = readNameAndType(getChar(index + 3)); 1.9 poolObj[i] = new VarSymbol(0, nt.name, nt.uniqueType.type, owner); 1.10 break; 1.11 } 1.12 case CONSTANT_Methodref: 1.13 case CONSTANT_InterfaceMethodref: { 1.14 ClassSymbol owner = readClassSymbol(getChar(index + 1)); 1.15 - NameAndType nt = (NameAndType)readPool(getChar(index + 3)); 1.16 + NameAndType nt = readNameAndType(getChar(index + 3)); 1.17 poolObj[i] = new MethodSymbol(0, nt.name, nt.uniqueType.type, owner); 1.18 break; 1.19 } 1.20 @@ -588,13 +588,34 @@ 1.21 /** Read class entry. 1.22 */ 1.23 ClassSymbol readClassSymbol(int i) { 1.24 - return (ClassSymbol) (readPool(i)); 1.25 + Object obj = readPool(i); 1.26 + if (obj != null && !(obj instanceof ClassSymbol)) 1.27 + throw badClassFile("bad.const.pool.entry", 1.28 + currentClassFile.toString(), 1.29 + "CONSTANT_Class_info", i); 1.30 + return (ClassSymbol)obj; 1.31 } 1.32 1.33 /** Read name. 1.34 */ 1.35 Name readName(int i) { 1.36 - return (Name) (readPool(i)); 1.37 + Object obj = readPool(i); 1.38 + if (obj != null && !(obj instanceof Name)) 1.39 + throw badClassFile("bad.const.pool.entry", 1.40 + currentClassFile.toString(), 1.41 + "CONSTANT_Utf8_info or CONSTANT_String_info", i); 1.42 + return (Name)obj; 1.43 + } 1.44 + 1.45 + /** Read name and type. 1.46 + */ 1.47 + NameAndType readNameAndType(int i) { 1.48 + Object obj = readPool(i); 1.49 + if (obj != null && !(obj instanceof NameAndType)) 1.50 + throw badClassFile("bad.const.pool.entry", 1.51 + currentClassFile.toString(), 1.52 + "CONSTANT_NameAndType_info", i); 1.53 + return (NameAndType)obj; 1.54 } 1.55 1.56 /************************************************************************ 1.57 @@ -1245,7 +1266,7 @@ 1.58 sym.owner.members().remove(sym); 1.59 ClassSymbol self = (ClassSymbol)sym; 1.60 ClassSymbol c = readClassSymbol(nextChar()); 1.61 - NameAndType nt = (NameAndType)readPool(nextChar()); 1.62 + NameAndType nt = readNameAndType(nextChar()); 1.63 1.64 if (c.members_field == null) 1.65 throw badClassFile("bad.enclosing.class", self, c);