/** * Returns the names of all the interfaces that this class implements. */ public String[] getInterfaces() { int size = mInterfaces.size(); String[] names = new String[size]; for (int i=0; i<size; i++) { names[i] = mInterfaces.get(i).getType().getRootName(); } return names; }
ArrayType(String desc, TypeDesc component) { super(desc, component.getRootName()); mComponent = component; mFullName = component.getFullName().concat("[]"); }
/** * Used to construct a ClassFile when read from a stream. */ private ClassFile(ConstantPool cp, Modifiers modifiers, ConstantClassInfo thisClass, ConstantClassInfo superClass, ClassFile outerClass) { mCp = cp; mModifiers = modifiers; mThisClass = thisClass; mSuperClass = superClass; mClassName = thisClass.getType().getRootName(); if (superClass == null) { mSuperClassName = null; } else { mSuperClassName = superClass.getType().getRootName(); } mOuterClass = outerClass; }
private String getClassName(TypeDesc classDesc) throws IllegalArgumentException { if (classDesc.isPrimitive()) { throw new IllegalArgumentException("Primitive type not allowed"); } if (classDesc.isArray()) { throw new IllegalArgumentException("Array type not allowed"); } return classDesc.getRootName(); }
public ConstantClassInfo(ConstantPool cp, TypeDesc type) { super(TAG_CLASS); String desc; if (type.isArray()) { desc = type.getDescriptor(); } else { desc = type.getRootName().replace('.', '/'); } mType = type; mNameConstant = cp.addConstantUTF(desc); }
name = "TypeDesc.".concat(type.getRootName().toUpperCase()); mTypeDescNames.put(type, name); return name; buf.append("TypeDesc.forClass("); buf.append('"'); buf.append(type.getRootName()); buf.append('"');
private static ClassFile readOuterClass(ConstantClassInfo outer, ClassFileDataLoader loader, AttributeFactory attrFactory, Map<String, ClassFile> loadedClassFiles) throws IOException { String name = outer.getType().getRootName(); ClassFile outerClass = loadedClassFiles.get(name); if (outerClass != null) { return outerClass; } InputStream in = loader.getClassData(name); if (in == null) { return null; } if (!(in instanceof DataInput)) { in = new DataInputStream(in); } return readFrom((DataInput)in, loader, attrFactory, loadedClassFiles, null); }
/** * @param from must be a primitive type * @param to must be an object type */ private void box(TypeDesc from, TypeDesc to) { if (mTarget >= 0x00010005) { // Call the new valueOf method. invokeStatic(to.getRootName(), "valueOf", to, new TypeDesc[] {from}); return; } switch (from.getTypeCode()) { case TypeDesc.BOOLEAN_CODE: toBoolean(true); break; case TypeDesc.CHAR_CODE: case TypeDesc.FLOAT_CODE: case TypeDesc.BYTE_CODE: case TypeDesc.SHORT_CODE: case TypeDesc.INT_CODE: case TypeDesc.DOUBLE_CODE: case TypeDesc.LONG_CODE: invokeConstructor(to.getRootName(), new TypeDesc[]{from}); break; } }
invokeVirtual(from.getRootName(), methodName, to, null);
private static ClassFile readInnerClass(ConstantClassInfo inner, ClassFileDataLoader loader, AttributeFactory attrFactory, Map<String, ClassFile> loadedClassFiles, ClassFile outerClass) throws IOException { String name = inner.getType().getRootName(); // Prevent cycles in inner class structure. for (ClassFile outer = outerClass; outer != null; outer = outer.getOuterClass()) { if (name.equals(outer.getClassName())) { // Cycle prevented. return null; } } // Prevent classes from being loaded multiple times. ClassFile innerClass = loadedClassFiles.get(name); if (innerClass != null) { return innerClass; } InputStream in = loader.getClassData(name); if (in == null) { return null; } if (!(in instanceof DataInput)) { in = new DataInputStream(in); } return readFrom((DataInput)in, loader, attrFactory, loadedClassFiles, outerClass); }
private void print(TypeDesc type) { if (type == null || type == TypeDesc.VOID) { print("null"); return; } if (type.isPrimitive()) { print("TypeDesc.".concat(type.getFullName().toUpperCase())); return; } else if (type == TypeDesc.OBJECT) { print("TypeDesc.OBJECT"); return; } else if (type == TypeDesc.STRING) { print("TypeDesc.STRING"); return; } TypeDesc componentType = type.getComponentType(); if (componentType != null) { print(componentType); print(".toArrayType()"); } else { print("TypeDesc.forClass(\""); print(escape(type.getRootName())); print("\")"); } }
index = din.readUnsignedShort(); ConstantClassInfo info = (ConstantClassInfo)cp.getConstant(index); cf.addInterface(info.getType().getRootName());
private void toBoolean(boolean box) { if (box && mTarget >= 0x00010004) { // Call the new valueOf method. invokeStatic("java.lang.Boolean", "valueOf", TypeDesc.BOOLEAN.toObjectType(), new TypeDesc[] {TypeDesc.BOOLEAN}); return; } Label nonZero = createLabel(); Label done = createLabel(); ifZeroComparisonBranch(nonZero, "!="); if (box) { TypeDesc newType = TypeDesc.BOOLEAN.toObjectType(); loadStaticField(newType.getRootName(), "FALSE", newType); branch(done); nonZero.setLocation(); loadStaticField(newType.getRootName(), "TRUE", newType); } else { loadConstant(false); branch(done); nonZero.setLocation(); loadConstant(true); } done.setLocation(); }
/** * Returns the names of all the interfaces that this class implements. */ public String[] getInterfaces() { int size = mInterfaces.size(); String[] names = new String[size]; for (int i=0; i<size; i++) { names[i] = mInterfaces.get(i).getType().getRootName(); } return names; }
ArrayType(String desc, TypeDesc component) { super(desc, component.getRootName()); mComponent = component; mFullName = component.getFullName().concat("[]"); }
private String getClassName(TypeDesc classDesc) throws IllegalArgumentException { if (classDesc.isPrimitive()) { throw new IllegalArgumentException("Primitive type not allowed"); } if (classDesc.isArray()) { throw new IllegalArgumentException("Array type not allowed"); } return classDesc.getRootName(); }
public ConstantClassInfo(ConstantPool cp, TypeDesc type) { super(TAG_CLASS); String desc; if (type.isArray()) { desc = type.getDescriptor(); } else { desc = type.getRootName().replace('.', '/'); } mType = type; mNameConstant = cp.addConstantUTF(desc); }
private static ClassFile readOuterClass(ConstantClassInfo outer, ClassFileDataLoader loader, AttributeFactory attrFactory, Map<String, ClassFile> loadedClassFiles) throws IOException { String name = outer.getType().getRootName(); ClassFile outerClass = loadedClassFiles.get(name); if (outerClass != null) { return outerClass; } InputStream in = loader.getClassData(name); if (in == null) { return null; } if (!(in instanceof DataInput)) { in = new DataInputStream(in); } return readFrom((DataInput)in, loader, attrFactory, loadedClassFiles, null); }
public Class getPropertyType(ClassLoader loader) throws SupportException { TypeDesc type = TypeDesc.forDescriptor(getPropertyTypeDescriptor()); Class propClass = type.toClass(loader); if (propClass == null) { throw new SupportException ("Unable to find class \"" + type.getRootName() + "\" for property \"" + getPropertyName() + '"'); } return propClass; }
public Class getPropertyType(ClassLoader loader) throws SupportException { TypeDesc type = TypeDesc.forDescriptor(getPropertyTypeDescriptor()); Class propClass = type.toClass(loader); if (propClass == null) { throw new SupportException ("Unable to find class \"" + type.getRootName() + "\" for property \"" + getPropertyName() + '"'); } return propClass; }