public void fixStack() { for (ClassGen cg : cgs.values()) { for (Method method : cg.getMethods()) { MethodGen mg = new MethodGen(method, cg.getClassName(), cg.getConstantPool()); mg.removeNOPs(); mg.setMaxLocals(); mg.setMaxStack(); cg.replaceMethod(method, mg.getMethod()); logger.debug(String.format("Reset MaxStack and MaxLocals in %s.%s", cg.getClassName(), mg.getName())); } } }
cg.replaceMethod(m, mg.getMethod()); cg.setConstantPool(cpg);
if (branchesSimplified > 0) { logger.debug("simplified " + branchesSimplified + " unconditional branches"); cg.replaceMethod(method, mg.getMethod());
if (branchesSimplified > 0) { logger.debug("simplified " + branchesSimplified + " unconditional branches"); cg.replaceMethod(method, mg.getMethod());
public void replaceCheckMethod() { ClassGen cg = cgs.get(AuthClass); Method method = cg.getMethods()[0]; MethodGen mg = new MethodGen(method, cg.getClassName(), cg.getConstantPool()); InstructionList list = new InstructionList(); list.append(new ICONST(1)); list.append(new IRETURN()); mg.removeExceptionHandlers(); mg.removeLineNumbers(); mg.removeLocalVariables(); mg.removeExceptions(); mg.setInstructionList(list); mg.setMaxLocals(); mg.setMaxStack(); cg.replaceMethod(method, mg.getMethod()); }
mg.setMaxLocals(); mg.setMaxStack(); cg.replaceMethod(m, mg.getMethod());
if (replaced > 0) { logger.debug("replaced " + replaced + " methodrefs in " + m.getName()); cg.replaceMethod(m, mg.getMethod());
mg.setMaxLocals(); mg.setMaxStack(); cg.replaceMethod(method, mg.getMethod()); mg.setMaxLocals(); mg.setMaxStack(); cg.replaceMethod(method, mg.getMethod());
mg.setMaxLocals(); mg.setMaxStack(); cg.replaceMethod(m, mg.getMethod());
mg.setMaxStack(); cg.replaceMethod(m, mg.getMethod()); mserTime.stop();
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()); } } }
mg.setMaxLocals(); mg.setMaxStack(); cg.replaceMethod(method, mg.getMethod());
mg.setMaxLocals(); mg.setMaxStack(); cg.replaceMethod(method, mg.getMethod());
mg.setMaxLocals(); mg.setMaxStack(); cg.replaceMethod(method, mg.getMethod());
mg.setMaxStack(); mg.setMaxLocals(); cg.replaceMethod(method, mg.getMethod());
mg.setMaxLocals(); mg.setMaxStack(); cg.replaceMethod(method, mg.getMethod());
mgen.setMaxLocals(); mgen.setMaxStack(); cg.replaceMethod(method, mgen.getMethod());
mg.setMaxLocals(); mg.setMaxStack(); cg.replaceMethod(method, mg.getMethod());
mgen.setMaxLocals(); mgen.setMaxStack(); cg.replaceMethod(method, mgen.getMethod());
mg.setMaxLocals(); mg.setMaxStack(); cg.replaceMethod(m, mg.getMethod()); continue;