Search in sources :

Example 1 with CompilationUnit

use of com.strobel.decompiler.languages.java.ast.CompilationUnit in project j2objc by google.

the class ClassFile method create.

public static ClassFile create(InputFile file) throws IOException {
    ITypeLoader loader;
    String path = file.getAbsolutePath();
    if (path.endsWith(".jar")) {
        loader = new JarTypeLoader(new JarFile(path));
        path = file.getUnitName();
        if (!path.endsWith(".class")) {
            return null;
        }
        // Remove .class suffix, as JarTypeLoader adds it.
        path = path.substring(0, path.length() - 6);
    } else {
        loader = new InputTypeLoader();
    }
    TypeReference typeRef = lookupType(path, loader);
    CompilationUnit unit = decompileClassFile(typeRef);
    return new ClassFile(unit, typeRef);
}
Also used : InputTypeLoader(com.strobel.assembler.InputTypeLoader) CompilationUnit(com.strobel.decompiler.languages.java.ast.CompilationUnit) JarTypeLoader(com.strobel.assembler.metadata.JarTypeLoader) TypeReference(com.strobel.assembler.metadata.TypeReference) JarFile(java.util.jar.JarFile) ITypeLoader(com.strobel.assembler.metadata.ITypeLoader)

Aggregations

InputTypeLoader (com.strobel.assembler.InputTypeLoader)1 ITypeLoader (com.strobel.assembler.metadata.ITypeLoader)1 JarTypeLoader (com.strobel.assembler.metadata.JarTypeLoader)1 TypeReference (com.strobel.assembler.metadata.TypeReference)1 CompilationUnit (com.strobel.decompiler.languages.java.ast.CompilationUnit)1 JarFile (java.util.jar.JarFile)1