com.strobel.assembler.InputTypeLoader Java Examples
The following examples show how to use
com.strobel.assembler.InputTypeLoader.
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: ProcyonDecompiler.java From java-disassembler with GNU General Public License v3.0 | 6 votes |
public DecompilerSettings getDecompilerSettings() { DecompilerSettings procyonSettings = new DecompilerSettings(); procyonSettings.setFlattenSwitchBlocks(settings.getEntry("fsb").getBool()); procyonSettings.setForceExplicitImports(!settings.getEntry("ci").getBool()); procyonSettings.setForceExplicitTypeArguments(settings.getEntry("ei").getBool()); procyonSettings.setRetainRedundantCasts(settings.getEntry("ec").getBool()); procyonSettings.setShowSyntheticMembers(settings.getEntry("ss").getBool()); procyonSettings.setExcludeNestedTypes(settings.getEntry("ent").getBool()); // procyonSettings.setOutputDirectory(options.getOutputDirectory()); procyonSettings.setIncludeLineNumbersInBytecode(settings.getEntry("dl").getBool()); procyonSettings.setRetainPointlessSwitches(settings.getEntry("ps").getBool()); procyonSettings.setUnicodeOutputEnabled(settings.getEntry("unicode").getBool()); procyonSettings.setMergeVariables(settings.getEntry("mv").getBool()); procyonSettings.setShowDebugLineNumbers(settings.getEntry("dl").getBool()); procyonSettings.setSimplifyMemberReferences(settings.getEntry("sm").getBool()); procyonSettings.setDisableForEachTransforms(settings.getEntry("disable-foreach").getBool()); procyonSettings.setTypeLoader(new InputTypeLoader()); // procyonSettings.setLanguage(Languages.bytecode()); // procyonSettings.setLanguage(settings.getEntry("Unoptimized AST").getBool() ? Languages.bytecodeAstUnoptimized() : Languages.bytecodeAst()); return procyonSettings; }
Example #2
Source File: UimaDecompiler.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * A special type loader that substitutes the byteArray for the given class name * @param classNameSlashes the name to look for to substitute * @param byteArray the value to substitute */ private void setDecompilerSettingsForByteArray(String classNameSlashes, byte[] byteArray) { ITypeLoader tl = new ITypeLoader() { @Override public boolean tryLoadType(String internalName, Buffer buffer) { if (classNameSlashes.equals(internalName)) { int length = byteArray.length; buffer.reset(length); System.arraycopy(byteArray, 0, buffer.array(), 0, length); return true; } else { return false; } } }; ITypeLoader tc = new CompositeTypeLoader(tl, getClasspathTypeLoader(), new InputTypeLoader()); decompilerSettings.setTypeLoader(tc); }
Example #3
Source File: ProcyonDecompiler.java From Recaf with MIT License | 5 votes |
@Override public String decompile(String name) { ITypeLoader loader = new ComposedTypeLoader(Arrays.asList( new RecafTypeLoader(getController()), new InputTypeLoader() )); Map<String, Boolean> options = getOptions(); DecompilerSettings settings = new DecompilerSettings(); settings.setFlattenSwitchBlocks(options.get("flatten-switch-blocks")); settings.setForceExplicitImports(!options.get("collapse-imports")); settings.setForceExplicitTypeArguments(options.get("force-explicit-type-arguments")); settings.setRetainRedundantCasts(options.get("retain-redundant-casts")); settings.setShowSyntheticMembers(options.get("show-synthetic-members")); settings.setExcludeNestedTypes(options.get("exclude-nested-types")); settings.setRetainPointlessSwitches(options.get("retain-pointless-switches")); settings.setUnicodeOutputEnabled(options.get("unicode-output")); settings.setMergeVariables(options.get("merge-variables")); settings.setShowDebugLineNumbers(options.get("show-debug-line-numbers")); settings.setSimplifyMemberReferences(options.get("simplify-member-references")); settings.setForceFullyQualifiedReferences(options.get("force-fully-qualified-references")); settings.setDisableForEachTransforms(options.get("disable-for-each-transforms")); settings.setTypeLoader(loader); settings.setJavaFormattingOptions(JavaFormattingOptions.createDefault()); MetadataSystem system = new MetadataSystem(loader); system.setEagerMethodLoadingEnabled(options.get("eager-methods-loading")); TypeReference ref = system.lookupType(name); DecompilationOptions decompilationOptions = new DecompilationOptions(); decompilationOptions.setSettings(settings); decompilationOptions.setFullDecompilation(true); StringWriter writer = new StringWriter(); settings.getLanguage().decompileType(ref.resolve(), new PlainTextOutput(writer), decompilationOptions); return writer.toString(); }
Example #4
Source File: ProcyonDecompiler.java From JByteMod-Beta with GNU General Public License v2.0 | 4 votes |
public String decompile(byte[] b, MethodNode mn) { try { //TODO decompile method only DecompilerSettings settings = new DecompilerSettings(); try { for (Field f : settings.getClass().getDeclaredFields()) { if (f.getType() == boolean.class) { f.setAccessible(true); f.setBoolean(settings, JByteMod.ops.get("procyon" + f.getName()).getBoolean()); } } } catch (Throwable t) { t.printStackTrace(); } settings.setShowSyntheticMembers(true); MetadataSystem metadataSystem = new MetadataSystem(new ITypeLoader() { private InputTypeLoader backLoader = new InputTypeLoader(); @Override public boolean tryLoadType(String s, Buffer buffer) { if (s.equals(cn.name)) { buffer.putByteArray(b, 0, b.length); buffer.position(0); return true; } else { return backLoader.tryLoadType(s, buffer); } } }); TypeReference type = metadataSystem.lookupType(cn.name); DecompilationOptions decompilationOptions = new DecompilationOptions(); decompilationOptions.setSettings(DecompilerSettings.javaDefaults()); decompilationOptions.setFullDecompilation(true); TypeDefinition resolvedType = null; if (type == null || ((resolvedType = type.resolve()) == null)) { new ErrorDisplay("Unable to resolve type."); return "error"; } StringWriter stringwriter = new StringWriter(); settings.getLanguage().decompileType(resolvedType, new PlainTextOutput(stringwriter), decompilationOptions); String decompiledSource = stringwriter.toString(); return decompiledSource; } catch (Exception e) { e.printStackTrace(); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); return sw.toString(); } }
Example #5
Source File: ProcyonDecompiler.java From java-disassembler with GNU General Public License v3.0 | 4 votes |
@Override public String decompileClassNode(FileContainer container, final ClassNode cn) { try { byte[] bytes = JDA.getClassBytes(container, cn); MetadataSystem metadataSystem = new MetadataSystem(new ITypeLoader() { private InputTypeLoader backLoader = new InputTypeLoader(); @Override public boolean tryLoadType(String s, Buffer buffer) { if (s.equals(cn.name)) { buffer.putByteArray(bytes, 0, bytes.length); buffer.position(0); return true; } else { String classFilename = s + ".class"; FileContainer otherContainer = JDA.findContainerForFile(classFilename); if (otherContainer != null) { byte[] toUse = otherContainer.getFiles().get(classFilename); if (toUse != null) { buffer.putByteArray(toUse, 0, toUse.length); buffer.position(0); return true; } } return backLoader.tryLoadType(s, buffer); } } }); TypeReference type = metadataSystem.lookupType(cn.name); DecompilationOptions decompilationOptions = new DecompilationOptions(); DecompilerSettings settings = getDecompilerSettings(); decompilationOptions.setSettings(settings); decompilationOptions.setFullDecompilation(true); TypeDefinition resolvedType; if (type == null || ((resolvedType = type.resolve()) == null)) { throw new Exception("Unable to resolve type."); } StringWriter stringwriter = new StringWriter(); settings.getLanguage().decompileType(resolvedType, new PlainTextOutput(stringwriter), decompilationOptions); String decompiledSource = stringwriter.toString(); return decompiledSource; } catch (Throwable e) { return parseException(e); } }
Example #6
Source File: ProcyonDecompiler.java From bytecode-viewer with GNU General Public License v3.0 | 4 votes |
public LuytenTypeLoader() { _typeLoaders = new ArrayList<ITypeLoader>(); _typeLoaders.add(new InputTypeLoader()); }
Example #7
Source File: LuytenTypeLoader.java From Luyten with Apache License 2.0 | 4 votes |
public LuytenTypeLoader() { _typeLoaders = new ArrayList<ITypeLoader>(); _typeLoaders.add(new InputTypeLoader()); }
Example #8
Source File: UimaDecompiler.java From uima-uimaj with Apache License 2.0 | 4 votes |
private void setDecompilerSettingsForClassLoader() { ITypeLoader tc = new CompositeTypeLoader(getClasspathTypeLoader(), new InputTypeLoader()); decompilerSettings.setTypeLoader(tc); }