public void visitExceptionInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, ExceptionInfo exceptionInfo) { // Mark the exception handler if it's relevant. if (!isReachable(exceptionInfo.u2handlerPC) && isReachable(exceptionInfo.u2startPC, exceptionInfo.u2endPC)) { markCode(clazz, method, codeAttribute, exceptionInfo.u2handlerPC); evaluateExceptions = true; } }
public void visitAnySwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SwitchInstruction switchInstruction) { // Mark the branch targets of the default jump offset. markBranchTarget(clazz, method, codeAttribute, offset + switchInstruction.defaultOffset); // Mark the branch targets of the jump offsets. markBranchTargets(clazz, method, codeAttribute, offset, switchInstruction.jumpOffsets); next = false; }
/** * Marks the branch target at the given offset. */ private void markBranchTarget(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset) { boolean oldNext = next; markCode(clazz, method, codeAttribute, offset); next = oldNext; }
public void visitCodeAttribute0(Clazz clazz, Method method, CodeAttribute codeAttribute) { if (DEBUG) { System.out.println("UnreachableCodeRemover: "+clazz.getName()+"."+method.getName(clazz)+method.getDescriptor(clazz)); } reachableCodeMarker.visitCodeAttribute(clazz, method, codeAttribute); codeAttributeEditor.reset(codeAttribute.u4codeLength); codeAttribute.instructionsAccept(clazz, method, this); codeAttributeEditor.visitCodeAttribute(clazz, method, codeAttribute); }
public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction) { // Mark the branch target. markBranchTarget(clazz, method, codeAttribute, offset + branchInstruction.branchOffset); byte opcode = branchInstruction.opcode; if (opcode == InstructionConstants.OP_GOTO || opcode == InstructionConstants.OP_GOTO_W) { next = false; } }
public void visitAnyInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, Instruction instruction) { if (DEBUG) { System.out.println(" "+(reachableCodeMarker.isReachable(offset) ? "+" : "-")+" "+instruction.toString(offset)); } // Is this instruction unreachable? if (!reachableCodeMarker.isReachable(offset)) { // Then delete it. codeAttributeEditor.deleteInstruction(offset); // Visit the instruction, if required. if (extraInstructionVisitor != null) { instruction.accept(clazz, method, codeAttribute, offset, extraInstructionVisitor); } } } }
/** * Marks the branch target at the given offset. */ private void markBranchTarget(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset) { boolean oldNext = next; markCode(clazz, method, codeAttribute, offset); next = oldNext; }
public void visitCodeAttribute0(Clazz clazz, Method method, CodeAttribute codeAttribute) { if (DEBUG) { System.out.println("UnreachableCodeRemover: "+clazz.getName()+"."+method.getName(clazz)+method.getDescriptor(clazz)); } reachableCodeMarker.visitCodeAttribute(clazz, method, codeAttribute); codeAttributeEditor.reset(codeAttribute.u4codeLength); codeAttribute.instructionsAccept(clazz, method, this); codeAttributeEditor.visitCodeAttribute(clazz, method, codeAttribute); }
public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction) { // Mark the branch target. markBranchTarget(clazz, method, codeAttribute, offset + branchInstruction.branchOffset); byte opcode = branchInstruction.opcode; if (opcode == InstructionConstants.OP_GOTO || opcode == InstructionConstants.OP_GOTO_W) { next = false; } }
public void visitAnyInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, Instruction instruction) { if (DEBUG) { System.out.println(" "+(reachableCodeMarker.isReachable(offset) ? "+" : "-")+" "+instruction.toString(offset)); } // Is this instruction unreachable? if (!reachableCodeMarker.isReachable(offset)) { // Then delete it. codeAttributeEditor.deleteInstruction(offset); // Visit the instruction, if required. if (extraInstructionVisitor != null) { instruction.accept(clazz, method, codeAttribute, offset, extraInstructionVisitor); } } } }
public void visitExceptionInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, ExceptionInfo exceptionInfo) { // Mark the exception handler if it's relevant. if (!isReachable(exceptionInfo.u2handlerPC) && isReachable(exceptionInfo.u2startPC, exceptionInfo.u2endPC)) { markCode(clazz, method, codeAttribute, exceptionInfo.u2handlerPC); evaluateExceptions = true; } }
public void visitAnySwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SwitchInstruction switchInstruction) { // Mark the branch targets of the default jump offset. markBranchTarget(clazz, method, codeAttribute, offset + switchInstruction.defaultOffset); // Mark the branch targets of the jump offsets. markBranchTargets(clazz, method, codeAttribute, offset, switchInstruction.jumpOffsets); next = false; }
/** * Marks the branch target at the given offset. */ private void markBranchTarget(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset) { boolean oldNext = next; markCode(clazz, method, codeAttribute, offset); next = oldNext; }
public void visitCodeAttribute0(Clazz clazz, Method method, CodeAttribute codeAttribute) { if (DEBUG) { System.out.println("UnreachableCodeRemover: "+clazz.getName()+"."+method.getName(clazz)+method.getDescriptor(clazz)); } reachableCodeMarker.visitCodeAttribute(clazz, method, codeAttribute); codeAttributeEditor.reset(codeAttribute.u4codeLength); codeAttribute.instructionsAccept(clazz, method, this); codeAttributeEditor.visitCodeAttribute(clazz, method, codeAttribute); }
public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction) { // Mark the branch target. markBranchTarget(clazz, method, codeAttribute, offset + branchInstruction.branchOffset); byte opcode = branchInstruction.opcode; if (opcode == InstructionConstants.OP_GOTO || opcode == InstructionConstants.OP_GOTO_W) { next = false; } }
public void visitAnyInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, Instruction instruction) { if (DEBUG) { System.out.println(" "+(reachableCodeMarker.isReachable(offset) ? "+" : "-")+" "+instruction.toString(offset)); } // Is this instruction unreachable? if (!reachableCodeMarker.isReachable(offset)) { // Then delete it. codeAttributeEditor.deleteInstruction(offset); // Visit the instruction, if required. if (extraInstructionVisitor != null) { instruction.accept(clazz, method, codeAttribute, offset, extraInstructionVisitor); } } } }
public void visitExceptionInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, ExceptionInfo exceptionInfo) { // Mark the exception handler if it's relevant. if (!isReachable(exceptionInfo.u2handlerPC) && isReachable(exceptionInfo.u2startPC, exceptionInfo.u2endPC)) { markCode(clazz, method, codeAttribute, exceptionInfo.u2handlerPC); evaluateExceptions = true; } }
public void visitAnySwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SwitchInstruction switchInstruction) { // Mark the branch targets of the default jump offset. markBranchTarget(clazz, method, codeAttribute, offset + switchInstruction.defaultOffset); // Mark the branch targets of the jump offsets. markBranchTargets(clazz, method, codeAttribute, offset, switchInstruction.jumpOffsets); next = false; }
/** * Marks the branch targets of the given jump offsets for the instruction * at the given offset. */ private void markBranchTargets(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, int[] jumpOffsets) { for (int index = 0; index < jumpOffsets.length; index++) { markCode(clazz, method, codeAttribute, offset + jumpOffsets[index]); } }
public void visitCodeAttribute0(Clazz clazz, Method method, CodeAttribute codeAttribute) { if (DEBUG) { System.out.println("UnreachableCodeRemover: "+clazz.getName()+"."+method.getName(clazz)+method.getDescriptor(clazz)); } reachableCodeMarker.visitCodeAttribute(clazz, method, codeAttribute); codeAttributeEditor.reset(codeAttribute.u4codeLength); codeAttribute.instructionsAccept(clazz, method, this); codeAttributeEditor.visitCodeAttribute(clazz, method, codeAttribute); }