Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix for issue #848 - additionally show smali code of all inner classes (recursively) #849

Merged
merged 1 commit into from
Feb 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -451,6 +452,18 @@ public List<ClassNode> getInnerClasses() {
return innerClasses;
}

/**
* Get all inner classes recursively
*
* @param innerClassesColl all identified inner classes are added to this collection
*/
public void getInnerClassesRecursive(Collection<ClassNode> innerClassesColl) {
for (ClassNode innerClass : innerClasses) {
innerClassesColl.add(innerClass);
innerClass.getInnerClassesRecursive(innerClassesColl);
}
}

public void addInnerClass(ClassNode cls) {
if (innerClasses.isEmpty()) {
innerClasses = new ArrayList<>(5);
Expand Down Expand Up @@ -537,7 +550,9 @@ public String getSmali() {
StringWriter stringWriter = new StringWriter(4096);
getSmali(this, stringWriter);
stringWriter.append(System.lineSeparator());
for (ClassNode innerClass : innerClasses) {
List<ClassNode> allInnerClasses = new ArrayList<>();
getInnerClassesRecursive(allInnerClasses);
for (ClassNode innerClass : allInnerClasses) {
getSmali(innerClass, stringWriter);
stringWriter.append(System.lineSeparator());
}
Expand Down