本文整理匯總了Java中com.strobel.decompiler.DecompilerSettings類的典型用法代碼示例。如果您正苦於以下問題:Java DecompilerSettings類的具體用法?Java DecompilerSettings怎麽用?Java DecompilerSettings使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DecompilerSettings類屬於com.strobel.decompiler包,在下文中一共展示了DecompilerSettings類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: Deobfuscator
import com.strobel.decompiler.DecompilerSettings; //導入依賴的package包/類
public Deobfuscator(JarFile jar) throws IOException {
m_jar = jar;
// build the jar index
m_jarIndex = new JarIndex();
m_jarIndex.indexJar(m_jar, true);
// config the decompiler
m_settings = DecompilerSettings.javaDefaults();
m_settings.setMergeVariables(true);
m_settings.setForceExplicitImports(true);
m_settings.setForceExplicitTypeArguments(true);
m_settings.setShowDebugLineNumbers(true);
// DEBUG
//m_settings.setShowSyntheticMembers(true);
// init defaults
m_translatorCache = Maps.newTreeMap();
// init mappings
setMappings(new Mappings());
markWordAsDeObfuscate();
}
示例2: saveText
import com.strobel.decompiler.DecompilerSettings; //導入依賴的package包/類
public void saveText(final String text, final File file) {
new Thread(new Runnable() {
@Override
public void run() {
DecompilerSettings settings = cloneSettings();
boolean isUnicodeEnabled = settings.isUnicodeOutputEnabled();
long time = System.currentTimeMillis();
try (FileOutputStream fos = new FileOutputStream(file);
OutputStreamWriter writer = isUnicodeEnabled ? new OutputStreamWriter(fos, "UTF-8")
: new OutputStreamWriter(fos);
BufferedWriter bw = new BufferedWriter(writer);) {
label.setText("Extracting: " + file.getName());
bar.setVisible(true);
bw.write(text);
bw.flush();
label.setText("Completed: " + getTime(time));
} catch (Exception e1) {
label.setText("Cannot save file: " + file.getName());
Luyten.showExceptionDialog("Unable to save file!\n", e1);
} finally {
setExtracting(false);
bar.setVisible(false);
}
}
}).start();
}
示例3: registerSettings
import com.strobel.decompiler.DecompilerSettings; //導入依賴的package包/類
@Override
protected void registerSettings() {
registerSetting(Boolean.class, new RawBooleanSetting("includelinenumbers", "Include line numbers in raw bytecode mode", true, DecompilerSettings::setIncludeLineNumbersInBytecode));
registerSetting(Boolean.class, new RawBooleanSetting("showsyntheticmembers", "Show synthetic (compiler-generated) members.", false, DecompilerSettings::setShowSyntheticMembers));
registerSetting(Boolean.class, new RawBooleanSetting("genexforcatch", "Always generate exception variables for catch blocks", true, DecompilerSettings::setAlwaysGenerateExceptionVariableForCatchBlocks));
registerSetting(Boolean.class, new RawBooleanSetting("forceexplicitimports", "[DEPRECATED] Explicit imports are now enabled by default. This option will be removed in a future release.", false, DecompilerSettings::setForceExplicitImports));
registerSetting(Boolean.class, new RawBooleanSetting("forceexplicittypeargs", "Always print type arguments to generic methods.", false, DecompilerSettings::setForceExplicitTypeArguments));
registerSetting(Boolean.class, new RawBooleanSetting("flattenswitch", "Drop the braces statements around switch sections when possible.", false, DecompilerSettings::setFlattenSwitchBlocks));
registerSetting(Boolean.class, new RawBooleanSetting("exclnested", "Exclude nested types when decompiling their enclosing types.", false, DecompilerSettings::setExcludeNestedTypes));
registerSetting(Boolean.class, new RawBooleanSetting("retaincasts", "Do not remove redundant explicit casts.", false, DecompilerSettings::setRetainRedundantCasts));
registerSetting(Boolean.class, new RawBooleanSetting("retainswitches", "Do not lift the contents of switches having only a default label.", false, DecompilerSettings::setRetainPointlessSwitches));
registerSetting(Boolean.class, new RawBooleanSetting("unicode", "Enable Unicode output (printable non-ASCII characters will not be escaped).", false, DecompilerSettings::setUnicodeOutputEnabled));
// registerSetting(Boolean.class, new RawBooleanSetting("errordiag", "Include error diagnostics", true, DecompilerSettings::setIncludeErrorDiagnostics));
registerSetting(Boolean.class, new RawBooleanSetting("mergevar", "Attempt to merge as many variables as possible. This may lead to fewer declarations, but at the expense of inlining and useful naming. This feature is experimental and may be removed or become the standard behavior in future releases.", false, DecompilerSettings::setMergeVariables));
registerSetting(Boolean.class, new RawBooleanSetting("disablefortransform", "Disable \'for each\' loop transforms.", false, DecompilerSettings::setDisableForEachTransforms));
registerSetting(Boolean.class, new RawBooleanSetting("showlinenumbers", "For debugging, show Java line numbers as inline comments (implies including line numbers)", true, DecompilerSettings::setShowDebugLineNumbers));
registerSetting(Boolean.class, new RawBooleanSetting("simplifymembers", "Simplify type-qualified member references in Java output [EXPERIMENTAL].", false, DecompilerSettings::setSimplifyMemberReferences));
}
示例4: Deobfuscator
import com.strobel.decompiler.DecompilerSettings; //導入依賴的package包/類
public Deobfuscator(JarFile jar) {
this.jar = jar;
// build the jar index
this.jarIndex = new JarIndex();
this.jarIndex.indexJar(this.jar, true);
// config the decompiler
this.settings = DecompilerSettings.javaDefaults();
this.settings.setMergeVariables(true);
this.settings.setForceExplicitImports(true);
this.settings.setForceExplicitTypeArguments(true);
this.settings.setShowDebugLineNumbers(true);
// DEBUG
//this.settings.setShowSyntheticMembers(true);
// init defaults
this.translatorCache = Maps.newTreeMap();
// init mappings
setMappings(new Mappings());
}
示例5: Deobfuscator
import com.strobel.decompiler.DecompilerSettings; //導入依賴的package包/類
public Deobfuscator(JarFile jar) throws IOException
{
m_jar = jar;
// build the jar index
m_jarIndex = new JarIndex();
m_jarIndex.indexJar(m_jar, true);
// config the decompiler
m_settings = DecompilerSettings.javaDefaults();
m_settings.setMergeVariables(true);
m_settings.setForceExplicitImports(true);
m_settings.setForceExplicitTypeArguments(false);
m_settings.setRetainRedundantCasts(false);
// m_settings.setShowDebugLineNumbers(true);
// DEBUG
// m_settings.setShowSyntheticMembers(true);
// init defaults
m_translatorCache = Maps.newTreeMap();
// init mappings
setMappings(new Mappings());
}
示例6: loadConfig
import com.strobel.decompiler.DecompilerSettings; //導入依賴的package包/類
/**
* Do not load, get the loaded instance
*/
private void loadConfig() {
decompilerSettings = new DecompilerSettings();
if (decompilerSettings.getJavaFormattingOptions() == null) {
decompilerSettings.setJavaFormattingOptions(JavaFormattingOptions.createDefault());
}
luytenPreferences = new LuytenPreferences();
mainWindowPosition = new WindowPosition();
findWindowPosition = new WindowPosition();
try {
Preferences prefs = Preferences.userNodeForPackage(ConfigSaver.class);
if (!prefs.get(LANGUAGE_NAME_ID, decompilerSettings.getLanguage().getName())
.equals(decompilerSettings.getLanguage().getName()))
prefs.put(LANGUAGE_NAME_ID, decompilerSettings.getLanguage().getName());
decompilerSettings.setFlattenSwitchBlocks(
prefs.getBoolean(FLATTEN_SWITCH_BLOCKS_ID, decompilerSettings.getFlattenSwitchBlocks()));
decompilerSettings.setForceExplicitImports(
prefs.getBoolean(FORCE_EXPLICIT_IMPORTS_ID, decompilerSettings.getForceExplicitImports()));
decompilerSettings.setShowSyntheticMembers(
prefs.getBoolean(SHOW_SYNTHETIC_MEMBERS_ID, decompilerSettings.getShowSyntheticMembers()));
decompilerSettings.setExcludeNestedTypes(
prefs.getBoolean(EXCLUDE_NESTED_TYPES_ID, decompilerSettings.getExcludeNestedTypes()));
decompilerSettings.setForceExplicitTypeArguments(prefs.getBoolean(FORCE_EXPLICIT_TYPE_ARGUMENTS_ID,
decompilerSettings.getForceExplicitTypeArguments()));
decompilerSettings.setRetainRedundantCasts(
prefs.getBoolean(RETAIN_REDUNDANT_CASTS_ID, decompilerSettings.getRetainRedundantCasts()));
decompilerSettings.setIncludeErrorDiagnostics(
prefs.getBoolean(INCLUDE_ERROR_DIAGNOSTICS_ID, decompilerSettings.getIncludeErrorDiagnostics()));
decompilerSettings.setLanguage(
findLanguageByName(prefs.get(LANGUAGE_NAME_ID, decompilerSettings.getLanguage().getName())));
decompilerSettings.setUnicodeOutputEnabled(prefs.getBoolean(UNICODE_REPLACE_ENABLED_ID, false));
mainWindowPosition = loadWindowPosition(prefs, MAIN_WINDOW_ID_PREFIX);
findWindowPosition = loadWindowPosition(prefs, FIND_WINDOW_ID_PREFIX);
luytenPreferences = loadLuytenPreferences(prefs);
} catch (Exception e) {
Luyten.showExceptionDialog("Exception!", e);
}
}
示例7: loadConfig
import com.strobel.decompiler.DecompilerSettings; //導入依賴的package包/類
/**
* Do not load, get the loaded instance
*/
private void loadConfig() {
decompilerSettings = new DecompilerSettings();
if (decompilerSettings.getJavaFormattingOptions() == null) {
decompilerSettings.setJavaFormattingOptions(JavaFormattingOptions.createDefault());
}
luytenPreferences = new LuytenPreferences();
mainWindowPosition = new WindowPosition();
findWindowPosition = new WindowPosition();
try {
Preferences prefs = Preferences.userNodeForPackage(ConfigSaver.class);
if (!prefs.get(LANGUAGE_NAME_ID, decompilerSettings.getLanguage().getName())
.equals(decompilerSettings.getLanguage().getName()))
prefs.put(LANGUAGE_NAME_ID, decompilerSettings.getLanguage().getName());
decompilerSettings.setFlattenSwitchBlocks(
prefs.getBoolean(FLATTEN_SWITCH_BLOCKS_ID, decompilerSettings.getFlattenSwitchBlocks()));
decompilerSettings.setForceExplicitImports(
prefs.getBoolean(FORCE_EXPLICIT_IMPORTS_ID, decompilerSettings.getForceExplicitImports()));
decompilerSettings.setShowSyntheticMembers(
prefs.getBoolean(SHOW_SYNTHETIC_MEMBERS_ID, decompilerSettings.getShowSyntheticMembers()));
decompilerSettings.setExcludeNestedTypes(
prefs.getBoolean(EXCLUDE_NESTED_TYPES_ID, decompilerSettings.getExcludeNestedTypes()));
decompilerSettings.setForceExplicitTypeArguments(prefs.getBoolean(FORCE_EXPLICIT_TYPE_ARGUMENTS_ID,
decompilerSettings.getForceExplicitTypeArguments()));
decompilerSettings.setRetainRedundantCasts(
prefs.getBoolean(RETAIN_REDUNDANT_CASTS_ID, decompilerSettings.getRetainRedundantCasts()));
decompilerSettings.setIncludeErrorDiagnostics(
prefs.getBoolean(INCLUDE_ERROR_DIAGNOSTICS_ID, decompilerSettings.getIncludeErrorDiagnostics()));
decompilerSettings.setLanguage(
findLanguageByName(prefs.get(LANGUAGE_NAME_ID, decompilerSettings.getLanguage().getName())));
decompilerSettings.setUnicodeOutputEnabled(prefs.getBoolean(UNICODE_REPLACE_ENABLED_ID, false));
mainWindowPosition = loadWindowPosition(prefs, MAIN_WINDOW_ID_PREFIX);
findWindowPosition = loadWindowPosition(prefs, FIND_WINDOW_ID_PREFIX);
luytenPreferences = loadLuytenPreferences(prefs);
} catch (Exception e) {
Luyten.showExceptionDialog("Exception!", e);
}
}
示例8: doSaveClassDecompiled
import com.strobel.decompiler.DecompilerSettings; //導入依賴的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();
}
}
示例9: cloneSettings
import com.strobel.decompiler.DecompilerSettings; //導入依賴的package包/類
private DecompilerSettings cloneSettings() {
DecompilerSettings settings = ConfigSaver.getLoadedInstance().getDecompilerSettings();
DecompilerSettings newSettings = new DecompilerSettings();
if (newSettings.getJavaFormattingOptions() == null) {
newSettings.setJavaFormattingOptions(JavaFormattingOptions.createDefault());
}
// synchronized: against main menu changes
synchronized (settings) {
newSettings.setExcludeNestedTypes(settings.getExcludeNestedTypes());
newSettings.setFlattenSwitchBlocks(settings.getFlattenSwitchBlocks());
newSettings.setForceExplicitImports(settings.getForceExplicitImports());
newSettings.setForceExplicitTypeArguments(settings.getForceExplicitTypeArguments());
newSettings.setOutputFileHeaderText(settings.getOutputFileHeaderText());
newSettings.setLanguage(settings.getLanguage());
newSettings.setShowSyntheticMembers(settings.getShowSyntheticMembers());
newSettings.setAlwaysGenerateExceptionVariableForCatchBlocks(
settings.getAlwaysGenerateExceptionVariableForCatchBlocks());
newSettings.setOutputDirectory(settings.getOutputDirectory());
newSettings.setRetainRedundantCasts(settings.getRetainRedundantCasts());
newSettings.setIncludeErrorDiagnostics(settings.getIncludeErrorDiagnostics());
newSettings.setIncludeLineNumbersInBytecode(settings.getIncludeLineNumbersInBytecode());
newSettings.setRetainPointlessSwitches(settings.getRetainPointlessSwitches());
newSettings.setUnicodeOutputEnabled(settings.isUnicodeOutputEnabled());
newSettings.setMergeVariables(settings.getMergeVariables());
newSettings.setShowDebugLineNumbers(settings.getShowDebugLineNumbers());
}
return newSettings;
}
示例10: decompile
import com.strobel.decompiler.DecompilerSettings; //導入依賴的package包/類
private void decompile(File classFile, File srcFolder) {
try {
File outputFile = convertClassFileToOutputFile(classFile, srcFolder);
outputFile.getParentFile().mkdirs();
PlainTextOutput output = new PlainTextOutput(new OutputStreamWriter(new FileOutputStream(outputFile.getAbsolutePath())));
DecompilerSettings settings = DecompilerSettings.javaDefaults();
settings.setForceExplicitImports(true);
settings.setOutputFileHeaderText("Generated with Procyon v" + Procyon.version());
Decompiler.decompile(classFile.getAbsolutePath(), output, settings);
} catch (IOException ex) {
Logger.error("Unable to decompile " + classFile.getAbsolutePath(), ex);
}
}
示例11: getDecompilerSettings
import com.strobel.decompiler.DecompilerSettings; //導入依賴的package包/類
public DecompilerSettings getDecompilerSettings() {
CommandLineOptions options = new CommandLineOptions();
JCommander jCommander = new JCommander(options);
String[] args = new String[Settings.values().length * 2];
int index = 0;
for (the.bytecode.club.bytecodeviewer.DecompilerSettings.Setting setting : Settings.values()) {
args[index++] = "--" + setting.getParam();
args[index++] = String.valueOf(getSettings().isSelected(setting));
}
jCommander.parse(args);
DecompilerSettings settings = new DecompilerSettings();
settings.setFlattenSwitchBlocks(options.getFlattenSwitchBlocks());
settings.setForceExplicitImports(!options.getCollapseImports());
settings.setForceExplicitTypeArguments(options.getForceExplicitTypeArguments());
settings.setRetainRedundantCasts(options.getRetainRedundantCasts());
settings.setShowSyntheticMembers(options.getShowSyntheticMembers());
settings.setExcludeNestedTypes(options.getExcludeNestedTypes());
settings.setOutputDirectory(options.getOutputDirectory());
settings.setIncludeLineNumbersInBytecode(options.getIncludeLineNumbers());
settings.setRetainPointlessSwitches(options.getRetainPointlessSwitches());
settings.setUnicodeOutputEnabled(options.isUnicodeOutputEnabled());
settings.setMergeVariables(options.getMergeVariables());
settings.setShowDebugLineNumbers(options.getShowDebugLineNumbers());
settings.setSimplifyMemberReferences(options.getSimplifyMemberReferences());
settings.setDisableForEachTransforms(options.getDisableForEachTransforms());
settings.setTypeLoader(new InputTypeLoader());
if (options.isRawBytecode()) {
settings.setLanguage(Languages.bytecode());
} else if (options.isBytecodeAst()) {
settings.setLanguage(options.isUnoptimized() ? Languages.bytecodeAstUnoptimized() : Languages.bytecodeAst());
}
return settings;
}
示例12: decompileClassFile
import com.strobel.decompiler.DecompilerSettings; //導入依賴的package包/類
/**
* Decompiles the given .class file and creates the specified output source file.
*
* @param classFilePath the .class file to be decompiled.
* @param outputDir The directory where decompiled .java files will be placed.
*/
@Override
public DecompilationResult decompileClassFile(Path rootDir, Path classFilePath, Path outputDir)
throws DecompilationException
{
Checks.checkDirectoryToBeRead(rootDir.toFile(), "Classes root dir");
File classFile = classFilePath.toFile();
Checks.checkFileToBeRead(classFile, "Class file");
Checks.checkDirectoryToBeFilled(outputDir.toFile(), "Output directory");
log.info("Decompiling .class '" + classFilePath + "' to '" + outputDir + "' from: '" + rootDir + "'");
String name = classFilePath.normalize().toAbsolutePath().toString().substring(rootDir.toAbsolutePath().toString().length() + 1);
final String typeName = StringUtils.removeEnd(name, ".class");// .replace('/', '.');
DecompilationResult result = new DecompilationResult();
try
{
DecompilerSettings settings = getDefaultSettings(outputDir.toFile());
this.procyonConf.setDecompilerSettings(settings); // TODO: This is horrible mess.
ITypeLoader typeLoader = new CompositeTypeLoader(new ClasspathTypeLoader(rootDir.toString()), new ClasspathTypeLoader());
MetadataSystem metadataSystem = new MetadataSystem(typeLoader);
File outputFile = this.decompileType(settings, metadataSystem, typeName);
result.addDecompiled(Collections.singletonList(classFilePath.toString()), outputFile.getAbsolutePath());
}
catch (Throwable e)
{
DecompilationFailure failure = new DecompilationFailure("Error during decompilation of "
+ classFilePath.toString() + ":\n " + e.getMessage(), Collections.singletonList(name), e);
log.severe(failure.getMessage());
result.addFailure(failure);
}
return result;
}
示例13: refreshMetadataCache
import com.strobel.decompiler.DecompilerSettings; //導入依賴的package包/類
/**
* The metadata cache can become huge over time. This simply flushes it periodically.
*/
private void refreshMetadataCache(final Queue<MetadataSystem> metadataSystemCache, final DecompilerSettings settings)
{
metadataSystemCache.clear();
for (int i = 0; i < this.getNumberOfThreads(); i++)
{
metadataSystemCache.add(new NoRetryMetadataSystem(settings.getTypeLoader()));
}
}
示例14: DecompileExecutor
import com.strobel.decompiler.DecompilerSettings; //導入依賴的package包/類
public DecompileExecutor(DecompilerSettings settings, MetadataSystem metadataSystem, String typeName)
{
this.settings = settings;
this.metadataSystem = metadataSystem;
this.typeName = typeName;
setDaemon(true);
}
示例15: getDefaultSettings
import com.strobel.decompiler.DecompilerSettings; //導入依賴的package包/類
/**
* Default settings set type loader to ClasspathTypeLoader if not set before.
*/
private DecompilerSettings getDefaultSettings(File outputDir)
{
DecompilerSettings settings = new DecompilerSettings();
procyonConf.setDecompilerSettings(settings);
settings.setOutputDirectory(outputDir.getPath());
settings.setShowSyntheticMembers(false);
settings.setForceExplicitImports(true);
if (settings.getTypeLoader() == null)
settings.setTypeLoader(new ClasspathTypeLoader());
return settings;
}