/** {@inheritDoc} */ @Override public void visitLdcInsn(Object cst) { // constantPool.add(cst); if (DependencyAnalysis.isTargetClassName(className)) { poolManager.addSUTConstant(cst); } else { poolManager.addNonSUTConstant(cst); } super.visitLdcInsn(cst); }
/** {@inheritDoc} */ @Override public MethodVisitor visitMethod(int methodAccess, String name, String descriptor, String signature, String[] exceptions) { MethodVisitor mv = super.visitMethod(methodAccess, name, descriptor, signature, exceptions); /* String classNameWithDots = Utils.getClassNameFromResourcePath(className); if (REPLACE_STRING && (classNameWithDots.equals(target_class) || (classNameWithDots.startsWith(target_class + "$")))) { mv = new StringReplacementMethodAdapter(methodAccess, descriptor, mv); } */ if (DependencyAnalysis.isTargetClassName(className)) { for (Type argumentType : Type.getArgumentTypes(descriptor)) { poolManager.addSUTConstant(argumentType); } } mv = new PrimitivePoolMethodAdapter(mv, className); return mv; }
@Override public void visitInnerClass(String name, String outerName, String innerName, int access) { if ((access & Opcodes.ACC_PUBLIC) == Opcodes.ACC_PUBLIC) { if (DependencyAnalysis.isTargetClassName(className)) { Type type = Type.getObjectType(name); poolManager.addSUTConstant(type); } } super.visitInnerClass(name, outerName, innerName, access); } }
/** {@inheritDoc} */ @Override public void visitIntInsn(int opcode, int operand) { if (opcode == Opcodes.BIPUSH || opcode == Opcodes.SIPUSH) { // constantPool.add(operand); if (DependencyAnalysis.isTargetClassName(className)) { poolManager.addSUTConstant(operand); } else { poolManager.addNonSUTConstant(operand); } } super.visitIntInsn(opcode, operand); }
/** * Determine if the given method should be instrumented * * @param className * @param methodName * @return */ public static boolean shouldInstrument(String className, String methodName) { // Always analyze if it is a target class if (isTargetClassName(className)) return true; // Also analyze if it is a superclass and instrument_parent = true if (Properties.INSTRUMENT_PARENT) { if (inheritanceTree.getSuperclasses(Properties.TARGET_CLASS).contains(className)) return true; } // Also analyze if it is in the calltree and we are considering the // context if (Properties.INSTRUMENT_CONTEXT) { CallGraph callGraph = callGraphs.get(Properties.TARGET_CLASS); if (callGraph != null && callGraph.isCalledMethod(className, methodName)){ if(Properties.INSTRUMENT_LIBRARIES || DependencyAnalysis.isTargetProject(className)) return true; } } return false; }
/** * Determine if the given class should be analyzed or instrumented * * @param className * @return */ public static boolean shouldAnalyze(String className) { // Always analyze if it is a target class if (isTargetClassName(className)) return true; if (inheritanceTree == null) { return false; } // Also analyze if it is a superclass and instrument_parent = true if (Properties.INSTRUMENT_PARENT) { if (inheritanceTree.getSuperclasses(Properties.TARGET_CLASS).contains(className)) return true; } // Also analyze if it is in the calltree and we are considering the // context if (Properties.INSTRUMENT_CONTEXT || ArrayUtil.contains(Properties.CRITERION, Criterion.DEFUSE)) { CallGraph callGraph = callGraphs.get(Properties.TARGET_CLASS); if (callGraph != null && callGraph.isCalledClass(className)) { return true; } } return false; }
if (DependencyAnalysis.isTargetClassName(className)) { poolManager.addSUTConstant(constant); } else {
/** {@inheritDoc} */ @Override public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { // We don't use serial numbers because they can be very long and are not used in any branches if (!"serialVersionUID".equals(name)) { if (DependencyAnalysis.isTargetClassName(className)) { poolManager.addSUTConstant(value); poolManager.addSUTConstant(Type.getType(desc)); } else { poolManager.addNonSUTConstant(value); } if(isEnum) { // static final values in enums are likely enum values if((access & Opcodes.ACC_FINAL) == Opcodes.ACC_FINAL && (access & Opcodes.ACC_STATIC) == Opcodes.ACC_STATIC) { if (DependencyAnalysis.isTargetClassName(className)) { poolManager.addSUTConstant(name); } else { poolManager.addNonSUTConstant(name); } } } // primitive_pool.add(value); } return super.visitField(access, name, desc, signature, value); }
for (int key : keys) { if (DependencyAnalysis.isTargetClassName(className)) { poolManager.addSUTConstant(key); } else {
if (! DependencyAnalysis.isTargetClassName(className)) return goals; if (methodName.equals("hashCode"))