public static Iterable<Entrypoint> makeMainEntrypoints(final AnalysisScope scope, final IClassHierarchy cha, final String[] classNames) { if (scope == null) { throw new IllegalArgumentException("scope is null"); } return makeMainEntrypoints(scope.getApplicationLoader(), cha, classNames); }
/** * @return set of all eligible Main classes in the class hierarchy * @throws IllegalArgumentException if scope is null */ public static Iterable<Entrypoint> makeMainEntrypoints(AnalysisScope scope, IClassHierarchy cha) { if (scope == null) { throw new IllegalArgumentException("scope is null"); } return makeMainEntrypoints(scope.getApplicationLoader(), cha); }
/** * @return set of all eligible Main classes in the class hierarchy * @throws IllegalArgumentException if scope is null */ public static Iterable<Entrypoint> makeMainEntrypoints(AnalysisScope scope, IClassHierarchy cha) { if (scope == null) { throw new IllegalArgumentException("scope is null"); } return makeMainEntrypoints(scope.getApplicationLoader(), cha); }
public static Iterable<Entrypoint> makeMainEntrypoints(final AnalysisScope scope, final IClassHierarchy cha, final String[] classNames) { if (scope == null) { throw new IllegalArgumentException("scope is null"); } return makeMainEntrypoints(scope.getApplicationLoader(), cha, classNames); }
/** * Add the application modules to the analysis scope. */ protected void addApplicationModulesToScope() { ClassLoaderReference app = scope.getApplicationLoader(); for (Object o : moduleFiles) { if (!(o instanceof Module)) { Assertions.UNREACHABLE("Unexpected type: " + o.getClass()); } Module M = (Module) o; scope.addToScope(app, M); } }
/** * Add the application modules to the analysis scope. */ protected void addApplicationModulesToScope() { ClassLoaderReference app = scope.getApplicationLoader(); for (Object o : moduleFiles) { if (!(o instanceof Module)) { Assertions.UNREACHABLE("Unexpected type: " + o.getClass()); } Module M = (Module) o; scope.addToScope(app, M); } }
private static void computeClassPath(AnalysisScope scope) { StringBuilder buf = new StringBuilder(); ClassLoaderReference cl = scope.getApplicationLoader(); while (cl != null) { List<Module> modules = scope.getModules(cl); for (Module m : modules) { if (buf.length() > 0) buf.append(File.pathSeparator); if (m instanceof JarFileModule) { JarFileModule jarFileModule = (JarFileModule) m; buf.append(jarFileModule.getAbsolutePath()); } else if (m instanceof DirectoryTreeModule) { DirectoryTreeModule directoryTreeModule = (DirectoryTreeModule) m; buf.append(directoryTreeModule.getPath()); } else Assertions.UNREACHABLE("Module entry is neither jar file nor directory"); } cl = cl.getParent(); } }
@Override protected void addApplicationModulesToScope() { ClassLoaderReference app = scope.getApplicationLoader(); for (Module M : userEntries) { scope.addToScope(app, M); } ClassLoaderReference src = ((JavaSourceAnalysisScope) scope).getSourceLoader(); for (Module M : sourceEntries) { scope.addToScope(src, M); } }
/** * @return true iff klass is loaded by the application loader. */ private static boolean isApplicationClass(AnalysisScope scope, IClass klass) { return scope.getApplicationLoader().equals(klass.getClassLoader().getReference()); } }
/** * @return true iff klass is loaded by the application loader. */ private static boolean isApplicationClass(AnalysisScope scope, IClass klass) { return scope.getApplicationLoader().equals(klass.getClassLoader().getReference()); } }
@Override protected void addApplicationModulesToScope() { ClassLoaderReference app = scope.getApplicationLoader(); for (Module M : userEntries) { scope.addToScope(app, M); } ClassLoaderReference src = ((JavaSourceAnalysisScope) scope).getSourceLoader(); for (Module M : sourceEntries) { scope.addToScope(src, M); } }
private static IClass getIClass(String name) { final TypeReference typeRef = TypeReference.findOrCreate(scope.getApplicationLoader(), name); return cha.lookupClass(typeRef); }
public static String getJavaJar(AnalysisScope javaScope) throws IOException { Module javaJar = javaScope.getModules(javaScope.getApplicationLoader()).iterator().next(); if (javaJar instanceof JarFileModule) { String javaJarPath = ((JarFileModule)javaJar).getAbsolutePath(); return javaJarPath; } else { assert javaJar instanceof NestedJarFileModule : javaJar; File F = File.createTempFile("android", ".jar"); //F.deleteOnExit(); System.err.println(F.getAbsolutePath()); TemporaryFile.streamToFile(F, ((NestedJarFileModule)javaJar).getNestedContents()); return F.getAbsolutePath(); } }
public static IClass getIClass(String name) { final TypeReference typeRef = TypeReference.findOrCreate(scope.getApplicationLoader(), name); return cha.lookupClass(typeRef); }
if ((!klass.isInterface()) && (cha.getScope().getApplicationLoader().equals(klass.getClassLoader().getReference()))) { for (Iterator<IMethod> m_iter = klass.getDeclaredMethods().iterator(); m_iter.hasNext(); ) { method = (IMethod) m_iter.next();
@Test public void testHello() throws ClassHierarchyException, IOException { if (analyzingJar()) return; AnalysisScope scope = null; scope = AnalysisScopeReader.readJavaScope(TestConstants.HELLO, null, MY_CLASSLOADER); // TODO: it's annoying to have to build a class hierarchy here. // see feature 38676 ClassHierarchy cha = ClassHierarchyFactory.make(scope); TypeReference t = TypeReference.findOrCreate(scope.getApplicationLoader(), TestConstants.HELLO_MAIN); IClass klass = cha.lookupClass(t); Assert.assertTrue("failed to load " + t, klass != null); String sourceFile = klass.getSourceFileName(); System.err.println("Source file: " + sourceFile); Assert.assertTrue(sourceFile != null); }
/** * test that getMethod() works even if a declared ancestor interface doesn't * exist */ @Test public void testBug38484() throws ClassHierarchyException, IOException { AnalysisScope scope = null; scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, (new FileProvider()).getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); ClassHierarchy cha = ClassHierarchyFactory.make(scope); TypeReference t = TypeReference.findOrCreateClass(scope.getApplicationLoader(), "cornerCases", "YuckyInterface"); IClass klass = cha.lookupClass(t); Assert.assertTrue(klass != null); IMethod m = klass.getMethod(new Selector(Atom.findOrCreateAsciiAtom("x"), Descriptor.findOrCreateUTF8("()V"))); Assert.assertTrue(m == null); }
.getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); ClassHierarchy cha = ClassHierarchyFactory.make(scope); TypeReference t = TypeReference.findOrCreateClass(scope.getApplicationLoader(), "cornerCases", "AliasNames"); IClass klass = cha.lookupClass(t); Assert.assertTrue(klass != null);
/** * test that type inference works in the presence of a getfield where the * field's declared type cannot be loaded */ @Test public void testBug38540() throws ClassHierarchyException, IOException { AnalysisScope scope = null; scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, (new FileProvider()).getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); AnalysisOptions options = new AnalysisOptions(); ClassHierarchy cha = ClassHierarchyFactory.make(scope); TypeReference t = TypeReference.findOrCreateClass(scope.getApplicationLoader(), "cornerCases", "Main"); IClass klass = cha.lookupClass(t); Assert.assertTrue(klass != null); ShrikeCTMethod m = (ShrikeCTMethod) klass.getMethod(new Selector(Atom.findOrCreateAsciiAtom("foo"), Descriptor .findOrCreateUTF8("()Ljava/lang/Object;"))); Assert.assertTrue(m != null); IR ir = new AnalysisCacheImpl().getSSACache().findOrCreateIR(m, Everywhere.EVERYWHERE, options.getSSAOptions()); TypeInference.make(ir, false); }