/** * Return true if the clone already contains a method that would resolve to this method, this is * the test that mimics virtual dispatch, so we don't clone in methods that would not be called. */ private boolean containsMethod(String signature) { // check this class for the method with polymorpism String mName = SootUtils.grabName(signature); String[] args = SootUtils.grabArgs(signature); String rtype = SootUtils.grabReturnType(signature); for (SootMethod curr : methods) { if (!curr.getName().equals(mName) || curr.getParameterCount() != args.length) continue; // check the return types Type returnType = SootUtils.toSootType(rtype); if (!SootUtils.isSubTypeOfIncluding(returnType, curr.getReturnType())) continue; boolean foundIncompArg = false; for (int i = 0; i < args.length; i++) { if (!SootUtils.isSubTypeOfIncluding( SootUtils.toSootType(args[i]), curr.getParameterType(i))) { foundIncompArg = true; continue; } } // at least one parameter does not match! if (foundIncompArg) continue; return true; } // didn't find it return false; }