510 // FIXME: (footprint) do not use toString here |
510 // FIXME: (footprint) do not use toString here |
511 poolObj[i] = readName(getChar(index + 1)).toString(); |
511 poolObj[i] = readName(getChar(index + 1)).toString(); |
512 break; |
512 break; |
513 case CONSTANT_Fieldref: { |
513 case CONSTANT_Fieldref: { |
514 ClassSymbol owner = readClassSymbol(getChar(index + 1)); |
514 ClassSymbol owner = readClassSymbol(getChar(index + 1)); |
515 NameAndType nt = (NameAndType)readPool(getChar(index + 3)); |
515 NameAndType nt = readNameAndType(getChar(index + 3)); |
516 poolObj[i] = new VarSymbol(0, nt.name, nt.uniqueType.type, owner); |
516 poolObj[i] = new VarSymbol(0, nt.name, nt.uniqueType.type, owner); |
517 break; |
517 break; |
518 } |
518 } |
519 case CONSTANT_Methodref: |
519 case CONSTANT_Methodref: |
520 case CONSTANT_InterfaceMethodref: { |
520 case CONSTANT_InterfaceMethodref: { |
521 ClassSymbol owner = readClassSymbol(getChar(index + 1)); |
521 ClassSymbol owner = readClassSymbol(getChar(index + 1)); |
522 NameAndType nt = (NameAndType)readPool(getChar(index + 3)); |
522 NameAndType nt = readNameAndType(getChar(index + 3)); |
523 poolObj[i] = new MethodSymbol(0, nt.name, nt.uniqueType.type, owner); |
523 poolObj[i] = new MethodSymbol(0, nt.name, nt.uniqueType.type, owner); |
524 break; |
524 break; |
525 } |
525 } |
526 case CONSTANT_NameandType: |
526 case CONSTANT_NameandType: |
527 poolObj[i] = new NameAndType( |
527 poolObj[i] = new NameAndType( |
586 } |
586 } |
587 |
587 |
588 /** Read class entry. |
588 /** Read class entry. |
589 */ |
589 */ |
590 ClassSymbol readClassSymbol(int i) { |
590 ClassSymbol readClassSymbol(int i) { |
591 return (ClassSymbol) (readPool(i)); |
591 Object obj = readPool(i); |
|
592 if (obj != null && !(obj instanceof ClassSymbol)) |
|
593 throw badClassFile("bad.const.pool.entry", |
|
594 currentClassFile.toString(), |
|
595 "CONSTANT_Class_info", i); |
|
596 return (ClassSymbol)obj; |
592 } |
597 } |
593 |
598 |
594 /** Read name. |
599 /** Read name. |
595 */ |
600 */ |
596 Name readName(int i) { |
601 Name readName(int i) { |
597 return (Name) (readPool(i)); |
602 Object obj = readPool(i); |
|
603 if (obj != null && !(obj instanceof Name)) |
|
604 throw badClassFile("bad.const.pool.entry", |
|
605 currentClassFile.toString(), |
|
606 "CONSTANT_Utf8_info or CONSTANT_String_info", i); |
|
607 return (Name)obj; |
|
608 } |
|
609 |
|
610 /** Read name and type. |
|
611 */ |
|
612 NameAndType readNameAndType(int i) { |
|
613 Object obj = readPool(i); |
|
614 if (obj != null && !(obj instanceof NameAndType)) |
|
615 throw badClassFile("bad.const.pool.entry", |
|
616 currentClassFile.toString(), |
|
617 "CONSTANT_NameAndType_info", i); |
|
618 return (NameAndType)obj; |
598 } |
619 } |
599 |
620 |
600 /************************************************************************ |
621 /************************************************************************ |
601 * Reading Types |
622 * Reading Types |
602 ***********************************************************************/ |
623 ***********************************************************************/ |
1243 // remove sym from it's current owners scope and place it in |
1264 // remove sym from it's current owners scope and place it in |
1244 // the scope specified by the attribute |
1265 // the scope specified by the attribute |
1245 sym.owner.members().remove(sym); |
1266 sym.owner.members().remove(sym); |
1246 ClassSymbol self = (ClassSymbol)sym; |
1267 ClassSymbol self = (ClassSymbol)sym; |
1247 ClassSymbol c = readClassSymbol(nextChar()); |
1268 ClassSymbol c = readClassSymbol(nextChar()); |
1248 NameAndType nt = (NameAndType)readPool(nextChar()); |
1269 NameAndType nt = readNameAndType(nextChar()); |
1249 |
1270 |
1250 if (c.members_field == null) |
1271 if (c.members_field == null) |
1251 throw badClassFile("bad.enclosing.class", self, c); |
1272 throw badClassFile("bad.enclosing.class", self, c); |
1252 |
1273 |
1253 MethodSymbol m = findMethod(nt, c.members_field, self.flags()); |
1274 MethodSymbol m = findMethod(nt, c.members_field, self.flags()); |