private static String wide(CodeIterator iter, int pos) { int opcode = iter.byteAt(pos + 1); int index = iter.u16bitAt(pos + 2); switch (opcode) { case ILOAD: case LLOAD: case FLOAD: case DLOAD: case ALOAD: case ISTORE: case LSTORE: case FSTORE: case DSTORE: case ASTORE: case IINC: case RET: return opcodes[opcode] + " " + index; default: throw new RuntimeException("Invalid WIDE operand"); } }
/** * Returns the name of the class in which the field is declared. */ public String getClassName() { int index = iterator.u16bitAt(currentPos + 1); return getConstPool().getFieldrefClassName(index); }
/** * Returns the signature of the field type. * The signature is represented by a character string * called field descriptor, which is defined in the JVM specification. * * @see javassist.bytecode.Descriptor#toCtClass(String, ClassPool) * @since 3.1 */ public String getSignature() { int index = iterator.u16bitAt(currentPos + 1); return getConstPool().getFieldrefType(index); }
private int getFieldSize(CodeIterator ci, int index) { String desc = constPool.getFieldrefType(ci.u16bitAt(index + 1)); return Descriptor.dataSize(desc); } }
/** * Returns the name of the field. */ public String getFieldName() { int index = iterator.u16bitAt(currentPos + 1); return getConstPool().getFieldrefName(index); }
/** * Get the signature of the constructor * * The signature is represented by a character string * called method descriptor, which is defined in the JVM specification. * * @see javassist.CtBehavior#getSignature() * @see javassist.bytecode.Descriptor * @return the signature */ public String getSignature() { ConstPool constPool = getConstPool(); int methodIndex = iterator.u16bitAt(currentPos + 1); // constructor return constPool.getMethodrefType(methodIndex); }
/** * Returns the dimension of the created array. */ public int getDimension() { if (opcode == Opcode.NEWARRAY) return 1; else if (opcode == Opcode.ANEWARRAY || opcode == Opcode.MULTIANEWARRAY) { int index = iterator.u16bitAt(currentPos + 1); String desc = getConstPool().getClassInfo(index); return Descriptor.arrayDimension(desc) + (opcode == Opcode.ANEWARRAY ? 1 : 0); } else throw new RuntimeException("bad opcode: " + opcode); }
/** * Returns the signature of the field type. * The signature is represented by a character string * called field descriptor, which is defined in the JVM specification. * * @see javassist.bytecode.Descriptor#toCtClass(String, ClassPool) * @since 3.1 */ public String getSignature() { int index = iterator.u16bitAt(currentPos + 1); return getConstPool().getFieldrefType(index); }
/** * Returns the name of the class in which the field is declared. */ public String getClassName() { int index = iterator.u16bitAt(currentPos + 1); return getConstPool().getFieldrefClassName(index); }
private int getFieldSize(CodeIterator ci, int index) { String desc = constPool.getFieldrefType(ci.u16bitAt(index + 1)); return Descriptor.dataSize(desc); } }
private int getNameAndType(ConstPool cp) { int pos = currentPos; int c = iterator.byteAt(pos); int index = iterator.u16bitAt(pos + 1); if (c == INVOKEINTERFACE) return cp.getInterfaceMethodrefNameAndType(index); else return cp.getMethodrefNameAndType(index); }
/** * Returns the constructor called for creating the object. */ public CtConstructor getConstructor() throws NotFoundException { ConstPool cp = getConstPool(); int index = iterator.u16bitAt(currentPos + 1); String desc = cp.getMethodrefType(index); return getCtClass().getConstructor(desc); }
/** * Returns the <code>CtClass</code> object representing * the type specified by the cast. */ public CtClass getType() throws NotFoundException { ConstPool cp = getConstPool(); int pos = currentPos; int index = iterator.u16bitAt(pos + 1); String name = cp.getClassInfo(index); return thisClass.getClassPool().getCtClass(name); }
/** * Returns the <code>CtClass</code> object representing * the type name on the right hand side * of the instanceof operator. */ public CtClass getType() throws NotFoundException { ConstPool cp = getConstPool(); int pos = currentPos; int index = iterator.u16bitAt(pos + 1); String name = cp.getClassInfo(index); return thisClass.getClassPool().getCtClass(name); }
private int getNameAndType(ConstPool cp) { int pos = currentPos; int c = iterator.byteAt(pos); int index = iterator.u16bitAt(pos + 1); if (c == INVOKEINTERFACE) return cp.getInterfaceMethodrefNameAndType(index); return cp.getMethodrefNameAndType(index); }
/** * Returns the class name of the target object, * which the method is called on. */ public String getClassName() { String cname; ConstPool cp = getConstPool(); int pos = currentPos; int c = iterator.byteAt(pos); int index = iterator.u16bitAt(pos + 1); if (c == INVOKEINTERFACE) cname = cp.getInterfaceMethodrefClassName(index); else cname = cp.getMethodrefClassName(index); if (cname.charAt(0) == '[') cname = Descriptor.toClassName(cname); return cname; }
/** * Returns the field accessed by this expression. */ public CtField getField() throws NotFoundException { CtClass cc = getCtClass(); int index = iterator.u16bitAt(currentPos + 1); ConstPool cp = getConstPool(); return cc.getField(cp.getFieldrefName(index), cp.getFieldrefType(index)); }
/** * Returns the type of array components. If the created array is * a two-dimensional array of <tt>int</tt>, * the type returned by this method is * not <tt>int[]</tt> but <tt>int</tt>. */ public CtClass getComponentType() throws NotFoundException { if (opcode == Opcode.NEWARRAY) { int atype = iterator.byteAt(currentPos + 1); return getPrimitiveType(atype); } else if (opcode == Opcode.ANEWARRAY || opcode == Opcode.MULTIANEWARRAY) { int index = iterator.u16bitAt(currentPos + 1); String desc = getConstPool().getClassInfo(index); int dim = Descriptor.arrayDimension(desc); desc = Descriptor.toArrayComponent(desc, dim); return Descriptor.toCtClass(desc, thisClass.getClassPool()); } else throw new RuntimeException("bad opcode: " + opcode); }
private void evalNewObjectArray(int pos, CodeIterator iter, Frame frame) throws BadBytecode { // Convert to x[] format Type type = resolveClassInfo(constPool.getClassInfo(iter.u16bitAt(pos + 1))); String name = type.getCtClass().getName(); int opcode = iter.byteAt(pos); int dimensions; if (opcode == MULTIANEWARRAY) { dimensions = iter.byteAt(pos + 3); } else { name = name + "[]"; dimensions = 1; } while (dimensions-- > 0) { verifyAssignable(Type.INTEGER, simplePop(frame)); } simplePush(getType(name), frame); }
protected int match2(int pos, CodeIterator iterator) throws BadBytecode { iterator.move(pos); iterator.insert(saveCode); iterator.insert(loadCode); int p = iterator.insertGap(3); iterator.setMark(p); iterator.insert(loadCode); pos = iterator.next(); p = iterator.getMark(); iterator.writeByte(iterator.byteAt(pos), p); iterator.write16bit(iterator.u16bitAt(pos + 1), p + 1); iterator.writeByte(INVOKESTATIC, pos); iterator.write16bit(newIndex, pos + 1); iterator.move(p); return iterator.next(); } }