-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add JADX decompiler * Use memory cache for JADX Speeds up things significantly. And yes, the memory is never reclaimed, but once we move the cache to the disk instead, that won't be an issue anymore * Much more efficient JADX implementation Now only passes the requested class instead of all input files. * Fix crash on second decompile * Un-`synchronize` JADX decompiling * New JADX implementation can decompile inner classes Also fix checkstyle issues * Fix JPMS issues * Put JADX menu entry underneath Vineflower * Small clean-up * Reduce JADX log spam * Remove JADX repackaging top-level classes workaround
- Loading branch information
1 parent
da3d2b9
commit 2cb3bbd
Showing
8 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package matcher.srcprocess; | ||
|
||
import java.io.IOException; | ||
import java.util.function.Consumer; | ||
|
||
import jadx.api.CommentsLevel; | ||
import jadx.api.JadxArgs; | ||
import jadx.api.JadxDecompiler; | ||
import jadx.api.impl.NoOpCodeCache; | ||
import jadx.api.plugins.input.data.IClassData; | ||
import jadx.api.plugins.input.data.ILoadResult; | ||
import jadx.api.plugins.input.data.IResourceData; | ||
import jadx.plugins.input.java.JavaClassReader; | ||
import jadx.plugins.input.java.data.JavaClassData; | ||
|
||
import matcher.NameType; | ||
import matcher.Util; | ||
import matcher.type.ClassFeatureExtractor; | ||
import matcher.type.ClassInstance; | ||
|
||
public class Jadx implements Decompiler { | ||
@Override | ||
public String decompile(ClassInstance cls, ClassFeatureExtractor env, NameType nameType) { | ||
String errorMessage = null; | ||
final String fullClassName = cls.getName(NameType.PLAIN, true); | ||
|
||
try (JadxDecompiler jadx = new JadxDecompiler(jadxArgs)) { | ||
jadx.addCustomLoad(new ILoadResult() { | ||
@Override | ||
public void close() throws IOException { } | ||
|
||
@Override | ||
public void visitClasses(Consumer<IClassData> consumer) { | ||
consumer.accept(new JavaClassData(new JavaClassReader(0, | ||
fullClassName + ".class", cls.serialize(nameType)))); | ||
} | ||
|
||
@Override | ||
public void visitResources(Consumer<IResourceData> consumer) { } | ||
|
||
@Override | ||
public boolean isEmpty() { | ||
return false; | ||
} | ||
}); | ||
jadx.load(); | ||
|
||
assert jadx.getClassesWithInners().size() == 1; | ||
return jadx.getClassesWithInners().get(0).getCode(); | ||
} catch (Exception e) { | ||
errorMessage = Util.getStackTrace(e); | ||
} | ||
|
||
throw new RuntimeException(errorMessage != null ? errorMessage : "JADX couldn't find the requested class"); | ||
} | ||
|
||
private static final JadxArgs jadxArgs; | ||
|
||
static { | ||
jadxArgs = new JadxArgs() { | ||
@Override | ||
public void close() { | ||
return; | ||
} | ||
}; | ||
jadxArgs.setCodeCache(NoOpCodeCache.INSTANCE); | ||
jadxArgs.setShowInconsistentCode(true); | ||
jadxArgs.setInlineAnonymousClasses(false); | ||
jadxArgs.setInlineMethods(false); | ||
jadxArgs.setSkipResources(true); | ||
jadxArgs.setRenameValid(false); | ||
jadxArgs.setRespectBytecodeAccModifiers(true); | ||
jadxArgs.setCommentsLevel(CommentsLevel.INFO); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
writer = console | ||
writer.format = {date: HH:mm:ss.SSS} [{thread}/{level}]: {message} | ||
writer.level = debug | ||
|
||
level@jadx = warn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
writer = console | ||
writer.format = {date: HH:mm:ss} [{level}]: {message} | ||
writer.level = info | ||
|
||
level@jadx = error |