@Override public final String toString() { return "< " + getDeclaringClass().getClassLoader().getName() + ", " + getDeclaringClass().getName() + ", " + selector + " >"; }
private static Atom getLanguage(MethodReference target) { return target .getDeclaringClass() .getClassLoader() .getLanguage(); }
private static Atom getLanguage(MethodReference target) { return target .getDeclaringClass() .getClassLoader() .getLanguage(); }
/** * @return something like: com.foo.bar.createLargeOrder(IILjava/lang/String;Ljava/sql/Date;)Ljava/lang/Integer; */ @Override public String getSignature() { // TODO: check that we're not calling this often. String s = getDeclaringClass().getName().toString().substring(1).replace('/', '.') + '.' + getName() + getDescriptor(); return s; }
/** * @return something like: com.foo.bar.createLargeOrder(IILjava/lang/String;Ljava/sql/Date;)Ljava/lang/Integer; */ @Override public String getSignature() { // TODO: check that we're not calling this often. String s = getDeclaringClass().getName().toString().substring(1).replace('/', '.') + '.' + getName() + getDescriptor(); return s; }
@Override public TypeReference getParameterType(int i) { if (isStatic()) { return method.getParameterType(i); } else { if (i == 0) { return method.getDeclaringClass(); } else { return method.getParameterType(i - 1); } } }
/** * return true iff m represents one of the well-known methods in java.lang.reflect.Arrays that do toString() on an array */ private static boolean isArrayToStringMethod(MethodReference m) { if (m.getDeclaringClass().equals(Arrays)) { if (m.getName().equals(toString)) { return true; } } return false; }
/** * return true iff m represents one of the well-known methods in java.lang.reflect.Arrays that do toString() on an array */ private static boolean isArrayToStringMethod(MethodReference m) { if (m.getDeclaringClass().equals(Arrays)) { if (m.getName().equals(toString)) { return true; } } return false; }
@Override public void visitGet(IGetInstruction instruction) { ClassLoaderReference loader = getReference().getDeclaringClass().getClassLoader(); FieldReference f = FieldReference.findOrCreate(loader, instruction.getClassType(), instruction.getFieldName(), instruction .getFieldType()); fieldsRead.add(f); }
@Override public void visitPut(IPutInstruction instruction) { ClassLoaderReference loader = getReference().getDeclaringClass().getClassLoader(); FieldReference f = FieldReference.findOrCreate(loader, instruction.getClassType(), instruction.getFieldName(), instruction .getFieldType()); fieldsWritten.add(f); }
@Override protected boolean sameMethod(CGNode opNode, String definingMethod) { MethodReference reference = opNode.getMethod().getReference(); String selector = reference.getSelector().toString(); String containingClass = reference.getDeclaringClass().getName().toString(); return definingMethod.equals(containingClass + '/' + selector); }
@Override protected boolean sameMethod(CGNode opNode, String definingMethod) { MethodReference reference = opNode.getMethod().getReference(); String selector = reference.getSelector().toString(); String containingClass = reference.getDeclaringClass().getName().toString(); return definingMethod.equals(containingClass + '/' + selector); }
@Override public void visitNew(NewInstruction instruction) { ClassLoaderReference loader = getReference().getDeclaringClass().getClassLoader(); TypeReference t = ShrikeUtil.makeTypeReference(loader, instruction.getType()); newSites.add(NewSiteReference.make(getProgramCounter(), t)); }
@Override public void visitGet(IGetInstruction instruction) { ClassLoaderReference loader = getReference().getDeclaringClass().getClassLoader(); FieldReference f = FieldReference.findOrCreate(loader, instruction.getClassType(), instruction.getFieldName(), instruction .getFieldType()); fieldsRead.add(f); }
@Override public SSAAbstractInvokeInstruction addDirectCall(int functionVn, int[] argVns, CallSiteReference callSite) { TypeReference type = callSite.getDeclaredTarget().getDeclaringClass(); Atom language = type.getClassLoader().getLanguage(); AbstractRootMethod root = getLanguageRoot(language); return ((ScriptFakeRoot) root).addDirectCall(functionVn, argVns, callSite); } }
protected Predicate<MethodReference> nameFilter(final String name) { return t -> { System.err.println(t + " " + name); return t.getSelector().equals(AstMethodReference.fnSelector) && t.getDeclaringClass().getName().toString().startsWith('L' + name); }; }
public static MethodNamePattern patternForReference(MethodReference methodRef) throws UTFDataFormatException { String className = methodRef.getDeclaringClass().getName().toUnicodeString(); String methodName = methodRef.getName().toUnicodeString(); String descriptor = methodRef.getDescriptor().toUnicodeString(); MethodNamePattern pattern = new MethodNamePattern(className, methodName, descriptor); return pattern; } }
/** * return true iff m represents one of the well-known methods in * java.lang.reflect.Arrays that do some sort of arraycopy */ private static boolean isArrayCopyMethod(MethodReference m) { if (m.getDeclaringClass().equals(Arrays)) { if (m.getName().equals(asList) || m.getName().equals(copyOf) || m.getName().equals(copyOfRange)) { return true; } } return false; }
protected void test(URI[] androidLibs, String mainClass, String javaScopeFile, String... args) throws ClassHierarchyException, IllegalArgumentException, IOException, CancelException, InterruptedException, ClassNotFoundException, SecurityException, InvalidClassFileException, FailureException { AnalysisScope javaScope = CallGraphTestUtil.makeJ2SEAnalysisScope(javaScopeFile, CallGraphTestUtil.REGRESSION_EXCLUSIONS); String javaJarPath = getJavaJar(javaScope); File androidDex = convertJarToDex(javaJarPath); Pair<CallGraph,PointerAnalysis<InstanceKey>> android = makeDalvikCallGraph(androidLibs, null, mainClass, androidDex.getAbsolutePath()); dynamicCG(new File(javaJarPath), mainClass, args); checkEdges(android.fst, t -> t.getDeclaringClass().getClassLoader().equals(ClassLoaderReference.Application)); }
protected static Set<MethodReference> applicationMethods(CallGraph cg) { return processCG(cg, t -> t.getMethod().getReference().getDeclaringClass().getClassLoader().equals(ClassLoaderReference.Application), object -> object.getMethod().getReference()); }