Commit 18a1788d authored by Skylot's avatar Skylot

gui: fix class members expand

parent d0aa1911
......@@ -54,6 +54,7 @@ public final class Decompiler {
private RootNode root;
private List<IDexTreeVisitor> passes;
private List<JavaClass> classes;
public Decompiler() {
this.args = new DefaultJadxArgs();
......@@ -95,6 +96,7 @@ public final class Decompiler {
public void save() {
try {
ExecutorService ex = getSaveExecutor();
ex.shutdown();
ex.awaitTermination(1, TimeUnit.DAYS);
} catch (InterruptedException e) {
LOG.error("Save interrupted", e);
......@@ -122,23 +124,24 @@ public final class Decompiler {
}
});
}
executor.shutdown();
return executor;
}
public List<JavaClass> getClasses() {
List<ClassNode> classNodeList = root.getClasses(false);
List<JavaClass> classes = new ArrayList<JavaClass>(classNodeList.size());
for (ClassNode classNode : classNodeList) {
classes.add(new JavaClass(this, classNode));
if (classes == null) {
List<ClassNode> classNodeList = root.getClasses(false);
List<JavaClass> clsList = new ArrayList<JavaClass>(classNodeList.size());
for (ClassNode classNode : classNodeList) {
clsList.add(new JavaClass(this, classNode));
}
classes = Collections.unmodifiableList(clsList);
}
return Collections.unmodifiableList(classes);
return classes;
}
public List<JavaPackage> getPackages() {
List<JavaClass> classes = getClasses();
Map<String, List<JavaClass>> map = new HashMap<String, List<JavaClass>>();
for (JavaClass javaClass : classes) {
for (JavaClass javaClass : getClasses()) {
String pkg = javaClass.getPackage();
List<JavaClass> clsList = map.get(pkg);
if (clsList == null) {
......@@ -168,14 +171,18 @@ public final class Decompiler {
}
void parse() throws DecodeException {
ClassInfo.clearCache();
ErrorsCounter.reset();
reset();
root = new RootNode();
LOG.info("loading ...");
root.load(inputFiles);
}
private void reset() {
ClassInfo.clearCache();
ErrorsCounter.reset();
classes = null;
}
void processClass(ClassNode cls) {
LOG.info("processing class {} ...", cls);
ProcessClass.process(cls, passes);
......@@ -184,4 +191,16 @@ public final class Decompiler {
RootNode getRoot() {
return root;
}
JavaClass findJavaClass(ClassNode cls) {
if (cls == null) {
return null;
}
for (JavaClass javaClass : getClasses()) {
if (javaClass.getClassNode().equals(cls)) {
return javaClass;
}
}
return null;
}
}
......@@ -48,6 +48,10 @@ public final class JavaClass {
}
}
ClassNode getClassNode() {
return cls;
}
private void load() {
int inClsCount = cls.getInnerClasses().size();
if (inClsCount != 0) {
......@@ -92,7 +96,7 @@ public final class JavaClass {
}
private Map<CodePosition, Object> getCodeAnnotations() {
getCode();
decompile();
return cls.getCode().getAnnotations();
}
......@@ -108,13 +112,17 @@ public final class JavaClass {
} else if (obj instanceof FieldNode) {
clsNode = ((FieldNode) obj).getParentClass();
}
if (clsNode != null) {
clsNode = clsNode.getParentClass();
JavaClass jCls = new JavaClass(decompiler, clsNode);
jCls.decompile();
int defLine = ((LineAttrNode) obj).getDecompiledLine();
return new CodePosition(jCls, defLine, 0);
if (clsNode == null) {
return null;
}
clsNode = clsNode.getParentClass();
JavaClass jCls = decompiler.findJavaClass(clsNode);
if (jCls == null) {
return null;
}
jCls.decompile();
int defLine = ((LineAttrNode) obj).getDecompiledLine();
return new CodePosition(jCls, defLine, 0);
}
return null;
}
......
......@@ -43,6 +43,7 @@ public class JadxWrapper {
try {
decompiler.setOutputDir(dir);
ThreadPoolExecutor ex = decompiler.getSaveExecutor();
ex.shutdown();
while (ex.isTerminating()) {
long total = ex.getTaskCount();
long done = ex.getCompletedTaskCount();
......
......@@ -45,8 +45,8 @@ public class JClass extends JNode {
if (!loaded) {
cls.decompile();
loaded = true;
update();
}
update();
}
public synchronized void update() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment