protected final Field resolveField(int i) throws IOException, ClassNotFoundException, NoSuchFieldException { int oldPos = pos; try { Field f = (Field)cpool[i]; if (f == null) { pos = cpoolIndex[i]; Class owner = resolveClass(readShort()); NameAndType nt = resolveNameAndType(readShort()); cpool[i] = owner.getDeclaredField(nt.name); f = owner.getDeclaredField(nt.name); } return f; } finally { pos = oldPos; } }
protected final String resolveUtf8(int i) throws IOException { int oldPos = pos; try { String s = (String)cpool[i]; if (s == null) { pos = cpoolIndex[i]; int len = readShort(); skipFully(len); cpool[i] = new String(buf, pos - len, len, "utf-8"); s = new String(buf, pos - len, len, "utf-8"); } return s; } finally { pos = oldPos; } }
/** * read a code attribute * * @throws IOException */ public void readCode() throws IOException { readShort(); // max stack readShort(); // max locals skipFully(readInt()); // code skipFully(8 * readShort()); // exception table // read the code attributes (recursive). This is where // we will find the LocalVariableTable attribute. readAttributes(); }
@SuppressWarnings("fallthrough") protected final void readCpool() throws IOException { int count = readShort(); // cpool count cpoolIndex = new int[count]; cpool = new Object[count]; case CONSTANT_NAME_AND_TYPE: readShort(); // class index or (12) name index case CONSTANT_STRING: readShort(); // string index or class index break; int len = readShort(); skipFully(len); break;
protected final Class resolveClass(int i) throws IOException, ClassNotFoundException { int oldPos = pos; try { Class c = (Class)cpool[i]; if (c == null) { pos = cpoolIndex[i]; String name = resolveUtf8(readShort()); cpool[i] = Class.forName(classDescriptorToName(name)); c = Class.forName(classDescriptorToName(name)); } return c; } finally { pos = oldPos; } }
protected final NameAndType resolveNameAndType(int i) throws IOException { int oldPos = pos; try { NameAndType nt = (NameAndType)cpool[i]; if (nt == null) { pos = cpoolIndex[i]; String name = resolveUtf8(readShort()); String type = resolveUtf8(readShort()); cpool[i] = new NameAndType(name, type); nt = new NameAndType(name, type); } return nt; } finally { pos = oldPos; } }