/** * Constructs and a return a stack map table containing * the written stack map entries. * * @param cp the constant pool used to write * the stack map entries. */ public StackMapTable toStackMapTable(ConstPool cp) { return new StackMapTable(cp, toByteArray()); }
/** * Updates this stack map table when a new local variable is inserted * for a new parameter. * * @param index the index of the added local variable. * @param tag the type tag of that local variable. * @param classInfo the index of the <code>CONSTANT_Class_info</code> structure * in a constant pool table. This should be zero unless the tag * is <code>ITEM_Object</code>. * * @see javassist.CtBehavior#addParameter(javassist.CtClass) * @see #typeTagOf(char) * @see ConstPool */ public void insertLocal(int index, int tag, int classInfo) throws BadBytecode { byte[] data = new InsertLocal(this.get(), index, tag, classInfo).doit(); this.set(data); }
void shiftPc(int where, int gapLength, boolean exclusive) throws BadBytecode { if (where < cursor || (where == cursor && exclusive)) cursor += gapLength; if (where < mark || (where == mark && exclusive)) mark += gapLength; if (where < mark0 || (where == mark0 && exclusive)) mark0 += gapLength; etable.shiftPc(where, gapLength, exclusive); if (line != null) line.shiftPc(where, gapLength, exclusive); if (vars != null) vars.shiftPc(where, gapLength, exclusive); if (types != null) types.shiftPc(where, gapLength, exclusive); if (stack != null) stack.shiftPc(where, gapLength, exclusive); if (stack2 != null) stack2.shiftPc(where, gapLength, exclusive); }
smt.insertLocal(where, StackMapTable.typeTagOf(typeDesc), classInfo); sm.insertLocal(where, StackMapTable.typeTagOf(typeDesc), classInfo);
/** * Constructs a walker. * * @param smt the StackMapTable that this walker * walks around. */ public Walker(StackMapTable smt) { this(smt.get()); }
public void doit() throws BadBytecode { parse(); if (updatedInfo != null) stackMap.set(updatedInfo); }
= (StackMapTable)iterator.get().getAttribute(StackMapTable.tag); if (smt != null) smt.removeNew(pos);
void shiftForSwitch(int where, int gapLength) throws BadBytecode { if (stack != null) stack.shiftForSwitch(where, gapLength); if (stack2 != null) stack2.shiftForSwitch(where, gapLength); } }
smt.insertLocal(where, StackMapTable.typeTagOf(typeDesc), classInfo); sm.insertLocal(where, StackMapTable.typeTagOf(typeDesc), classInfo);
/** * Constructs a walker. * * @param smt the StackMapTable that this walker * walks around. */ public Walker(StackMapTable smt) { this(smt.get()); }
public void doit() throws BadBytecode { parse(); if (updatedInfo != null) stackMap.set(updatedInfo); }
= (StackMapTable)iterator.get().getAttribute(StackMapTable.tag); if (smt != null) smt.removeNew(pos);
void shiftForSwitch(int where, int gapLength) throws BadBytecode { if (stack != null) stack.shiftForSwitch(where, gapLength); if (stack2 != null) stack2.shiftForSwitch(where, gapLength); } }
/** * Undocumented method. Do not use; internal-use only. * * <p>This method is for javassist.convert.TransformNew. * It is called to update the stack map table when * the NEW opcode (and the following DUP) is removed. * * @param where the position of the removed NEW opcode. */ public void removeNew(int where) throws CannotCompileException { try { byte[] data = new NewRemover(this.get(), where).doit(); this.set(data); } catch (BadBytecode e) { throw new CannotCompileException("bad stack map table", e); } }
/** * Constructs and a return a stack map table containing * the written stack map entries. * * @param cp the constant pool used to write * the stack map entries. */ public StackMapTable toStackMapTable(ConstPool cp) { return new StackMapTable(cp, toByteArray()); }
private void addParameter2(int where, CtClass type, String desc) throws BadBytecode { CodeAttribute ca = methodInfo.getCodeAttribute(); if (ca != null) { int size = 1; char typeDesc = 'L'; int classInfo = 0; if (type.isPrimitive()) { CtPrimitiveType cpt = (CtPrimitiveType)type; size = cpt.getDataSize(); typeDesc = cpt.getDescriptor(); } else classInfo = methodInfo.getConstPool().addClassInfo(type); ca.insertLocalVar(where, size); LocalVariableAttribute va = (LocalVariableAttribute) ca.getAttribute(LocalVariableAttribute.tag); if (va != null) va.shiftIndex(where, size); StackMapTable smt = (StackMapTable)ca.getAttribute(StackMapTable.tag); if (smt != null) smt.insertLocal(where, StackMapTable.typeTagOf(typeDesc), classInfo); StackMap sm = (StackMap)ca.getAttribute(StackMap.tag); if (sm != null) sm.insertLocal(where, StackMapTable.typeTagOf(typeDesc), classInfo); } }
/** * Prints the stack table map. */ public static void print(StackMapTable smt, PrintWriter writer) { try { new Printer(smt.get(), writer).parse(); } catch (BadBytecode e) { writer.println(e.getMessage()); } }
void shiftPc(int where, int gapLength, boolean exclusive) throws BadBytecode { if (where < cursor || (where == cursor && exclusive)) cursor += gapLength; if (where < mark || (where == mark && exclusive)) mark += gapLength; if (where < mark0 || (where == mark0 && exclusive)) mark0 += gapLength; etable.shiftPc(where, gapLength, exclusive); if (line != null) line.shiftPc(where, gapLength, exclusive); if (vars != null) vars.shiftPc(where, gapLength, exclusive); if (types != null) types.shiftPc(where, gapLength, exclusive); if (stack != null) stack.shiftPc(where, gapLength, exclusive); if (stack2 != null) stack2.shiftPc(where, gapLength, exclusive); }
public void doit() throws BadBytecode { parse(); if (updatedInfo != null) stackMap.set(updatedInfo); }
= (StackMapTable)iterator.get().getAttribute(StackMapTable.tag); if (smt != null) smt.removeNew(pos);