From b4286f27551dcda4f7629c81f9d6aa42b3b757cd Mon Sep 17 00:00:00 2001 From: NebelNidas Date: Wed, 12 Apr 2023 13:07:47 +0200 Subject: [PATCH] New JADX implementation can decompile inner classes Also fix checkstyle issues --- src/main/java/matcher/srcprocess/Jadx.java | 56 ++++++++++------------ 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/src/main/java/matcher/srcprocess/Jadx.java b/src/main/java/matcher/srcprocess/Jadx.java index 9478fc11..a18bcf22 100644 --- a/src/main/java/matcher/srcprocess/Jadx.java +++ b/src/main/java/matcher/srcprocess/Jadx.java @@ -1,8 +1,6 @@ package matcher.srcprocess; -import java.io.ByteArrayInputStream; import java.io.IOException; -import java.io.InputStream; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; @@ -27,39 +25,35 @@ public String decompile(ClassInstance cls, ClassFeatureExtractor env, NameType n String errorMessage = null; final String fullClassName = cls.getName(NameType.PLAIN, true); - if (fullClassName.contains("$")) { - errorMessage = "JADX doesn't support decompiling inner classes!"; - } else { - try (JadxDecompiler jadx = new JadxDecompiler(jadxArgs)) { - jadx.addCustomLoad(new ILoadResult() { - @Override - public void close() throws IOException { - return; - } + try (JadxDecompiler jadx = new JadxDecompiler(jadxArgs)) { + jadx.addCustomLoad(new ILoadResult() { + @Override + public void close() throws IOException { + return; + } - @Override - public void visitClasses(Consumer consumer) { - consumer.accept(new JavaClassData(new JavaClassReader(idGenerator.getAndIncrement(), - fullClassName + ".class", cls.serialize(nameType)))); - } + @Override + public void visitClasses(Consumer consumer) { + consumer.accept(new JavaClassData(new JavaClassReader(idGenerator.getAndIncrement(), + fullClassName + ".class", cls.serialize(nameType)))); + } - @Override - public void visitResources(Consumer consumer) { - return; - } + @Override + public void visitResources(Consumer consumer) { + return; + } - @Override - public boolean isEmpty() { - return false; - } - }); - jadx.load(); + @Override + public boolean isEmpty() { + return false; + } + }); + jadx.load(); - assert jadx.getClassesWithInners().size() == 1; - return jadx.getClassesWithInners().get(0).getCode(); - } catch (Exception e) { - errorMessage = Utils.getStackTrace(e); - } + assert jadx.getClassesWithInners().size() == 1; + return jadx.getClassesWithInners().get(0).getCode(); + } catch (Exception e) { + errorMessage = Utils.getStackTrace(e); } throw new RuntimeException(errorMessage != null ? errorMessage : "JADX couldn't find the requested class");