feat: save jobf when decompiling to Java (#1274) (PR #1275)

* Save jobf when decompiling to Java through the cli
* Skip jobf saving if it's empty
* Update jadx-core/src/main/java/jadx/core/deobf/DeobfPresets.java

Co-authored-by: Yotam Nachum <me@yotam.net>
Co-authored-by: skylot <118523+skylot@users.noreply.github.com>
This commit is contained in:
Yotam
2021-11-14 22:49:27 +02:00
committed by GitHub
parent 570e7528a7
commit 985ccd6bba
2 changed files with 7 additions and 1 deletions
@@ -134,6 +134,12 @@ public class DeobfPresets {
list.add(String.format("m %s = %s", mthEntry.getKey(), mthEntry.getValue()));
}
Collections.sort(list);
if (list.isEmpty()) {
if (LOG.isDebugEnabled()) {
LOG.debug("Deobfuscation map is empty, not saving it");
}
return;
}
Files.write(deobfMapFile, list, MAP_FILE_CHARSET,
StandardOpenOption.WRITE, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
if (LOG.isDebugEnabled()) {
@@ -46,7 +46,7 @@ public class RenameVisitor extends AbstractVisitor {
checkClasses(deobfuscator, root, args);
UserRenames.applyForNodes(root);
if (args.isDeobfuscationOn()) {
if (args.isDeobfuscationOn() || !args.isJsonOutput()) {
deobfuscator.savePresets();
deobfuscator.clear();
}