当前位置: 首页>>代码示例>>Java>>正文


Java DecompilationOptions.setFullDecompilation方法代码示例

本文整理汇总了Java中com.strobel.decompiler.DecompilationOptions.setFullDecompilation方法的典型用法代码示例。如果您正苦于以下问题:Java DecompilationOptions.setFullDecompilation方法的具体用法?Java DecompilationOptions.setFullDecompilation怎么用?Java DecompilationOptions.setFullDecompilation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.strobel.decompiler.DecompilationOptions的用法示例。


在下文中一共展示了DecompilationOptions.setFullDecompilation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doSaveClassDecompiled

import com.strobel.decompiler.DecompilationOptions; //导入方法依赖的package包/类
private void doSaveClassDecompiled(File inFile, File outFile) throws Exception {
	DecompilerSettings settings = cloneSettings();
	LuytenTypeLoader typeLoader = new LuytenTypeLoader();
	MetadataSystem metadataSystem = new MetadataSystem(typeLoader);
	TypeReference type = metadataSystem.lookupType(inFile.getCanonicalPath());

	DecompilationOptions decompilationOptions = new DecompilationOptions();
	decompilationOptions.setSettings(settings);
	decompilationOptions.setFullDecompilation(true);

	boolean isUnicodeEnabled = decompilationOptions.getSettings().isUnicodeOutputEnabled();
	TypeDefinition resolvedType = null;
	if (type == null || ((resolvedType = type.resolve()) == null)) {
		throw new Exception("Unable to resolve type.");
	}
	StringWriter stringwriter = new StringWriter();
	PlainTextOutput plainTextOutput = new PlainTextOutput(stringwriter);
	plainTextOutput.setUnicodeOutputEnabled(isUnicodeEnabled);
	settings.getLanguage().decompileType(resolvedType, plainTextOutput, decompilationOptions);
	String decompiledSource = stringwriter.toString();

	System.out.println("[SaveAll]: " + inFile.getName() + " -> " + outFile.getName());
	try (FileOutputStream fos = new FileOutputStream(outFile);
			OutputStreamWriter writer = isUnicodeEnabled ? new OutputStreamWriter(fos, "UTF-8")
					: new OutputStreamWriter(fos);
			BufferedWriter bw = new BufferedWriter(writer);) {
		bw.write(decompiledSource);
		bw.flush();
	}
}
 
开发者ID:KevinPriv,项目名称:Luyten4Forge,代码行数:31,代码来源:FileSaver.java

示例2: decompileClassNode

import com.strobel.decompiler.DecompilationOptions; //导入方法依赖的package包/类
@Override
public String decompileClassNode(final ClassNode cn, byte[] b) {
    try {
        if (cn.version < 49) {
            b = fixBytes(b);
        }
        final byte[] bytesToUse = b;
        final Map<String, byte[]> loadedClasses = BytecodeViewer.getLoadedBytes();
        DecompilerSettings settings = getDecompilerSettings();
        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(bytesToUse, 0, bytesToUse.length);
                    buffer.position(0);
                    return true;
                } else {
                    byte[] toUse = loadedClasses.get(s + ".class");
                    if (toUse != null) {
                        buffer.putByteArray(toUse, 0, toUse.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)) {
            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);
    }
}
 
开发者ID:Konloch,项目名称:bytecode-viewer,代码行数:47,代码来源:ProcyonDecompiler.java


注:本文中的com.strobel.decompiler.DecompilationOptions.setFullDecompilation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。