public boolean checkCode(InstructionHandle[] match) { InstructionHandle ih = match[0]; CPInstruction ldc_w = (CPInstruction) ih.getInstruction(); Constant cc = cpool.getConstant(ldc_w.getIndex()); if (cc.getTag() != CONSTANT_Class) return false; ih = match[1]; CPInstruction invokevirtual = (CPInstruction) ih.getInstruction(); ConstantMethodref cm = (ConstantMethodref) cpool.getConstant(invokevirtual.getIndex()); ConstantNameAndType cnt = (ConstantNameAndType) cpool.getConstant(cm.getNameAndTypeIndex()); if (!cnt.getName(cpool.getConstantPool()).equals("desiredAssertionStatus")) return false; return true; }
public void visitCPInstruction(CPInstruction cpi) { int index = cpi.getIndex(); Constant oldConstant = oldCP.getConstant(index); if (oldConstant instanceof org.apache.bcel.classfile.ConstantCP) { org.apache.bcel.classfile.ConstantCP fr = (org.apache.bcel.classfile.ConstantCP) oldConstant; if (fr.getClass(oldCP.getConstantPool()).equals(oldClass)) fr.setClassIndex(oldCP.addClass(newClass)); } index = newCP.addConstant(oldConstant, oldCP); cpi.setIndex(index); }
public boolean checkCode(InstructionHandle[] match) { InstructionHandle ih = match[2]; CPInstruction putfield = (CPInstruction) ih.getInstruction(); Constant cc = cpool.getConstant(putfield.getIndex()); if (cc.getTag() != CONSTANT_Fieldref) return false; ConstantFieldref cfield = (ConstantFieldref) cc; ConstantNameAndType cnt = (ConstantNameAndType) cpool.getConstant(cfield.getNameAndTypeIndex()); if (!cnt.getName(cpool.getConstantPool()).equals("this$0")) return false; return true; }
public void visitAllocationInstruction( AllocationInstruction i ) { Type type; if (i instanceof CPInstruction) { type = ((CPInstruction) i).getType(_cp); } else { type = ((NEWARRAY) i).getType(); } short opcode = ((Instruction) i).getOpcode(); int dim = 1; switch (opcode) { case Constants.NEW: _out.println("il.append(_factory.createNew(\"" + ((ObjectType) type).getClassName() + "\"));"); break; case Constants.MULTIANEWARRAY: dim = ((MULTIANEWARRAY) i).getDimensions(); case Constants.ANEWARRAY: case Constants.NEWARRAY: if (type instanceof ArrayType) { type = ((ArrayType) type).getBasicType(); } _out.println("il.append(_factory.createNewArray(" + BCELifier.printType(type) + ", (short) " + dim + "));"); break; default: throw new RuntimeException("Oops: " + opcode); } }
private void emitCPInstruction(Element xml_inst, CPInstruction inst) { addConstant(xml_inst, inst.getIndex()); }