private static void addCall(HashMap<MethodEntry, Set<MethodEntry>> calls, String sourceClassName, String sourceMethodName, String sourceDescriptor, String targetClassName, String targetMethodName, String targetDescriptor) { MethodEntry sourceEntry = new MethodEntry(sourceClassName, sourceMethodName, sourceDescriptor); MethodEntry targetEntry = new MethodEntry(targetClassName, targetMethodName, targetDescriptor); if (!calls.containsKey(sourceEntry)) { calls.put(sourceEntry, new HashSet<MethodEntry>()); } calls.get(sourceEntry).add(targetEntry); }
public void addUpdatesFieldMethod(String className, String methodName, String descriptor) { String classNameWithDots = className.replace('/', '.'); MethodEntry entry = new MethodEntry(classNameWithDots, methodName, descriptor); updateFieldMethodList.add(entry); }
/** * Returns if a Method is <code>cheap-pure</code> * @param method * @return true if the method is cheap-pure, otherwise false. */ public boolean isPure(java.lang.reflect.Method method) { // Using getName rather than getCanonicalName because that's what // the inheritancetree also uses String className = method.getDeclaringClass().getName(); if (MockList.isAMockClass(className)) { className = method.getDeclaringClass().getSuperclass().getName(); } String methodName = method.getName(); String descriptor = Type.getMethodDescriptor(method); MethodEntry entry = new MethodEntry(className, methodName, descriptor); boolean isPureValue = isPure(entry); return isPureValue; }
if (!entry.className.equals(subclassName)) { MethodEntry subclassEntry = new MethodEntry(subclassName, entry.methodName, entry.descriptor);
private boolean isPureSuperclass(MethodEntry entry, Stack<MethodEntry> callStack) { InheritanceTree inheritanceTree = TestCluster.getInheritanceTree(); for (String superClassName : inheritanceTree .getOrderedSuperclasses(entry.className)) { if (superClassName.equals(entry.className)) continue; MethodEntry superEntry = new MethodEntry(superClassName, entry.methodName, entry.descriptor); if (!callStack.contains(superEntry) && methodsWithBodies.contains(superEntry)) { // We can conclude the purity of this method because // we found an implementation in a super class for it Stack<MethodEntry> newStack = new Stack<MethodEntry>(); newStack.addAll(callStack); newStack.add(superEntry); boolean purityValueForSuperClass = isPure(superEntry, newStack); return purityValueForSuperClass; } } // We cannot conclusive decide if the // method is pure or not, so we fail // to default purity value return DEFAULT_PURITY_VALUE; }
public void addMethodWithBody(String className, String methodName, String methodDescriptor) { MethodEntry entry = new MethodEntry(className, methodName, methodDescriptor); methodsWithBodies.add(entry); }
public void addMethod(String className, String methodName, String methodDescriptor) { MethodEntry entry = new MethodEntry(className, methodName, methodDescriptor); methodEntries.add(entry); }
public void addInterfaceMethod(String className, String methodName, String methodDescriptor) { MethodEntry entry = new MethodEntry(className, methodName, methodDescriptor); interfaceMethodEntries.add(entry); }
/** * Returns if the method is cheap-pure. * * @param className The declaring class name * @param methodName The method name * @param descriptor The method descriptor * @return true if the method is cheap-pure, false otherwise */ public boolean isPure(String className, String methodName, String descriptor) { MethodEntry entry = new MethodEntry(className, methodName, descriptor); return isPure(entry); }