/** * The constructor. * * @param id the id of this collection. */ public ClassTranslator(int id, ClassFile cf) throws InvalidByteCodeException { this.id = id; this.cf = cf; // Name name = StubManager.removeStub(cf.getThisClassName()); // Fields FieldInfo[] fi = cf.getFields(); for (int i = 0; i < fi.length; i++) { // Creates field translator Translator.log("\tfield: %s%n", fi[i].getName()); FieldTranslator field = new FieldTranslator(fi[i]); if (field.isStatic()) { staticFields.put(field.getName(), field); } else { instanceFields.put(field.getName(), field); } } // Super class superClass = StubManager.removeStub(cf.getSuperClassName()); // Interfaces interfaces = getInterfaces(cf); }
/** * Returns the interface names that this class implements. * * @param cf the class file. * @return the array of interface names. * @throws InvalidByteCodeException */ private String[] getInterfaces(ClassFile cf) throws InvalidByteCodeException { int[] indices = cf.getInterfaces(); if (indices == null) return null; String[] interfaces = new String[indices.length]; for (int i = 0; i < indices.length; i++) { ConstantClassInfo info = (ConstantClassInfo) cf.getConstantPoolEntry(indices[i], ConstantClassInfo.class); interfaces[i] = StubManager.removeStub(info.getName()); } return interfaces; }