feat: add option to disable methods inline (#1170)
This commit is contained in:
@@ -68,7 +68,7 @@ and also packed to `build/jadx-<version>.zip`
|
||||
|
||||
### Usage
|
||||
```
|
||||
jadx[-gui] [options] <input file> (.apk, .dex, .jar, .class, .smali, .zip, .aar, .arsc, .aab)
|
||||
jadx[-gui] [options] <input files> (.apk, .dex, .jar, .class, .smali, .zip, .aar, .arsc, .aab)
|
||||
options:
|
||||
-d, --output-dir - output directory
|
||||
-ds, --output-dir-src - output directory for sources
|
||||
@@ -82,7 +82,9 @@ options:
|
||||
--show-bad-code - show inconsistent code (incorrectly decompiled)
|
||||
--no-imports - disable use of imports, always write entire package name
|
||||
--no-debug-info - disable debug info
|
||||
--add-debug-lines - add comments with debug line numbers if available
|
||||
--no-inline-anonymous - disable anonymous classes inline
|
||||
--no-inline-methods - disable methods inline
|
||||
--no-replace-consts - don't replace constant value with matching constant field
|
||||
--escape-unicode - escape non latin characters in strings (with \u)
|
||||
--respect-bytecode-access-modifiers - don't change original access modifiers
|
||||
|
||||
@@ -64,6 +64,9 @@ public class JadxCLIArgs {
|
||||
@Parameter(names = { "--no-inline-anonymous" }, description = "disable anonymous classes inline")
|
||||
protected boolean inlineAnonymousClasses = true;
|
||||
|
||||
@Parameter(names = { "--no-inline-methods" }, description = "disable methods inline")
|
||||
protected boolean inlineMethods = true;
|
||||
|
||||
@Parameter(names = "--no-replace-consts", description = "don't replace constant value with matching constant field")
|
||||
protected boolean replaceConsts = true;
|
||||
|
||||
@@ -215,6 +218,7 @@ public class JadxCLIArgs {
|
||||
args.setDebugInfo(debugInfo);
|
||||
args.setInsertDebugLines(addDebugLines);
|
||||
args.setInlineAnonymousClasses(inlineAnonymousClasses);
|
||||
args.setInlineMethods(inlineMethods);
|
||||
args.setRenameCaseSensitive(isRenameCaseSensitive());
|
||||
args.setRenameValid(isRenameValid());
|
||||
args.setRenamePrintable(isRenamePrintable());
|
||||
@@ -274,6 +278,10 @@ public class JadxCLIArgs {
|
||||
return inlineAnonymousClasses;
|
||||
}
|
||||
|
||||
public boolean isInlineMethods() {
|
||||
return inlineMethods;
|
||||
}
|
||||
|
||||
public boolean isDeobfuscationOn() {
|
||||
return deobfuscationOn;
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ public class JadxArgs {
|
||||
private boolean debugInfo = true;
|
||||
private boolean insertDebugLines = false;
|
||||
private boolean inlineAnonymousClasses = true;
|
||||
private boolean inlineMethods = true;
|
||||
|
||||
private boolean skipResources = false;
|
||||
private boolean skipSources = false;
|
||||
@@ -199,6 +200,14 @@ public class JadxArgs {
|
||||
this.inlineAnonymousClasses = inlineAnonymousClasses;
|
||||
}
|
||||
|
||||
public boolean isInlineMethods() {
|
||||
return inlineMethods;
|
||||
}
|
||||
|
||||
public void setInlineMethods(boolean inlineMethods) {
|
||||
this.inlineMethods = inlineMethods;
|
||||
}
|
||||
|
||||
public boolean isSkipResources() {
|
||||
return skipResources;
|
||||
}
|
||||
|
||||
@@ -125,8 +125,9 @@ public class Jadx {
|
||||
if (args.isDebugInfo()) {
|
||||
passes.add(new DebugInfoApplyVisitor());
|
||||
}
|
||||
|
||||
passes.add(new InlineMethods());
|
||||
if (args.isInlineMethods()) {
|
||||
passes.add(new InlineMethods());
|
||||
}
|
||||
passes.add(new GenericTypesVisitor());
|
||||
passes.add(new ShadowFieldVisitor());
|
||||
passes.add(new DeboxingVisitor());
|
||||
@@ -153,8 +154,9 @@ public class Jadx {
|
||||
passes.add(new ClassModifier());
|
||||
passes.add(new LoopRegionVisitor());
|
||||
|
||||
passes.add(new MarkMethodsForInline());
|
||||
|
||||
if (args.isInlineMethods()) {
|
||||
passes.add(new MarkMethodsForInline());
|
||||
}
|
||||
passes.add(new ProcessVariables());
|
||||
passes.add(new PrepareForCodeGen());
|
||||
if (args.isCfgOutput()) {
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package jadx.gui.settings;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Font;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Window;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
@@ -13,7 +17,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.JFrame;
|
||||
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -37,7 +41,7 @@ public class JadxSettings extends JadxCLIArgs {
|
||||
|
||||
private static final Path USER_HOME = Paths.get(System.getProperty("user.home"));
|
||||
private static final int RECENT_PROJECTS_COUNT = 15;
|
||||
private static final int CURRENT_SETTINGS_VERSION = 11;
|
||||
private static final int CURRENT_SETTINGS_VERSION = 12;
|
||||
|
||||
private static final Font DEFAULT_FONT = new RSyntaxTextArea().getFont();
|
||||
|
||||
@@ -336,6 +340,10 @@ public class JadxSettings extends JadxCLIArgs {
|
||||
this.inlineAnonymousClasses = inlineAnonymousClasses;
|
||||
}
|
||||
|
||||
public void setInlineMethods(boolean inlineMethods) {
|
||||
this.inlineMethods = inlineMethods;
|
||||
}
|
||||
|
||||
public void setFsCaseSensitive(boolean fsCaseSensitive) {
|
||||
this.fsCaseSensitive = fsCaseSensitive;
|
||||
}
|
||||
@@ -583,6 +591,10 @@ public class JadxSettings extends JadxCLIArgs {
|
||||
fontStr = fontStr.replace('-', '/');
|
||||
fromVersion++;
|
||||
}
|
||||
if (fromVersion == 11) {
|
||||
inlineMethods = true;
|
||||
fromVersion++;
|
||||
}
|
||||
if (fromVersion != CURRENT_SETTINGS_VERSION) {
|
||||
throw new JadxRuntimeException("Incorrect settings upgrade");
|
||||
}
|
||||
|
||||
@@ -442,6 +442,13 @@ public class JadxSettingsWindow extends JDialog {
|
||||
needReload();
|
||||
});
|
||||
|
||||
JCheckBox inlineMethods = new JCheckBox();
|
||||
inlineMethods.setSelected(settings.isInlineMethods());
|
||||
inlineMethods.addItemListener(e -> {
|
||||
settings.setInlineMethods(e.getStateChange() == ItemEvent.SELECTED);
|
||||
needReload();
|
||||
});
|
||||
|
||||
JCheckBox fsCaseSensitive = new JCheckBox();
|
||||
fsCaseSensitive.setSelected(settings.isFsCaseSensitive());
|
||||
fsCaseSensitive.addItemListener(e -> {
|
||||
@@ -460,6 +467,7 @@ public class JadxSettingsWindow extends JDialog {
|
||||
other.addRow(NLS.str("preferences.respectBytecodeAccessModifiers"), respectBytecodeAccessModifiers);
|
||||
other.addRow(NLS.str("preferences.useImports"), useImports);
|
||||
other.addRow(NLS.str("preferences.inlineAnonymous"), inlineAnonymous);
|
||||
other.addRow(NLS.str("preferences.inlineMethods"), inlineMethods);
|
||||
other.addRow(NLS.str("preferences.fsCaseSensitive"), fsCaseSensitive);
|
||||
other.addRow(NLS.str("preferences.fallback"), fallback);
|
||||
other.addRow(NLS.str("preferences.skipResourcesDecode"), resourceDecode);
|
||||
|
||||
@@ -118,6 +118,7 @@ preferences.replaceConsts=Konstanten ersetzen
|
||||
preferences.respectBytecodeAccessModifiers=Modifikatoren für Bytecode-Zugriff beachten
|
||||
preferences.useImports=Importauszüge verwenden
|
||||
preferences.inlineAnonymous=Anonyme Inline-Klassen
|
||||
#preferences.inlineMethods=Inline methods
|
||||
preferences.fsCaseSensitive=Dateisystem unterscheidet zwischen Groß/Kleinschreibung
|
||||
preferences.skipResourcesDecode=Keine Ressourcen dekodieren
|
||||
preferences.autoSave=Autom. speichern
|
||||
|
||||
@@ -118,6 +118,7 @@ preferences.replaceConsts=Replace constants
|
||||
preferences.respectBytecodeAccessModifiers=Respect bytecode access modifiers
|
||||
preferences.useImports=Use import statements
|
||||
preferences.inlineAnonymous=Inline anonymous classes
|
||||
preferences.inlineMethods=Inline methods
|
||||
preferences.fsCaseSensitive=File system is case sensitive
|
||||
preferences.skipResourcesDecode=Don't decode resources
|
||||
preferences.autoSave=Auto save
|
||||
|
||||
@@ -118,6 +118,7 @@ preferences.replaceConsts=Reemplazar constantes
|
||||
#preferences.respectBytecodeAccessModifiers=
|
||||
#preferences.useImports=
|
||||
#preferences.inlineAnonymous=
|
||||
#preferences.inlineMethods=Inline methods
|
||||
#preferences.fsCaseSensitive=
|
||||
preferences.skipResourcesDecode=No descodificar recursos
|
||||
#preferences.autoSave=
|
||||
|
||||
@@ -118,6 +118,7 @@ preferences.replaceConsts=상수 바꾸기
|
||||
preferences.respectBytecodeAccessModifiers=바이트코드 액세스 수정자 존중
|
||||
preferences.useImports=import 문 사용
|
||||
preferences.inlineAnonymous=인라인 익명 클래스
|
||||
#preferences.inlineMethods=Inline methods
|
||||
preferences.fsCaseSensitive=파일 시스템 대소문자 구별
|
||||
preferences.skipResourcesDecode=리소스 디코딩 하지 않기
|
||||
preferences.autoSave=자동 저장
|
||||
|
||||
@@ -118,6 +118,7 @@ preferences.replaceConsts=替换常量
|
||||
preferences.respectBytecodeAccessModifiers=遵守字节码访问修饰符
|
||||
preferences.useImports=使用 import 语句
|
||||
preferences.inlineAnonymous=内联匿名类
|
||||
#preferences.inlineMethods=Inline methods
|
||||
preferences.fsCaseSensitive=文件系统区分大小写
|
||||
preferences.skipResourcesDecode=不反编译资源文件
|
||||
preferences.autoSave=自动保存
|
||||
|
||||
Reference in New Issue
Block a user