summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar liach2020-04-02 10:36:27 -0500
committerGravatar GitHub2020-04-02 16:36:27 +0100
commitccccfa1786d783867daf91fbfa522d4a5c55dfdb (patch)
treeb09cbde37e4757c993d59dfd70bfee81fbbd5e63
parentMerge pull request #203 from Runemoro/fix-cfr (diff)
downloadenigma-ccccfa1786d783867daf91fbfa522d4a5c55dfdb.tar.gz
enigma-ccccfa1786d783867daf91fbfa522d4a5c55dfdb.tar.xz
enigma-ccccfa1786d783867daf91fbfa522d4a5c55dfdb.zip
Support java 9+ and gradle 6+ (#206)
* Support java 9+ and gradle 6+ * Update asm Signed-off-by: liach <liach@users.noreply.github.com> * Use asm 8 and move that to a constant * Bump version * fix version format Co-authored-by: liach <liach@users.noreply.github.com>
-rw-r--r--build.gradle25
-rw-r--r--src/main/java/cuchaz/enigma/EnigmaProject.java3
-rw-r--r--src/main/java/cuchaz/enigma/analysis/BuiltinPlugin.java3
-rw-r--r--src/main/java/cuchaz/enigma/analysis/ClassCache.java3
-rw-r--r--src/main/java/cuchaz/enigma/analysis/IndexSimpleVerifier.java3
-rw-r--r--src/main/java/cuchaz/enigma/analysis/InterpreterPair.java3
-rw-r--r--src/main/java/cuchaz/enigma/analysis/index/JarIndex.java5
-rw-r--r--src/main/java/cuchaz/enigma/bytecode/translators/TranslationSignatureVisitor.java3
-rw-r--r--src/main/java/cuchaz/enigma/gui/GuiController.java2
-rw-r--r--src/main/java/cuchaz/enigma/utils/Utils.java3
-rw-r--r--src/test/resources/proguard-build.conf3
-rw-r--r--src/test/resources/proguard-test.conf3
12 files changed, 35 insertions, 24 deletions
diff --git a/build.gradle b/build.gradle
index 7d1e4196..34573cf0 100644
--- a/build.gradle
+++ b/build.gradle
@@ -19,14 +19,12 @@ apply plugin: 'com.github.johnrengelman.shadow'
19apply plugin: 'maven' 19apply plugin: 'maven'
20 20
21group = 'cuchaz' 21group = 'cuchaz'
22version = '0.15' 22version = '0.15.1'
23 23
24def generatedSourcesDir = "$buildDir/generated-src" 24def generatedSourcesDir = "$buildDir/generated-src"
25 25
26def ENV = System.getenv() 26def ENV = System.getenv()
27if (ENV.BUILD_NUMBER) { 27version = version + "+" + (ENV.BUILD_NUMBER ? ("build." + ENV.BUILD_NUMBER) : "local")
28 version = version + "." + "${System.getenv().BUILD_NUMBER}"
29}
30 28
31sourceCompatibility = 1.8 29sourceCompatibility = 1.8
32targetCompatibility = 1.8 30targetCompatibility = 1.8
@@ -60,6 +58,9 @@ repositories {
60 ivy { 58 ivy {
61 name "darcula" 59 name "darcula"
62 artifactPattern "https://raw.githubusercontent.com/bulenkov/Darcula/master/build/[module].[ext]" 60 artifactPattern "https://raw.githubusercontent.com/bulenkov/Darcula/master/build/[module].[ext]"
61 metadataSources {
62 artifact()
63 }
63 } 64 }
64} 65}
65 66
@@ -73,10 +74,10 @@ configurations {
73dependencies { 74dependencies {
74 compile 'com.google.guava:guava:28.0-jre' 75 compile 'com.google.guava:guava:28.0-jre'
75 compile 'com.google.code.gson:gson:2.8.5' 76 compile 'com.google.code.gson:gson:2.8.5'
76 compile 'org.ow2.asm:asm:7.1' 77 compile 'org.ow2.asm:asm:8.0'
77 compile 'org.ow2.asm:asm-commons:7.1' 78 compile 'org.ow2.asm:asm-commons:8.0'
78 compile 'org.ow2.asm:asm-tree:7.1' 79 compile 'org.ow2.asm:asm-tree:8.0'
79 compile 'org.ow2.asm:asm-util:7.1' 80 compile 'org.ow2.asm:asm-util:8.0'
80 compile 'net.sf.jopt-simple:jopt-simple:6.0-alpha-3' 81 compile 'net.sf.jopt-simple:jopt-simple:6.0-alpha-3'
81 82
82 compile 'net.fabricmc:procyon-fabric-compilertools:0.5.35.+' 83 compile 'net.fabricmc:procyon-fabric-compilertools:0.5.35.+'
@@ -88,9 +89,11 @@ dependencies {
88 89
89 testCompile 'junit:junit:4.+' 90 testCompile 'junit:junit:4.+'
90 testCompile 'org.hamcrest:hamcrest-all:1.+' 91 testCompile 'org.hamcrest:hamcrest-all:1.+'
91 proGuard 'net.sf.proguard:proguard-base:5.+' 92 proGuard 'net.sf.proguard:proguard-base:6.+'
92} 93}
93 94
95def libraryJarsArg = JavaVersion.current().java9Compatible ? "<java.home>/jmods": "<java.home>/lib/rt.jar"
96
94// For each set of test inputs, create an output jar and obfuscate it. 97// For each set of test inputs, create an output jar and obfuscate it.
95file('src/test/java/cuchaz/enigma/inputs').listFiles().each { theFile -> 98file('src/test/java/cuchaz/enigma/inputs').listFiles().each { theFile ->
96 if (theFile.directory) { 99 if (theFile.directory) {
@@ -110,8 +113,8 @@ file('src/test/java/cuchaz/enigma/inputs').listFiles().each { theFile ->
110 classpath configurations.proGuard 113 classpath configurations.proGuard
111 114
112 args '@src/test/resources/proguard-test.conf', '-injars', file('build/test-inputs/' + 115 args '@src/test/resources/proguard-test.conf', '-injars', file('build/test-inputs/' +
113 "${theFile.name}.jar"), '-outjars', file('build/test-obf/' + 116 "${theFile.name}.jar"), '-libraryjars', libraryJarsArg,
114 "${theFile.name}.jar") 117 '-outjars', file('build/test-obf/' + "${theFile.name}.jar")
115 } 118 }
116 119
117 test.dependsOn "${theFile.name}TestObf" 120 test.dependsOn "${theFile.name}TestObf"
diff --git a/src/main/java/cuchaz/enigma/EnigmaProject.java b/src/main/java/cuchaz/enigma/EnigmaProject.java
index 78b49b57..852bfc49 100644
--- a/src/main/java/cuchaz/enigma/EnigmaProject.java
+++ b/src/main/java/cuchaz/enigma/EnigmaProject.java
@@ -18,6 +18,7 @@ import cuchaz.enigma.translation.representation.entry.LocalVariableEntry;
18import cuchaz.enigma.translation.representation.entry.MethodEntry; 18import cuchaz.enigma.translation.representation.entry.MethodEntry;
19import cuchaz.enigma.utils.I18n; 19import cuchaz.enigma.utils.I18n;
20 20
21import cuchaz.enigma.utils.Utils;
21import org.objectweb.asm.ClassWriter; 22import org.objectweb.asm.ClassWriter;
22import org.objectweb.asm.Opcodes; 23import org.objectweb.asm.Opcodes;
23import org.objectweb.asm.tree.ClassNode; 24import org.objectweb.asm.tree.ClassNode;
@@ -152,7 +153,7 @@ public class EnigmaProject {
152 ClassNode node = classCache.getClassNode(entry.getFullName()); 153 ClassNode node = classCache.getClassNode(entry.getFullName());
153 if (node != null) { 154 if (node != null) {
154 ClassNode translatedNode = new ClassNode(); 155 ClassNode translatedNode = new ClassNode();
155 node.accept(new TranslationClassVisitor(deobfuscator, Opcodes.ASM5, new SourceFixVisitor(Opcodes.ASM5, translatedNode, jarIndex))); 156 node.accept(new TranslationClassVisitor(deobfuscator, Utils.ASM_VERSION, new SourceFixVisitor(Utils.ASM_VERSION, translatedNode, jarIndex)));
156 return translatedNode; 157 return translatedNode;
157 } 158 }
158 159
diff --git a/src/main/java/cuchaz/enigma/analysis/BuiltinPlugin.java b/src/main/java/cuchaz/enigma/analysis/BuiltinPlugin.java
index fddd9a8e..dc3f5535 100644
--- a/src/main/java/cuchaz/enigma/analysis/BuiltinPlugin.java
+++ b/src/main/java/cuchaz/enigma/analysis/BuiltinPlugin.java
@@ -12,6 +12,7 @@ import cuchaz.enigma.translation.representation.entry.ClassEntry;
12import cuchaz.enigma.translation.representation.entry.Entry; 12import cuchaz.enigma.translation.representation.entry.Entry;
13import cuchaz.enigma.translation.representation.entry.FieldEntry; 13import cuchaz.enigma.translation.representation.entry.FieldEntry;
14import cuchaz.enigma.utils.Pair; 14import cuchaz.enigma.utils.Pair;
15import cuchaz.enigma.utils.Utils;
15import org.objectweb.asm.ClassReader; 16import org.objectweb.asm.ClassReader;
16import org.objectweb.asm.ClassVisitor; 17import org.objectweb.asm.ClassVisitor;
17import org.objectweb.asm.FieldVisitor; 18import org.objectweb.asm.FieldVisitor;
@@ -69,7 +70,7 @@ public final class BuiltinPlugin implements EnigmaPlugin {
69 private final List<MethodNode> classInits = new ArrayList<>(); 70 private final List<MethodNode> classInits = new ArrayList<>();
70 71
71 EnumFieldNameFindingVisitor(Map<Entry<?>, String> mappings) { 72 EnumFieldNameFindingVisitor(Map<Entry<?>, String> mappings) {
72 super(Opcodes.ASM7); 73 super(Utils.ASM_VERSION);
73 this.mappings = mappings; 74 this.mappings = mappings;
74 } 75 }
75 76
diff --git a/src/main/java/cuchaz/enigma/analysis/ClassCache.java b/src/main/java/cuchaz/enigma/analysis/ClassCache.java
index d97b2041..f694bf35 100644
--- a/src/main/java/cuchaz/enigma/analysis/ClassCache.java
+++ b/src/main/java/cuchaz/enigma/analysis/ClassCache.java
@@ -7,6 +7,7 @@ import cuchaz.enigma.ClassProvider;
7import cuchaz.enigma.ProgressListener; 7import cuchaz.enigma.ProgressListener;
8import cuchaz.enigma.analysis.index.JarIndex; 8import cuchaz.enigma.analysis.index.JarIndex;
9import cuchaz.enigma.bytecode.translators.LocalVariableFixVisitor; 9import cuchaz.enigma.bytecode.translators.LocalVariableFixVisitor;
10import cuchaz.enigma.utils.Utils;
10import org.objectweb.asm.ClassReader; 11import org.objectweb.asm.ClassReader;
11import org.objectweb.asm.ClassVisitor; 12import org.objectweb.asm.ClassVisitor;
12import org.objectweb.asm.Opcodes; 13import org.objectweb.asm.Opcodes;
@@ -77,7 +78,7 @@ public final class ClassCache implements AutoCloseable, ClassProvider {
77 78
78 ClassNode node = new ClassNode(); 79 ClassNode node = new ClassNode();
79 80
80 LocalVariableFixVisitor visitor = new LocalVariableFixVisitor(Opcodes.ASM5, node); 81 LocalVariableFixVisitor visitor = new LocalVariableFixVisitor(Utils.ASM_VERSION, node);
81 reader.accept(visitor, 0); 82 reader.accept(visitor, 0);
82 83
83 return node; 84 return node;
diff --git a/src/main/java/cuchaz/enigma/analysis/IndexSimpleVerifier.java b/src/main/java/cuchaz/enigma/analysis/IndexSimpleVerifier.java
index da2b5efe..80a71546 100644
--- a/src/main/java/cuchaz/enigma/analysis/IndexSimpleVerifier.java
+++ b/src/main/java/cuchaz/enigma/analysis/IndexSimpleVerifier.java
@@ -5,6 +5,7 @@ import cuchaz.enigma.analysis.index.InheritanceIndex;
5import cuchaz.enigma.translation.representation.AccessFlags; 5import cuchaz.enigma.translation.representation.AccessFlags;
6import cuchaz.enigma.translation.representation.entry.ClassDefEntry; 6import cuchaz.enigma.translation.representation.entry.ClassDefEntry;
7import cuchaz.enigma.translation.representation.entry.ClassEntry; 7import cuchaz.enigma.translation.representation.entry.ClassEntry;
8import cuchaz.enigma.utils.Utils;
8import org.objectweb.asm.Type; 9import org.objectweb.asm.Type;
9import org.objectweb.asm.tree.analysis.BasicValue; 10import org.objectweb.asm.tree.analysis.BasicValue;
10import org.objectweb.asm.tree.analysis.SimpleVerifier; 11import org.objectweb.asm.tree.analysis.SimpleVerifier;
@@ -17,7 +18,7 @@ public class IndexSimpleVerifier extends SimpleVerifier {
17 private final InheritanceIndex inheritanceIndex; 18 private final InheritanceIndex inheritanceIndex;
18 19
19 public IndexSimpleVerifier(EntryIndex entryIndex, InheritanceIndex inheritanceIndex) { 20 public IndexSimpleVerifier(EntryIndex entryIndex, InheritanceIndex inheritanceIndex) {
20 super(ASM7, null, null, null, false); 21 super(Utils.ASM_VERSION, null, null, null, false);
21 this.entryIndex = entryIndex; 22 this.entryIndex = entryIndex;
22 this.inheritanceIndex = inheritanceIndex; 23 this.inheritanceIndex = inheritanceIndex;
23 } 24 }
diff --git a/src/main/java/cuchaz/enigma/analysis/InterpreterPair.java b/src/main/java/cuchaz/enigma/analysis/InterpreterPair.java
index af74c854..f2607291 100644
--- a/src/main/java/cuchaz/enigma/analysis/InterpreterPair.java
+++ b/src/main/java/cuchaz/enigma/analysis/InterpreterPair.java
@@ -1,5 +1,6 @@
1package cuchaz.enigma.analysis; 1package cuchaz.enigma.analysis;
2 2
3import cuchaz.enigma.utils.Utils;
3import org.objectweb.asm.Opcodes; 4import org.objectweb.asm.Opcodes;
4import org.objectweb.asm.Type; 5import org.objectweb.asm.Type;
5import org.objectweb.asm.tree.AbstractInsnNode; 6import org.objectweb.asm.tree.AbstractInsnNode;
@@ -16,7 +17,7 @@ public class InterpreterPair<V extends Value, W extends Value> extends Interpret
16 private final Interpreter<W> right; 17 private final Interpreter<W> right;
17 18
18 public InterpreterPair(Interpreter<V> left, Interpreter<W> right) { 19 public InterpreterPair(Interpreter<V> left, Interpreter<W> right) {
19 super(Opcodes.ASM7); 20 super(Utils.ASM_VERSION);
20 this.left = left; 21 this.left = left;
21 this.right = right; 22 this.right = right;
22 } 23 }
diff --git a/src/main/java/cuchaz/enigma/analysis/index/JarIndex.java b/src/main/java/cuchaz/enigma/analysis/index/JarIndex.java
index c96e7747..e401c2f7 100644
--- a/src/main/java/cuchaz/enigma/analysis/index/JarIndex.java
+++ b/src/main/java/cuchaz/enigma/analysis/index/JarIndex.java
@@ -22,6 +22,7 @@ import cuchaz.enigma.translation.representation.Lambda;
22import cuchaz.enigma.translation.representation.entry.*; 22import cuchaz.enigma.translation.representation.entry.*;
23import cuchaz.enigma.utils.I18n; 23import cuchaz.enigma.utils.I18n;
24 24
25import cuchaz.enigma.utils.Utils;
25import org.objectweb.asm.ClassReader; 26import org.objectweb.asm.ClassReader;
26import org.objectweb.asm.Opcodes; 27import org.objectweb.asm.Opcodes;
27 28
@@ -63,10 +64,10 @@ public class JarIndex implements JarIndexer {
63 progress.init(4, I18n.translate("progress.jar.indexing")); 64 progress.init(4, I18n.translate("progress.jar.indexing"));
64 65
65 progress.step(1, I18n.translate("progress.jar.indexing.entries")); 66 progress.step(1, I18n.translate("progress.jar.indexing.entries"));
66 classCache.visit(() -> new IndexClassVisitor(this, Opcodes.ASM5), ClassReader.SKIP_CODE); 67 classCache.visit(() -> new IndexClassVisitor(this, Utils.ASM_VERSION), ClassReader.SKIP_CODE);
67 68
68 progress.step(2, I18n.translate("progress.jar.indexing.references")); 69 progress.step(2, I18n.translate("progress.jar.indexing.references"));
69 classCache.visit(() -> new IndexReferenceVisitor(this, entryIndex, inheritanceIndex, Opcodes.ASM5), 0); 70 classCache.visit(() -> new IndexReferenceVisitor(this, entryIndex, inheritanceIndex, Utils.ASM_VERSION), 0);
70 71
71 progress.step(3, I18n.translate("progress.jar.indexing.methods")); 72 progress.step(3, I18n.translate("progress.jar.indexing.methods"));
72 bridgeMethodIndex.findBridgeMethods(); 73 bridgeMethodIndex.findBridgeMethods();
diff --git a/src/main/java/cuchaz/enigma/bytecode/translators/TranslationSignatureVisitor.java b/src/main/java/cuchaz/enigma/bytecode/translators/TranslationSignatureVisitor.java
index e66b085f..8e7780e6 100644
--- a/src/main/java/cuchaz/enigma/bytecode/translators/TranslationSignatureVisitor.java
+++ b/src/main/java/cuchaz/enigma/bytecode/translators/TranslationSignatureVisitor.java
@@ -1,5 +1,6 @@
1package cuchaz.enigma.bytecode.translators; 1package cuchaz.enigma.bytecode.translators;
2 2
3import cuchaz.enigma.utils.Utils;
3import org.objectweb.asm.Opcodes; 4import org.objectweb.asm.Opcodes;
4import org.objectweb.asm.signature.SignatureVisitor; 5import org.objectweb.asm.signature.SignatureVisitor;
5 6
@@ -13,7 +14,7 @@ public class TranslationSignatureVisitor extends SignatureVisitor {
13 private final Stack<String> classStack = new Stack<>(); 14 private final Stack<String> classStack = new Stack<>();
14 15
15 public TranslationSignatureVisitor(Function<String, String> remapper, SignatureVisitor sv) { 16 public TranslationSignatureVisitor(Function<String, String> remapper, SignatureVisitor sv) {
16 super(Opcodes.ASM5); 17 super(Utils.ASM_VERSION);
17 this.remapper = remapper; 18 this.remapper = remapper;
18 this.sv = sv; 19 this.sv = sv;
19 } 20 }
diff --git a/src/main/java/cuchaz/enigma/gui/GuiController.java b/src/main/java/cuchaz/enigma/gui/GuiController.java
index 17c81dde..261238b7 100644
--- a/src/main/java/cuchaz/enigma/gui/GuiController.java
+++ b/src/main/java/cuchaz/enigma/gui/GuiController.java
@@ -111,7 +111,7 @@ public class GuiController {
111 } 111 }
112 112
113 ClassNode fixedNode = new ClassNode(); 113 ClassNode fixedNode = new ClassNode();
114 node.accept(new SourceFixVisitor(Opcodes.ASM7, fixedNode, project.getJarIndex())); 114 node.accept(new SourceFixVisitor(Utils.ASM_VERSION, fixedNode, project.getJarIndex()));
115 return fixedNode; 115 return fixedNode;
116 }, new SourceSettings(true, true)); 116 }, new SourceSettings(true, true));
117 } 117 }
diff --git a/src/main/java/cuchaz/enigma/utils/Utils.java b/src/main/java/cuchaz/enigma/utils/Utils.java
index 17f6fb8f..b8f2ec23 100644
--- a/src/main/java/cuchaz/enigma/utils/Utils.java
+++ b/src/main/java/cuchaz/enigma/utils/Utils.java
@@ -12,6 +12,7 @@
12package cuchaz.enigma.utils; 12package cuchaz.enigma.utils;
13 13
14import com.google.common.io.CharStreams; 14import com.google.common.io.CharStreams;
15import org.objectweb.asm.Opcodes;
15 16
16import javax.swing.*; 17import javax.swing.*;
17import java.awt.*; 18import java.awt.*;
@@ -30,6 +31,8 @@ import java.util.StringJoiner;
30import java.util.stream.Collectors; 31import java.util.stream.Collectors;
31 32
32public class Utils { 33public class Utils {
34
35 public static final int ASM_VERSION = Opcodes.ASM8;
33 36
34 public static int combineHashesOrdered(Object... objs) { 37 public static int combineHashesOrdered(Object... objs) {
35 final int prime = 67; 38 final int prime = 67;
diff --git a/src/test/resources/proguard-build.conf b/src/test/resources/proguard-build.conf
index 117180e6..ba3575ae 100644
--- a/src/test/resources/proguard-build.conf
+++ b/src/test/resources/proguard-build.conf
@@ -1,7 +1,6 @@
1-libraryjars <java.home>/lib/rt.jar
2-dontoptimize 1-dontoptimize
3-dontobfuscate 2-dontobfuscate
4-dontwarn 3-dontwarn
5-keep class cuchaz.enigma.Main { static void main(java.lang.String[]); } 4-keep class cuchaz.enigma.Main { static void main(java.lang.String[]); }
6-keep class cuchaz.enigma.CommandMain { static void main(java.lang.String[]); } 5-keep class cuchaz.enigma.CommandMain { static void main(java.lang.String[]); }
7-keep class de.sciss.syntaxpane.** { *; } \ No newline at end of file 6-keep class de.sciss.syntaxpane.** { *; }
diff --git a/src/test/resources/proguard-test.conf b/src/test/resources/proguard-test.conf
index 0d3d60e9..9411d269 100644
--- a/src/test/resources/proguard-test.conf
+++ b/src/test/resources/proguard-test.conf
@@ -1,4 +1,3 @@
1-libraryjars <java.home>/lib/rt.jar
2-overloadaggressively 1-overloadaggressively
3-repackageclasses 2-repackageclasses
4-allowaccessmodification 3-allowaccessmodification
@@ -6,4 +5,4 @@
6-dontshrink 5-dontshrink
7-keepparameternames 6-keepparameternames
8-keepattributes 7-keepattributes
9-keep class cuchaz.enigma.inputs.Keep \ No newline at end of file 8-keep class cuchaz.enigma.inputs.Keep