本文整理汇总了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();
}
}
示例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);
}
}