Class ClassFileSourceImpl

    • Field Detail

      • explicitJars

        private final java.util.Set<java.lang.String> explicitJars
      • options

        private final Options options
      • 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: ClassFileSource
        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. Or it's invalid. This allows you to remap paths.
        Specified by:
        getPossiblyRenamedPath in interface ClassFileSource
        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: ClassFileSource
        Given a path to a class file, return a pair of * the content, as a byte array. * the path where you found this.
        Specified by:
        getClassFileContent in interface ClassFileSource
        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: ClassFileSource
        CFR would like to know about all classes contained within the jar at jarPath
        Specified by:
        addJar in interface ClassFileSource
        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: ClassFileSource2
        CFR would like to know about all classes contained within the jar at jarPath
        Specified by:
        addJarContent in interface ClassFileSource2
        Parameters:
        jarPath - path to a jar.
        Returns:
      • 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: ClassFileSource
        CFR has loaded your class, and it has decided that if it were in the correct location, it would instead be at classFilePath. 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:
        informAnalysisRelativePathDetail in interface ClassFileSource
        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.