/*private*/ protected InstructionHandle(Instruction i) { setInstruction(i); }
/*private*/protected InstructionHandle(final Instruction i) { setInstruction(i); }
/** * Set new contents. Old instruction is disposed and may not be used anymore. */ public void setInstruction(Instruction i) { super.setInstruction(i); if(!(i instanceof BranchInstruction)) throw new ClassGenException("Assigning " + i + " to branch handle which is not a branch instruction"); bi = (BranchInstruction)i; } }
/** Factory method. */ static InstructionHandle getInstructionHandle( final Instruction i ) { if (ih_list == null) { return new InstructionHandle(i); } final InstructionHandle ih = ih_list; ih_list = ih.next; ih.setInstruction(i); return ih; }
/** Factory method. */ static final InstructionHandle getInstructionHandle(Instruction i) { if(ih_list == null) return new InstructionHandle(i); else { InstructionHandle ih = ih_list; ih_list = ih.next; ih.setInstruction(i); return ih; } }
/** * Set new contents. Old instruction is disposed and may not be used anymore. */ @Override // This is only done in order to apply the additional type check; could be merged with super impl. public void setInstruction( final Instruction i ) { // TODO could be package-protected? super.setInstruction(i); if (!(i instanceof BranchInstruction)) { throw new ClassGenException("Assigning " + i + " to branch handle which is not a branch instruction"); } bi = (BranchInstruction) i; } }
&& !cgs.containsKey(callClass)) { if (GenericMethods.getCallArgTypes(handles[i].getInstruction(), cg.getConstantPool()).length == 0) { handles[i].setInstruction(new NOP()); if (handles[i + 1].getInstruction() instanceof ASTORE) { handles[i + 1].setInstruction(new NOP()); } else { handles[i - 1].setInstruction(new NOP()); handles[i].setInstruction(new NOP()); if (handles[i + 1].getInstruction() instanceof ASTORE) { handles[i + 1].setInstruction(new NOP()); (!callClass.startsWith("org") || callClass.contains("PingBack")) && !cgs.containsKey(callClass)) { handles[i].setInstruction(new NOP()); logger.debug("NOPed out NEW " + callClass); replaced++;
@Test(expected=ClassGenException.class) public void testsetInstructionNull() { final InstructionHandle ih = InstructionHandle.getInstructionHandle(new NOP());// have to start with a valid non BI Assert.assertNotNull(ih); ih.setInstruction(null); Assert.assertNotNull(ih); }
int index = cg.getConstantPool().addString(decrypt(enc)); LDC lc = new LDC(index); handles[i].setInstruction(lc); handles[i + 1].setInstruction(new NOP()); logger.debug(enc + " -> " + decrypt(enc));
int stringRef = cg.getConstantPool().addString(getActualString(cg.getClassName(), con1, con2)); LDC data = new LDC(stringRef); handles[x].setInstruction(data); handles[x + 1].setInstruction(nop); handles[x + 2].setInstruction(nop); handles[x + 3].setInstruction(nop); replaced++; mg.setInstructionList(list);
LDC lc = new LDC(stringRef); NOP nop = new NOP(); handles[i].setInstruction(lc); handles[i + 1].setInstruction(nop); handles[i + 2].setInstruction(nop); replaced++;
@Test(expected=ClassGenException.class) public void testsetInstructionnotI() { final InstructionHandle ih = InstructionHandle.getInstructionHandle(new NOP());// have to start with a valid non BI Assert.assertNotNull(ih); ih.setInstruction(new GOTO(null)); Assert.assertNotNull(ih); }
@Test public void testsetInstructionI() { final InstructionHandle ih = InstructionHandle.getInstructionHandle(new NOP());// have to start with a valid non BI Assert.assertNotNull(ih); ih.setInstruction(new NOP()); Assert.assertNotNull(ih); }
String newz = val.replace(inputScan, substitute); int stringRef = cg.getConstantPool().addString(newz); handle.setInstruction(new LDC(stringRef)); logger.log(val + "->" + newz + " in " + cg.getClassName() + "." + m.getName());
LDC lc = new LDC(stringRef); NOP nop = new NOP(); handles[i].setInstruction(lc); handles[i - 1].setInstruction(nop); replaced++;
int newindex = cg.getConstantPool().addMethodref(newClassName, newMethodName, newSignature); Instruction newInvoke = GenericMethods.getNewInvoke(handle.getInstruction(), newindex); handle.setInstruction(newInvoke); replaced++;
LDC lc = new LDC(stringRef); NOP nop = new NOP(); handles[i].setInstruction(lc); handles[i - 1].setInstruction(nop); replaced++; } else {
LDC lc = new LDC(stringRef); NOP nop = new NOP(); handles[i].setInstruction(lc); handles[i - 1].setInstruction(nop); replaced++;
public void fixPOPs() { for (ClassGen cg : cgs.values()) { int replaced = 0; for (Method method : cg.getMethods()) { //logger.debug("in method " + method.getName()); MethodGen mg = new MethodGen(method, cg.getClassName(), cg.getConstantPool()); InstructionList list = mg.getInstructionList(); if (list == null) { continue; } InstructionHandle[] handles = list.getInstructionHandles(); if (handles[0].getInstruction() instanceof DUP || handles[0].getInstruction() instanceof ASTORE || handles[0].getInstruction() instanceof POP) { handles[0].setInstruction(new NOP()); replaced++; } mg.setInstructionList(list); mg.removeNOPs(); mg.setMaxLocals(); mg.setMaxStack(); cg.replaceMethod(method, mg.getMethod()); } if (replaced > 0) { logger.debug("Removed " + replaced + " invalid POPs in " + cg.getClassName()); } } }
theBranch.setInstruction(new GOTO(((BranchHandle) theBranch).getTarget())); } else { try {