Package soot
Class SourceLocator
- java.lang.Object
-
- soot.SourceLocator
-
- Direct Known Subclasses:
ModulePathSourceLocator
public class SourceLocator extends Object
Provides utility methods to retrieve an input stream for a class name, given a classfile, or jimple or baf output files.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classSourceLocator.ClassSourceType
-
Field Summary
Fields Modifier and Type Field Description protected Set<ClassLoader>additionalClassLoadersprotected com.google.common.cache.LoadingCache<String,Set<String>>archivePathToEntriesCacheprotected List<String>classPathprotected List<ClassProvider>classProvidersprotected booleanjava9Modeprotected com.google.common.cache.LoadingCache<String,SourceLocator.ClassSourceType>pathToSourceTypeprotected List<String>sourcePath
-
Constructor Summary
Constructors Constructor Description SourceLocator(Singletons.Global g)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadditionalClassLoader(ClassLoader c)Set<String>classesInDynamicPackage(String str)List<String>classPath()voidclearDexClassPathExtensions()Clears the set of dex or apk or assembly files that still need to be indexedMap<String,File>dexClassIndex()Return the class index that maps class names to dex/assembly(exe/dll) files.static voidensureDirectoryExists(File dir)Create the given directory and all parent directories ifdiris non-null.static List<String>explodeClassPath(String classPath)Explodes a class path into a list of individual class path entries.voidextendClassPath(String newPathElement)List<String>getClassesUnder(String aPath)List<String>getClassesUnder(String aPath, String prefix)ClassSourcegetClassSource(String className)Given a class name, uses the soot-class-path to return a ClassSource for the given class.protected SourceLocator.ClassSourceTypegetClassSourceType(String path)Set<String>getDexClassPathExtensions()Gets all files that were added to the classpath later on and that have not yet been processed for the dexClassIndex mappingStringgetExtensionFor(int rep)StringgetFileNameFor(SootClass c, int rep)StringgetOutputDir()Returns the output directory given byOptionsor a default if not set.StringgetOutputJarName()If {@link Options#v()#output_jar()} is set, returns the name of the jar file to which the output will be written.StringgetSourceForClass(String className)Returns the name of the class in which the (possibly inner) class className appears.voidinvalidateCaches()voidinvalidateClassPath()protected IFoundFilelookupInArchive(String archivePath, String fileName)IFoundFilelookupInClassPath(String fileName)Searches for a file with the given name in the exploded classPath.protected IFoundFilelookupInDir(String dir, String fileName)voidresetCaches()Resets the cached class path, class providers, and source path to null.voidsetClassProviders(List<ClassProvider> classProviders)voidsetDexClassIndex(Map<String,File> index)Set the class_container (dex, assembly) class indexprotected voidsetupClassProviders()List<String>sourcePath()static SourceLocatorv()
-
-
-
Field Detail
-
additionalClassLoaders
protected final Set<ClassLoader> additionalClassLoaders
-
classProviders
protected List<ClassProvider> classProviders
-
java9Mode
protected boolean java9Mode
-
pathToSourceType
protected final com.google.common.cache.LoadingCache<String,SourceLocator.ClassSourceType> pathToSourceType
-
-
Constructor Detail
-
SourceLocator
public SourceLocator(Singletons.Global g)
-
-
Method Detail
-
invalidateCaches
public void invalidateCaches()
-
v
public static SourceLocator v()
-
ensureDirectoryExists
public static void ensureDirectoryExists(File dir)
Create the given directory and all parent directories ifdiris non-null.- Parameters:
dir-
-
explodeClassPath
public static List<String> explodeClassPath(String classPath)
Explodes a class path into a list of individual class path entries.
-
getClassSource
public ClassSource getClassSource(String className)
Given a class name, uses the soot-class-path to return a ClassSource for the given class.
-
additionalClassLoader
public void additionalClassLoader(ClassLoader c)
-
setupClassProviders
protected void setupClassProviders()
-
setClassProviders
public void setClassProviders(List<ClassProvider> classProviders)
-
invalidateClassPath
public void invalidateClassPath()
-
getClassSourceType
protected SourceLocator.ClassSourceType getClassSourceType(String path)
-
getExtensionFor
public String getExtensionFor(int rep)
-
getOutputDir
public String getOutputDir()
Returns the output directory given byOptionsor a default if not set. Also ensures that all directories in the path exist.- Returns:
- the output directory from
Optionsor a default if not set
-
getOutputJarName
public String getOutputJarName()
If {@link Options#v()#output_jar()} is set, returns the name of the jar file to which the output will be written. The name of the jar file can be given with the -output-dir option or a default will be used. Also ensures that all directories in the path exist.- Returns:
- the name of the Jar file to which outputs are written
-
lookupInClassPath
public IFoundFile lookupInClassPath(String fileName)
Searches for a file with the given name in the exploded classPath.
-
lookupInDir
protected IFoundFile lookupInDir(String dir, String fileName)
-
lookupInArchive
protected IFoundFile lookupInArchive(String archivePath, String fileName)
-
getSourceForClass
public String getSourceForClass(String className)
Returns the name of the class in which the (possibly inner) class className appears.
-
dexClassIndex
public Map<String,File> dexClassIndex()
Return the class index that maps class names to dex/assembly(exe/dll) files. A dex/exe/dll file contains multiple classes and is not structured as a "folder structure"- Returns:
- the index
-
setDexClassIndex
public void setDexClassIndex(Map<String,File> index)
Set the class_container (dex, assembly) class index- Parameters:
index- the index
-
extendClassPath
public void extendClassPath(String newPathElement)
-
getDexClassPathExtensions
public Set<String> getDexClassPathExtensions()
Gets all files that were added to the classpath later on and that have not yet been processed for the dexClassIndex mapping- Returns:
- The set of dex or apk or assembly (exe/dll) files that still need to be indexed
-
clearDexClassPathExtensions
public void clearDexClassPathExtensions()
Clears the set of dex or apk or assembly files that still need to be indexed
-
resetCaches
public void resetCaches()
Resets the cached class path, class providers, and source path to null. This method allows for subsequent calls toScene.loadNecessaryClasses()to recompute and load the classes using updated configurations if provided.
-
-