private static String generateDescriptor(TypeDesc ret, TypeDesc[] params) { int length = ret.getDescriptor().length() + 2; int paramsLength = params.length; for (int i=paramsLength; --i >=0; ) { length += params[i].getDescriptor().length(); } char[] buf = new char[length]; buf[0] = '('; int index = 1; String paramDesc; for (int i=0; i<paramsLength; i++) { paramDesc = params[i].getDescriptor(); int paramDescLength = paramDesc.length(); paramDesc.getChars(0, paramDescLength, buf, index); index += paramDescLength; } buf[index++] = ')'; paramDesc = ret.getDescriptor(); paramDesc.getChars(0, paramDesc.length(), buf, index); return new String(buf); }
/** * Returns an annotation descriptor that has no parameters. */ public static String makePlainDescriptor(Class<? extends Annotation> annotationType) { return "" + TAG_ANNOTATION + TypeDesc.forClass(annotationType).getDescriptor(); }
public Object visit(String name, int pos, Class value, Object param) { appendName(name, pos, TAG_CLASS); if (value == String.class) { mBuilder.append(TAG_STRING); } else if (value == Class.class) { mBuilder.append(TAG_CLASS); } else { mBuilder.append(TypeDesc.forClass(value).getDescriptor()); } return null; }
public Object visit(String name, int pos, Annotation value, Object param) { if (appendName(name, pos, TAG_ANNOTATION)) { mBuilder.append(TypeDesc.forClass(value.annotationType()).getDescriptor()); } super.visit(name, pos, value, param); mBuilder.append(';'); return null; }
public void setType(TypeDesc type) { setTypeConstant(mCp.addConstantUTF(type.getDescriptor())); }
public MemberValue makeMemberValue(TypeDesc value) { return new MemberValue(MEMBER_TAG_CLASS, mCp.addConstantUTF(value.getDescriptor())); }
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); }
FieldInfo(ClassFile parent, Modifiers modifiers, String name, TypeDesc type) { mParent = parent; mCp = parent.getConstantPool(); mName = name; mType = type; mModifiers = modifiers; mNameConstant = mCp.addConstantUTF(name); mDescriptorConstant = mCp.addConstantUTF(type.getDescriptor()); }
/** * Used to describe an array class. */ public ConstantClassInfo(ConstantPool cp, String className, int dim) { super(TAG_CLASS); TypeDesc type = TypeDesc.forClass(className); String desc; if (dim > 0) { while (--dim >= 0) { type = type.toArrayType(); } desc = type.getDescriptor(); } else { desc = className.replace('.', '/'); } mType = type; mNameConstant = cp.addConstantUTF(desc); }
type = new ObjectType(type.getDescriptor(), clazz.getName()); ((ObjectType) type).setClass(clazz);
public MemberValue makeMemberValue(TypeDesc enumType, String enumName) { return new MemberValue(MEMBER_TAG_ENUM, new EnumConstValue(mCp.addConstantUTF(enumType.getDescriptor()), mCp.addConstantUTF(enumName))); }
/** * Add an entry into the LocalVariableTableAttr. */ public void addEntry(LocalVariable localVar) { String varName = localVar.getName(); if (varName == null) { int num = localVar.getNumber(); varName = num < 0 ? "_" : ("v" + num + '$'); } ConstantUTFInfo name = getConstantPool().addConstantUTF(varName); ConstantUTFInfo descriptor = getConstantPool().addConstantUTF(localVar.getType().getDescriptor()); mEntries.add(new Entry(localVar, name, descriptor)); mCleanEntries = null; }
/** * Returns an annotation descriptor that has no parameters. */ public static String makePlainDescriptor(Class<? extends Annotation> annotationType) { return "" + TAG_ANNOTATION + TypeDesc.forClass(annotationType).getDescriptor(); }
/** * Returns an annotation descriptor that has no parameters. */ public static String makePlainDescriptor(Class<? extends Annotation> annotationType) { return "" + TAG_ANNOTATION + TypeDesc.forClass(annotationType).getDescriptor(); }
private RParameter(Class<T> type, int flags) { mType = type; mFlags = flags; mDescriptor = TypeDesc.forClass(type).getDescriptor().intern(); }
@Override public Object visit(String name, int pos, Class value, Object param) { appendName(name, pos, TAG_CLASS); if (value == String.class) { mBuilder.append(TAG_STRING); } else if (value == Class.class) { mBuilder.append(TAG_CLASS); } else { mBuilder.append(TypeDesc.forClass(value).getDescriptor()); } return null; }
@Override public Object visit(String name, int pos, Annotation value, Object param) { if (appendName(name, pos, TAG_ANNOTATION)) { mBuilder.append(TypeDesc.forClass(value.annotationType()).getDescriptor()); } super.visit(name, pos, value, param); mBuilder.append(';'); return null; }
public Object visit(String name, int pos, Annotation value, Object param) { if (appendName(name, pos, TAG_ANNOTATION)) { mBuilder.append(TypeDesc.forClass(value.annotationType()).getDescriptor()); } super.visit(name, pos, value, param); mBuilder.append(';'); return null; }
FieldInfo(ClassFile parent, Modifiers modifiers, String name, TypeDesc type) { mParent = parent; mCp = parent.getConstantPool(); mName = name; mType = type; mModifiers = modifiers; mNameConstant = mCp.addConstantUTF(name); mDescriptorConstant = mCp.addConstantUTF(type.getDescriptor()); }
public MemberValue makeMemberValue(TypeDesc enumType, String enumName) { return new MemberValue(MEMBER_TAG_ENUM, new EnumConstValue(mCp.addConstantUTF(enumType.getDescriptor()), mCp.addConstantUTF(enumName))); }