/** * Adds a new <code>CONSTANT_Fieldref_info</code> structure. * * <p>This also adds a new <code>CONSTANT_NameAndType_info</code> * structure. * * @param classInfo <code>class_index</code> * @param name <code>name_index</code> * of <code>CONSTANT_NameAndType_info</code>. * @param type <code>descriptor_index</code> * of <code>CONSTANT_NameAndType_info</code>. * @return the index of the added entry. */ public int addFieldrefInfo(int classInfo, String name, String type) { int nt = addNameAndTypeInfo(name, type); return addFieldrefInfo(classInfo, nt); }
/** * Adds a new <code>CONSTANT_Methodref_info</code> structure. * * <p>This also adds a new <code>CONSTANT_NameAndType_info</code> * structure. * * @param classInfo <code>class_index</code> * @param name <code>name_index</code> * of <code>CONSTANT_NameAndType_info</code>. * @param type <code>descriptor_index</code> * of <code>CONSTANT_NameAndType_info</code>. * @return the index of the added entry. */ public int addMethodrefInfo(int classInfo, String name, String type) { int nt = addNameAndTypeInfo(name, type); return addMethodrefInfo(classInfo, nt); }
/** * Adds a new <code>CONSTANT_InterfaceMethodref_info</code> * structure. * * <p>This also adds a new <code>CONSTANT_NameAndType_info</code> * structure. * * @param classInfo <code>class_index</code> * @param name <code>name_index</code> * of <code>CONSTANT_NameAndType_info</code>. * @param type <code>descriptor_index</code> * of <code>CONSTANT_NameAndType_info</code>. * @return the index of the added entry. */ public int addInterfaceMethodrefInfo(int classInfo, String name, String type) { int nt = addNameAndTypeInfo(name, type); return addInterfaceMethodrefInfo(classInfo, nt); }
/** * Adds a new <code>CONSTANT_NameAndType_info</code> structure. * * <p>This also adds <code>CONSTANT_Utf8_info</code> structures. * * @param name <code>name_index</code> * @param type <code>descriptor_index</code> * @return the index of the added entry. */ public int addNameAndTypeInfo(String name, String type) { return addNameAndTypeInfo(addUtf8Info(name), addUtf8Info(type)); }
/** * Adds a new <code>CONSTANT_Methodref_info</code> structure. * * <p>This also adds a new <code>CONSTANT_NameAndType_info</code> * structure. * * @param classInfo <code>class_index</code> * @param name <code>name_index</code> * of <code>CONSTANT_NameAndType_info</code>. * @param type <code>descriptor_index</code> * of <code>CONSTANT_NameAndType_info</code>. * @return the index of the added entry. */ public int addMethodrefInfo(int classInfo, String name, String type) { int nt = addNameAndTypeInfo(name, type); return addMethodrefInfo(classInfo, nt); }
/** * Adds a new <code>CONSTANT_Fieldref_info</code> structure. * * <p>This also adds a new <code>CONSTANT_NameAndType_info</code> * structure. * * @param classInfo <code>class_index</code> * @param name <code>name_index</code> * of <code>CONSTANT_NameAndType_info</code>. * @param type <code>descriptor_index</code> * of <code>CONSTANT_NameAndType_info</code>. * @return the index of the added entry. */ public int addFieldrefInfo(int classInfo, String name, String type) { int nt = addNameAndTypeInfo(name, type); return addFieldrefInfo(classInfo, nt); }
/** * Constructs an EnclosingMethod attribute. * * @param cp a constant pool table. * @param className the name of the innermost enclosing class. * @param methodName the name of the enclosing method. * @param methodDesc the descriptor of the enclosing method. */ public EnclosingMethodAttribute(ConstPool cp, String className, String methodName, String methodDesc) { super(cp, tag); int ci = cp.addClassInfo(className); int ni = cp.addNameAndTypeInfo(methodName, methodDesc); byte[] bvalue = new byte[4]; bvalue[0] = (byte)(ci >>> 8); bvalue[1] = (byte)ci; bvalue[2] = (byte)(ni >>> 8); bvalue[3] = (byte)ni; set(bvalue); }
/** * Adds a new <code>CONSTANT_NameAndType_info</code> structure. * * <p>This also adds <code>CONSTANT_Utf8_info</code> structures. * * @param name <code>name_index</code> * @param type <code>descriptor_index</code> * @return the index of the added entry. */ public int addNameAndTypeInfo(String name, String type) { return addNameAndTypeInfo(addUtf8Info(name), addUtf8Info(type)); }
/** * Constructs an EnclosingMethod attribute. * * @param cp a constant pool table. * @param className the name of the innermost enclosing class. * @param methodName the name of the enclosing method. * @param methodDesc the descriptor of the enclosing method. */ public EnclosingMethodAttribute(ConstPool cp, String className, String methodName, String methodDesc) { super(cp, tag); int ci = cp.addClassInfo(className); int ni = cp.addNameAndTypeInfo(methodName, methodDesc); byte[] bvalue = new byte[4]; bvalue[0] = (byte)(ci >>> 8); bvalue[1] = (byte)ci; bvalue[2] = (byte)(ni >>> 8); bvalue[3] = (byte)ni; set(bvalue); }
public int copy(ConstPool src, ConstPool dest, Map map) { String mname = src.getUtf8Info(memberName); String tdesc = src.getUtf8Info(typeDescriptor); tdesc = Descriptor.rename(tdesc, map); return dest.addNameAndTypeInfo(dest.addUtf8Info(mname), dest.addUtf8Info(tdesc)); }
private int computeMethodref(int typedesc, ConstPool cp) { int classIndex = cp.addClassInfo(trapClass); int mnameIndex = cp.addUtf8Info(trapMethod); typedesc = cp.addUtf8Info( Descriptor.changeReturnType(classname, cp.getUtf8Info(typedesc))); return cp.addMethodrefInfo(classIndex, cp.addNameAndTypeInfo(mnameIndex, typedesc)); } }
protected int match(int c, int pos, CodeIterator iterator, int typedesc, ConstPool cp) throws BadBytecode { if (newIndex == 0) { String desc = Descriptor.ofParameters(parameterTypes) + 'V'; desc = Descriptor.insertParameter(classname, desc); int nt = cp.addNameAndTypeInfo(newMethodname, desc); int ci = cp.addClassInfo(newClassname); newIndex = cp.addMethodrefInfo(ci, nt); constPool = cp; } if (saveCode == null) makeCode(parameterTypes, cp); return match2(pos, iterator); }
@Override public int copy(ConstPool src, ConstPool dest, Map<String,String> map) { String mname = src.getUtf8Info(memberName); String tdesc = src.getUtf8Info(typeDescriptor); tdesc = Descriptor.rename(tdesc, map); return dest.addNameAndTypeInfo(dest.addUtf8Info(mname), dest.addUtf8Info(tdesc)); }
/** * Appends INVOKEDYNAMIC. * * @param bootstrap an index into the <code>bootstrap_methods</code> array * of the bootstrap method table. * @param name the method name. * @param desc the method descriptor. * @see Descriptor#ofMethod(CtClass,CtClass[]) * @since 3.17 */ public void addInvokedynamic(int bootstrap, String name, String desc) { int nt = constPool.addNameAndTypeInfo(name, desc); int dyn = constPool.addInvokeDynamicInfo(bootstrap, nt); add(INVOKEDYNAMIC); addIndex(dyn); add(0, 0); growStack(Descriptor.dataSize(desc)); // assume ConstPool#REF_invokeStatic }
protected int match(int c, int pos, CodeIterator iterator, int typedesc, ConstPool cp) throws BadBytecode { if (newIndex == 0) { int nt = cp.addNameAndTypeInfo(cp.addUtf8Info(newMethodname), typedesc); int ci = cp.addClassInfo(newClassname); if (c == INVOKEINTERFACE) newIndex = cp.addInterfaceMethodrefInfo(ci, nt); else { if (newMethodIsPrivate && c == INVOKEVIRTUAL) iterator.writeByte(INVOKESPECIAL, pos); newIndex = cp.addMethodrefInfo(ci, nt); } constPool = cp; } iterator.write16bit(newIndex, pos + 1); return pos; } }
private int computeMethodref(int typedesc, ConstPool cp) { int classIndex = cp.addClassInfo(trapClass); int mnameIndex = cp.addUtf8Info(trapMethod); typedesc = cp.addUtf8Info( Descriptor.changeReturnType(classname, cp.getUtf8Info(typedesc))); return cp.addMethodrefInfo(classIndex, cp.addNameAndTypeInfo(mnameIndex, typedesc)); } }
@Override protected int match(int c, int pos, CodeIterator iterator, int typedesc, ConstPool cp) throws BadBytecode { if (newIndex == 0) { String desc = Descriptor.ofParameters(parameterTypes) + 'V'; desc = Descriptor.insertParameter(classname, desc); int nt = cp.addNameAndTypeInfo(newMethodname, desc); int ci = cp.addClassInfo(newClassname); newIndex = cp.addMethodrefInfo(ci, nt); constPool = cp; } if (saveCode == null) makeCode(parameterTypes, cp); return match2(pos, iterator); }
/** * Appends INVOKEDYNAMIC. * * @param bootstrap an index into the <code>bootstrap_methods</code> array * of the bootstrap method table. * @param name the method name. * @param desc the method descriptor. * @see Descriptor#ofMethod(CtClass,CtClass[]) * @since 3.17 */ public void addInvokedynamic(int bootstrap, String name, String desc) { int nt = constPool.addNameAndTypeInfo(name, desc); int dyn = constPool.addInvokeDynamicInfo(bootstrap, nt); add(INVOKEDYNAMIC); addIndex(dyn); add(0, 0); growStack(Descriptor.dataSize(desc)); // assume ConstPool#REF_invokeStatic }
protected int match(int c, int pos, CodeIterator iterator, int typedesc, ConstPool cp) throws BadBytecode { if (newIndex == 0) { int nt = cp.addNameAndTypeInfo(cp.addUtf8Info(newMethodname), typedesc); int ci = cp.addClassInfo(newClassname); if (c == INVOKEINTERFACE) newIndex = cp.addInterfaceMethodrefInfo(ci, nt); else { if (newMethodIsPrivate && c == INVOKEVIRTUAL) iterator.writeByte(INVOKESPECIAL, pos); newIndex = cp.addMethodrefInfo(ci, nt); } constPool = cp; } iterator.write16bit(newIndex, pos + 1); return pos; } }
if (typedesc != null) { if (newIndex == 0) { int nt = cp.addNameAndTypeInfo(newFieldname, typedesc); newIndex = cp.addFieldrefInfo(