add some variants of existing methods to be independent of scandroid specific stuff
This commit is contained in:
parent
e82155e27b
commit
cc239d5803
|
@ -38,6 +38,7 @@
|
|||
|
||||
package com.ibm.wala.dalvik.dex.util.config;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
@ -49,6 +50,7 @@ import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
|||
import com.ibm.wala.shrikeCT.InvalidClassFileException;
|
||||
import com.ibm.wala.types.ClassLoaderReference;
|
||||
import com.ibm.wala.util.config.AnalysisScopeReader;
|
||||
import com.ibm.wala.util.config.FileOfClasses;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
|
||||
/**
|
||||
|
@ -64,6 +66,19 @@ public class DexAnalysisScopeReader extends AnalysisScopeReader {
|
|||
private static final String BASIC_FILE = /**"conf" + File.separator
|
||||
+ */"primordial.txt";
|
||||
|
||||
|
||||
|
||||
public static AnalysisScope makeAndroidBinaryAnalysisScope(String classPath, String exclusions) throws IOException {
|
||||
if (classPath == null) {
|
||||
throw new IllegalArgumentException("classPath null");
|
||||
}
|
||||
|
||||
AnalysisScope scope = AnalysisScope.createJavaAnalysisScope();
|
||||
scope.setExclusions(new FileOfClasses(new ByteArrayInputStream(exclusions.getBytes())));
|
||||
ClassLoaderReference loader = scope.getLoader(AnalysisScope.APPLICATION);
|
||||
addClassPathToScope(classPath, scope, loader);
|
||||
return scope;
|
||||
}
|
||||
/**
|
||||
* @param classPath
|
||||
* class path to analyze, delimited by File.pathSeparator
|
||||
|
|
|
@ -134,31 +134,7 @@ public class AndroidAnalysisContext {
|
|||
ClassHierarchyException, URISyntaxException {
|
||||
logger.debug(DefaultSCanDroidOptions.dumpString(options));
|
||||
this.options = options;
|
||||
scope = DexAnalysisScopeReader.makeAndroidBinaryAnalysisScope(
|
||||
options.getClasspath(), exclusions);
|
||||
|
||||
scope.setLoaderImpl(ClassLoaderReference.Application,
|
||||
"com.ibm.wala.dalvik.classLoader.WDexClassLoaderImpl");
|
||||
|
||||
scope.setLoaderImpl(ClassLoaderReference.Primordial,
|
||||
"com.ibm.wala.dalvik.classLoader.WDexClassLoaderImpl");
|
||||
|
||||
// TODO: this check is case-sensitive :(
|
||||
URI androidLib = options.getAndroidLibrary();
|
||||
if (androidLib.getPath().endsWith(".dex")) {
|
||||
Module dexMod = new DexFileModule(new File(androidLib));
|
||||
|
||||
// Iterator<ModuleEntry> mitr = dexMod.getEntries();
|
||||
// while (mitr.hasNext()) {
|
||||
// ModuleEntry moduleEntry = (ModuleEntry) mitr.next();
|
||||
// logger.error("dex module: {}", moduleEntry.getName());
|
||||
// }
|
||||
|
||||
scope.addToScope(ClassLoaderReference.Primordial, dexMod);
|
||||
} else {
|
||||
scope.addToScope(ClassLoaderReference.Primordial, new JarFile(new File(
|
||||
androidLib)));
|
||||
}
|
||||
scope = AndroidAnalysisScope.setUpAndroidAnalysisScope(options.getAndroidLibrary(), options.getClasspath(), exclusions);
|
||||
|
||||
|
||||
cha = ClassHierarchy.make(scope);
|
||||
|
@ -173,6 +149,8 @@ public class AndroidAnalysisContext {
|
|||
}
|
||||
Warnings.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ContextSelector, entry points, reflection options, IR Factory, call graph
|
||||
// type, include library
|
||||
|
|
Loading…
Reference in New Issue