@Test public void testRun() { ClassGroup group = ClassGroupFactory.generateGroup(); Code code = group.findClass("test").findMethod("func").getCode(); Instructions ins = code.getInstructions(); code.setMaxStack(3); CheckCast checkCast = new CheckCast(ins); checkCast.setType(new Type("test")); Instruction[] instructions = { new LDC(ins, 2), new AConstNull(ins), checkCast, new LDC(ins, 2), new IAdd(ins), new Return(ins, InstructionType.IRETURN) }; for (Instruction i : instructions) { ins.addInstruction(i); } Assert.assertEquals(6, ins.getInstructions().size()); CastNull lvt = new CastNull(); lvt.run(group); Assert.assertEquals(5, ins.getInstructions().size()); Optional<Instruction> o = ins.getInstructions().stream().filter(i -> i instanceof CheckCast).findAny(); Assert.assertFalse(o.isPresent()); }
@Override public void run(ClassGroup group) { Execution execution = new Execution(group); execution.addExecutionVisitor(i -> visit(i)); execution.addMethodContextVisitor(i -> visit(i)); execution.populateInitialMethods(); execution.run(); logger.info("Removed {} casts on null", removed); }
CastNull implements Deobfuscator { @Override public void run(ClassGroup group) { Execution execution = new Execution(group); execution.addExecutionVisitor(i -> visit(i)); execution.addMethodContextVisitor(i -> visit(i)); execution.populateInitialMethods(); execution.run(); logger.info("Removed {} casts on null", removed); } }
CastNull implements Deobfuscator { @Override public void run(ClassGroup group) { Execution execution = new Execution(group); execution.addExecutionVisitor(i -> visit(i)); execution.addMethodContextVisitor(i -> visit(i)); execution.populateInitialMethods(); execution.run(); logger.info("Removed {} casts on null", removed); }  }
CastNull implements Deobfuscator { @Override public void run(ClassGroup group) { Execution execution = new Execution(group); execution.addExecutionVisitor(i -> visit(i)); execution.addMethodContextVisitor(i -> visit(i)); execution.populateInitialMethods(); execution.run(); logger.info("Removed {} casts on null", removed); }  @Override void run(ClassGroup group); }
CastNull implements Deobfuscator { @Override public void run(ClassGroup group) { Execution execution = new Execution(group); execution.addExecutionVisitor(i -> visit(i)); execution.addMethodContextVisitor(i -> visit(i)); execution.populateInitialMethods(); execution.run(); logger.info("Removed {} casts on null", removed); }  @Override void run(ClassGroup group);  }