本文整理汇总了Java中com.strobel.decompiler.DecompilationOptions类的典型用法代码示例。如果您正苦于以下问题:Java DecompilationOptions类的具体用法?Java DecompilationOptions怎么用?Java DecompilationOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DecompilationOptions类属于com.strobel.decompiler包,在下文中一共展示了DecompilationOptions类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: setDecompilerReferences
import com.strobel.decompiler.DecompilationOptions; //导入依赖的package包/类
public void setDecompilerReferences(MetadataSystem metadataSystem, DecompilerSettings settings,
DecompilationOptions decompilationOptions) {
this.metadataSystem = metadataSystem;
this.settings = settings;
this.decompilationOptions = decompilationOptions;
}
示例3: actionPerformed
import com.strobel.decompiler.DecompilationOptions; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent event) {
tmp_thread = new Thread() {
public void run() {
if (findButton.getText().equals("Stop")) {
if (tmp_thread != null)
tmp_thread.interrupt();
setStatus("Stopped.");
findButton.setText("Find");
} else {
findButton.setText("Stop");
classesList.clear();
ConfigSaver configSaver = ConfigSaver.getLoadedInstance();
DecompilerSettings settings = configSaver.getDecompilerSettings();
File inFile = MainWindow.model.getOpenedFile();
boolean filter = ConfigSaver.getLoadedInstance().getLuytenPreferences()
.isFilterOutInnerClassEntries();
try {
JarFile jfile = new JarFile(inFile);
Enumeration<JarEntry> entLength = jfile.entries();
initProgressBar(Collections.list(entLength).size());
Enumeration<JarEntry> ent = jfile.entries();
while (ent.hasMoreElements() && findButton.getText().equals("Stop")) {
JarEntry entry = ent.nextElement();
String name = entry.getName();
setStatus(name);
if (filter && name.contains("$"))
continue;
if (entry.getName().endsWith(".class")) {
synchronized (settings) {
String internalName = StringUtilities.removeRight(entry.getName(), ".class");
TypeReference type = Model.metadataSystem.lookupType(internalName);
TypeDefinition resolvedType = null;
if (type == null || ((resolvedType = type.resolve()) == null)) {
throw new Exception("Unable to resolve type.");
}
StringWriter stringwriter = new StringWriter();
DecompilationOptions decompilationOptions;
decompilationOptions = new DecompilationOptions();
decompilationOptions.setSettings(settings);
decompilationOptions.setFullDecompilation(true);
PlainTextOutput plainTextOutput = new PlainTextOutput(stringwriter);
plainTextOutput.setUnicodeOutputEnabled(
decompilationOptions.getSettings().isUnicodeOutputEnabled());
settings.getLanguage().decompileType(resolvedType, plainTextOutput,
decompilationOptions);
String decompiledSource = stringwriter.toString().toLowerCase();
if (decompiledSource.contains(textField.getText().toLowerCase())) {
addClassName(entry.getName());
}
}
}
}
setSearching(false);
if (findButton.getText().equals("Stop")) {
setStatus("Done.");
findButton.setText("Find");
}
jfile.close();
} catch (Exception e) {
Luyten.showExceptionDialog("Exception!", e);
}
}
}
};
tmp_thread.start();
}
示例4: setDecompilerReferences
import com.strobel.decompiler.DecompilationOptions; //导入依赖的package包/类
public void setDecompilerReferences(MetadataSystem metadataSystem, DecompilerSettings settings,
DecompilationOptions decompilationOptions) {
this.metadataSystem = metadataSystem;
this.settings = settings;
this.decompilationOptions = decompilationOptions;
}
示例5: 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);
}
}