List of usage examples for org.objectweb.asm Opcodes INVOKEVIRTUAL
int INVOKEVIRTUAL
To view the source code for org.objectweb.asm Opcodes INVOKEVIRTUAL.
Click Source Link
From source file:org.evosuite.graphs.cfg.BytecodeInstructionPool.java
License:Open Source License
/** * Determine how many bytes the current instruction occupies together with * its operands//from w w w. j a v a 2 s. c o m * * @return */ private int getBytecodeIncrement(AbstractInsnNode instructionNode) { int opcode = instructionNode.getOpcode(); switch (opcode) { case Opcodes.ALOAD: // index case Opcodes.ASTORE: // index case Opcodes.DLOAD: case Opcodes.DSTORE: case Opcodes.FLOAD: case Opcodes.FSTORE: case Opcodes.ILOAD: case Opcodes.ISTORE: case Opcodes.LLOAD: case Opcodes.LSTORE: VarInsnNode varNode = (VarInsnNode) instructionNode; if (varNode.var > 3) return 1; else return 0; case Opcodes.BIPUSH: // byte case Opcodes.NEWARRAY: case Opcodes.RET: return 1; case Opcodes.LDC: LdcInsnNode ldcNode = (LdcInsnNode) instructionNode; if (ldcNode.cst instanceof Double || ldcNode.cst instanceof Long) return 2; // LDC2_W else return 1; case 19: //LDC_W case 20: //LDC2_W return 2; case Opcodes.ANEWARRAY: // indexbyte1, indexbyte2 case Opcodes.CHECKCAST: // indexbyte1, indexbyte2 case Opcodes.GETFIELD: case Opcodes.GETSTATIC: case Opcodes.GOTO: case Opcodes.IF_ACMPEQ: case Opcodes.IF_ACMPNE: case Opcodes.IF_ICMPEQ: case Opcodes.IF_ICMPNE: case Opcodes.IF_ICMPGE: case Opcodes.IF_ICMPGT: case Opcodes.IF_ICMPLE: case Opcodes.IF_ICMPLT: case Opcodes.IFLE: case Opcodes.IFLT: case Opcodes.IFGE: case Opcodes.IFGT: case Opcodes.IFNE: case Opcodes.IFEQ: case Opcodes.IFNONNULL: case Opcodes.IFNULL: case Opcodes.IINC: case Opcodes.INSTANCEOF: case Opcodes.INVOKESPECIAL: case Opcodes.INVOKESTATIC: case Opcodes.INVOKEVIRTUAL: case Opcodes.JSR: case Opcodes.NEW: case Opcodes.PUTFIELD: case Opcodes.PUTSTATIC: case Opcodes.SIPUSH: // case Opcodes.LDC_W // case Opcodes.LDC2_W return 2; case Opcodes.MULTIANEWARRAY: return 3; case Opcodes.INVOKEDYNAMIC: case Opcodes.INVOKEINTERFACE: return 4; case Opcodes.LOOKUPSWITCH: case Opcodes.TABLESWITCH: // TODO: Could be more return 4; // case Opcodes.GOTO_W // case Opcodes.JSR_W } return 0; }
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 www. 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.DequeInstrumentation.java
License:Open Source License
@Override public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { if (listNames.contains(owner)) { if (emptyListMethods.contains(name)) { // empty Map<Integer, Integer> tempVariables = getMethodCallee(desc); tagBranchStart();/*w ww . j ava 2 s. c o m*/ mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, owner, "isEmpty", "()Z", false); insertBranchWithoutTag(Opcodes.IFLE, "java/util/NoSuchElementException"); tagBranchEnd(); restoreMethodParameters(tempVariables, desc); } } }
From source file:org.evosuite.instrumentation.error.LinkedHashSetInstrumentation.java
License:Open Source License
@Override public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { if (owner.equals(SETNAME)) { if (emptyListMethods.contains(name)) { // empty Map<Integer, Integer> tempVariables = getMethodCallee(desc); tagBranchStart();/*from w ww . jav a 2 s . com*/ mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, SETNAME, "isEmpty", "()Z", false); insertBranchWithoutTag(Opcodes.IFLE, "java/util/NoSuchElementException"); 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();//from www. ja v a 2s . 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 ww . j av a 2 s. c om*/ 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.NullPointerExceptionInstrumentation.java
License:Open Source License
@Override public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { // If non-static, add a null check // TODO: Do we need to also check INVOKESPECIAL? if (opcode == Opcodes.INVOKEVIRTUAL || opcode == Opcodes.INVOKEINTERFACE) { Type[] args = Type.getArgumentTypes(desc); Map<Integer, Integer> to = new HashMap<Integer, Integer>(); for (int i = args.length - 1; i >= 0; i--) { int loc = mv.newLocal(args[i]); mv.storeLocal(loc);//from w ww . j a v a 2s. c o m to.put(i, loc); } mv.dup();//callee insertBranch(Opcodes.IFNONNULL, "java/lang/NullPointerException"); for (int i = 0; i < args.length; i++) { mv.loadLocal(to.get(i)); } } }
From source file:org.evosuite.instrumentation.error.QueueInstrumentation.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();/*w ww .j a v a 2 s .c om*/ mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, LISTNAME, "isEmpty", "()Z", false); insertBranchWithoutTag(Opcodes.IFLE, "java/util/NoSuchElementException"); tagBranchEnd(); restoreMethodParameters(tempVariables, desc); } } }
From source file:org.evosuite.instrumentation.error.StackInstrumentation.java
License:Open Source License
@Override public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { if (owner.equals(LISTNAME)) { if (emptyStackMethods.contains(name)) { // empty 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, "empty", "()Z", false); insertBranchWithoutTag(Opcodes.IFLE, "java/util/EmptyStackException"); 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 . java 2 s . 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); } } }