org.jetbrains.java.decompiler.main.extern.IBytecodeProvider Java Examples

The following examples show how to use org.jetbrains.java.decompiler.main.extern.IBytecodeProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RuntimeDecompiler.java    From Mixin with MIT License 6 votes vote down vote up
@Override
public void decompile(final File file) {
    try {
        Fernflower fernflower = new Fernflower(new IBytecodeProvider() {
            
            private byte[] byteCode;
            
            @Override
            public byte[] getBytecode(String externalPath, String internalPath) throws IOException {
                if (this.byteCode == null) {
                    this.byteCode = InterpreterUtil.getBytes(new File(externalPath));
                }
                return this.byteCode;
            }
            
        }, this, this.options, this);
        
        fernflower.getStructContext().addSpace(file, true);
        fernflower.decompileContext();
    } catch (Throwable ex) {
        this.logger.warn("Decompilation error while processing {}", file.getName());
    }
}
 
Example #2
Source File: Fernflower.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
public Fernflower(IBytecodeProvider provider, IResultSaver saver, Map<String, Object> customProperties, IFernflowerLogger logger) {
    Map<String, Object> properties = new HashMap<>(IFernflowerPreferences.DEFAULTS);
    if (customProperties != null) {
        properties.putAll(customProperties);
    }

    String level = (String) properties.get(IFernflowerPreferences.LOG_LEVEL);
    if (level != null) {
        try {
            logger.setSeverity(IFernflowerLogger.Severity.valueOf(level.toUpperCase(Locale.US)));
        } catch (IllegalArgumentException ignore) {
        }
    }

    structContext = new StructContext(saver, this, new LazyLoader(provider));
    classProcessor = new ClassesProcessor(structContext);

    PoolInterceptor interceptor = null;
    if ("1".equals(properties.get(IFernflowerPreferences.RENAME_ENTITIES))) {
        helper = loadHelper((String) properties.get(IFernflowerPreferences.USER_RENAMER_CLASS), logger);
        interceptor = new PoolInterceptor();
        converter = new IdentifierConverter(structContext, helper, interceptor);
    } else {
        helper = null;
        converter = null;
    }

    DecompilerContext context = new DecompilerContext(properties, logger, structContext, classProcessor, interceptor);
    DecompilerContext.setCurrentContext(context);
}
 
Example #3
Source File: FernflowerDecompiler.java    From windup with Eclipse Public License 1.0 5 votes vote down vote up
private IBytecodeProvider getByteCodeProvider()
{
    return new IBytecodeProvider()
    {
        @Override
        public byte[] getBytecode(String externalPath, String internalPath) throws IOException
        {
            return InterpreterUtil.getBytes(new File(externalPath));
        }
    };
}
 
Example #4
Source File: BaseDecompiler.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
public BaseDecompiler(IBytecodeProvider provider, IResultSaver saver, Map<String, Object> options, IFernflowerLogger logger) {
    engine = new Fernflower(provider, saver, options, logger);
}
 
Example #5
Source File: Fernflower.java    From JByteMod-Beta with GNU General Public License v2.0 4 votes vote down vote up
public Fernflower(IBytecodeProvider provider, IResultSaver saver, Map<String, Object> options, IFernflowerLogger logger) {
  structContext = new StructContext(saver, this, new LazyLoader(provider));
  DecompilerContext.initContext(options);
  DecompilerContext.setCounterContainer(new CounterContainer());
  DecompilerContext.setLogger(logger);
}
 
Example #6
Source File: BaseDecompiler.java    From JByteMod-Beta with GNU General Public License v2.0 4 votes vote down vote up
public BaseDecompiler(IBytecodeProvider provider, IResultSaver saver, Map<String, Object> options, IFernflowerLogger logger) {
  fernflower = new Fernflower(provider, saver, options, logger);
}
 
Example #7
Source File: LazyLoader.java    From JByteMod-Beta with GNU General Public License v2.0 4 votes vote down vote up
public LazyLoader(IBytecodeProvider provider) {
  this.provider = provider;
}