protected int copy2(ConstPool dest, int cindex, int ntindex) { return dest.addMethodrefInfo(cindex, ntindex); } }
@Override protected int copy2(ConstPool dest, int cindex, int ntindex) { return dest.addMethodrefInfo(cindex, ntindex); } }
/** * 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_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); }
/** * Appends INVOKESPECIAL. * * @param isInterface true if the invoked method is a default method * declared in an interface. * @param clazz the index of <code>CONSTANT_Class_info</code> * structure. * @param name the method name * @param desc the descriptor of the method signature. * * @see Descriptor#ofMethod(CtClass,CtClass[]) * @see Descriptor#ofConstructor(CtClass[]) */ public void addInvokespecial(boolean isInterface, int clazz, String name, String desc) { int index; if (isInterface) index = constPool.addInterfaceMethodrefInfo(clazz, name, desc); else index = constPool.addMethodrefInfo(clazz, name, desc); addInvokespecial(index, desc); }
public static int addMethod(ConstPool cPool, CtMethod method) { return cPool.addMethodrefInfo( cPool.getThisClassInfo(), method.getName(), method.getSignature() ); }
private void addInvokestatic(int clazz, String name, String desc, boolean isInterface) { add(INVOKESTATIC); int index; if (isInterface) index = constPool.addInterfaceMethodrefInfo(clazz, name, desc); else index = constPool.addMethodrefInfo(clazz, name, desc); addIndex(index); growStack(Descriptor.dataSize(desc)); }
/** * Appends INVOKEVIRTUAL. * * <p>The specified method must not be an inherited method. * It must be directly declared in the class specified * by <code>clazz</code>. * * @param clazz the index of <code>CONSTANT_Class_info</code> * structure. * @param name the method name * @param desc the descriptor of the method signature. * * @see Descriptor#ofMethod(CtClass,CtClass[]) */ public void addInvokevirtual(int clazz, String name, String desc) { add(INVOKEVIRTUAL); addIndex(constPool.addMethodrefInfo(clazz, name, desc)); growStack(Descriptor.dataSize(desc) - 1); }
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); }
private void addInvokestatic(int clazz, String name, String desc, boolean isInterface) { add(INVOKESTATIC); int index; if (isInterface) index = constPool.addInterfaceMethodrefInfo(clazz, name, desc); else index = constPool.addMethodrefInfo(clazz, name, desc); addIndex(index); growStack(Descriptor.dataSize(desc)); }
/** * Appends INVOKEVIRTUAL. * * <p>The specified method must not be an inherited method. * It must be directly declared in the class specified * by <code>clazz</code>. * * @param clazz the index of <code>CONSTANT_Class_info</code> * structure. * @param name the method name * @param desc the descriptor of the method signature. * * @see Descriptor#ofMethod(CtClass,CtClass[]) */ public void addInvokevirtual(int clazz, String name, String desc) { add(INVOKEVIRTUAL); addIndex(constPool.addMethodrefInfo(clazz, name, desc)); growStack(Descriptor.dataSize(desc) - 1); }
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); }
if (newMethodNTIndex != nt) { newMethodNTIndex = nt; newMethodIndex = cp.addMethodrefInfo(newClassIndex, nt);
pos = gap.position; int mi = cp.addClassInfo(methodClassname); int methodref = cp.addMethodrefInfo(mi, methodName, signature); iterator.writeByte(INVOKESTATIC, pos); iterator.write16bit(methodref, pos + 1);
int nt = cp.getMethodrefNameAndType(mref); int sc = cp.addClassInfo(superclass); int mref2 = cp.addMethodrefInfo(sc, nt); ByteArray.write16bit(mref2, code, pos + 1);
public int transform(CtClass tclazz, int pos, CodeIterator iterator, ConstPool cp) throws BadBytecode { int c = iterator.byteAt(pos); if (c == GETFIELD || c == GETSTATIC) { int index = iterator.u16bitAt(pos + 1); String typedesc = isField(tclazz.getClassPool(), cp, fieldClass, fieldname, isPrivate, index); if (typedesc != null) { if (c == GETSTATIC) { iterator.move(pos); pos = iterator.insertGap(1); // insertGap() may insert 4 bytes. iterator.writeByte(ACONST_NULL, pos); pos = iterator.next(); } String type = "(Ljava/lang/Object;)" + typedesc; int mi = cp.addClassInfo(methodClassname); int methodref = cp.addMethodrefInfo(mi, methodName, type); iterator.writeByte(INVOKESTATIC, pos); iterator.write16bit(methodref, pos + 1); return pos; } } return pos; } }
int methodref = cp.addMethodrefInfo(mi, methodName, type); iterator.writeByte(INVOKESTATIC, pos); iterator.write16bit(methodref, pos + 1);