List of usage examples for org.objectweb.asm Opcodes IF_ICMPGT
int IF_ICMPGT
To view the source code for org.objectweb.asm Opcodes IF_ICMPGT.
Click Source Link
From source file:org.evosuite.instrumentation.error.ArrayListInstrumentation.java
License:Open Source License
@Override public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { if (owner.equals(LISTNAME)) { if (indexListMethods.contains(name)) { Type[] args = Type.getArgumentTypes(desc); if (args.length == 0) return; if (!args[0].equals(Type.INT_TYPE)) return; Map<Integer, Integer> tempVariables = getMethodCallee(desc); tagBranchStart();//from w w w . j a va2 s . c o m mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, LISTNAME, "size", "()I", false); // index >= size mv.loadLocal(tempVariables.get(0)); insertBranch(Opcodes.IF_ICMPGT, "java/lang/IndexOutOfBoundsException"); // index < 0 mv.loadLocal(tempVariables.get(0)); insertBranch(Opcodes.IFGE, "java/lang/IndexOutOfBoundsException"); tagBranchEnd(); restoreMethodParameters(tempVariables, desc); } } }
From source file:org.evosuite.instrumentation.error.LinkedListInstrumentation.java
License:Open Source License
@Override public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { if (owner.equals(LISTNAME)) { if (emptyListMethods.contains(name)) { // empty Map<Integer, Integer> tempVariables = getMethodCallee(desc); //tagBranchStart(); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, LISTNAME, "isEmpty", "()Z", false); insertBranch(Opcodes.IFLE, "java/util/NoSuchElementException"); //tagBranchEnd(); restoreMethodParameters(tempVariables, desc); } else if (indexListMethods.contains(name)) { Type[] args = Type.getArgumentTypes(desc); if (args.length == 0) return; if (!args[0].equals(Type.INT_TYPE)) return; Map<Integer, Integer> tempVariables = getMethodCallee(desc); tagBranchStart();/* w w w .ja v a2s . c o m*/ mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, LISTNAME, "size", "()I", false); // index >= size mv.loadLocal(tempVariables.get(0)); insertBranch(Opcodes.IF_ICMPGT, "java/lang/IndexOutOfBoundsException"); // index < 0 mv.loadLocal(tempVariables.get(0)); insertBranch(Opcodes.IFGE, "java/lang/IndexOutOfBoundsException"); tagBranchEnd(); restoreMethodParameters(tempVariables, desc); } } }
From source file:org.evosuite.instrumentation.error.ListInstrumentation.java
License:Open Source License
@Override public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { if (owner.equals(LISTNAME)) { if (indexListMethods.contains(name)) { Type[] args = Type.getArgumentTypes(desc); if (args.length == 0) return; if (!args[0].equals(Type.INT_TYPE)) return; Map<Integer, Integer> tempVariables = getMethodCallee(desc); tagBranchStart();/*from w w w .j a v a 2 s. c o m*/ mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, LISTNAME, "size", "()I", false); // index >= size mv.loadLocal(tempVariables.get(0)); insertBranch(Opcodes.IF_ICMPGT, "java/lang/IndexOutOfBoundsException"); // index < 0 mv.loadLocal(tempVariables.get(0)); insertBranch(Opcodes.IFGE, "java/lang/IndexOutOfBoundsException"); tagBranchEnd(); restoreMethodParameters(tempVariables, desc); } } }
From source file:org.evosuite.instrumentation.error.VectorInstrumentation.java
License:Open Source License
@Override public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { if (owner.equals(VECTORNAME)) { if (emptyListMethods.contains(name)) { // empty Map<Integer, Integer> tempVariables = getMethodCallee(desc); //tagBranchStart(); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, VECTORNAME, "isEmpty", "()Z", false); insertBranch(Opcodes.IFLE, "java/util/NoSuchElementException"); // tagBranchEnd(); restoreMethodParameters(tempVariables, desc); } else if (indexListMethods.contains(name)) { Type[] args = Type.getArgumentTypes(desc); if (args.length == 0) return; if (!args[0].equals(Type.INT_TYPE)) return; Map<Integer, Integer> tempVariables = getMethodCallee(desc); tagBranchStart();// w ww. ja va2s . c o m mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, VECTORNAME, "size", "()I", false); // index >= size mv.loadLocal(tempVariables.get(0)); insertBranch(Opcodes.IF_ICMPGT, "java/lang/IndexOutOfBoundsException"); // index < 0 mv.loadLocal(tempVariables.get(0)); insertBranch(Opcodes.IFGE, "java/lang/IndexOutOfBoundsException"); tagBranchEnd(); restoreMethodParameters(tempVariables, desc); } } }
From source file:org.evosuite.instrumentation.mutation.ReplaceComparisonOperator.java
License:Open Source License
private String getOp(int opcode) { switch (opcode) { case Opcodes.IFEQ: case Opcodes.IF_ACMPEQ: case Opcodes.IF_ICMPEQ: return "=="; case Opcodes.IFNE: case Opcodes.IF_ACMPNE: case Opcodes.IF_ICMPNE: return "!="; case Opcodes.IFLT: case Opcodes.IF_ICMPLT: return "<"; case Opcodes.IFLE: case Opcodes.IF_ICMPLE: return "<="; case Opcodes.IFGT: case Opcodes.IF_ICMPGT: return ">"; case Opcodes.IFGE: case Opcodes.IF_ICMPGE: return ">="; case Opcodes.IFNULL: return "= null"; case Opcodes.IFNONNULL: return "!= null"; }/*from w ww .j a va 2 s . c om*/ throw new RuntimeException("Unknown opcode: " + opcode); }
From source file:org.evosuite.instrumentation.mutation.ReplaceComparisonOperator.java
License:Open Source License
/** * <p>getInfectionDistance</p> * * @param opcodeOrig a int./*from w w w. j a v a 2 s .co m*/ * @param opcodeNew a int. * @return a {@link org.objectweb.asm.tree.InsnList} object. */ public InsnList getInfectionDistance(int opcodeOrig, int opcodeNew) { InsnList distance = new InsnList(); switch (opcodeOrig) { case Opcodes.IF_ICMPEQ: case Opcodes.IF_ICMPNE: case Opcodes.IF_ICMPLE: case Opcodes.IF_ICMPLT: case Opcodes.IF_ICMPGE: case Opcodes.IF_ICMPGT: distance.add(new InsnNode(Opcodes.DUP2)); distance.add(new LdcInsnNode(opcodeOrig)); distance.add(new LdcInsnNode(opcodeNew)); distance.add(new MethodInsnNode(Opcodes.INVOKESTATIC, PackageInfo.getNameWithSlash(ReplaceComparisonOperator.class), "getInfectionDistance", "(IIII)D", false)); break; case Opcodes.IFEQ: case Opcodes.IFNE: case Opcodes.IFLE: case Opcodes.IFLT: case Opcodes.IFGE: case Opcodes.IFGT: distance.add(new InsnNode(Opcodes.DUP)); distance.add(new LdcInsnNode(opcodeOrig)); distance.add(new LdcInsnNode(opcodeNew)); distance.add(new MethodInsnNode(Opcodes.INVOKESTATIC, PackageInfo.getNameWithSlash(ReplaceComparisonOperator.class), "getInfectionDistance", "(III)D", false)); break; default: distance.add(new LdcInsnNode(0.0)); } return distance; }
From source file:org.evosuite.instrumentation.mutation.ReplaceComparisonOperator.java
License:Open Source License
/** * <p>getInfectionDistance</p> * * @param left a int./*from w w w . ja v a 2s.c o m*/ * @param right a int. * @param opcodeOrig a int. * @param opcodeNew a int. * @return a double. */ public static double getInfectionDistance(int left, int right, int opcodeOrig, int opcodeNew) { long val = (long) left - (long) right; switch (opcodeOrig) { case Opcodes.IF_ICMPLT: switch (opcodeNew) { case Opcodes.IF_ICMPLE: // Only differs for val == 0 return Math.abs(val); case Opcodes.IF_ICMPEQ: // Only differs for val <= 0 return val > 0 ? val : 0.0; case Opcodes.IF_ICMPGT: // Only same for val == 0 return val == 0 ? 1.0 : 0.0; case Opcodes.IF_ICMPGE: // Always differs return 0.0; case Opcodes.IF_ICMPNE: // Only differs for val > 0 return val <= 0 ? Math.abs(val) + 1.0 : 0.0; case TRUE: return val < 0 ? 1.0 : 0.0; case FALSE: return val < 0 ? 0.0 : 1.0; } case Opcodes.IF_ICMPLE: switch (opcodeNew) { case Opcodes.IF_ICMPLT: // Only differs for val == 0 return Math.abs(val); case Opcodes.IF_ICMPEQ: return val >= 0 ? val + 1.0 : 0.0; case Opcodes.IF_ICMPGE: // Only equals for val == 0 return val == 0 ? 1.0 : 0.0; case Opcodes.IF_ICMPGT: // Always differs return 0.0; case Opcodes.IF_ICMPNE: // Only differs if val >= 0 return val < 0 ? Math.abs(val) : 0.0; case TRUE: return val <= 0 ? 1.0 : 0.0; case FALSE: return val <= 0 ? 0.0 : 1.0; } case Opcodes.IF_ICMPGT: switch (opcodeNew) { case Opcodes.IF_ICMPGE: // Only differs for val == 0 return Math.abs(val); case Opcodes.IF_ICMPEQ: // Only differs for val >= 0 return val < 0 ? Math.abs(val) : 0.0; case Opcodes.IF_ICMPLT: // Only same for val == 0 return val == 0 ? 1.0 : 0.0; case Opcodes.IF_ICMPLE: // Always differs return 0.0; case Opcodes.IF_ICMPNE: // Only differs for val < 0 return val >= 0 ? val + 1.0 : 0.0; case TRUE: return val > 0 ? 1.0 : 0.0; case FALSE: return val > 0 ? 0.0 : 1.0; } case Opcodes.IF_ICMPGE: switch (opcodeNew) { case Opcodes.IF_ICMPGT: // Only differs for val == 0 return Math.abs(val); case Opcodes.IF_ICMPEQ: return val <= 0 ? Math.abs(val) + 1.0 : 0.0; case Opcodes.IF_ICMPLE: // Only equals for val == 0 return val == 0 ? 1.0 : 0.0; case Opcodes.IF_ICMPLT: // Always differs return 0.0; case Opcodes.IF_ICMPNE: // Only differs if val > 0 return val > 0 ? val : 0.0; case TRUE: return val >= 0 ? 1.0 : 0.0; case FALSE: return val >= 0 ? 0.0 : 1.0; } case Opcodes.IF_ICMPEQ: switch (opcodeNew) { case Opcodes.IF_ICMPLT: // Only differs if val <= 0 return val > 0 ? val : 0.0; case Opcodes.IF_ICMPGT: // Only differs if val >= 0 return val < 0 ? Math.abs(val) : 0.0; case Opcodes.IF_ICMPNE: // Always differs return 0.0; case Opcodes.IF_ICMPLE: return val >= 0 ? val + 1.0 : 0.0; case Opcodes.IF_ICMPGE: return val <= 0 ? Math.abs(val) + 1.0 : 0.0; case TRUE: return val == 0 ? 1.0 : 0.0; case FALSE: return val == 0 ? 0.0 : 1.0; } case Opcodes.IF_ICMPNE: switch (opcodeNew) { case Opcodes.IF_ICMPEQ: return 0.0; case Opcodes.IF_ICMPLT: // Only differs for val > 0 return val <= 0 ? Math.abs(val) + 1.0 : 0.0; case Opcodes.IF_ICMPLE: // Only differs for val > 0 return val < 0 ? Math.abs(val) : 0.0; case Opcodes.IF_ICMPGT: return val >= 0 ? val + 1.0 : 0.0; case Opcodes.IF_ICMPGE: return val > 0 ? val : 0.0; case TRUE: return val != 0 ? 1.0 : 0.0; case FALSE: return val != 0 ? 0.0 : 1.0; } } throw new RuntimeException("Unknown operator replacement: " + opcodeOrig + " -> " + opcodeNew); }
From source file:org.evosuite.instrumentation.mutation.ReplaceComparisonOperator.java
License:Open Source License
private int getBooleanIntIntReplacement(int opcode) { logger.debug("Getting Boolean int int replacement"); switch (opcode) { case Opcodes.IF_ICMPEQ: return Opcodes.IF_ICMPNE; case Opcodes.IF_ICMPNE: return Opcodes.IF_ICMPEQ; case Opcodes.IF_ICMPGT: return Opcodes.IF_ICMPEQ; case Opcodes.IF_ICMPLE: return Opcodes.IF_ICMPGT; // The rest should not occur except if our interpreter did something wrong case Opcodes.IF_ICMPGE: return Opcodes.IF_ICMPLT; case Opcodes.IF_ICMPLT: return Opcodes.IF_ICMPGE; }//from www .ja va2s .c om throw new RuntimeException("Illegal opcode received: " + opcode); }
From source file:org.evosuite.instrumentation.mutation.ReplaceComparisonOperator.java
License:Open Source License
private Set<Integer> getIntIntReplacement(int opcode) { logger.info("Getting int int replacement"); Set<Integer> replacement = new HashSet<Integer>(); switch (opcode) { case Opcodes.IF_ICMPEQ: replacement.add(Opcodes.IF_ICMPGE); replacement.add(Opcodes.IF_ICMPLE); // False/*from ww w . ja v a 2 s. c o m*/ replacement.add(FALSE); break; case Opcodes.IF_ICMPNE: replacement.add(Opcodes.IF_ICMPLT); replacement.add(Opcodes.IF_ICMPGT); // True replacement.add(TRUE); break; case Opcodes.IF_ICMPGT: replacement.add(Opcodes.IF_ICMPGE); replacement.add(Opcodes.IF_ICMPNE); // False replacement.add(FALSE); break; case Opcodes.IF_ICMPLE: replacement.add(Opcodes.IF_ICMPLT); replacement.add(Opcodes.IF_ICMPEQ); // True replacement.add(TRUE); break; case Opcodes.IF_ICMPGE: replacement.add(Opcodes.IF_ICMPGT); replacement.add(Opcodes.IF_ICMPEQ); // True replacement.add(TRUE); break; case Opcodes.IF_ICMPLT: replacement.add(Opcodes.IF_ICMPLE); replacement.add(Opcodes.IF_ICMPNE); // False replacement.add(FALSE); break; } return replacement; }
From source file:org.evosuite.instrumentation.mutation.TestComparisonOperator.java
License:Open Source License
@Test public void testComparisonTwoEQ() { // x == 0 vs x != 0 assertEquals(0.0,//from ww w. j av a2s. c o m ReplaceComparisonOperator.getInfectionDistance(0, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPNE), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPNE), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPNE), 0.0); // x == 0 vs x < 0 assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPLT), 0.0); assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(1, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPLT), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPLT), 0.0); // x == 0 vs x <= 0 assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(0, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPLE), 0.0); assertEquals(2.0, ReplaceComparisonOperator.getInfectionDistance(1, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPLE), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(-1, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPLE), 0.0); // x == 0 vs x > 0 assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(0, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPGT), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPGT), 0.0); assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(-1, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPGT), 0.0); // x == 0 vs x >= 0 assertEquals(1.0, ReplaceComparisonOperator.getInfectionDistance(0, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPGE), 0.0); assertEquals(0.0, ReplaceComparisonOperator.getInfectionDistance(1, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPGE), 0.0); assertEquals(2.0, ReplaceComparisonOperator.getInfectionDistance(-1, 0, Opcodes.IF_ICMPEQ, Opcodes.IF_ICMPGE), 0.0); }