/** * Computes the data size of parameters. * If one of the parameters is double type, the size of that parameter * is 2 words. For example, if the given descriptor is * <code>"(IJ)D"</code>, then this method returns 3. The size of the * return type is not computed. * * @param desc a method descriptor. */ public static int paramSize(String desc) { return -dataSize(desc, false); }
/** * Computes the data size specified by the given descriptor. * For example, if the descriptor is "D", this method returns 2. * * <p>If the descriptor represents a method type, this method returns * (the size of the returned value) - (the sum of the data sizes * of all the parameters). For example, if the descriptor is * <code>"(I)D"</code>, then this method returns 1 (= 2 - 1). * * @param desc descriptor */ public static int dataSize(String desc) { return dataSize(desc, true); }
private int getFieldSize(CodeIterator ci, int index) { String desc = constPool.getFieldrefType(ci.u16bitAt(index + 1)); return Descriptor.dataSize(desc); } }
private int getFieldSize(CodeIterator ci, int index) { String desc = constPool.getFieldrefType(ci.u16bitAt(index + 1)); return Descriptor.dataSize(desc); } }
/** * Appends INVOKESPECIAL. * * @param index the index of <code>CONSTANT_Methodref_info</code> * or <code>CONSTANT_InterfaceMethodref_info</code> * @param desc the descriptor of the method signature. * * @see Descriptor#ofMethod(CtClass,CtClass[]) * @see Descriptor#ofConstructor(CtClass[]) */ public void addInvokespecial(int index, String desc) { add(INVOKESPECIAL); addIndex(index); growStack(Descriptor.dataSize(desc) - 1); }
private int doPutField(int pos, byte[] code, boolean notStatic) throws BadBytecode { int index = ByteArray.readU16bit(code, pos + 1); String desc = cpool.getFieldrefType(index); stackTop -= Descriptor.dataSize(desc); char c = desc.charAt(0); if (c == 'L') stackTypes[stackTop].setType(getFieldClassName(desc, 0), classPool); else if (c == '[') stackTypes[stackTop].setType(desc, classPool); setFieldTarget(notStatic, index); return 3; }
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); }
/** * Appends GETSTATIC. * * @param c the fully-qualified class name * @param name the field name * @param type the descriptor of the field type. * * @see Descriptor#of(CtClass) */ public void addGetstatic(String c, String name, String type) { add(GETSTATIC); int ci = constPool.addClassInfo(c); addIndex(constPool.addFieldrefInfo(ci, name, type)); growStack(Descriptor.dataSize(type)); }
/** * Appends GETFIELD. * * @param c the fully-qualified class name. * @param name the field name. * @param type the descriptor of the field type. * * @see Descriptor#of(CtClass) */ public void addGetfield(String c, String name, String type) { add(GETFIELD); int ci = constPool.addClassInfo(c); addIndex(constPool.addFieldrefInfo(ci, name, type)); growStack(Descriptor.dataSize(type) - 1); }
/** * Appends GETFIELD. * * @param c the class. * @param name the field name. * @param type the descriptor of the field type. * * @see Descriptor#of(CtClass) */ public void addGetfield(CtClass c, String name, String type) { add(GETFIELD); int ci = constPool.addClassInfo(c); addIndex(constPool.addFieldrefInfo(ci, name, type)); growStack(Descriptor.dataSize(type) - 1); }
/** * Appends GETSTATIC. * * @param c the class * @param name the field name * @param type the descriptor of the field type. * * @see Descriptor#of(CtClass) */ public void addGetstatic(CtClass c, String name, String type) { add(GETSTATIC); int ci = constPool.addClassInfo(c); addIndex(constPool.addFieldrefInfo(ci, name, type)); growStack(Descriptor.dataSize(type)); }
private void addPutfield0(CtClass target, String classname, String name, String desc) { add(PUTFIELD); // target is null if it represents THIS. int ci = classname == null ? constPool.addClassInfo(target) : constPool.addClassInfo(classname); addIndex(constPool.addFieldrefInfo(ci, name, desc)); growStack(-1 - Descriptor.dataSize(desc)); }
private int doPutField(int pos, byte[] code, boolean notStatic) throws BadBytecode { int index = ByteArray.readU16bit(code, pos + 1); String desc = cpool.getFieldrefType(index); stackTop -= Descriptor.dataSize(desc); char c = desc.charAt(0); if (c == 'L') stackTypes[stackTop].setType(getFieldClassName(desc, 0), classPool); else if (c == '[') stackTypes[stackTop].setType(desc, classPool); setFieldTarget(notStatic, index); return 3; }
private void addPutstatic0(CtClass target, String classname, String fieldName, String desc) { add(PUTSTATIC); // target is null if it represents THIS. int ci = classname == null ? constPool.addClassInfo(target) : constPool.addClassInfo(classname); addIndex(constPool.addFieldrefInfo(ci, fieldName, desc)); growStack(-Descriptor.dataSize(desc)); }
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 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 }
/** * Appends INVOKEINTERFACE. * * @param clazz the index of <code>CONSTANT_Class_info</code> * structure. * @param name the method name * @param desc the descriptor of the method signature. * @param count the count operand of the instruction. * * @see Descriptor#ofMethod(CtClass,CtClass[]) */ public void addInvokeinterface(int clazz, String name, String desc, int count) { add(INVOKEINTERFACE); addIndex(constPool.addInterfaceMethodrefInfo(clazz, name, desc)); add(count); add(0); growStack(Descriptor.dataSize(desc) - 1); }
private void addPutfield0(CtClass target, String classname, String name, String desc) { add(PUTFIELD); // target is null if it represents THIS. int ci = classname == null ? constPool.addClassInfo(target) : constPool.addClassInfo(classname); addIndex(constPool.addFieldrefInfo(ci, name, desc)); growStack(-1 - Descriptor.dataSize(desc)); }
private void addPutstatic0(CtClass target, String classname, String fieldName, String desc) { add(PUTSTATIC); // target is null if it represents THIS. int ci = classname == null ? constPool.addClassInfo(target) : constPool.addClassInfo(classname); addIndex(constPool.addFieldrefInfo(ci, fieldName, desc)); growStack(-Descriptor.dataSize(desc)); }