Package org.benf.cfr.reader.state
Class ClassFileSourceImpl
- java.lang.Object
-
- org.benf.cfr.reader.state.ClassFileSourceImpl
-
- All Implemented Interfaces:
ClassFileSource,ClassFileSource2
public class ClassFileSourceImpl extends java.lang.Object implements ClassFileSource2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classClassFileSourceImpl.JarSourceEntry-
Nested classes/interfaces inherited from interface org.benf.cfr.reader.api.ClassFileSource
ClassFileSource.Factory
-
-
Field Summary
Fields Modifier and Type Field Description private ClassFileRelocatorclassRelocatorprivate ClassRenamerclassRenamerprivate java.util.Map<java.lang.String,ClassFileSourceImpl.JarSourceEntry>classToPathMapprivate java.util.Set<java.lang.String>explicitJarsprivate static booleanJrtPresentprivate Optionsoptionsprivate static java.util.Map<java.lang.String,java.lang.String>packMap
-
Constructor Summary
Constructors Constructor Description ClassFileSourceImpl(Options options)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.util.Collection<java.lang.String>addJar(java.lang.String jarPath)Deprecated.JarContentaddJarContent(java.lang.String jarPath, AnalysisType analysisType)CFR would like to know about all classes contained within the jar atjarPathprivate voidaddToRelativeClassPath(java.io.File file, java.lang.String jarClassPath)private static booleanCheckJrt()private byte[]getBytesFromFile(java.io.InputStream is, long length)Pair<byte[],java.lang.String>getClassFileContent(java.lang.String inputPath)Given a path to a class file, return a pair of * the content, as a byte array.private java.util.Map<java.lang.String,ClassFileSourceImpl.JarSourceEntry>getClassPathClasses()private byte[]getContentByFromReflectedClass(java.lang.String inputPath)private byte[]getInternalContent(java.lang.String inputPath)private java.util.Map<java.lang.String,java.lang.String>getManifestContent(java.util.zip.ZipFile zipFile)private static java.util.Map<java.lang.String,java.lang.String>getPackageToModuleMap()java.lang.StringgetPossiblyRenamedPath(java.lang.String path)It's possible that an obfuscator might have generated a bizarre and magic file inside a jar such that it's path is too big to read.private byte[]getUrlContent(java.net.URL url)voidinformAnalysisRelativePathDetail(java.lang.String usePath, java.lang.String specPath)CFR has loaded your class, and it has decided that if it were in the correct location, it would instead be atclassFilePath.private JarContentprocessClassPathFile(java.io.File file, boolean dump, AnalysisType analysisType)private voidprocessClassPathFile(java.io.File file, java.lang.String absolutePath, java.util.Map<java.lang.String,ClassFileSourceImpl.JarSourceEntry> classToPathMap, AnalysisType analysisType, boolean dump)private voidprocessToClassPath(boolean dump, java.lang.String path)
-
-
-
Field Detail
-
explicitJars
private final java.util.Set<java.lang.String> explicitJars
-
classToPathMap
private java.util.Map<java.lang.String,ClassFileSourceImpl.JarSourceEntry> classToPathMap
-
options
private final Options options
-
classRenamer
private ClassRenamer classRenamer
-
classRelocator
private ClassFileRelocator classRelocator
-
JrtPresent
private static final boolean JrtPresent
-
packMap
private static final java.util.Map<java.lang.String,java.lang.String> packMap
-
-
Constructor Detail
-
ClassFileSourceImpl
public ClassFileSourceImpl(Options options)
-
-
Method Detail
-
CheckJrt
private static boolean CheckJrt()
-
getBytesFromFile
private byte[] getBytesFromFile(java.io.InputStream is, long length) throws java.io.IOException- Throws:
java.io.IOException
-
getPossiblyRenamedPath
public java.lang.String getPossiblyRenamedPath(java.lang.String path)
Description copied from interface:ClassFileSourceIt's possible that an obfuscator might have generated a bizarre and magic file inside a jar such that it's path is too big to read. Or it's invalid. This allows you to remap paths.- Specified by:
getPossiblyRenamedPathin interfaceClassFileSource- Parameters:
path- Path CFR would like to use- Returns:
- Remapped path.
-
getClassFileContent
public Pair<byte[],java.lang.String> getClassFileContent(java.lang.String inputPath) throws java.io.IOException
Description copied from interface:ClassFileSourceGiven a path to a class file, return a pair of * the content, as a byte array. * the path where you found this.- Specified by:
getClassFileContentin interfaceClassFileSource- Parameters:
inputPath- relative path of class we wish to load.- Returns:
- Pair<byte[], String> of class file content, and file location.
- Throws:
java.io.IOException- if you can't find the class.
-
getPackageToModuleMap
private static java.util.Map<java.lang.String,java.lang.String> getPackageToModuleMap()
-
getContentByFromReflectedClass
private byte[] getContentByFromReflectedClass(java.lang.String inputPath)
-
getUrlContent
private byte[] getUrlContent(java.net.URL url)
-
getInternalContent
private byte[] getInternalContent(java.lang.String inputPath) throws java.io.IOException- Throws:
java.io.IOException
-
addJar
@Deprecated public java.util.Collection<java.lang.String> addJar(java.lang.String jarPath)
Deprecated.Description copied from interface:ClassFileSourceCFR would like to know about all classes contained within the jar atjarPath- Specified by:
addJarin interfaceClassFileSource- Parameters:
jarPath- path to a jar.- Returns:
- paths (inside jar) of all classes.
-
addJarContent
public JarContent addJarContent(java.lang.String jarPath, AnalysisType analysisType)
Description copied from interface:ClassFileSource2CFR would like to know about all classes contained within the jar atjarPath- Specified by:
addJarContentin interfaceClassFileSource2- Parameters:
jarPath- path to a jar.- Returns:
-
getClassPathClasses
private java.util.Map<java.lang.String,ClassFileSourceImpl.JarSourceEntry> getClassPathClasses()
-
processToClassPath
private void processToClassPath(boolean dump, java.lang.String path)
-
addToRelativeClassPath
private void addToRelativeClassPath(java.io.File file, java.lang.String jarClassPath)
-
processClassPathFile
private void processClassPathFile(java.io.File file, java.lang.String absolutePath, java.util.Map<java.lang.String,ClassFileSourceImpl.JarSourceEntry> classToPathMap, AnalysisType analysisType, boolean dump)
-
processClassPathFile
private JarContent processClassPathFile(java.io.File file, boolean dump, AnalysisType analysisType)
-
getManifestContent
private java.util.Map<java.lang.String,java.lang.String> getManifestContent(java.util.zip.ZipFile zipFile)
-
informAnalysisRelativePathDetail
public void informAnalysisRelativePathDetail(java.lang.String usePath, java.lang.String specPath)Description copied from interface:ClassFileSourceCFR has loaded your class, and it has decided that if it were in the correct location, it would instead be atclassFilePath. This information should be taken into account when loading any inner classes, or other classes that CFR tries to load in order to improve decompilation. Why do you care? Let's say you have a class in a top level outside its normal structure, Bob.class. It should be found at org/person/Bob.class. Implementors of this will be called back with "", and "org/person", telling you that org.person are implicit in your path. CFR may later ask you to load "org/person/Bob$1.class". You should adjust this path to match where Bob$1 actually is. This will also be called with null, null to reset.- Specified by:
informAnalysisRelativePathDetailin interfaceClassFileSource- Parameters:
usePath- the path that was used to load a class file.specPath- the path that CFR actually suspects it should have been, based on package name.
-
-