langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
changeset 24068 d8a1180faaa9
parent 23975 c7c81595aea9
child 24298 cc4f0f71a505
equal deleted inserted replaced
24067:76e7b6bbbd85 24068:d8a1180faaa9
   473             // FIXME: (footprint) do not use toString here
   473             // FIXME: (footprint) do not use toString here
   474             poolObj[i] = readName(getChar(index + 1)).toString();
   474             poolObj[i] = readName(getChar(index + 1)).toString();
   475             break;
   475             break;
   476         case CONSTANT_Fieldref: {
   476         case CONSTANT_Fieldref: {
   477             ClassSymbol owner = readClassSymbol(getChar(index + 1));
   477             ClassSymbol owner = readClassSymbol(getChar(index + 1));
   478             NameAndType nt = (NameAndType)readPool(getChar(index + 3));
   478             NameAndType nt = readNameAndType(getChar(index + 3));
   479             poolObj[i] = new VarSymbol(0, nt.name, nt.uniqueType.type, owner);
   479             poolObj[i] = new VarSymbol(0, nt.name, nt.uniqueType.type, owner);
   480             break;
   480             break;
   481         }
   481         }
   482         case CONSTANT_Methodref:
   482         case CONSTANT_Methodref:
   483         case CONSTANT_InterfaceMethodref: {
   483         case CONSTANT_InterfaceMethodref: {
   484             ClassSymbol owner = readClassSymbol(getChar(index + 1));
   484             ClassSymbol owner = readClassSymbol(getChar(index + 1));
   485             NameAndType nt = (NameAndType)readPool(getChar(index + 3));
   485             NameAndType nt = readNameAndType(getChar(index + 3));
   486             poolObj[i] = new MethodSymbol(0, nt.name, nt.uniqueType.type, owner);
   486             poolObj[i] = new MethodSymbol(0, nt.name, nt.uniqueType.type, owner);
   487             break;
   487             break;
   488         }
   488         }
   489         case CONSTANT_NameandType:
   489         case CONSTANT_NameandType:
   490             poolObj[i] = new NameAndType(
   490             poolObj[i] = new NameAndType(
   549     }
   549     }
   550 
   550 
   551     /** Read class entry.
   551     /** Read class entry.
   552      */
   552      */
   553     ClassSymbol readClassSymbol(int i) {
   553     ClassSymbol readClassSymbol(int i) {
   554         return (ClassSymbol) (readPool(i));
   554         Object obj = readPool(i);
       
   555         if (obj != null && !(obj instanceof ClassSymbol))
       
   556             throw badClassFile("bad.const.pool.entry",
       
   557                                currentClassFile.toString(),
       
   558                                "CONSTANT_Class_info", i);
       
   559         return (ClassSymbol)obj;
   555     }
   560     }
   556 
   561 
   557     /** Read name.
   562     /** Read name.
   558      */
   563      */
   559     Name readName(int i) {
   564     Name readName(int i) {
   560         return (Name) (readPool(i));
   565         Object obj = readPool(i);
       
   566         if (obj != null && !(obj instanceof Name))
       
   567             throw badClassFile("bad.const.pool.entry",
       
   568                                currentClassFile.toString(),
       
   569                                "CONSTANT_Utf8_info or CONSTANT_String_info", i);
       
   570         return (Name)obj;
       
   571     }
       
   572 
       
   573     /** Read name and type.
       
   574      */
       
   575     NameAndType readNameAndType(int i) {
       
   576         Object obj = readPool(i);
       
   577         if (obj != null && !(obj instanceof NameAndType))
       
   578             throw badClassFile("bad.const.pool.entry",
       
   579                                currentClassFile.toString(),
       
   580                                "CONSTANT_NameAndType_info", i);
       
   581         return (NameAndType)obj;
   561     }
   582     }
   562 
   583 
   563 /************************************************************************
   584 /************************************************************************
   564  * Reading Types
   585  * Reading Types
   565  ***********************************************************************/
   586  ***********************************************************************/
  1207         // remove sym from it's current owners scope and place it in
  1228         // remove sym from it's current owners scope and place it in
  1208         // the scope specified by the attribute
  1229         // the scope specified by the attribute
  1209         sym.owner.members().remove(sym);
  1230         sym.owner.members().remove(sym);
  1210         ClassSymbol self = (ClassSymbol)sym;
  1231         ClassSymbol self = (ClassSymbol)sym;
  1211         ClassSymbol c = readClassSymbol(nextChar());
  1232         ClassSymbol c = readClassSymbol(nextChar());
  1212         NameAndType nt = (NameAndType)readPool(nextChar());
  1233         NameAndType nt = readNameAndType(nextChar());
  1213 
  1234 
  1214         if (c.members_field == null)
  1235         if (c.members_field == null)
  1215             throw badClassFile("bad.enclosing.class", self, c);
  1236             throw badClassFile("bad.enclosing.class", self, c);
  1216 
  1237 
  1217         MethodSymbol m = findMethod(nt, c.members_field, self.flags());
  1238         MethodSymbol m = findMethod(nt, c.members_field, self.flags());