void compareAllVariables(String className, String methodName) throws Exception { println("compareAllVariables for method: " + className + "." + methodName); Method method = getMethod(className, methodName); List localVars; try { localVars = method.variables(); println("\n Success: got a list of all method variables: " + methodName); } catch (com.sun.jdi.AbsentInformationException ex) { failure("\n AbsentInformationException has been thrown"); return; } // We consider N*N combinations for set of N variables int index1 = 0; for (Iterator it1 = localVars.iterator(); it1.hasNext(); index1++) { LocalVariable lv1 = (LocalVariable) it1.next(); int index2 = 0; for (Iterator it2 = localVars.iterator(); it2.hasNext(); index2++) { LocalVariable lv2 = (LocalVariable) it2.next(); println("\n Two variables:"); printVariable(lv1, index1); printVariable(lv2, index2); println(""); if (index1 == index2) { compareTwoEqualVars(lv1, lv2); } else { compareTwoDifferentVars(lv1, lv2); } } } println(""); return; }
public BreakpointRequest setBreakpoint( String clsName, String methodName, String methodSignature) { ReferenceType rt = findReferenceType(clsName); if (rt == null) { rt = resumeToPrepareOf(clsName).referenceType(); } Method method = findMethod(rt, methodName, methodSignature); if (method == null) { throw new IllegalArgumentException("Bad method name/signature"); } BreakpointRequest bpr = eventRequestManager().createBreakpointRequest(method.location()); bpr.setSuspendPolicy(EventRequest.SUSPEND_ALL); bpr.enable(); return bpr; }