/** {@inheritDoc} */ @Override public List<Mutation> apply( MethodNode mn, String className, String methodName, BytecodeInstruction instruction, Frame frame) { JumpInsnNode node = (JumpInsnNode) instruction.getASMNode(); List<Mutation> mutations = new LinkedList<Mutation>(); LabelNode target = node.label; boolean isBoolean = frame.getStack(frame.getStackSize() - 1) == BooleanValueInterpreter.BOOLEAN_VALUE; for (Integer op : getOperators(node.getOpcode(), isBoolean)) { logger.debug("Adding replacement " + op); if (op >= 0) { // insert mutation into bytecode with conditional JumpInsnNode mutation = new JumpInsnNode(op, target); // insert mutation into pool Mutation mutationObject = MutationPool.addMutation( className, methodName, "ReplaceComparisonOperator " + getOp(node.getOpcode()) + " -> " + getOp(op), instruction, mutation, getInfectionDistance(node.getOpcode(), op)); mutations.add(mutationObject); } else { // Replace relational operator with TRUE/FALSE InsnList mutation = new InsnList(); if (opcodesInt.contains(node.getOpcode())) mutation.add(new InsnNode(Opcodes.POP)); else mutation.add(new InsnNode(Opcodes.POP2)); if (op == TRUE) { mutation.add(new LdcInsnNode(1)); } else { mutation.add(new LdcInsnNode(0)); } mutation.add(new JumpInsnNode(Opcodes.IFNE, target)); Mutation mutationObject = MutationPool.addMutation( className, methodName, "ReplaceComparisonOperator " + getOp(node.getOpcode()) + " -> " + op, instruction, mutation, getInfectionDistance(node.getOpcode(), op)); mutations.add(mutationObject); } } return mutations; }
protected String printJumpInsnNode(JumpInsnNode jin, ListIterator<?> it) { String line = nameOpcode(jin.opcode()) + " L" + resolveLabel(jin.label); return line; }