Skip to content

Commit

Permalink
fix(gui): workaround to force class decompilation in loading task (#2400
Browse files Browse the repository at this point in the history
)
  • Loading branch information
skylot committed Jan 25, 2025
1 parent 306547d commit 54fbbd9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
12 changes: 7 additions & 5 deletions jadx-core/src/main/java/jadx/api/JavaClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,24 +122,27 @@ public ClassNode getClassNode() {
if (listsLoaded) {
return null;
}
listsLoaded = true;

ICodeInfo code;
if (cls.getState().isProcessComplete()) {
// already decompiled -> class internals loaded
code = null;
} else {
code = cls.decompile();
}
loadLists();
return code;
}

private void loadLists() {
listsLoaded = true;
JadxDecompiler rootDecompiler = getRootDecompiler();
int inClsCount = cls.getInnerClasses().size();
if (inClsCount != 0) {
List<JavaClass> list = new ArrayList<>(inClsCount);
for (ClassNode inner : cls.getInnerClasses()) {
if (!inner.contains(AFlag.DONT_GENERATE)) {
JavaClass javaClass = rootDecompiler.convertClassNode(inner);
javaClass.load();
javaClass.loadLists();
list.add(javaClass);
}
}
Expand All @@ -150,7 +153,7 @@ public ClassNode getClassNode() {
List<JavaClass> list = new ArrayList<>(inlinedClsCount);
for (ClassNode inner : cls.getInlinedClasses()) {
JavaClass javaClass = rootDecompiler.convertClassNode(inner);
javaClass.load();
javaClass.loadLists();
list.add(javaClass);
}
this.inlinedClasses = Collections.unmodifiableList(list);
Expand Down Expand Up @@ -178,7 +181,6 @@ public ClassNode getClassNode() {
mths.sort(Comparator.comparing(JavaMethod::getName));
this.methods = Collections.unmodifiableList(mths);
}
return code;
}

JadxDecompiler getRootDecompiler() {
Expand Down
5 changes: 3 additions & 2 deletions jadx-gui/src/main/java/jadx/gui/treemodel/JClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ public void loadNode() {
public SimpleTask getLoadTask() {
JClass rootClass = getRootClass();
return new SimpleTask(NLS.str("progress.decompile"),
() -> rootClass.getCls().decompile(),
rootClass::load);
() -> rootClass.getCls().getClassNode().decompile(), // run decompilation in background
rootClass::load // load class internals and update UI
);
}

private synchronized void load() {
Expand Down

0 comments on commit 54fbbd9

Please sign in to comment.