List of usage examples for org.objectweb.asm Opcodes INVOKESTATIC
int INVOKESTATIC
To view the source code for org.objectweb.asm Opcodes INVOKESTATIC.
Click Source Link
From source file:org.evosuite.instrumentation.testability.ComparisonTransformation.java
License:Open Source License
private void insertDoubleComparisonL(AbstractInsnNode position, InsnList list) { MethodInsnNode get = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "doubleSubL", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.DOUBLE_TYPE, Type.DOUBLE_TYPE }), false); list.insert(position, get);//from ww w . j a v a 2 s. c om list.remove(position); }
From source file:org.evosuite.instrumentation.testability.ContainerBooleanInterpreter.java
License:Open Source License
/** {@inheritDoc} */ @Override// w ww . j a v a2 s. com public BasicValue naryOperation(AbstractInsnNode insn, @SuppressWarnings("rawtypes") List values) throws AnalyzerException { if (insn.getOpcode() == Opcodes.INVOKESTATIC) { MethodInsnNode mn = (MethodInsnNode) insn; if (mn.owner.equals(Type.getInternalName(ContainerHelper.class)) && (mn.name.startsWith("collection") || mn.name.startsWith("map"))) { return CONTAINER_BOOLEAN; } } return super.naryOperation(insn, values); }
From source file:org.evosuite.instrumentation.testability.ContainerTransformation.java
License:Open Source License
/** * Replace boolean-returning method calls on Collection classes * //from w ww .ja v a 2s . c o m * @param mn */ @SuppressWarnings("unchecked") public boolean transformMethod(MethodNode mn) { boolean changed = false; ListIterator<AbstractInsnNode> iterator = mn.instructions.iterator(); while (iterator.hasNext()) { AbstractInsnNode node = iterator.next(); if (node instanceof MethodInsnNode) { MethodInsnNode methodNode = (MethodInsnNode) node; if (methodNode.owner.equals("java/util/Collection") || methodNode.owner.equals("java/util/List") || methodNode.owner.equals("java/util/ArrayList") || methodNode.owner.equals("java/util/Set") || methodNode.owner.equals("java/util/Queue") || methodNode.owner.equals("java/util/SortedSet")) { if (methodNode.name.equals("isEmpty")) { logger.debug("Test Transformation of " + methodNode.owner + "." + methodNode.name + " -> " + Type.getInternalName(ContainerHelper.class) + "." + "collectionIsEmpty"); MethodInsnNode n = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(ContainerHelper.class), "collectionIsEmpty", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.getType(Collection.class) }), false); InsnList il = createNewIfThenElse(n); mn.instructions.insertBefore(node, il); mn.instructions.remove(node); TransformationStatistics.transformedContainerComparison(); changed = true; } else if (methodNode.name.equals("contains")) { logger.debug("Test Transformation of " + methodNode.owner + "." + methodNode.name + " -> " + Type.getInternalName(ContainerHelper.class) + "." + "collectionContains"); MethodInsnNode n = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(ContainerHelper.class), "collectionContains", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.getType(Collection.class), Type.getType(Object.class) }), false); InsnList il = createNewIfThenElse(n); mn.instructions.insertBefore(node, il); mn.instructions.remove(node); TransformationStatistics.transformedContainerComparison(); changed = true; } else if (methodNode.name.equals("containsAll")) { logger.debug("Test Transformation of " + methodNode.owner + "." + methodNode.name + " -> " + Type.getInternalName(ContainerHelper.class) + "." + "collectionContainsAll"); MethodInsnNode n = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(ContainerHelper.class), "collectionContainsAll", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.getType(Collection.class), Type.getType(Collection.class) }), false); InsnList il = createNewIfThenElse(n); mn.instructions.insertBefore(node, il); mn.instructions.remove(node); TransformationStatistics.transformedContainerComparison(); changed = true; } } else if (methodNode.owner.equals("java/util/Map")) { if (methodNode.name.equals("isEmpty")) { logger.debug("Test Transformation of " + methodNode.owner + "." + methodNode.name + " -> " + Type.getInternalName(ContainerHelper.class) + "." + "mapIsEmpty"); MethodInsnNode n = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(ContainerHelper.class), "mapIsEmpty", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.getType(Map.class) }), false); InsnList il = createNewIfThenElse(n); mn.instructions.insertBefore(node, il); mn.instructions.remove(node); TransformationStatistics.transformedContainerComparison(); changed = true; } else if (methodNode.name.equals("containsKey")) { logger.debug("Test Transformation of " + methodNode.owner + "." + methodNode.name + " -> " + Type.getInternalName(ContainerHelper.class) + "." + "mapContainsKey"); MethodInsnNode n = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(ContainerHelper.class), "mapContainsKey", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.getType(Map.class), Type.getType(Object.class) }), false); InsnList il = createNewIfThenElse(n); mn.instructions.insertBefore(node, il); mn.instructions.remove(node); TransformationStatistics.transformedContainerComparison(); changed = true; } else if (methodNode.name.equals("containsValue")) { logger.debug("Test Transformation of " + methodNode.owner + "." + methodNode.name + " -> " + Type.getInternalName(ContainerHelper.class) + "." + "mapContainsValue"); MethodInsnNode n = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(ContainerHelper.class), "mapContainsValue", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.getType(Map.class), Type.getType(Object.class) }), false); InsnList il = createNewIfThenElse(n); mn.instructions.insertBefore(node, il); mn.instructions.remove(node); TransformationStatistics.transformedContainerComparison(); changed = true; } } } } return changed; }
From source file:org.evosuite.instrumentation.testability.StringBooleanInterpreter.java
License:Open Source License
/** {@inheritDoc} */ @Override//from w w w . j a v a 2s . com public BasicValue naryOperation(AbstractInsnNode insn, @SuppressWarnings("rawtypes") List values) throws AnalyzerException { if (insn.getOpcode() == Opcodes.INVOKESTATIC) { MethodInsnNode mn = (MethodInsnNode) insn; if (mn.owner.equals(Type.getInternalName(StringHelper.class)) && mn.name.startsWith("String")) { return STRING_BOOLEAN; } } return super.naryOperation(insn, values); }
From source file:org.evosuite.instrumentation.testability.StringTransformation.java
License:Open Source License
/** * Replace boolean-returning method calls on String classes * /*from www .j a v a2s .c o m*/ * @param mn */ @SuppressWarnings("unchecked") private boolean transformStrings(MethodNode mn) { logger.info("Current method: " + mn.name); boolean changed = false; ListIterator<AbstractInsnNode> iterator = mn.instructions.iterator(); while (iterator.hasNext()) { AbstractInsnNode node = iterator.next(); if (node instanceof MethodInsnNode) { MethodInsnNode min = (MethodInsnNode) node; if (min.owner.equals("java/lang/String")) { if (min.name.equals("equals")) { changed = true; MethodInsnNode equalCheck = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(StringHelper.class), "StringEquals", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.getType(String.class), Type.getType(Object.class) }), false); mn.instructions.insertBefore(node, equalCheck); mn.instructions.remove(node); /* MethodInsnNode equalCheck = new MethodInsnNode( Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "StringEqualsCharacterDistance", Type.getMethodDescriptor(Type.DOUBLE_TYPE, new Type[] { Type.getType(String.class), Type.getType(Object.class) })); mn.instructions.insertBefore(node, equalCheck); mn.instructions.insertBefore(node, new LdcInsnNode(0.0)); mn.instructions.insertBefore(node, new InsnNode(Opcodes.DCMPG)); mn.instructions.remove(node); */ TransformationStatistics.transformedStringComparison(); } else if (min.name.equals("equalsIgnoreCase")) { changed = true; MethodInsnNode equalCheck = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(StringHelper.class), "StringEqualsIgnoreCase", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.getType(String.class), Type.getType(String.class) }), false); mn.instructions.insertBefore(node, equalCheck); mn.instructions.remove(node); TransformationStatistics.transformedStringComparison(); } else if (min.name.equals("startsWith")) { changed = true; if (min.desc.equals("(Ljava/lang/String;)Z")) { mn.instructions.insertBefore(node, new InsnNode(Opcodes.ICONST_0)); } MethodInsnNode equalCheck = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(StringHelper.class), "StringStartsWith", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.getType(String.class), Type.getType(String.class), Type.INT_TYPE }), false); mn.instructions.insertBefore(node, equalCheck); mn.instructions.remove(node); TransformationStatistics.transformedStringComparison(); } else if (min.name.equals("endsWith")) { changed = true; MethodInsnNode equalCheck = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(StringHelper.class), "StringEndsWith", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.getType(String.class), Type.getType(String.class) }), false); mn.instructions.insertBefore(node, equalCheck); mn.instructions.remove(node); TransformationStatistics.transformedStringComparison(); } else if (min.name.equals("isEmpty")) { changed = true; MethodInsnNode equalCheck = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(StringHelper.class), "StringIsEmpty", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.getType(String.class) }), false); mn.instructions.insertBefore(node, equalCheck); mn.instructions.remove(node); TransformationStatistics.transformedStringComparison(); } else if (min.name.equals("matches")) { changed = true; MethodInsnNode equalCheck = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(StringHelper.class), "StringMatches", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.getType(String.class), Type.getType(String.class) }), false); mn.instructions.insertBefore(node, equalCheck); mn.instructions.remove(node); TransformationStatistics.transformedStringComparison(); } else if (min.name.equals("regionMatches")) { Type[] argumentTypes = Type.getArgumentTypes(min.desc); if (argumentTypes.length == 4) { changed = true; MethodInsnNode equalCheck = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(StringHelper.class), "StringRegionMatches", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.getType(String.class), Type.INT_TYPE, Type.getType(String.class), Type.INT_TYPE, Type.INT_TYPE }), false); mn.instructions.insertBefore(node, equalCheck); mn.instructions.remove(node); TransformationStatistics.transformedStringComparison(); } else if (argumentTypes.length == 5) { changed = true; MethodInsnNode equalCheck = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(StringHelper.class), "StringRegionMatches", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.getType(String.class), Type.BOOLEAN_TYPE, Type.INT_TYPE, Type.getType(String.class), Type.INT_TYPE, Type.INT_TYPE }), false); mn.instructions.insertBefore(node, equalCheck); mn.instructions.remove(node); TransformationStatistics.transformedStringComparison(); } } } else if (min.owner.equals("java/util/regex/Pattern")) { if (min.name.equals("matches")) { changed = true; MethodInsnNode equalCheck = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(StringHelper.class), "StringMatchRegex", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.getType(String.class), Type.getType(CharSequence.class) }), false); mn.instructions.insertBefore(node, equalCheck); mn.instructions.remove(node); } } else if (min.owner.equals("java/util/regex/Matcher")) { if (min.name.equals("matches")) { changed = true; MethodInsnNode equalCheck = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(StringHelper.class), "StringMatchRegex", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.getType(Matcher.class) }), false); mn.instructions.insertBefore(node, equalCheck); mn.instructions.remove(node); } } } } return changed; }
From source file:org.evosuite.instrumentation.testability.StringTransformation.java
License:Open Source License
private static boolean isStringMethod(AbstractInsnNode node) { if (node.getOpcode() == Opcodes.INVOKESTATIC) { MethodInsnNode methodInsnNode = (MethodInsnNode) node; return methodInsnNode.owner.equals(Type.getInternalName(StringHelper.class)) && methodInsnNode.name.startsWith("String"); }//from w w w .ja v a 2 s .co m return false; }
From source file:org.evosuite.instrumentation.testability.StringTransformation.java
License:Open Source License
/** * <p>/* w ww.ja va2s .c o m*/ * transformMethod * </p> * * @param mn * a {@link org.objectweb.asm.tree.MethodNode} object. * @return a boolean. */ public boolean transformMethod(MethodNode mn) { boolean changed = transformStrings(mn); if (changed) { try { mn.maxStack++; Analyzer a = new Analyzer(new StringBooleanInterpreter()); a.analyze(cn.name, mn); Frame[] frames = a.getFrames(); AbstractInsnNode node = mn.instructions.getFirst(); boolean done = false; while (!done) { if (node == mn.instructions.getLast()) done = true; AbstractInsnNode next = node.getNext(); int index = mn.instructions.indexOf(node); if (index >= frames.length) break; Frame current = frames[index]; if (current == null) break; int size = current.getStackSize(); if (node.getOpcode() == Opcodes.IFNE) { JumpInsnNode branch = (JumpInsnNode) node; if (current.getStack(size - 1) == StringBooleanInterpreter.STRING_BOOLEAN || isStringMethod(node.getPrevious())) { logger.info("IFNE -> IFGT"); branch.setOpcode(Opcodes.IFGT); } } else if (node.getOpcode() == Opcodes.IFEQ) { JumpInsnNode branch = (JumpInsnNode) node; if (current.getStack(size - 1) == StringBooleanInterpreter.STRING_BOOLEAN || isStringMethod(node.getPrevious())) { logger.info("IFEQ -> IFLE"); branch.setOpcode(Opcodes.IFLE); } } else if (node.getOpcode() == Opcodes.IF_ICMPEQ) { JumpInsnNode branch = (JumpInsnNode) node; if (current.getStack(size - 2) == StringBooleanInterpreter.STRING_BOOLEAN || isStringMethod(node.getPrevious().getPrevious())) { if (node.getPrevious().getOpcode() == Opcodes.ICONST_0) { branch.setOpcode(Opcodes.IFLE); mn.instructions.remove(node.getPrevious()); } else if (node.getPrevious().getOpcode() == Opcodes.ICONST_1) { branch.setOpcode(Opcodes.IFGT); mn.instructions.remove(node.getPrevious()); } } } else if (node.getOpcode() == Opcodes.IF_ICMPNE) { JumpInsnNode branch = (JumpInsnNode) node; if (current.getStack(size - 2) == StringBooleanInterpreter.STRING_BOOLEAN || isStringMethod(node.getPrevious().getPrevious())) { if (node.getPrevious().getOpcode() == Opcodes.ICONST_0) { branch.setOpcode(Opcodes.IFGT); mn.instructions.remove(node.getPrevious()); } else if (node.getPrevious().getOpcode() == Opcodes.ICONST_1) { branch.setOpcode(Opcodes.IFLE); mn.instructions.remove(node.getPrevious()); } } } else if (node.getOpcode() == Opcodes.IRETURN) { if (current.getStack(size - 1) == StringBooleanInterpreter.STRING_BOOLEAN || isStringMethod(node.getPrevious())) { logger.info("IFEQ -> IFLE"); MethodInsnNode n = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "intToBoolean", Type.getMethodDescriptor(Type.BOOLEAN_TYPE, new Type[] { Type.INT_TYPE }), false); mn.instructions.insertBefore(node, n); } } node = next; } } catch (Exception e) { logger.warn("EXCEPTION DURING STRING TRANSFORMATION: " + e); return changed; } } return changed; }
From source file:org.evosuite.instrumentation.testability.transformer.BitwiseOperatorTransformer.java
License:Open Source License
@Override protected AbstractInsnNode transformInsnNode(MethodNode mn, InsnNode insnNode) { if (insnNode.getOpcode() == Opcodes.IOR || insnNode.getOpcode() == Opcodes.IAND || insnNode.getOpcode() == Opcodes.IXOR) { if (this.booleanTestabilityTransformation.isBooleanOnStack(mn, insnNode, 0) && this.booleanTestabilityTransformation.isBooleanOnStack(mn, insnNode, 1)) { if (insnNode.getOpcode() == Opcodes.IOR) { MethodInsnNode push = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "IOR", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.INT_TYPE, Type.INT_TYPE })); mn.instructions.insertBefore(insnNode, push); mn.instructions.remove(insnNode); TransformationStatistics.transformedBitwise(); return push; } else if (insnNode.getOpcode() == Opcodes.IAND) { MethodInsnNode push = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "IAND", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.INT_TYPE, Type.INT_TYPE })); mn.instructions.insertBefore(insnNode, push); mn.instructions.remove(insnNode); TransformationStatistics.transformedBitwise(); return push; } else if (insnNode.getOpcode() == Opcodes.IXOR) { MethodInsnNode push = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "IXOR", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.INT_TYPE, Type.INT_TYPE })); mn.instructions.insertBefore(insnNode, push); mn.instructions.remove(insnNode); TransformationStatistics.transformedBitwise(); return push; }//from w ww . ja v a 2 s. com } } return insnNode; }
From source file:org.evosuite.instrumentation.testability.transformer.BooleanCallsTransformer.java
License:Open Source License
@Override protected AbstractInsnNode transformMethodInsnNode(MethodNode mn, MethodInsnNode methodNode) { if (methodNode.owner.equals(Type.getInternalName(BooleanHelper.class))) return methodNode; methodNode.desc = this.booleanTestabilityTransformation.transformMethodDescriptor(methodNode.owner, methodNode.name, methodNode.desc); methodNode.name = DescriptorMapping.getInstance().getMethodName(methodNode.owner, methodNode.name, methodNode.desc);//w w w . j a v a 2s. co m if (DescriptorMapping.getInstance().isBooleanMethod(methodNode.desc)) { BooleanTestabilityTransformation.logger.info("Method needs value transformation: " + methodNode.name); if (DescriptorMapping.getInstance().hasBooleanParameters(methodNode.desc)) { BooleanTestabilityTransformation.logger .info("Method needs parameter transformation: " + methodNode.name); TransformationStatistics.transformBackToBooleanParameter(); int firstBooleanParameterIndex = -1; Type[] types = Type.getArgumentTypes(methodNode.desc); for (int i = 0; i < types.length; i++) { if (types[i].getDescriptor().equals("Z")) { if (firstBooleanParameterIndex == -1) { firstBooleanParameterIndex = i; break; } } } if (firstBooleanParameterIndex != -1) { int numOfPushs = types.length - 1 - firstBooleanParameterIndex; // int numOfPushs = types.length - firstBooleanParameterIndex; if (numOfPushs == 0) { if (!(methodNode.getPrevious().getOpcode() == Opcodes.ICONST_1 || methodNode.getPrevious().getOpcode() == Opcodes.ICONST_0)) { //the boolean parameter is the last parameter MethodInsnNode booleanHelperInvoke = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "intToBoolean", Type.getMethodDescriptor(Type.BOOLEAN_TYPE, new Type[] { Type.INT_TYPE })); mn.instructions.insertBefore(methodNode, booleanHelperInvoke); } } else { InsnList insnlist = new InsnList(); for (int i = 0; i < numOfPushs; i++) { MethodInsnNode booleanHelperPushParameter; if (types[types.length - 1 - i] == Type.BOOLEAN_TYPE || types[types.length - 1 - i] == Type.CHAR_TYPE || types[types.length - 1 - i] == Type.BYTE_TYPE || types[types.length - 1 - i] == Type.SHORT_TYPE || types[types.length - 1 - i] == Type.INT_TYPE || types[types.length - 1 - i] == Type.FLOAT_TYPE || types[types.length - 1 - i] == Type.LONG_TYPE || types[types.length - 1 - i] == Type.DOUBLE_TYPE) { if (types[types.length - 1 - i] == Type.BOOLEAN_TYPE) { booleanHelperPushParameter = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "pushParameter", Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE })); } else { booleanHelperPushParameter = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "pushParameter", Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { types[types.length - 1 - i] })); } } else { booleanHelperPushParameter = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "pushParameter", Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.getType(Object.class) })); } insnlist.add(booleanHelperPushParameter); } for (int i = firstBooleanParameterIndex; i < types.length; i++) { if (i == firstBooleanParameterIndex) { MethodInsnNode booleanHelperInvoke = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "intToBoolean", Type.getMethodDescriptor(Type.BOOLEAN_TYPE, new Type[] { Type.INT_TYPE })); insnlist.add(booleanHelperInvoke); } else { MethodInsnNode booleanHelperPopParameter; boolean objectNeedCast = false; if (types[i] == Type.BOOLEAN_TYPE) { booleanHelperPopParameter = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "popParameterBooleanFromInt", Type.getMethodDescriptor(types[i], new Type[] {})); } else if (types[i] == Type.CHAR_TYPE) { booleanHelperPopParameter = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "popParameterChar", Type.getMethodDescriptor(types[i], new Type[] {})); } else if (types[i] == Type.BYTE_TYPE) { booleanHelperPopParameter = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "popParameterByte", Type.getMethodDescriptor(types[i], new Type[] {})); } else if (types[i] == Type.SHORT_TYPE) { booleanHelperPopParameter = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "popParameterShort", Type.getMethodDescriptor(types[i], new Type[] {})); } else if (types[i] == Type.INT_TYPE) { booleanHelperPopParameter = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "popParameterInt", Type.getMethodDescriptor(types[i], new Type[] {})); } else if (types[i] == Type.FLOAT_TYPE) { booleanHelperPopParameter = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "popParameterFloat", Type.getMethodDescriptor(types[i], new Type[] {})); } else if (types[i] == Type.LONG_TYPE) { booleanHelperPopParameter = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "popParameterLong", Type.getMethodDescriptor(types[i], new Type[] {})); } else if (types[i] == Type.DOUBLE_TYPE) { booleanHelperPopParameter = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "popParameterDouble", Type.getMethodDescriptor(types[i], new Type[] {})); } else { objectNeedCast = true; booleanHelperPopParameter = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "popParameterObject", Type.getMethodDescriptor(Type.getType(Object.class), new Type[] {})); } insnlist.add(booleanHelperPopParameter); if (objectNeedCast) { TypeInsnNode tin = new TypeInsnNode(Opcodes.CHECKCAST, types[i].getInternalName()); insnlist.add(tin); } } } mn.instructions.insertBefore(methodNode, insnlist); } } } if (Type.getReturnType(methodNode.desc).equals(Type.BOOLEAN_TYPE)) { BooleanTestabilityTransformation.logger .info("Method needs return transformation: " + methodNode.name); TransformationStatistics.transformBackToBooleanParameter(); MethodInsnNode n = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "booleanToInt", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.BOOLEAN_TYPE })); mn.instructions.insert(methodNode, n); return n; } } else { BooleanTestabilityTransformation.logger.info("Method needs no transformation: " + methodNode.name); } // TODO: If this is a method that is not transformed, and it requires a Boolean parameter // then we need to convert this boolean back to an int // For example, we could use flow analysis to determine the point where the value is added to the stack // and insert a conversion function there return methodNode; }