summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/cuchaz/enigma/TestDeobfed.java28
-rw-r--r--src/test/java/cuchaz/enigma/TestDeobfuscator.java29
-rw-r--r--src/test/java/cuchaz/enigma/TestEntryFactory.java49
-rw-r--r--src/test/java/cuchaz/enigma/TestInnerClasses.java53
-rw-r--r--src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java63
-rw-r--r--src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java117
-rw-r--r--src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java67
-rw-r--r--src/test/java/cuchaz/enigma/TestSignature.java40
-rw-r--r--src/test/java/cuchaz/enigma/TestSourceIndex.java30
-rw-r--r--src/test/java/cuchaz/enigma/TestTokensConstructors.java45
-rw-r--r--src/test/java/cuchaz/enigma/TestTranslator.java19
-rw-r--r--src/test/java/cuchaz/enigma/TestType.java46
-rw-r--r--src/test/java/cuchaz/enigma/TokenChecker.java32
-rw-r--r--src/test/java/cuchaz/enigma/inputs/Keep.java3
-rw-r--r--src/test/java/cuchaz/enigma/inputs/constructors/BaseClass.java7
-rw-r--r--src/test/java/cuchaz/enigma/inputs/constructors/Caller.java17
-rw-r--r--src/test/java/cuchaz/enigma/inputs/constructors/DefaultConstructable.java3
-rw-r--r--src/test/java/cuchaz/enigma/inputs/constructors/SubClass.java11
-rw-r--r--src/test/java/cuchaz/enigma/inputs/constructors/SubSubClass.java5
-rw-r--r--src/test/java/cuchaz/enigma/inputs/inheritanceTree/BaseClass.java11
-rw-r--r--src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassA.java5
-rw-r--r--src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassB.java13
-rw-r--r--src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubsubclassAA.java9
-rw-r--r--src/test/java/cuchaz/enigma/inputs/innerClasses/A_Anonymous.java5
-rw-r--r--src/test/java/cuchaz/enigma/inputs/innerClasses/B_AnonymousWithScopeArgs.java5
-rw-r--r--src/test/java/cuchaz/enigma/inputs/innerClasses/C_ConstructorArgs.java21
-rw-r--r--src/test/java/cuchaz/enigma/inputs/innerClasses/D_Simple.java5
-rw-r--r--src/test/java/cuchaz/enigma/inputs/innerClasses/E_AnonymousWithOuterAccess.java9
-rw-r--r--src/test/java/cuchaz/enigma/inputs/innerClasses/F_ClassTree.java16
-rw-r--r--src/test/java/cuchaz/enigma/inputs/loneClass/LoneClass.java9
-rw-r--r--src/test/java/cuchaz/enigma/inputs/translation/A_Basic.java13
-rw-r--r--src/test/java/cuchaz/enigma/inputs/translation/B_BaseClass.java9
-rw-r--r--src/test/java/cuchaz/enigma/inputs/translation/C_SubClass.java9
-rw-r--r--src/test/java/cuchaz/enigma/inputs/translation/D_AnonymousTesting.java5
-rw-r--r--src/test/java/cuchaz/enigma/inputs/translation/E_Bridges.java4
-rw-r--r--src/test/java/cuchaz/enigma/inputs/translation/F_ObjectMethods.java7
-rw-r--r--src/test/java/cuchaz/enigma/inputs/translation/G_OuterClass.java18
-rw-r--r--src/test/java/cuchaz/enigma/inputs/translation/H_NamelessClass.java20
-rw-r--r--src/test/java/cuchaz/enigma/inputs/translation/I_Generics.java22
39 files changed, 444 insertions, 435 deletions
diff --git a/src/test/java/cuchaz/enigma/TestDeobfed.java b/src/test/java/cuchaz/enigma/TestDeobfed.java
index 76a3d3b5..e6c1b746 100644
--- a/src/test/java/cuchaz/enigma/TestDeobfed.java
+++ b/src/test/java/cuchaz/enigma/TestDeobfed.java
@@ -4,38 +4,36 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11package cuchaz.enigma;
12
13
14import static cuchaz.enigma.TestEntryFactory.*;
15import static org.hamcrest.MatcherAssert.*;
16import static org.hamcrest.Matchers.*;
17 11
18import java.util.jar.JarFile; 12package cuchaz.enigma;
19 13
14import cuchaz.enigma.analysis.JarIndex;
20import org.junit.BeforeClass; 15import org.junit.BeforeClass;
21import org.junit.Test; 16import org.junit.Test;
22 17
23import cuchaz.enigma.analysis.JarIndex; 18import java.util.jar.JarFile;
24 19
20import static cuchaz.enigma.TestEntryFactory.newClass;
21import static org.hamcrest.MatcherAssert.assertThat;
22import static org.hamcrest.Matchers.containsInAnyOrder;
25 23
26public class TestDeobfed { 24public class TestDeobfed {
27 25
28 private static JarFile jar; 26 private static JarFile jar;
29 private static JarIndex index; 27 private static JarIndex index;
30 28
31 @BeforeClass 29 @BeforeClass
32 public static void beforeClass() 30 public static void beforeClass()
33 throws Exception { 31 throws Exception {
34 jar = new JarFile("build/test-deobf/translation.jar"); 32 jar = new JarFile("build/test-deobf/translation.jar");
35 index = new JarIndex(); 33 index = new JarIndex();
36 index.indexJar(jar, true); 34 index.indexJar(jar, true);
37 } 35 }
38 36
39 @Test 37 @Test
40 public void obfEntries() { 38 public void obfEntries() {
41 assertThat(index.getObfClassEntries(), containsInAnyOrder( 39 assertThat(index.getObfClassEntries(), containsInAnyOrder(
@@ -64,10 +62,10 @@ public class TestDeobfed {
64 newClass("i$b") 62 newClass("i$b")
65 )); 63 ));
66 } 64 }
67 65
68 @Test 66 @Test
69 public void decompile() 67 public void decompile()
70 throws Exception { 68 throws Exception {
71 Deobfuscator deobfuscator = new Deobfuscator(jar); 69 Deobfuscator deobfuscator = new Deobfuscator(jar);
72 deobfuscator.getSourceTree("a"); 70 deobfuscator.getSourceTree("a");
73 deobfuscator.getSourceTree("b"); 71 deobfuscator.getSourceTree("b");
diff --git a/src/test/java/cuchaz/enigma/TestDeobfuscator.java b/src/test/java/cuchaz/enigma/TestDeobfuscator.java
index 8c97ff34..62a52861 100644
--- a/src/test/java/cuchaz/enigma/TestDeobfuscator.java
+++ b/src/test/java/cuchaz/enigma/TestDeobfuscator.java
@@ -4,40 +4,39 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma; 12package cuchaz.enigma;
12 13
13import static org.junit.Assert.*; 14import com.google.common.collect.Lists;
15import cuchaz.enigma.mapping.ClassEntry;
16import org.junit.Test;
14 17
15import java.io.IOException; 18import java.io.IOException;
16import java.util.List; 19import java.util.List;
17import java.util.jar.JarFile; 20import java.util.jar.JarFile;
18 21
19import org.junit.Test; 22import static org.junit.Assert.assertEquals;
20
21import com.google.common.collect.Lists;
22
23import cuchaz.enigma.mapping.ClassEntry;
24 23
25public class TestDeobfuscator { 24public class TestDeobfuscator {
26 25
27 private Deobfuscator getDeobfuscator() 26 private Deobfuscator getDeobfuscator()
28 throws IOException { 27 throws IOException {
29 return new Deobfuscator(new JarFile("build/test-obf/loneClass.jar")); 28 return new Deobfuscator(new JarFile("build/test-obf/loneClass.jar"));
30 } 29 }
31 30
32 @Test 31 @Test
33 public void loadJar() 32 public void loadJar()
34 throws Exception { 33 throws Exception {
35 getDeobfuscator(); 34 getDeobfuscator();
36 } 35 }
37 36
38 @Test 37 @Test
39 public void getClasses() 38 public void getClasses()
40 throws Exception { 39 throws Exception {
41 Deobfuscator deobfuscator = getDeobfuscator(); 40 Deobfuscator deobfuscator = getDeobfuscator();
42 List<ClassEntry> obfClasses = Lists.newArrayList(); 41 List<ClassEntry> obfClasses = Lists.newArrayList();
43 List<ClassEntry> deobfClasses = Lists.newArrayList(); 42 List<ClassEntry> deobfClasses = Lists.newArrayList();
@@ -47,10 +46,10 @@ public class TestDeobfuscator {
47 assertEquals(1, deobfClasses.size()); 46 assertEquals(1, deobfClasses.size());
48 assertEquals("cuchaz/enigma/inputs/Keep", deobfClasses.get(0).getName()); 47 assertEquals("cuchaz/enigma/inputs/Keep", deobfClasses.get(0).getName());
49 } 48 }
50 49
51 @Test 50 @Test
52 public void decompileClass() 51 public void decompileClass()
53 throws Exception { 52 throws Exception {
54 Deobfuscator deobfuscator = getDeobfuscator(); 53 Deobfuscator deobfuscator = getDeobfuscator();
55 deobfuscator.getSource(deobfuscator.getSourceTree("a")); 54 deobfuscator.getSource(deobfuscator.getSourceTree("a"));
56 } 55 }
diff --git a/src/test/java/cuchaz/enigma/TestEntryFactory.java b/src/test/java/cuchaz/enigma/TestEntryFactory.java
index 4aa773b6..1c527f53 100644
--- a/src/test/java/cuchaz/enigma/TestEntryFactory.java
+++ b/src/test/java/cuchaz/enigma/TestEntryFactory.java
@@ -4,64 +4,59 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma; 12package cuchaz.enigma;
12 13
13import cuchaz.enigma.analysis.EntryReference; 14import cuchaz.enigma.analysis.EntryReference;
14import cuchaz.enigma.mapping.BehaviorEntry; 15import cuchaz.enigma.mapping.*;
15import cuchaz.enigma.mapping.ClassEntry;
16import cuchaz.enigma.mapping.ConstructorEntry;
17import cuchaz.enigma.mapping.FieldEntry;
18import cuchaz.enigma.mapping.MethodEntry;
19import cuchaz.enigma.mapping.Signature;
20import cuchaz.enigma.mapping.Type;
21 16
22public class TestEntryFactory { 17public class TestEntryFactory {
23 18
24 public static ClassEntry newClass(String name) { 19 public static ClassEntry newClass(String name) {
25 return new ClassEntry(name); 20 return new ClassEntry(name);
26 } 21 }
27 22
28 public static FieldEntry newField(String className, String fieldName, String fieldType) { 23 public static FieldEntry newField(String className, String fieldName, String fieldType) {
29 return newField(newClass(className), fieldName, fieldType); 24 return newField(newClass(className), fieldName, fieldType);
30 } 25 }
31 26
32 public static FieldEntry newField(ClassEntry classEntry, String fieldName, String fieldType) { 27 public static FieldEntry newField(ClassEntry classEntry, String fieldName, String fieldType) {
33 return new FieldEntry(classEntry, fieldName, new Type(fieldType)); 28 return new FieldEntry(classEntry, fieldName, new Type(fieldType));
34 } 29 }
35 30
36 public static MethodEntry newMethod(String className, String methodName, String methodSignature) { 31 public static MethodEntry newMethod(String className, String methodName, String methodSignature) {
37 return newMethod(newClass(className), methodName, methodSignature); 32 return newMethod(newClass(className), methodName, methodSignature);
38 } 33 }
39 34
40 public static MethodEntry newMethod(ClassEntry classEntry, String methodName, String methodSignature) { 35 public static MethodEntry newMethod(ClassEntry classEntry, String methodName, String methodSignature) {
41 return new MethodEntry(classEntry, methodName, new Signature(methodSignature)); 36 return new MethodEntry(classEntry, methodName, new Signature(methodSignature));
42 } 37 }
43 38
44 public static ConstructorEntry newConstructor(String className, String signature) { 39 public static ConstructorEntry newConstructor(String className, String signature) {
45 return newConstructor(newClass(className), signature); 40 return newConstructor(newClass(className), signature);
46 } 41 }
47 42
48 public static ConstructorEntry newConstructor(ClassEntry classEntry, String signature) { 43 public static ConstructorEntry newConstructor(ClassEntry classEntry, String signature) {
49 return new ConstructorEntry(classEntry, new Signature(signature)); 44 return new ConstructorEntry(classEntry, new Signature(signature));
50 } 45 }
51 46
52 public static EntryReference<FieldEntry,BehaviorEntry> newFieldReferenceByMethod(FieldEntry fieldEntry, String callerClassName, String callerName, String callerSignature) { 47 public static EntryReference<FieldEntry, BehaviorEntry> newFieldReferenceByMethod(FieldEntry fieldEntry, String callerClassName, String callerName, String callerSignature) {
53 return new EntryReference<FieldEntry,BehaviorEntry>(fieldEntry, "", newMethod(callerClassName, callerName, callerSignature)); 48 return new EntryReference<FieldEntry, BehaviorEntry>(fieldEntry, "", newMethod(callerClassName, callerName, callerSignature));
54 } 49 }
55 50
56 public static EntryReference<FieldEntry,BehaviorEntry> newFieldReferenceByConstructor(FieldEntry fieldEntry, String callerClassName, String callerSignature) { 51 public static EntryReference<FieldEntry, BehaviorEntry> newFieldReferenceByConstructor(FieldEntry fieldEntry, String callerClassName, String callerSignature) {
57 return new EntryReference<FieldEntry,BehaviorEntry>(fieldEntry, "", newConstructor(callerClassName, callerSignature)); 52 return new EntryReference<FieldEntry, BehaviorEntry>(fieldEntry, "", newConstructor(callerClassName, callerSignature));
58 } 53 }
59 54
60 public static EntryReference<BehaviorEntry,BehaviorEntry> newBehaviorReferenceByMethod(BehaviorEntry behaviorEntry, String callerClassName, String callerName, String callerSignature) { 55 public static EntryReference<BehaviorEntry, BehaviorEntry> newBehaviorReferenceByMethod(BehaviorEntry behaviorEntry, String callerClassName, String callerName, String callerSignature) {
61 return new EntryReference<BehaviorEntry,BehaviorEntry>(behaviorEntry, "", newMethod(callerClassName, callerName, callerSignature)); 56 return new EntryReference<BehaviorEntry, BehaviorEntry>(behaviorEntry, "", newMethod(callerClassName, callerName, callerSignature));
62 } 57 }
63 58
64 public static EntryReference<BehaviorEntry,BehaviorEntry> newBehaviorReferenceByConstructor(BehaviorEntry behaviorEntry, String callerClassName, String callerSignature) { 59 public static EntryReference<BehaviorEntry, BehaviorEntry> newBehaviorReferenceByConstructor(BehaviorEntry behaviorEntry, String callerClassName, String callerSignature) {
65 return new EntryReference<BehaviorEntry,BehaviorEntry>(behaviorEntry, "", newConstructor(callerClassName, callerSignature)); 60 return new EntryReference<BehaviorEntry, BehaviorEntry>(behaviorEntry, "", newConstructor(callerClassName, callerSignature));
66 } 61 }
67} 62}
diff --git a/src/test/java/cuchaz/enigma/TestInnerClasses.java b/src/test/java/cuchaz/enigma/TestInnerClasses.java
index 64a695a9..38db0df9 100644
--- a/src/test/java/cuchaz/enigma/TestInnerClasses.java
+++ b/src/test/java/cuchaz/enigma/TestInnerClasses.java
@@ -4,29 +4,28 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11package cuchaz.enigma;
12
13import static org.hamcrest.MatcherAssert.*;
14import static org.hamcrest.Matchers.*;
15 11
16import java.util.jar.JarFile; 12package cuchaz.enigma;
17 13
14import cuchaz.enigma.analysis.JarIndex;
15import cuchaz.enigma.mapping.ClassEntry;
18import org.junit.Test; 16import org.junit.Test;
19 17
20import static cuchaz.enigma.TestEntryFactory.*; 18import java.util.jar.JarFile;
21 19
22import cuchaz.enigma.analysis.JarIndex; 20import static cuchaz.enigma.TestEntryFactory.newClass;
23import cuchaz.enigma.mapping.ClassEntry; 21import static org.hamcrest.MatcherAssert.assertThat;
22import static org.hamcrest.Matchers.containsInAnyOrder;
23import static org.hamcrest.Matchers.empty;
24import static org.hamcrest.Matchers.is;
25import static org.hamcrest.Matchers.nullValue;
24 26
25public class TestInnerClasses { 27public class TestInnerClasses {
26 28
27 private JarIndex index;
28 private Deobfuscator deobfuscator;
29
30 private static final ClassEntry AnonymousOuter = newClass("a"); 29 private static final ClassEntry AnonymousOuter = newClass("a");
31 private static final ClassEntry AnonymousInner = newClass("a$1"); 30 private static final ClassEntry AnonymousInner = newClass("a$1");
32 private static final ClassEntry SimpleOuter = newClass("d"); 31 private static final ClassEntry SimpleOuter = newClass("d");
@@ -41,15 +40,17 @@ public class TestInnerClasses {
41 private static final ClassEntry ClassTreeLevel1 = newClass("f$a"); 40 private static final ClassEntry ClassTreeLevel1 = newClass("f$a");
42 private static final ClassEntry ClassTreeLevel2 = newClass("f$a$a"); 41 private static final ClassEntry ClassTreeLevel2 = newClass("f$a$a");
43 private static final ClassEntry ClassTreeLevel3 = newClass("f$a$a$a"); 42 private static final ClassEntry ClassTreeLevel3 = newClass("f$a$a$a");
44 43 private JarIndex index;
44 private Deobfuscator deobfuscator;
45
45 public TestInnerClasses() 46 public TestInnerClasses()
46 throws Exception { 47 throws Exception {
47 index = new JarIndex(); 48 index = new JarIndex();
48 JarFile jar = new JarFile("build/test-obf/innerClasses.jar"); 49 JarFile jar = new JarFile("build/test-obf/innerClasses.jar");
49 index.indexJar(jar, true); 50 index.indexJar(jar, true);
50 deobfuscator = new Deobfuscator(jar); 51 deobfuscator = new Deobfuscator(jar);
51 } 52 }
52 53
53 @Test 54 @Test
54 public void simple() { 55 public void simple() {
55 assertThat(index.getOuterClass(SimpleInner), is(SimpleOuter)); 56 assertThat(index.getOuterClass(SimpleInner), is(SimpleOuter));
@@ -57,7 +58,7 @@ public class TestInnerClasses {
57 assertThat(index.isAnonymousClass(SimpleInner), is(false)); 58 assertThat(index.isAnonymousClass(SimpleInner), is(false));
58 decompile(SimpleOuter); 59 decompile(SimpleOuter);
59 } 60 }
60 61
61 @Test 62 @Test
62 public void anonymous() { 63 public void anonymous() {
63 assertThat(index.getOuterClass(AnonymousInner), is(AnonymousOuter)); 64 assertThat(index.getOuterClass(AnonymousInner), is(AnonymousOuter));
@@ -65,7 +66,7 @@ public class TestInnerClasses {
65 assertThat(index.isAnonymousClass(AnonymousInner), is(true)); 66 assertThat(index.isAnonymousClass(AnonymousInner), is(true));
66 decompile(AnonymousOuter); 67 decompile(AnonymousOuter);
67 } 68 }
68 69
69 @Test 70 @Test
70 public void constructorArgs() { 71 public void constructorArgs() {
71 assertThat(index.getOuterClass(ConstructorArgsInner), is(ConstructorArgsOuter)); 72 assertThat(index.getOuterClass(ConstructorArgsInner), is(ConstructorArgsOuter));
@@ -73,7 +74,7 @@ public class TestInnerClasses {
73 assertThat(index.isAnonymousClass(ConstructorArgsInner), is(false)); 74 assertThat(index.isAnonymousClass(ConstructorArgsInner), is(false));
74 decompile(ConstructorArgsOuter); 75 decompile(ConstructorArgsOuter);
75 } 76 }
76 77
77 @Test 78 @Test
78 public void anonymousWithScopeArgs() { 79 public void anonymousWithScopeArgs() {
79 assertThat(index.getOuterClass(AnonymousWithScopeArgsInner), is(AnonymousWithScopeArgsOuter)); 80 assertThat(index.getOuterClass(AnonymousWithScopeArgsInner), is(AnonymousWithScopeArgsOuter));
@@ -81,7 +82,7 @@ public class TestInnerClasses {
81 assertThat(index.isAnonymousClass(AnonymousWithScopeArgsInner), is(true)); 82 assertThat(index.isAnonymousClass(AnonymousWithScopeArgsInner), is(true));
82 decompile(AnonymousWithScopeArgsOuter); 83 decompile(AnonymousWithScopeArgsOuter);
83 } 84 }
84 85
85 @Test 86 @Test
86 public void anonymousWithOuterAccess() { 87 public void anonymousWithOuterAccess() {
87 assertThat(index.getOuterClass(AnonymousWithOuterAccessInner), is(AnonymousWithOuterAccessOuter)); 88 assertThat(index.getOuterClass(AnonymousWithOuterAccessInner), is(AnonymousWithOuterAccessOuter));
@@ -89,15 +90,15 @@ public class TestInnerClasses {
89 assertThat(index.isAnonymousClass(AnonymousWithOuterAccessInner), is(true)); 90 assertThat(index.isAnonymousClass(AnonymousWithOuterAccessInner), is(true));
90 decompile(AnonymousWithOuterAccessOuter); 91 decompile(AnonymousWithOuterAccessOuter);
91 } 92 }
92 93
93 @Test 94 @Test
94 public void classTree() { 95 public void classTree() {
95 96
96 // root level 97 // root level
97 assertThat(index.containsObfClass(ClassTreeRoot), is(true)); 98 assertThat(index.containsObfClass(ClassTreeRoot), is(true));
98 assertThat(index.getOuterClass(ClassTreeRoot), is(nullValue())); 99 assertThat(index.getOuterClass(ClassTreeRoot), is(nullValue()));
99 assertThat(index.getInnerClasses(ClassTreeRoot), containsInAnyOrder(ClassTreeLevel1)); 100 assertThat(index.getInnerClasses(ClassTreeRoot), containsInAnyOrder(ClassTreeLevel1));
100 101
101 // level 1 102 // level 1
102 ClassEntry fullClassEntry = new ClassEntry(ClassTreeRoot.getName() 103 ClassEntry fullClassEntry = new ClassEntry(ClassTreeRoot.getName()
103 + "$" + ClassTreeLevel1.getInnermostClassName() 104 + "$" + ClassTreeLevel1.getInnermostClassName()
@@ -105,7 +106,7 @@ public class TestInnerClasses {
105 assertThat(index.containsObfClass(fullClassEntry), is(true)); 106 assertThat(index.containsObfClass(fullClassEntry), is(true));
106 assertThat(index.getOuterClass(ClassTreeLevel1), is(ClassTreeRoot)); 107 assertThat(index.getOuterClass(ClassTreeLevel1), is(ClassTreeRoot));
107 assertThat(index.getInnerClasses(ClassTreeLevel1), containsInAnyOrder(ClassTreeLevel2)); 108 assertThat(index.getInnerClasses(ClassTreeLevel1), containsInAnyOrder(ClassTreeLevel2));
108 109
109 // level 2 110 // level 2
110 fullClassEntry = new ClassEntry(ClassTreeRoot.getName() 111 fullClassEntry = new ClassEntry(ClassTreeRoot.getName()
111 + "$" + ClassTreeLevel1.getInnermostClassName() 112 + "$" + ClassTreeLevel1.getInnermostClassName()
@@ -114,7 +115,7 @@ public class TestInnerClasses {
114 assertThat(index.containsObfClass(fullClassEntry), is(true)); 115 assertThat(index.containsObfClass(fullClassEntry), is(true));
115 assertThat(index.getOuterClass(ClassTreeLevel2), is(ClassTreeLevel1)); 116 assertThat(index.getOuterClass(ClassTreeLevel2), is(ClassTreeLevel1));
116 assertThat(index.getInnerClasses(ClassTreeLevel2), containsInAnyOrder(ClassTreeLevel3)); 117 assertThat(index.getInnerClasses(ClassTreeLevel2), containsInAnyOrder(ClassTreeLevel3));
117 118
118 // level 3 119 // level 3
119 fullClassEntry = new ClassEntry(ClassTreeRoot.getName() 120 fullClassEntry = new ClassEntry(ClassTreeRoot.getName()
120 + "$" + ClassTreeLevel1.getInnermostClassName() 121 + "$" + ClassTreeLevel1.getInnermostClassName()
@@ -125,7 +126,7 @@ public class TestInnerClasses {
125 assertThat(index.getOuterClass(ClassTreeLevel3), is(ClassTreeLevel2)); 126 assertThat(index.getOuterClass(ClassTreeLevel3), is(ClassTreeLevel2));
126 assertThat(index.getInnerClasses(ClassTreeLevel3), is(empty())); 127 assertThat(index.getInnerClasses(ClassTreeLevel3), is(empty()));
127 } 128 }
128 129
129 private void decompile(ClassEntry classEntry) { 130 private void decompile(ClassEntry classEntry) {
130 deobfuscator.getSourceTree(classEntry.getName()); 131 deobfuscator.getSourceTree(classEntry.getName());
131 } 132 }
diff --git a/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java b/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java
index 01d4bab6..edb859a7 100644
--- a/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java
+++ b/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java
@@ -4,62 +4,67 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma; 12package cuchaz.enigma;
12 13
13import static cuchaz.enigma.TestEntryFactory.*; 14import cuchaz.enigma.analysis.EntryReference;
14import static org.hamcrest.MatcherAssert.*; 15import cuchaz.enigma.analysis.JarIndex;
15import static org.hamcrest.Matchers.*; 16import cuchaz.enigma.mapping.BehaviorEntry;
17import cuchaz.enigma.mapping.ClassEntry;
18import org.junit.Test;
16 19
17import java.io.File; 20import java.io.File;
18import java.util.Collection; 21import java.util.Collection;
19import java.util.jar.JarFile; 22import java.util.jar.JarFile;
20 23
21import org.junit.Test; 24import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByConstructor;
22 25import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByMethod;
23import cuchaz.enigma.analysis.EntryReference; 26import static cuchaz.enigma.TestEntryFactory.newClass;
24import cuchaz.enigma.analysis.JarIndex; 27import static cuchaz.enigma.TestEntryFactory.newConstructor;
25import cuchaz.enigma.mapping.BehaviorEntry; 28import static org.hamcrest.MatcherAssert.assertThat;
26import cuchaz.enigma.mapping.ClassEntry; 29import static org.hamcrest.Matchers.containsInAnyOrder;
30import static org.hamcrest.Matchers.empty;
31import static org.hamcrest.Matchers.is;
27 32
28public class TestJarIndexConstructorReferences { 33public class TestJarIndexConstructorReferences {
29 34
30 private JarIndex index; 35 private JarIndex index;
31 36
32 private ClassEntry baseClass = newClass("a"); 37 private ClassEntry baseClass = newClass("a");
33 private ClassEntry subClass = newClass("d"); 38 private ClassEntry subClass = newClass("d");
34 private ClassEntry subsubClass = newClass("e"); 39 private ClassEntry subsubClass = newClass("e");
35 private ClassEntry defaultClass = newClass("c"); 40 private ClassEntry defaultClass = newClass("c");
36 private ClassEntry callerClass = newClass("b"); 41 private ClassEntry callerClass = newClass("b");
37 42
38 public TestJarIndexConstructorReferences() 43 public TestJarIndexConstructorReferences()
39 throws Exception { 44 throws Exception {
40 File jarFile = new File("build/test-obf/constructors.jar"); 45 File jarFile = new File("build/test-obf/constructors.jar");
41 index = new JarIndex(); 46 index = new JarIndex();
42 index.indexJar(new JarFile(jarFile), false); 47 index.indexJar(new JarFile(jarFile), false);
43 } 48 }
44 49
45 @Test 50 @Test
46 public void obfEntries() { 51 public void obfEntries() {
47 assertThat(index.getObfClassEntries(), containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), baseClass, 52 assertThat(index.getObfClassEntries(), containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), baseClass,
48 subClass, subsubClass, defaultClass, callerClass)); 53 subClass, subsubClass, defaultClass, callerClass));
49 } 54 }
50 55
51 @Test 56 @Test
52 @SuppressWarnings("unchecked") 57 @SuppressWarnings("unchecked")
53 public void baseDefault() { 58 public void baseDefault() {
54 BehaviorEntry source = newConstructor(baseClass, "()V"); 59 BehaviorEntry source = newConstructor(baseClass, "()V");
55 Collection<EntryReference<BehaviorEntry,BehaviorEntry>> references = index.getBehaviorReferences(source); 60 Collection<EntryReference<BehaviorEntry, BehaviorEntry>> references = index.getBehaviorReferences(source);
56 assertThat(references, containsInAnyOrder( 61 assertThat(references, containsInAnyOrder(
57 newBehaviorReferenceByMethod(source, callerClass.getName(), "a", "()V"), 62 newBehaviorReferenceByMethod(source, callerClass.getName(), "a", "()V"),
58 newBehaviorReferenceByConstructor(source, subClass.getName(), "()V"), 63 newBehaviorReferenceByConstructor(source, subClass.getName(), "()V"),
59 newBehaviorReferenceByConstructor(source, subClass.getName(), "(III)V") 64 newBehaviorReferenceByConstructor(source, subClass.getName(), "(III)V")
60 )); 65 ));
61 } 66 }
62 67
63 @Test 68 @Test
64 @SuppressWarnings("unchecked") 69 @SuppressWarnings("unchecked")
65 public void baseInt() { 70 public void baseInt() {
@@ -68,7 +73,7 @@ public class TestJarIndexConstructorReferences {
68 newBehaviorReferenceByMethod(source, callerClass.getName(), "b", "()V") 73 newBehaviorReferenceByMethod(source, callerClass.getName(), "b", "()V")
69 )); 74 ));
70 } 75 }
71 76
72 @Test 77 @Test
73 @SuppressWarnings("unchecked") 78 @SuppressWarnings("unchecked")
74 public void subDefault() { 79 public void subDefault() {
@@ -78,7 +83,7 @@ public class TestJarIndexConstructorReferences {
78 newBehaviorReferenceByConstructor(source, subClass.getName(), "(I)V") 83 newBehaviorReferenceByConstructor(source, subClass.getName(), "(I)V")
79 )); 84 ));
80 } 85 }
81 86
82 @Test 87 @Test
83 @SuppressWarnings("unchecked") 88 @SuppressWarnings("unchecked")
84 public void subInt() { 89 public void subInt() {
@@ -89,7 +94,7 @@ public class TestJarIndexConstructorReferences {
89 newBehaviorReferenceByConstructor(source, subsubClass.getName(), "(I)V") 94 newBehaviorReferenceByConstructor(source, subsubClass.getName(), "(I)V")
90 )); 95 ));
91 } 96 }
92 97
93 @Test 98 @Test
94 @SuppressWarnings("unchecked") 99 @SuppressWarnings("unchecked")
95 public void subIntInt() { 100 public void subIntInt() {
@@ -98,13 +103,13 @@ public class TestJarIndexConstructorReferences {
98 newBehaviorReferenceByMethod(source, callerClass.getName(), "e", "()V") 103 newBehaviorReferenceByMethod(source, callerClass.getName(), "e", "()V")
99 )); 104 ));
100 } 105 }
101 106
102 @Test 107 @Test
103 public void subIntIntInt() { 108 public void subIntIntInt() {
104 BehaviorEntry source = newConstructor(subClass, "(III)V"); 109 BehaviorEntry source = newConstructor(subClass, "(III)V");
105 assertThat(index.getBehaviorReferences(source), is(empty())); 110 assertThat(index.getBehaviorReferences(source), is(empty()));
106 } 111 }
107 112
108 @Test 113 @Test
109 @SuppressWarnings("unchecked") 114 @SuppressWarnings("unchecked")
110 public void subsubInt() { 115 public void subsubInt() {
@@ -113,7 +118,7 @@ public class TestJarIndexConstructorReferences {
113 newBehaviorReferenceByMethod(source, callerClass.getName(), "f", "()V") 118 newBehaviorReferenceByMethod(source, callerClass.getName(), "f", "()V")
114 )); 119 ));
115 } 120 }
116 121
117 @Test 122 @Test
118 @SuppressWarnings("unchecked") 123 @SuppressWarnings("unchecked")
119 public void defaultConstructable() { 124 public void defaultConstructable() {
diff --git a/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java b/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java
index 4d9c8dc1..62469780 100644
--- a/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java
+++ b/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java
@@ -4,31 +4,12 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11package cuchaz.enigma;
12
13import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByConstructor;
14import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByMethod;
15import static cuchaz.enigma.TestEntryFactory.newClass;
16import static cuchaz.enigma.TestEntryFactory.newConstructor;
17import static cuchaz.enigma.TestEntryFactory.newField;
18import static cuchaz.enigma.TestEntryFactory.newFieldReferenceByConstructor;
19import static cuchaz.enigma.TestEntryFactory.newFieldReferenceByMethod;
20import static cuchaz.enigma.TestEntryFactory.newMethod;
21import static org.hamcrest.MatcherAssert.assertThat;
22import static org.hamcrest.Matchers.contains;
23import static org.hamcrest.Matchers.containsInAnyOrder;
24import static org.hamcrest.Matchers.empty;
25import static org.hamcrest.Matchers.is;
26 11
27import java.util.Collection; 12package cuchaz.enigma;
28import java.util.Set;
29import java.util.jar.JarFile;
30
31import org.junit.Test;
32 13
33import cuchaz.enigma.analysis.Access; 14import cuchaz.enigma.analysis.Access;
34import cuchaz.enigma.analysis.EntryReference; 15import cuchaz.enigma.analysis.EntryReference;
@@ -38,70 +19,82 @@ import cuchaz.enigma.mapping.BehaviorEntry;
38import cuchaz.enigma.mapping.ClassEntry; 19import cuchaz.enigma.mapping.ClassEntry;
39import cuchaz.enigma.mapping.FieldEntry; 20import cuchaz.enigma.mapping.FieldEntry;
40import cuchaz.enigma.mapping.MethodEntry; 21import cuchaz.enigma.mapping.MethodEntry;
22import org.junit.Test;
23
24import java.util.Collection;
25import java.util.Set;
26import java.util.jar.JarFile;
27
28import static cuchaz.enigma.TestEntryFactory.*;
29import static org.hamcrest.MatcherAssert.assertThat;
30import static org.hamcrest.Matchers.contains;
31import static org.hamcrest.Matchers.containsInAnyOrder;
32import static org.hamcrest.Matchers.empty;
33import static org.hamcrest.Matchers.is;
41 34
42public class TestJarIndexInheritanceTree { 35public class TestJarIndexInheritanceTree {
43 36
44 private JarIndex index; 37 private JarIndex index;
45 38
46 private ClassEntry objectClass = newClass("java/lang/Object"); 39 private ClassEntry objectClass = newClass("java/lang/Object");
47 private ClassEntry baseClass = newClass("a"); 40 private ClassEntry baseClass = newClass("a");
48 private ClassEntry subClassA = newClass("b"); 41 private ClassEntry subClassA = newClass("b");
49 private ClassEntry subClassAA = newClass("d"); 42 private ClassEntry subClassAA = newClass("d");
50 private ClassEntry subClassB = newClass("c"); 43 private ClassEntry subClassB = newClass("c");
51 private FieldEntry nameField = newField(baseClass, "a", "Ljava/lang/String;"); 44 private FieldEntry nameField = newField(baseClass, "a", "Ljava/lang/String;");
52 private FieldEntry numThingsField = newField(subClassB, "a", "I"); 45 private FieldEntry numThingsField = newField(subClassB, "a", "I");
53 46
54 public TestJarIndexInheritanceTree() 47 public TestJarIndexInheritanceTree()
55 throws Exception { 48 throws Exception {
56 index = new JarIndex(); 49 index = new JarIndex();
57 index.indexJar(new JarFile("build/test-obf/inheritanceTree.jar"), false); 50 index.indexJar(new JarFile("build/test-obf/inheritanceTree.jar"), false);
58 } 51 }
59 52
60 @Test 53 @Test
61 public void obfEntries() { 54 public void obfEntries() {
62 assertThat(index.getObfClassEntries(), containsInAnyOrder( 55 assertThat(index.getObfClassEntries(), containsInAnyOrder(
63 newClass("cuchaz/enigma/inputs/Keep"), baseClass, subClassA, subClassAA, subClassB 56 newClass("cuchaz/enigma/inputs/Keep"), baseClass, subClassA, subClassAA, subClassB
64 )); 57 ));
65 } 58 }
66 59
67 @Test 60 @Test
68 public void translationIndex() { 61 public void translationIndex() {
69 62
70 TranslationIndex index = this.index.getTranslationIndex(); 63 TranslationIndex index = this.index.getTranslationIndex();
71 64
72 // base class 65 // base class
73 assertThat(index.getSuperclass(baseClass), is(objectClass)); 66 assertThat(index.getSuperclass(baseClass), is(objectClass));
74 assertThat(index.getAncestry(baseClass), contains(objectClass)); 67 assertThat(index.getAncestry(baseClass), contains(objectClass));
75 assertThat(index.getSubclass(baseClass), containsInAnyOrder(subClassA, subClassB 68 assertThat(index.getSubclass(baseClass), containsInAnyOrder(subClassA, subClassB
76 )); 69 ));
77 70
78 // subclass a 71 // subclass a
79 assertThat(index.getSuperclass(subClassA), is(baseClass)); 72 assertThat(index.getSuperclass(subClassA), is(baseClass));
80 assertThat(index.getAncestry(subClassA), contains(baseClass, objectClass)); 73 assertThat(index.getAncestry(subClassA), contains(baseClass, objectClass));
81 assertThat(index.getSubclass(subClassA), contains(subClassAA)); 74 assertThat(index.getSubclass(subClassA), contains(subClassAA));
82 75
83 // subclass aa 76 // subclass aa
84 assertThat(index.getSuperclass(subClassAA), is(subClassA)); 77 assertThat(index.getSuperclass(subClassAA), is(subClassA));
85 assertThat(index.getAncestry(subClassAA), contains(subClassA, baseClass, objectClass)); 78 assertThat(index.getAncestry(subClassAA), contains(subClassA, baseClass, objectClass));
86 assertThat(index.getSubclass(subClassAA), is(empty())); 79 assertThat(index.getSubclass(subClassAA), is(empty()));
87 80
88 // subclass b 81 // subclass b
89 assertThat(index.getSuperclass(subClassB), is(baseClass)); 82 assertThat(index.getSuperclass(subClassB), is(baseClass));
90 assertThat(index.getAncestry(subClassB), contains(baseClass, objectClass)); 83 assertThat(index.getAncestry(subClassB), contains(baseClass, objectClass));
91 assertThat(index.getSubclass(subClassB), is(empty())); 84 assertThat(index.getSubclass(subClassB), is(empty()));
92 } 85 }
93 86
94 @Test 87 @Test
95 public void access() { 88 public void access() {
96 assertThat(index.getAccess(nameField), is(Access.PRIVATE)); 89 assertThat(index.getAccess(nameField), is(Access.PRIVATE));
97 assertThat(index.getAccess(numThingsField), is(Access.PRIVATE)); 90 assertThat(index.getAccess(numThingsField), is(Access.PRIVATE));
98 } 91 }
99 92
100 @Test 93 @Test
101 public void relatedMethodImplementations() { 94 public void relatedMethodImplementations() {
102 95
103 Set<MethodEntry> entries; 96 Set<MethodEntry> entries;
104 97
105 // getName() 98 // getName()
106 entries = index.getRelatedMethodImplementations(newMethod(baseClass, "a", "()Ljava/lang/String;")); 99 entries = index.getRelatedMethodImplementations(newMethod(baseClass, "a", "()Ljava/lang/String;"));
107 assertThat(entries, containsInAnyOrder( 100 assertThat(entries, containsInAnyOrder(
@@ -113,7 +106,7 @@ public class TestJarIndexInheritanceTree {
113 newMethod(baseClass, "a", "()Ljava/lang/String;"), 106 newMethod(baseClass, "a", "()Ljava/lang/String;"),
114 newMethod(subClassAA, "a", "()Ljava/lang/String;") 107 newMethod(subClassAA, "a", "()Ljava/lang/String;")
115 )); 108 ));
116 109
117 // doBaseThings() 110 // doBaseThings()
118 entries = index.getRelatedMethodImplementations(newMethod(baseClass, "a", "()V")); 111 entries = index.getRelatedMethodImplementations(newMethod(baseClass, "a", "()V"));
119 assertThat(entries, containsInAnyOrder( 112 assertThat(entries, containsInAnyOrder(
@@ -133,24 +126,24 @@ public class TestJarIndexInheritanceTree {
133 newMethod(subClassAA, "a", "()V"), 126 newMethod(subClassAA, "a", "()V"),
134 newMethod(subClassB, "a", "()V") 127 newMethod(subClassB, "a", "()V")
135 )); 128 ));
136 129
137 // doBThings 130 // doBThings
138 entries = index.getRelatedMethodImplementations(newMethod(subClassB, "b", "()V")); 131 entries = index.getRelatedMethodImplementations(newMethod(subClassB, "b", "()V"));
139 assertThat(entries, containsInAnyOrder(newMethod(subClassB, "b", "()V"))); 132 assertThat(entries, containsInAnyOrder(newMethod(subClassB, "b", "()V")));
140 } 133 }
141 134
142 @Test 135 @Test
143 @SuppressWarnings("unchecked") 136 @SuppressWarnings("unchecked")
144 public void fieldReferences() { 137 public void fieldReferences() {
145 Collection<EntryReference<FieldEntry,BehaviorEntry>> references; 138 Collection<EntryReference<FieldEntry, BehaviorEntry>> references;
146 139
147 // name 140 // name
148 references = index.getFieldReferences(nameField); 141 references = index.getFieldReferences(nameField);
149 assertThat(references, containsInAnyOrder( 142 assertThat(references, containsInAnyOrder(
150 newFieldReferenceByConstructor(nameField, baseClass.getName(), "(Ljava/lang/String;)V"), 143 newFieldReferenceByConstructor(nameField, baseClass.getName(), "(Ljava/lang/String;)V"),
151 newFieldReferenceByMethod(nameField, baseClass.getName(), "a", "()Ljava/lang/String;") 144 newFieldReferenceByMethod(nameField, baseClass.getName(), "a", "()Ljava/lang/String;")
152 )); 145 ));
153 146
154 // numThings 147 // numThings
155 references = index.getFieldReferences(numThingsField); 148 references = index.getFieldReferences(numThingsField);
156 assertThat(references, containsInAnyOrder( 149 assertThat(references, containsInAnyOrder(
@@ -158,14 +151,14 @@ public class TestJarIndexInheritanceTree {
158 newFieldReferenceByMethod(numThingsField, subClassB.getName(), "b", "()V") 151 newFieldReferenceByMethod(numThingsField, subClassB.getName(), "b", "()V")
159 )); 152 ));
160 } 153 }
161 154
162 @Test 155 @Test
163 @SuppressWarnings("unchecked") 156 @SuppressWarnings("unchecked")
164 public void behaviorReferences() { 157 public void behaviorReferences() {
165 158
166 BehaviorEntry source; 159 BehaviorEntry source;
167 Collection<EntryReference<BehaviorEntry,BehaviorEntry>> references; 160 Collection<EntryReference<BehaviorEntry, BehaviorEntry>> references;
168 161
169 // baseClass constructor 162 // baseClass constructor
170 source = newConstructor(baseClass, "(Ljava/lang/String;)V"); 163 source = newConstructor(baseClass, "(Ljava/lang/String;)V");
171 references = index.getBehaviorReferences(source); 164 references = index.getBehaviorReferences(source);
@@ -173,14 +166,14 @@ public class TestJarIndexInheritanceTree {
173 newBehaviorReferenceByConstructor(source, subClassA.getName(), "(Ljava/lang/String;)V"), 166 newBehaviorReferenceByConstructor(source, subClassA.getName(), "(Ljava/lang/String;)V"),
174 newBehaviorReferenceByConstructor(source, subClassB.getName(), "()V") 167 newBehaviorReferenceByConstructor(source, subClassB.getName(), "()V")
175 )); 168 ));
176 169
177 // subClassA constructor 170 // subClassA constructor
178 source = newConstructor(subClassA, "(Ljava/lang/String;)V"); 171 source = newConstructor(subClassA, "(Ljava/lang/String;)V");
179 references = index.getBehaviorReferences(source); 172 references = index.getBehaviorReferences(source);
180 assertThat(references, containsInAnyOrder( 173 assertThat(references, containsInAnyOrder(
181 newBehaviorReferenceByConstructor(source, subClassAA.getName(), "()V") 174 newBehaviorReferenceByConstructor(source, subClassAA.getName(), "()V")
182 )); 175 ));
183 176
184 // baseClass.getName() 177 // baseClass.getName()
185 source = newMethod(baseClass, "a", "()Ljava/lang/String;"); 178 source = newMethod(baseClass, "a", "()Ljava/lang/String;");
186 references = index.getBehaviorReferences(source); 179 references = index.getBehaviorReferences(source);
@@ -188,7 +181,7 @@ public class TestJarIndexInheritanceTree {
188 newBehaviorReferenceByMethod(source, subClassAA.getName(), "a", "()Ljava/lang/String;"), 181 newBehaviorReferenceByMethod(source, subClassAA.getName(), "a", "()Ljava/lang/String;"),
189 newBehaviorReferenceByMethod(source, subClassB.getName(), "a", "()V") 182 newBehaviorReferenceByMethod(source, subClassB.getName(), "a", "()V")
190 )); 183 ));
191 184
192 // subclassAA.getName() 185 // subclassAA.getName()
193 source = newMethod(subClassAA, "a", "()Ljava/lang/String;"); 186 source = newMethod(subClassAA, "a", "()Ljava/lang/String;");
194 references = index.getBehaviorReferences(source); 187 references = index.getBehaviorReferences(source);
@@ -196,38 +189,38 @@ public class TestJarIndexInheritanceTree {
196 newBehaviorReferenceByMethod(source, subClassAA.getName(), "a", "()V") 189 newBehaviorReferenceByMethod(source, subClassAA.getName(), "a", "()V")
197 )); 190 ));
198 } 191 }
199 192
200 @Test 193 @Test
201 public void containsEntries() { 194 public void containsEntries() {
202 195
203 // classes 196 // classes
204 assertThat(index.containsObfClass(baseClass), is(true)); 197 assertThat(index.containsObfClass(baseClass), is(true));
205 assertThat(index.containsObfClass(subClassA), is(true)); 198 assertThat(index.containsObfClass(subClassA), is(true));
206 assertThat(index.containsObfClass(subClassAA), is(true)); 199 assertThat(index.containsObfClass(subClassAA), is(true));
207 assertThat(index.containsObfClass(subClassB), is(true)); 200 assertThat(index.containsObfClass(subClassB), is(true));
208 201
209 // fields 202 // fields
210 assertThat(index.containsObfField(nameField), is(true)); 203 assertThat(index.containsObfField(nameField), is(true));
211 assertThat(index.containsObfField(numThingsField), is(true)); 204 assertThat(index.containsObfField(numThingsField), is(true));
212 205
213 // methods 206 // methods
214 // getName() 207 // getName()
215 assertThat(index.containsObfBehavior(newMethod(baseClass, "a", "()Ljava/lang/String;")), is(true)); 208 assertThat(index.containsObfBehavior(newMethod(baseClass, "a", "()Ljava/lang/String;")), is(true));
216 assertThat(index.containsObfBehavior(newMethod(subClassA, "a", "()Ljava/lang/String;")), is(false)); 209 assertThat(index.containsObfBehavior(newMethod(subClassA, "a", "()Ljava/lang/String;")), is(false));
217 assertThat(index.containsObfBehavior(newMethod(subClassAA, "a", "()Ljava/lang/String;")), is(true)); 210 assertThat(index.containsObfBehavior(newMethod(subClassAA, "a", "()Ljava/lang/String;")), is(true));
218 assertThat(index.containsObfBehavior(newMethod(subClassB, "a", "()Ljava/lang/String;")), is(false)); 211 assertThat(index.containsObfBehavior(newMethod(subClassB, "a", "()Ljava/lang/String;")), is(false));
219 212
220 // doBaseThings() 213 // doBaseThings()
221 assertThat(index.containsObfBehavior(newMethod(baseClass, "a", "()V")), is(true)); 214 assertThat(index.containsObfBehavior(newMethod(baseClass, "a", "()V")), is(true));
222 assertThat(index.containsObfBehavior(newMethod(subClassA, "a", "()V")), is(false)); 215 assertThat(index.containsObfBehavior(newMethod(subClassA, "a", "()V")), is(false));
223 assertThat(index.containsObfBehavior(newMethod(subClassAA, "a", "()V")), is(true)); 216 assertThat(index.containsObfBehavior(newMethod(subClassAA, "a", "()V")), is(true));
224 assertThat(index.containsObfBehavior(newMethod(subClassB, "a", "()V")), is(true)); 217 assertThat(index.containsObfBehavior(newMethod(subClassB, "a", "()V")), is(true));
225 218
226 // doBThings() 219 // doBThings()
227 assertThat(index.containsObfBehavior(newMethod(baseClass, "b", "()V")), is(false)); 220 assertThat(index.containsObfBehavior(newMethod(baseClass, "b", "()V")), is(false));
228 assertThat(index.containsObfBehavior(newMethod(subClassA, "b", "()V")), is(false)); 221 assertThat(index.containsObfBehavior(newMethod(subClassA, "b", "()V")), is(false));
229 assertThat(index.containsObfBehavior(newMethod(subClassAA, "b", "()V")), is(false)); 222 assertThat(index.containsObfBehavior(newMethod(subClassAA, "b", "()V")), is(false));
230 assertThat(index.containsObfBehavior(newMethod(subClassB, "b", "()V")), is(true)); 223 assertThat(index.containsObfBehavior(newMethod(subClassB, "b", "()V")), is(true));
231 224
232 } 225 }
233} 226}
diff --git a/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java b/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java
index 8efa57c6..6cab1c84 100644
--- a/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java
+++ b/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java
@@ -4,44 +4,35 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma; 12package cuchaz.enigma;
12 13
13import static cuchaz.enigma.TestEntryFactory.*; 14import cuchaz.enigma.analysis.*;
14import static org.hamcrest.MatcherAssert.*; 15import cuchaz.enigma.mapping.*;
15import static org.hamcrest.Matchers.*; 16import org.junit.Test;
16 17
17import java.util.Collection; 18import java.util.Collection;
18import java.util.Set; 19import java.util.Set;
19import java.util.jar.JarFile; 20import java.util.jar.JarFile;
20 21
21import org.junit.Test; 22import static cuchaz.enigma.TestEntryFactory.*;
22 23import static org.hamcrest.MatcherAssert.assertThat;
23import cuchaz.enigma.analysis.Access; 24import static org.hamcrest.Matchers.*;
24import cuchaz.enigma.analysis.ClassImplementationsTreeNode;
25import cuchaz.enigma.analysis.ClassInheritanceTreeNode;
26import cuchaz.enigma.analysis.EntryReference;
27import cuchaz.enigma.analysis.JarIndex;
28import cuchaz.enigma.analysis.MethodInheritanceTreeNode;
29import cuchaz.enigma.mapping.BehaviorEntry;
30import cuchaz.enigma.mapping.ClassEntry;
31import cuchaz.enigma.mapping.FieldEntry;
32import cuchaz.enigma.mapping.MethodEntry;
33import cuchaz.enigma.mapping.Translator;
34 25
35public class TestJarIndexLoneClass { 26public class TestJarIndexLoneClass {
36 27
37 private JarIndex index; 28 private JarIndex index;
38 29
39 public TestJarIndexLoneClass() 30 public TestJarIndexLoneClass()
40 throws Exception { 31 throws Exception {
41 index = new JarIndex(); 32 index = new JarIndex();
42 index.indexJar(new JarFile("build/test-obf/loneClass.jar"), false); 33 index.indexJar(new JarFile("build/test-obf/loneClass.jar"), false);
43 } 34 }
44 35
45 @Test 36 @Test
46 public void obfEntries() { 37 public void obfEntries() {
47 assertThat(index.getObfClassEntries(), containsInAnyOrder( 38 assertThat(index.getObfClassEntries(), containsInAnyOrder(
@@ -49,7 +40,7 @@ public class TestJarIndexLoneClass {
49 newClass("a") 40 newClass("a")
50 )); 41 ));
51 } 42 }
52 43
53 @Test 44 @Test
54 public void translationIndex() { 45 public void translationIndex() {
55 assertThat(index.getTranslationIndex().getSuperclass(new ClassEntry("a")), is(new ClassEntry("java/lang/Object"))); 46 assertThat(index.getTranslationIndex().getSuperclass(new ClassEntry("a")), is(new ClassEntry("java/lang/Object")));
@@ -59,7 +50,7 @@ public class TestJarIndexLoneClass {
59 assertThat(index.getTranslationIndex().getSubclass(new ClassEntry("a")), is(empty())); 50 assertThat(index.getTranslationIndex().getSubclass(new ClassEntry("a")), is(empty()));
60 assertThat(index.getTranslationIndex().getSubclass(new ClassEntry("cuchaz/enigma/inputs/Keep")), is(empty())); 51 assertThat(index.getTranslationIndex().getSubclass(new ClassEntry("cuchaz/enigma/inputs/Keep")), is(empty()));
61 } 52 }
62 53
63 @Test 54 @Test
64 public void access() { 55 public void access() {
65 assertThat(index.getAccess(newField("a", "a", "Ljava/lang/String;")), is(Access.PRIVATE)); 56 assertThat(index.getAccess(newField("a", "a", "Ljava/lang/String;")), is(Access.PRIVATE));
@@ -67,7 +58,7 @@ public class TestJarIndexLoneClass {
67 assertThat(index.getAccess(newField("a", "b", "Ljava/lang/String;")), is(nullValue())); 58 assertThat(index.getAccess(newField("a", "b", "Ljava/lang/String;")), is(nullValue()));
68 assertThat(index.getAccess(newField("a", "a", "LFoo;")), is(nullValue())); 59 assertThat(index.getAccess(newField("a", "a", "LFoo;")), is(nullValue()));
69 } 60 }
70 61
71 @Test 62 @Test
72 public void classInheritance() { 63 public void classInheritance() {
73 ClassInheritanceTreeNode node = index.getClassInheritance(new Translator(), newClass("a")); 64 ClassInheritanceTreeNode node = index.getClassInheritance(new Translator(), newClass("a"));
@@ -75,7 +66,7 @@ public class TestJarIndexLoneClass {
75 assertThat(node.getObfClassName(), is("a")); 66 assertThat(node.getObfClassName(), is("a"));
76 assertThat(node.getChildCount(), is(0)); 67 assertThat(node.getChildCount(), is(0));
77 } 68 }
78 69
79 @Test 70 @Test
80 public void methodInheritance() { 71 public void methodInheritance() {
81 MethodEntry source = newMethod("a", "a", "()Ljava/lang/String;"); 72 MethodEntry source = newMethod("a", "a", "()Ljava/lang/String;");
@@ -84,19 +75,19 @@ public class TestJarIndexLoneClass {
84 assertThat(node.getMethodEntry(), is(source)); 75 assertThat(node.getMethodEntry(), is(source));
85 assertThat(node.getChildCount(), is(0)); 76 assertThat(node.getChildCount(), is(0));
86 } 77 }
87 78
88 @Test 79 @Test
89 public void classImplementations() { 80 public void classImplementations() {
90 ClassImplementationsTreeNode node = index.getClassImplementations(new Translator(), newClass("a")); 81 ClassImplementationsTreeNode node = index.getClassImplementations(new Translator(), newClass("a"));
91 assertThat(node, is(nullValue())); 82 assertThat(node, is(nullValue()));
92 } 83 }
93 84
94 @Test 85 @Test
95 public void methodImplementations() { 86 public void methodImplementations() {
96 MethodEntry source = newMethod("a", "a", "()Ljava/lang/String;"); 87 MethodEntry source = newMethod("a", "a", "()Ljava/lang/String;");
97 assertThat(index.getMethodImplementations(new Translator(), source), is(empty())); 88 assertThat(index.getMethodImplementations(new Translator(), source), is(empty()));
98 } 89 }
99 90
100 @Test 91 @Test
101 public void relatedMethodImplementations() { 92 public void relatedMethodImplementations() {
102 Set<MethodEntry> entries = index.getRelatedMethodImplementations(newMethod("a", "a", "()Ljava/lang/String;")); 93 Set<MethodEntry> entries = index.getRelatedMethodImplementations(newMethod("a", "a", "()Ljava/lang/String;"));
@@ -104,53 +95,53 @@ public class TestJarIndexLoneClass {
104 newMethod("a", "a", "()Ljava/lang/String;") 95 newMethod("a", "a", "()Ljava/lang/String;")
105 )); 96 ));
106 } 97 }
107 98
108 @Test 99 @Test
109 @SuppressWarnings("unchecked") 100 @SuppressWarnings("unchecked")
110 public void fieldReferences() { 101 public void fieldReferences() {
111 FieldEntry source = newField("a", "a", "Ljava/lang/String;"); 102 FieldEntry source = newField("a", "a", "Ljava/lang/String;");
112 Collection<EntryReference<FieldEntry,BehaviorEntry>> references = index.getFieldReferences(source); 103 Collection<EntryReference<FieldEntry, BehaviorEntry>> references = index.getFieldReferences(source);
113 assertThat(references, containsInAnyOrder( 104 assertThat(references, containsInAnyOrder(
114 newFieldReferenceByConstructor(source, "a", "(Ljava/lang/String;)V"), 105 newFieldReferenceByConstructor(source, "a", "(Ljava/lang/String;)V"),
115 newFieldReferenceByMethod(source, "a", "a", "()Ljava/lang/String;") 106 newFieldReferenceByMethod(source, "a", "a", "()Ljava/lang/String;")
116 )); 107 ));
117 } 108 }
118 109
119 @Test 110 @Test
120 public void behaviorReferences() { 111 public void behaviorReferences() {
121 assertThat(index.getBehaviorReferences(newMethod("a", "a", "()Ljava/lang/String;")), is(empty())); 112 assertThat(index.getBehaviorReferences(newMethod("a", "a", "()Ljava/lang/String;")), is(empty()));
122 } 113 }
123 114
124 @Test 115 @Test
125 public void innerClasses() { 116 public void innerClasses() {
126 assertThat(index.getInnerClasses(newClass("a")), is(empty())); 117 assertThat(index.getInnerClasses(newClass("a")), is(empty()));
127 } 118 }
128 119
129 @Test 120 @Test
130 public void outerClass() { 121 public void outerClass() {
131 assertThat(index.getOuterClass(newClass("a")), is(nullValue())); 122 assertThat(index.getOuterClass(newClass("a")), is(nullValue()));
132 } 123 }
133 124
134 @Test 125 @Test
135 public void isAnonymousClass() { 126 public void isAnonymousClass() {
136 assertThat(index.isAnonymousClass(newClass("a")), is(false)); 127 assertThat(index.isAnonymousClass(newClass("a")), is(false));
137 } 128 }
138 129
139 @Test 130 @Test
140 public void interfaces() { 131 public void interfaces() {
141 assertThat(index.getInterfaces("a"), is(empty())); 132 assertThat(index.getInterfaces("a"), is(empty()));
142 } 133 }
143 134
144 @Test 135 @Test
145 public void implementingClasses() { 136 public void implementingClasses() {
146 assertThat(index.getImplementingClasses("a"), is(empty())); 137 assertThat(index.getImplementingClasses("a"), is(empty()));
147 } 138 }
148 139
149 @Test 140 @Test
150 public void isInterface() { 141 public void isInterface() {
151 assertThat(index.isInterface("a"), is(false)); 142 assertThat(index.isInterface("a"), is(false));
152 } 143 }
153 144
154 @Test 145 @Test
155 public void testContains() { 146 public void testContains() {
156 assertThat(index.containsObfClass(newClass("a")), is(true)); 147 assertThat(index.containsObfClass(newClass("a")), is(true));
diff --git a/src/test/java/cuchaz/enigma/TestSignature.java b/src/test/java/cuchaz/enigma/TestSignature.java
index 8537adfb..534b43ae 100644
--- a/src/test/java/cuchaz/enigma/TestSignature.java
+++ b/src/test/java/cuchaz/enigma/TestSignature.java
@@ -4,31 +4,33 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11package cuchaz.enigma;
12
13import static org.hamcrest.MatcherAssert.*;
14import static org.hamcrest.Matchers.*;
15 11
16import org.junit.Test; 12package cuchaz.enigma;
17 13
18import cuchaz.enigma.mapping.ClassNameReplacer; 14import cuchaz.enigma.mapping.ClassNameReplacer;
19import cuchaz.enigma.mapping.Signature; 15import cuchaz.enigma.mapping.Signature;
20import cuchaz.enigma.mapping.Type; 16import cuchaz.enigma.mapping.Type;
17import org.junit.Test;
21 18
19import static org.hamcrest.MatcherAssert.assertThat;
20import static org.hamcrest.Matchers.contains;
21import static org.hamcrest.Matchers.empty;
22import static org.hamcrest.Matchers.is;
23import static org.hamcrest.Matchers.not;
22 24
23public class TestSignature { 25public class TestSignature {
24 26
25 @Test 27 @Test
26 public void easiest() { 28 public void easiest() {
27 final Signature sig = new Signature("()V"); 29 final Signature sig = new Signature("()V");
28 assertThat(sig.getArgumentTypes(), is(empty())); 30 assertThat(sig.getArgumentTypes(), is(empty()));
29 assertThat(sig.getReturnType(), is(new Type("V"))); 31 assertThat(sig.getReturnType(), is(new Type("V")));
30 } 32 }
31 33
32 @Test 34 @Test
33 public void primitives() { 35 public void primitives() {
34 { 36 {
@@ -56,7 +58,7 @@ public class TestSignature {
56 assertThat(sig.getReturnType(), is(new Type("Z"))); 58 assertThat(sig.getReturnType(), is(new Type("Z")));
57 } 59 }
58 } 60 }
59 61
60 @Test 62 @Test
61 public void classes() { 63 public void classes() {
62 { 64 {
@@ -82,7 +84,7 @@ public class TestSignature {
82 assertThat(sig.getReturnType(), is(new Type("LBar;"))); 84 assertThat(sig.getReturnType(), is(new Type("LBar;")));
83 } 85 }
84 } 86 }
85 87
86 @Test 88 @Test
87 public void arrays() { 89 public void arrays() {
88 { 90 {
@@ -109,7 +111,7 @@ public class TestSignature {
109 assertThat(sig.getReturnType(), is(new Type("[D"))); 111 assertThat(sig.getReturnType(), is(new Type("[D")));
110 } 112 }
111 } 113 }
112 114
113 @Test 115 @Test
114 public void mixed() { 116 public void mixed() {
115 { 117 {
@@ -131,7 +133,7 @@ public class TestSignature {
131 assertThat(sig.getReturnType(), is(new Type("[LFoo;"))); 133 assertThat(sig.getReturnType(), is(new Type("[LFoo;")));
132 } 134 }
133 } 135 }
134 136
135 @Test 137 @Test
136 public void replaceClasses() { 138 public void replaceClasses() {
137 { 139 {
@@ -195,7 +197,7 @@ public class TestSignature {
195 assertThat(sig.getReturnType(), is(new Type("LCow;"))); 197 assertThat(sig.getReturnType(), is(new Type("LCow;")));
196 } 198 }
197 } 199 }
198 200
199 @Test 201 @Test
200 public void replaceArrayClasses() { 202 public void replaceArrayClasses() {
201 { 203 {
@@ -217,13 +219,13 @@ public class TestSignature {
217 assertThat(sig.getReturnType(), is(new Type("[[[LBeer;"))); 219 assertThat(sig.getReturnType(), is(new Type("[[[LBeer;")));
218 } 220 }
219 } 221 }
220 222
221 @Test 223 @Test
222 public void equals() { 224 public void equals() {
223 225
224 // base 226 // base
225 assertThat(new Signature("()V"), is(new Signature("()V"))); 227 assertThat(new Signature("()V"), is(new Signature("()V")));
226 228
227 // arguments 229 // arguments
228 assertThat(new Signature("(I)V"), is(new Signature("(I)V"))); 230 assertThat(new Signature("(I)V"), is(new Signature("(I)V")));
229 assertThat(new Signature("(ZIZ)V"), is(new Signature("(ZIZ)V"))); 231 assertThat(new Signature("(ZIZ)V"), is(new Signature("(ZIZ)V")));
@@ -238,7 +240,7 @@ public class TestSignature {
238 assertThat(new Signature("([[Z)V"), is(not(new Signature("([[LFoo;)V")))); 240 assertThat(new Signature("([[Z)V"), is(not(new Signature("([[LFoo;)V"))));
239 assertThat(new Signature("(LFoo;LBar;)V"), is(not(new Signature("(LFoo;LCow;)V")))); 241 assertThat(new Signature("(LFoo;LBar;)V"), is(not(new Signature("(LFoo;LCow;)V"))));
240 assertThat(new Signature("([LFoo;LBar;)V"), is(not(new Signature("(LFoo;LCow;)V")))); 242 assertThat(new Signature("([LFoo;LBar;)V"), is(not(new Signature("(LFoo;LCow;)V"))));
241 243
242 // return type 244 // return type
243 assertThat(new Signature("()I"), is(new Signature("()I"))); 245 assertThat(new Signature("()I"), is(new Signature("()I")));
244 assertThat(new Signature("()Z"), is(new Signature("()Z"))); 246 assertThat(new Signature("()Z"), is(new Signature("()Z")));
@@ -246,7 +248,7 @@ public class TestSignature {
246 assertThat(new Signature("()[[[Z"), is(new Signature("()[[[Z"))); 248 assertThat(new Signature("()[[[Z"), is(new Signature("()[[[Z")));
247 assertThat(new Signature("()LFoo;"), is(new Signature("()LFoo;"))); 249 assertThat(new Signature("()LFoo;"), is(new Signature("()LFoo;")));
248 assertThat(new Signature("()[LFoo;"), is(new Signature("()[LFoo;"))); 250 assertThat(new Signature("()[LFoo;"), is(new Signature("()[LFoo;")));
249 251
250 assertThat(new Signature("()I"), is(not(new Signature("()Z")))); 252 assertThat(new Signature("()I"), is(not(new Signature("()Z"))));
251 assertThat(new Signature("()Z"), is(not(new Signature("()I")))); 253 assertThat(new Signature("()Z"), is(not(new Signature("()I"))));
252 assertThat(new Signature("()[D"), is(not(new Signature("()[J")))); 254 assertThat(new Signature("()[D"), is(not(new Signature("()[J"))));
@@ -254,7 +256,7 @@ public class TestSignature {
254 assertThat(new Signature("()LFoo;"), is(not(new Signature("()LBar;")))); 256 assertThat(new Signature("()LFoo;"), is(not(new Signature("()LBar;"))));
255 assertThat(new Signature("()[LFoo;"), is(not(new Signature("()[LBar;")))); 257 assertThat(new Signature("()[LFoo;"), is(not(new Signature("()[LBar;"))));
256 } 258 }
257 259
258 @Test 260 @Test
259 public void testToString() { 261 public void testToString() {
260 assertThat(new Signature("()V").toString(), is("()V")); 262 assertThat(new Signature("()V").toString(), is("()V"));
diff --git a/src/test/java/cuchaz/enigma/TestSourceIndex.java b/src/test/java/cuchaz/enigma/TestSourceIndex.java
index 58d9ca91..6e9e5aec 100644
--- a/src/test/java/cuchaz/enigma/TestSourceIndex.java
+++ b/src/test/java/cuchaz/enigma/TestSourceIndex.java
@@ -4,27 +4,26 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11package cuchaz.enigma;
12
13import java.io.File;
14import java.util.Set;
15import java.util.jar.JarFile;
16 11
17import org.junit.Test; 12package cuchaz.enigma;
18 13
19import com.google.common.collect.Sets; 14import com.google.common.collect.Sets;
20import com.strobel.decompiler.languages.java.ast.CompilationUnit; 15import com.strobel.decompiler.languages.java.ast.CompilationUnit;
21
22import cuchaz.enigma.mapping.ClassEntry; 16import cuchaz.enigma.mapping.ClassEntry;
17import org.junit.Test;
18
19import java.io.File;
20import java.util.Set;
21import java.util.jar.JarFile;
23 22
24public class TestSourceIndex { 23public class TestSourceIndex {
25 @Test 24 @Test
26 public void indexEverything() 25 public void indexEverything()
27 throws Exception { 26 throws Exception {
28 // Figure out where Minecraft is... 27 // Figure out where Minecraft is...
29 final String mcDir = System.getProperty("enigma.test.minecraftdir"); 28 final String mcDir = System.getProperty("enigma.test.minecraftdir");
30 File mcJar = null; 29 File mcJar = null;
@@ -32,20 +31,17 @@ public class TestSourceIndex {
32 String osname = System.getProperty("os.name").toLowerCase(); 31 String osname = System.getProperty("os.name").toLowerCase();
33 if (osname.contains("nix") || osname.contains("nux") || osname.contains("solaris")) { 32 if (osname.contains("nix") || osname.contains("nux") || osname.contains("solaris")) {
34 mcJar = new File(System.getProperty("user.home"), ".minecraft/versions/1.8.3/1.8.3.jar"); 33 mcJar = new File(System.getProperty("user.home"), ".minecraft/versions/1.8.3/1.8.3.jar");
35 } 34 } else if (osname.contains("mac") || osname.contains("darwin")) {
36 else if (osname.contains("mac") || osname.contains("darwin")) {
37 mcJar = new File(System.getProperty("user.home"), "Library/Application Support/minecraft/versions/1.8.3/1.8.3.jar"); 35 mcJar = new File(System.getProperty("user.home"), "Library/Application Support/minecraft/versions/1.8.3/1.8.3.jar");
38 } 36 } else if (osname.contains("win")) {
39 else if (osname.contains("win")) {
40 mcJar = new File(System.getenv("AppData"), ".minecraft/versions/1.8.3/1.8.3.jar"); 37 mcJar = new File(System.getenv("AppData"), ".minecraft/versions/1.8.3/1.8.3.jar");
41 } 38 }
42 } 39 } else {
43 else {
44 mcJar = new File(mcDir, "versions/1.8.3/1.8.3.jar"); 40 mcJar = new File(mcDir, "versions/1.8.3/1.8.3.jar");
45 } 41 }
46 42
47 Deobfuscator deobfuscator = new Deobfuscator(new JarFile(mcJar)); 43 Deobfuscator deobfuscator = new Deobfuscator(new JarFile(mcJar));
48 44
49 // get all classes that aren't inner classes 45 // get all classes that aren't inner classes
50 Set<ClassEntry> classEntries = Sets.newHashSet(); 46 Set<ClassEntry> classEntries = Sets.newHashSet();
51 for (ClassEntry obfClassEntry : deobfuscator.getJarIndex().getObfClassEntries()) { 47 for (ClassEntry obfClassEntry : deobfuscator.getJarIndex().getObfClassEntries()) {
@@ -53,7 +49,7 @@ public class TestSourceIndex {
53 classEntries.add(obfClassEntry); 49 classEntries.add(obfClassEntry);
54 } 50 }
55 } 51 }
56 52
57 for (ClassEntry obfClassEntry : classEntries) { 53 for (ClassEntry obfClassEntry : classEntries) {
58 try { 54 try {
59 CompilationUnit tree = deobfuscator.getSourceTree(obfClassEntry.getName()); 55 CompilationUnit tree = deobfuscator.getSourceTree(obfClassEntry.getName());
diff --git a/src/test/java/cuchaz/enigma/TestTokensConstructors.java b/src/test/java/cuchaz/enigma/TestTokensConstructors.java
index 890a4fd3..e40d5fdc 100644
--- a/src/test/java/cuchaz/enigma/TestTokensConstructors.java
+++ b/src/test/java/cuchaz/enigma/TestTokensConstructors.java
@@ -4,35 +4,40 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma; 12package cuchaz.enigma;
12 13
13import static cuchaz.enigma.TestEntryFactory.*; 14import cuchaz.enigma.mapping.BehaviorEntry;
14import static org.hamcrest.MatcherAssert.*; 15import org.junit.Test;
15import static org.hamcrest.Matchers.*;
16 16
17import java.util.jar.JarFile; 17import java.util.jar.JarFile;
18 18
19import org.junit.Test; 19import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByConstructor;
20 20import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByMethod;
21import cuchaz.enigma.mapping.BehaviorEntry; 21import static cuchaz.enigma.TestEntryFactory.newConstructor;
22import static org.hamcrest.MatcherAssert.assertThat;
23import static org.hamcrest.Matchers.containsInAnyOrder;
24import static org.hamcrest.Matchers.empty;
25import static org.hamcrest.Matchers.is;
26import static org.hamcrest.Matchers.nullValue;
22 27
23public class TestTokensConstructors extends TokenChecker { 28public class TestTokensConstructors extends TokenChecker {
24 29
25 public TestTokensConstructors() 30 public TestTokensConstructors()
26 throws Exception { 31 throws Exception {
27 super(new JarFile("build/test-obf/constructors.jar")); 32 super(new JarFile("build/test-obf/constructors.jar"));
28 } 33 }
29 34
30 @Test 35 @Test
31 public void baseDeclarations() { 36 public void baseDeclarations() {
32 assertThat(getDeclarationToken(newConstructor("a", "()V")), is("a")); 37 assertThat(getDeclarationToken(newConstructor("a", "()V")), is("a"));
33 assertThat(getDeclarationToken(newConstructor("a", "(I)V")), is("a")); 38 assertThat(getDeclarationToken(newConstructor("a", "(I)V")), is("a"));
34 } 39 }
35 40
36 @Test 41 @Test
37 public void subDeclarations() { 42 public void subDeclarations() {
38 assertThat(getDeclarationToken(newConstructor("d", "()V")), is("d")); 43 assertThat(getDeclarationToken(newConstructor("d", "()V")), is("d"));
@@ -40,17 +45,17 @@ public class TestTokensConstructors extends TokenChecker {
40 assertThat(getDeclarationToken(newConstructor("d", "(II)V")), is("d")); 45 assertThat(getDeclarationToken(newConstructor("d", "(II)V")), is("d"));
41 assertThat(getDeclarationToken(newConstructor("d", "(III)V")), is("d")); 46 assertThat(getDeclarationToken(newConstructor("d", "(III)V")), is("d"));
42 } 47 }
43 48
44 @Test 49 @Test
45 public void subsubDeclarations() { 50 public void subsubDeclarations() {
46 assertThat(getDeclarationToken(newConstructor("e", "(I)V")), is("e")); 51 assertThat(getDeclarationToken(newConstructor("e", "(I)V")), is("e"));
47 } 52 }
48 53
49 @Test 54 @Test
50 public void defaultDeclarations() { 55 public void defaultDeclarations() {
51 assertThat(getDeclarationToken(newConstructor("c", "()V")), nullValue()); 56 assertThat(getDeclarationToken(newConstructor("c", "()V")), nullValue());
52 } 57 }
53 58
54 @Test 59 @Test
55 public void baseDefaultReferences() { 60 public void baseDefaultReferences() {
56 BehaviorEntry source = newConstructor("a", "()V"); 61 BehaviorEntry source = newConstructor("a", "()V");
@@ -67,7 +72,7 @@ public class TestTokensConstructors extends TokenChecker {
67 is(empty()) // implicit call, not decompiled to token 72 is(empty()) // implicit call, not decompiled to token
68 ); 73 );
69 } 74 }
70 75
71 @Test 76 @Test
72 public void baseIntReferences() { 77 public void baseIntReferences() {
73 BehaviorEntry source = newConstructor("a", "(I)V"); 78 BehaviorEntry source = newConstructor("a", "(I)V");
@@ -76,7 +81,7 @@ public class TestTokensConstructors extends TokenChecker {
76 containsInAnyOrder("a") 81 containsInAnyOrder("a")
77 ); 82 );
78 } 83 }
79 84
80 @Test 85 @Test
81 public void subDefaultReferences() { 86 public void subDefaultReferences() {
82 BehaviorEntry source = newConstructor("d", "()V"); 87 BehaviorEntry source = newConstructor("d", "()V");
@@ -89,7 +94,7 @@ public class TestTokensConstructors extends TokenChecker {
89 containsInAnyOrder("this") 94 containsInAnyOrder("this")
90 ); 95 );
91 } 96 }
92 97
93 @Test 98 @Test
94 public void subIntReferences() { 99 public void subIntReferences() {
95 BehaviorEntry source = newConstructor("d", "(I)V"); 100 BehaviorEntry source = newConstructor("d", "(I)V");
@@ -106,7 +111,7 @@ public class TestTokensConstructors extends TokenChecker {
106 containsInAnyOrder("super") 111 containsInAnyOrder("super")
107 ); 112 );
108 } 113 }
109 114
110 @Test 115 @Test
111 public void subIntIntReferences() { 116 public void subIntIntReferences() {
112 BehaviorEntry source = newConstructor("d", "(II)V"); 117 BehaviorEntry source = newConstructor("d", "(II)V");
@@ -115,7 +120,7 @@ public class TestTokensConstructors extends TokenChecker {
115 containsInAnyOrder("d") 120 containsInAnyOrder("d")
116 ); 121 );
117 } 122 }
118 123
119 @Test 124 @Test
120 public void subsubIntReferences() { 125 public void subsubIntReferences() {
121 BehaviorEntry source = newConstructor("e", "(I)V"); 126 BehaviorEntry source = newConstructor("e", "(I)V");
@@ -124,7 +129,7 @@ public class TestTokensConstructors extends TokenChecker {
124 containsInAnyOrder("e") 129 containsInAnyOrder("e")
125 ); 130 );
126 } 131 }
127 132
128 @Test 133 @Test
129 public void defaultConstructableReferences() { 134 public void defaultConstructableReferences() {
130 BehaviorEntry source = newConstructor("c", "()V"); 135 BehaviorEntry source = newConstructor("c", "()V");
diff --git a/src/test/java/cuchaz/enigma/TestTranslator.java b/src/test/java/cuchaz/enigma/TestTranslator.java
index 2c54603b..b63dff86 100644
--- a/src/test/java/cuchaz/enigma/TestTranslator.java
+++ b/src/test/java/cuchaz/enigma/TestTranslator.java
@@ -8,28 +8,29 @@
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11package cuchaz.enigma;
12
13import static cuchaz.enigma.TestEntryFactory.*;
14 11
15import org.junit.BeforeClass; 12package cuchaz.enigma;
16import org.junit.Test;
17 13
18import cuchaz.enigma.mapping.Entry; 14import cuchaz.enigma.mapping.Entry;
19import cuchaz.enigma.mapping.Mappings; 15import cuchaz.enigma.mapping.Mappings;
20import cuchaz.enigma.mapping.Translator; 16import cuchaz.enigma.mapping.Translator;
17import org.junit.BeforeClass;
18import org.junit.Test;
21 19
20import static cuchaz.enigma.TestEntryFactory.newClass;
21import static cuchaz.enigma.TestEntryFactory.newField;
22import static cuchaz.enigma.TestEntryFactory.newMethod;
22 23
23public class TestTranslator { 24public class TestTranslator {
24 25
25 private static Deobfuscator deobfuscator; 26 private static Deobfuscator deobfuscator;
26 private static Mappings mappings; 27 private static Mappings mappings;
27 private static Translator deobfTranslator; 28 private static Translator deobfTranslator;
28 private static Translator obfTranslator; 29 private static Translator obfTranslator;
29 30
30 @BeforeClass 31 @BeforeClass
31 public static void beforeClass() 32 public static void beforeClass()
32 throws Exception { 33 throws Exception {
33 //TODO FIx 34 //TODO FIx
34 //deobfuscator = new Deobfuscator(new JarFile("build/test-obf/translation.jar")); 35 //deobfuscator = new Deobfuscator(new JarFile("build/test-obf/translation.jar"));
35 //try (InputStream in = TestTranslator.class.getResourceAsStream("/cuchaz/enigma/resources/translation.mappings")) { 36 //try (InputStream in = TestTranslator.class.getResourceAsStream("/cuchaz/enigma/resources/translation.mappings")) {
diff --git a/src/test/java/cuchaz/enigma/TestType.java b/src/test/java/cuchaz/enigma/TestType.java
index 01c235b8..43dacb0c 100644
--- a/src/test/java/cuchaz/enigma/TestType.java
+++ b/src/test/java/cuchaz/enigma/TestType.java
@@ -4,23 +4,23 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11package cuchaz.enigma;
12
13import static cuchaz.enigma.TestEntryFactory.*;
14import static org.hamcrest.MatcherAssert.*;
15import static org.hamcrest.Matchers.*;
16 11
17import org.junit.Test; 12package cuchaz.enigma;
18 13
19import cuchaz.enigma.mapping.Type; 14import cuchaz.enigma.mapping.Type;
15import org.junit.Test;
20 16
17import static cuchaz.enigma.TestEntryFactory.newClass;
18import static org.hamcrest.MatcherAssert.assertThat;
19import static org.hamcrest.Matchers.is;
20import static org.hamcrest.Matchers.not;
21 21
22public class TestType { 22public class TestType {
23 23
24 @Test 24 @Test
25 public void isVoid() { 25 public void isVoid() {
26 assertThat(new Type("V").isVoid(), is(true)); 26 assertThat(new Type("V").isVoid(), is(true));
@@ -34,7 +34,7 @@ public class TestType {
34 assertThat(new Type("LFoo;").isVoid(), is(false)); 34 assertThat(new Type("LFoo;").isVoid(), is(false));
35 assertThat(new Type("[I").isVoid(), is(false)); 35 assertThat(new Type("[I").isVoid(), is(false));
36 } 36 }
37 37
38 @Test 38 @Test
39 public void isPrimitive() { 39 public void isPrimitive() {
40 assertThat(new Type("V").isPrimitive(), is(false)); 40 assertThat(new Type("V").isPrimitive(), is(false));
@@ -48,7 +48,7 @@ public class TestType {
48 assertThat(new Type("LFoo;").isPrimitive(), is(false)); 48 assertThat(new Type("LFoo;").isPrimitive(), is(false));
49 assertThat(new Type("[I").isPrimitive(), is(false)); 49 assertThat(new Type("[I").isPrimitive(), is(false));
50 } 50 }
51 51
52 @Test 52 @Test
53 public void getPrimitive() { 53 public void getPrimitive() {
54 assertThat(new Type("Z").getPrimitive(), is(Type.Primitive.Boolean)); 54 assertThat(new Type("Z").getPrimitive(), is(Type.Primitive.Boolean));
@@ -59,7 +59,7 @@ public class TestType {
59 assertThat(new Type("F").getPrimitive(), is(Type.Primitive.Float)); 59 assertThat(new Type("F").getPrimitive(), is(Type.Primitive.Float));
60 assertThat(new Type("D").getPrimitive(), is(Type.Primitive.Double)); 60 assertThat(new Type("D").getPrimitive(), is(Type.Primitive.Double));
61 } 61 }
62 62
63 @Test 63 @Test
64 public void isClass() { 64 public void isClass() {
65 assertThat(new Type("V").isClass(), is(false)); 65 assertThat(new Type("V").isClass(), is(false));
@@ -73,19 +73,19 @@ public class TestType {
73 assertThat(new Type("LFoo;").isClass(), is(true)); 73 assertThat(new Type("LFoo;").isClass(), is(true));
74 assertThat(new Type("[I").isClass(), is(false)); 74 assertThat(new Type("[I").isClass(), is(false));
75 } 75 }
76 76
77 @Test 77 @Test
78 public void getClassEntry() { 78 public void getClassEntry() {
79 assertThat(new Type("LFoo;").getClassEntry(), is(newClass("Foo"))); 79 assertThat(new Type("LFoo;").getClassEntry(), is(newClass("Foo")));
80 assertThat(new Type("Ljava/lang/String;").getClassEntry(), is(newClass("java/lang/String"))); 80 assertThat(new Type("Ljava/lang/String;").getClassEntry(), is(newClass("java/lang/String")));
81 } 81 }
82 82
83 @Test 83 @Test
84 public void getArrayClassEntry() { 84 public void getArrayClassEntry() {
85 assertThat(new Type("[LFoo;").getClassEntry(), is(newClass("Foo"))); 85 assertThat(new Type("[LFoo;").getClassEntry(), is(newClass("Foo")));
86 assertThat(new Type("[[[Ljava/lang/String;").getClassEntry(), is(newClass("java/lang/String"))); 86 assertThat(new Type("[[[Ljava/lang/String;").getClassEntry(), is(newClass("java/lang/String")));
87 } 87 }
88 88
89 @Test 89 @Test
90 public void isArray() { 90 public void isArray() {
91 assertThat(new Type("V").isArray(), is(false)); 91 assertThat(new Type("V").isArray(), is(false));
@@ -99,14 +99,14 @@ public class TestType {
99 assertThat(new Type("LFoo;").isArray(), is(false)); 99 assertThat(new Type("LFoo;").isArray(), is(false));
100 assertThat(new Type("[I").isArray(), is(true)); 100 assertThat(new Type("[I").isArray(), is(true));
101 } 101 }
102 102
103 @Test 103 @Test
104 public void getArrayDimension() { 104 public void getArrayDimension() {
105 assertThat(new Type("[I").getArrayDimension(), is(1)); 105 assertThat(new Type("[I").getArrayDimension(), is(1));
106 assertThat(new Type("[[I").getArrayDimension(), is(2)); 106 assertThat(new Type("[[I").getArrayDimension(), is(2));
107 assertThat(new Type("[[[I").getArrayDimension(), is(3)); 107 assertThat(new Type("[[[I").getArrayDimension(), is(3));
108 } 108 }
109 109
110 @Test 110 @Test
111 public void getArrayType() { 111 public void getArrayType() {
112 assertThat(new Type("[I").getArrayType(), is(new Type("I"))); 112 assertThat(new Type("[I").getArrayType(), is(new Type("I")));
@@ -114,7 +114,7 @@ public class TestType {
114 assertThat(new Type("[[[I").getArrayType(), is(new Type("I"))); 114 assertThat(new Type("[[[I").getArrayType(), is(new Type("I")));
115 assertThat(new Type("[Ljava/lang/String;").getArrayType(), is(new Type("Ljava/lang/String;"))); 115 assertThat(new Type("[Ljava/lang/String;").getArrayType(), is(new Type("Ljava/lang/String;")));
116 } 116 }
117 117
118 @Test 118 @Test
119 public void hasClass() { 119 public void hasClass() {
120 assertThat(new Type("LFoo;").hasClass(), is(true)); 120 assertThat(new Type("LFoo;").hasClass(), is(true));
@@ -127,7 +127,7 @@ public class TestType {
127 assertThat(new Type("[[[I").hasClass(), is(false)); 127 assertThat(new Type("[[[I").hasClass(), is(false));
128 assertThat(new Type("Z").hasClass(), is(false)); 128 assertThat(new Type("Z").hasClass(), is(false));
129 } 129 }
130 130
131 @Test 131 @Test
132 public void parseVoid() { 132 public void parseVoid() {
133 final String answer = "V"; 133 final String answer = "V";
@@ -138,7 +138,7 @@ public class TestType {
138 assertThat(Type.parseFirst("VLFoo;"), is(answer)); 138 assertThat(Type.parseFirst("VLFoo;"), is(answer));
139 assertThat(Type.parseFirst("V[LFoo;"), is(answer)); 139 assertThat(Type.parseFirst("V[LFoo;"), is(answer));
140 } 140 }
141 141
142 @Test 142 @Test
143 public void parsePrimitive() { 143 public void parsePrimitive() {
144 final String answer = "I"; 144 final String answer = "I";
@@ -149,7 +149,7 @@ public class TestType {
149 assertThat(Type.parseFirst("ILFoo;"), is(answer)); 149 assertThat(Type.parseFirst("ILFoo;"), is(answer));
150 assertThat(Type.parseFirst("I[LFoo;"), is(answer)); 150 assertThat(Type.parseFirst("I[LFoo;"), is(answer));
151 } 151 }
152 152
153 @Test 153 @Test
154 public void parseClass() { 154 public void parseClass() {
155 { 155 {
@@ -199,7 +199,7 @@ public class TestType {
199 assertThat(Type.parseFirst("[LFoo;LFoo;"), is(answer)); 199 assertThat(Type.parseFirst("[LFoo;LFoo;"), is(answer));
200 } 200 }
201 } 201 }
202 202
203 @Test 203 @Test
204 public void equals() { 204 public void equals() {
205 assertThat(new Type("V"), is(new Type("V"))); 205 assertThat(new Type("V"), is(new Type("V")));
@@ -214,7 +214,7 @@ public class TestType {
214 assertThat(new Type("[I"), is(new Type("[I"))); 214 assertThat(new Type("[I"), is(new Type("[I")));
215 assertThat(new Type("[[[I"), is(new Type("[[[I"))); 215 assertThat(new Type("[[[I"), is(new Type("[[[I")));
216 assertThat(new Type("[LFoo;"), is(new Type("[LFoo;"))); 216 assertThat(new Type("[LFoo;"), is(new Type("[LFoo;")));
217 217
218 assertThat(new Type("V"), is(not(new Type("I")))); 218 assertThat(new Type("V"), is(not(new Type("I"))));
219 assertThat(new Type("I"), is(not(new Type("J")))); 219 assertThat(new Type("I"), is(not(new Type("J"))));
220 assertThat(new Type("I"), is(not(new Type("LBar;")))); 220 assertThat(new Type("I"), is(not(new Type("LBar;"))));
@@ -224,7 +224,7 @@ public class TestType {
224 assertThat(new Type("[[[I"), is(not(new Type("[I")))); 224 assertThat(new Type("[[[I"), is(not(new Type("[I"))));
225 assertThat(new Type("[LFoo;"), is(not(new Type("[LBar;")))); 225 assertThat(new Type("[LFoo;"), is(not(new Type("[LBar;"))));
226 } 226 }
227 227
228 @Test 228 @Test
229 public void testToString() { 229 public void testToString() {
230 assertThat(new Type("V").toString(), is("V")); 230 assertThat(new Type("V").toString(), is("V"));
diff --git a/src/test/java/cuchaz/enigma/TokenChecker.java b/src/test/java/cuchaz/enigma/TokenChecker.java
index 07463206..c6ced488 100644
--- a/src/test/java/cuchaz/enigma/TokenChecker.java
+++ b/src/test/java/cuchaz/enigma/TokenChecker.java
@@ -4,34 +4,34 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11package cuchaz.enigma;
12 11
13import java.io.IOException; 12package cuchaz.enigma;
14import java.util.Collection;
15import java.util.List;
16import java.util.jar.JarFile;
17 13
18import com.google.common.collect.Lists; 14import com.google.common.collect.Lists;
19import com.strobel.decompiler.languages.java.ast.CompilationUnit; 15import com.strobel.decompiler.languages.java.ast.CompilationUnit;
20
21import cuchaz.enigma.analysis.EntryReference; 16import cuchaz.enigma.analysis.EntryReference;
22import cuchaz.enigma.analysis.SourceIndex; 17import cuchaz.enigma.analysis.SourceIndex;
23import cuchaz.enigma.analysis.Token; 18import cuchaz.enigma.analysis.Token;
24import cuchaz.enigma.mapping.Entry; 19import cuchaz.enigma.mapping.Entry;
25 20
21import java.io.IOException;
22import java.util.Collection;
23import java.util.List;
24import java.util.jar.JarFile;
25
26public class TokenChecker { 26public class TokenChecker {
27 27
28 private Deobfuscator deobfuscator; 28 private Deobfuscator deobfuscator;
29 29
30 protected TokenChecker(JarFile jarFile) 30 protected TokenChecker(JarFile jarFile)
31 throws IOException { 31 throws IOException {
32 deobfuscator = new Deobfuscator(jarFile); 32 deobfuscator = new Deobfuscator(jarFile);
33 } 33 }
34 34
35 protected String getDeclarationToken(Entry entry) { 35 protected String getDeclarationToken(Entry entry) {
36 // decompile the class 36 // decompile the class
37 CompilationUnit tree = deobfuscator.getSourceTree(entry.getClassName()); 37 CompilationUnit tree = deobfuscator.getSourceTree(entry.getClassName());
@@ -39,7 +39,7 @@ public class TokenChecker {
39 // tree.acceptVisitor( new TreeDumpVisitor( new File( "tree." + entry.getClassName().replace( '/', '.' ) + ".txt" ) ), null ); 39 // tree.acceptVisitor( new TreeDumpVisitor( new File( "tree." + entry.getClassName().replace( '/', '.' ) + ".txt" ) ), null );
40 String source = deobfuscator.getSource(tree); 40 String source = deobfuscator.getSource(tree);
41 SourceIndex index = deobfuscator.getSourceIndex(tree, source); 41 SourceIndex index = deobfuscator.getSourceIndex(tree, source);
42 42
43 // get the token value 43 // get the token value
44 Token token = index.getDeclarationToken(entry); 44 Token token = index.getDeclarationToken(entry);
45 if (token == null) { 45 if (token == null) {
@@ -47,17 +47,17 @@ public class TokenChecker {
47 } 47 }
48 return source.substring(token.start, token.end); 48 return source.substring(token.start, token.end);
49 } 49 }
50 50
51 @SuppressWarnings("unchecked") 51 @SuppressWarnings("unchecked")
52 protected Collection<String> getReferenceTokens(EntryReference<? extends Entry,? extends Entry> reference) { 52 protected Collection<String> getReferenceTokens(EntryReference<? extends Entry, ? extends Entry> reference) {
53 // decompile the class 53 // decompile the class
54 CompilationUnit tree = deobfuscator.getSourceTree(reference.context.getClassName()); 54 CompilationUnit tree = deobfuscator.getSourceTree(reference.context.getClassName());
55 String source = deobfuscator.getSource(tree); 55 String source = deobfuscator.getSource(tree);
56 SourceIndex index = deobfuscator.getSourceIndex(tree, source); 56 SourceIndex index = deobfuscator.getSourceIndex(tree, source);
57 57
58 // get the token values 58 // get the token values
59 List<String> values = Lists.newArrayList(); 59 List<String> values = Lists.newArrayList();
60 for (Token token : index.getReferenceTokens((EntryReference<Entry,Entry>)reference)) { 60 for (Token token : index.getReferenceTokens((EntryReference<Entry, Entry>) reference)) {
61 values.add(source.substring(token.start, token.end)); 61 values.add(source.substring(token.start, token.end));
62 } 62 }
63 return values; 63 return values;
diff --git a/src/test/java/cuchaz/enigma/inputs/Keep.java b/src/test/java/cuchaz/enigma/inputs/Keep.java
index f04875f5..4dbe8e2f 100644
--- a/src/test/java/cuchaz/enigma/inputs/Keep.java
+++ b/src/test/java/cuchaz/enigma/inputs/Keep.java
@@ -4,10 +4,11 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.inputs; 12package cuchaz.enigma.inputs;
12 13
13public class Keep { 14public class Keep {
diff --git a/src/test/java/cuchaz/enigma/inputs/constructors/BaseClass.java b/src/test/java/cuchaz/enigma/inputs/constructors/BaseClass.java
index ad5e950e..f07e1f8b 100644
--- a/src/test/java/cuchaz/enigma/inputs/constructors/BaseClass.java
+++ b/src/test/java/cuchaz/enigma/inputs/constructors/BaseClass.java
@@ -4,20 +4,21 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.inputs.constructors; 12package cuchaz.enigma.inputs.constructors;
12 13
13// a 14// a
14public class BaseClass { 15public class BaseClass {
15 16
16 // <init>()V 17 // <init>()V
17 public BaseClass() { 18 public BaseClass() {
18 System.out.println("Default constructor"); 19 System.out.println("Default constructor");
19 } 20 }
20 21
21 // <init>(I)V 22 // <init>(I)V
22 public BaseClass(int i) { 23 public BaseClass(int i) {
23 System.out.println("Int constructor " + i); 24 System.out.println("Int constructor " + i);
diff --git a/src/test/java/cuchaz/enigma/inputs/constructors/Caller.java b/src/test/java/cuchaz/enigma/inputs/constructors/Caller.java
index dcd96173..71439fd1 100644
--- a/src/test/java/cuchaz/enigma/inputs/constructors/Caller.java
+++ b/src/test/java/cuchaz/enigma/inputs/constructors/Caller.java
@@ -4,51 +4,52 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.inputs.constructors; 12package cuchaz.enigma.inputs.constructors;
12 13
13// b 14// b
14public class Caller { 15public class Caller {
15 16
16 // a()V 17 // a()V
17 public void callBaseDefault() { 18 public void callBaseDefault() {
18 // a.<init>()V 19 // a.<init>()V
19 System.out.println(new BaseClass()); 20 System.out.println(new BaseClass());
20 } 21 }
21 22
22 // b()V 23 // b()V
23 public void callBaseInt() { 24 public void callBaseInt() {
24 // a.<init>(I)V 25 // a.<init>(I)V
25 System.out.println(new BaseClass(5)); 26 System.out.println(new BaseClass(5));
26 } 27 }
27 28
28 // c()V 29 // c()V
29 public void callSubDefault() { 30 public void callSubDefault() {
30 // d.<init>()V 31 // d.<init>()V
31 System.out.println(new SubClass()); 32 System.out.println(new SubClass());
32 } 33 }
33 34
34 // d()V 35 // d()V
35 public void callSubInt() { 36 public void callSubInt() {
36 // d.<init>(I)V 37 // d.<init>(I)V
37 System.out.println(new SubClass(6)); 38 System.out.println(new SubClass(6));
38 } 39 }
39 40
40 // e()V 41 // e()V
41 public void callSubIntInt() { 42 public void callSubIntInt() {
42 // d.<init>(II)V 43 // d.<init>(II)V
43 System.out.println(new SubClass(4, 2)); 44 System.out.println(new SubClass(4, 2));
44 } 45 }
45 46
46 // f()V 47 // f()V
47 public void callSubSubInt() { 48 public void callSubSubInt() {
48 // e.<init>(I)V 49 // e.<init>(I)V
49 System.out.println(new SubSubClass(3)); 50 System.out.println(new SubSubClass(3));
50 } 51 }
51 52
52 // g()V 53 // g()V
53 public void callDefaultConstructable() { 54 public void callDefaultConstructable() {
54 // c.<init>()V 55 // c.<init>()V
diff --git a/src/test/java/cuchaz/enigma/inputs/constructors/DefaultConstructable.java b/src/test/java/cuchaz/enigma/inputs/constructors/DefaultConstructable.java
index 655f4da3..c3d41705 100644
--- a/src/test/java/cuchaz/enigma/inputs/constructors/DefaultConstructable.java
+++ b/src/test/java/cuchaz/enigma/inputs/constructors/DefaultConstructable.java
@@ -4,10 +4,11 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.inputs.constructors; 12package cuchaz.enigma.inputs.constructors;
12 13
13public class DefaultConstructable { 14public class DefaultConstructable {
diff --git a/src/test/java/cuchaz/enigma/inputs/constructors/SubClass.java b/src/test/java/cuchaz/enigma/inputs/constructors/SubClass.java
index b2934a27..bc56b3b2 100644
--- a/src/test/java/cuchaz/enigma/inputs/constructors/SubClass.java
+++ b/src/test/java/cuchaz/enigma/inputs/constructors/SubClass.java
@@ -4,33 +4,34 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.inputs.constructors; 12package cuchaz.enigma.inputs.constructors;
12 13
13// d extends a 14// d extends a
14public class SubClass extends BaseClass { 15public class SubClass extends BaseClass {
15 16
16 // <init>()V 17 // <init>()V
17 public SubClass() { 18 public SubClass() {
18 // a.<init>()V 19 // a.<init>()V
19 } 20 }
20 21
21 // <init>(I)V 22 // <init>(I)V
22 public SubClass(int num) { 23 public SubClass(int num) {
23 // <init>()V 24 // <init>()V
24 this(); 25 this();
25 System.out.println("SubClass " + num); 26 System.out.println("SubClass " + num);
26 } 27 }
27 28
28 // <init>(II)V 29 // <init>(II)V
29 public SubClass(int a, int b) { 30 public SubClass(int a, int b) {
30 // <init>(I)V 31 // <init>(I)V
31 this(a + b); 32 this(a + b);
32 } 33 }
33 34
34 // <init>(III)V 35 // <init>(III)V
35 public SubClass(int a, int b, int c) { 36 public SubClass(int a, int b, int c) {
36 // a.<init>()V 37 // a.<init>()V
diff --git a/src/test/java/cuchaz/enigma/inputs/constructors/SubSubClass.java b/src/test/java/cuchaz/enigma/inputs/constructors/SubSubClass.java
index c1725fea..87b69d32 100644
--- a/src/test/java/cuchaz/enigma/inputs/constructors/SubSubClass.java
+++ b/src/test/java/cuchaz/enigma/inputs/constructors/SubSubClass.java
@@ -4,15 +4,16 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.inputs.constructors; 12package cuchaz.enigma.inputs.constructors;
12 13
13// e extends d 14// e extends d
14public class SubSubClass extends SubClass { 15public class SubSubClass extends SubClass {
15 16
16 // <init>(I)V 17 // <init>(I)V
17 public SubSubClass(int i) { 18 public SubSubClass(int i) {
18 // c.<init>(I)V 19 // c.<init>(I)V
diff --git a/src/test/java/cuchaz/enigma/inputs/inheritanceTree/BaseClass.java b/src/test/java/cuchaz/enigma/inputs/inheritanceTree/BaseClass.java
index 1b1f3694..b9c4929c 100644
--- a/src/test/java/cuchaz/enigma/inputs/inheritanceTree/BaseClass.java
+++ b/src/test/java/cuchaz/enigma/inputs/inheritanceTree/BaseClass.java
@@ -4,28 +4,29 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.inputs.inheritanceTree; 12package cuchaz.enigma.inputs.inheritanceTree;
12 13
13// a 14// a
14public abstract class BaseClass { 15public abstract class BaseClass {
15 16
16 // a 17 // a
17 private String name; 18 private String name;
18 19
19 // <init>(Ljava/lang/String;)V 20 // <init>(Ljava/lang/String;)V
20 protected BaseClass(String name) { 21 protected BaseClass(String name) {
21 this.name = name; 22 this.name = name;
22 } 23 }
23 24
24 // a()Ljava/lang/String; 25 // a()Ljava/lang/String;
25 public String getName() { 26 public String getName() {
26 return name; 27 return name;
27 } 28 }
28 29
29 // a()V 30 // a()V
30 public abstract void doBaseThings(); 31 public abstract void doBaseThings();
31} 32}
diff --git a/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassA.java b/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassA.java
index d0213a37..50e963c0 100644
--- a/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassA.java
+++ b/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassA.java
@@ -4,15 +4,16 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.inputs.inheritanceTree; 12package cuchaz.enigma.inputs.inheritanceTree;
12 13
13// b extends a 14// b extends a
14public abstract class SubclassA extends BaseClass { 15public abstract class SubclassA extends BaseClass {
15 16
16 // <init>(Ljava/lang/String;)V 17 // <init>(Ljava/lang/String;)V
17 protected SubclassA(String name) { 18 protected SubclassA(String name) {
18 // call to a.<init>(Ljava/lang/String)V 19 // call to a.<init>(Ljava/lang/String)V
diff --git a/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassB.java b/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassB.java
index 6d3b0d0f..d0dd664d 100644
--- a/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassB.java
+++ b/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassB.java
@@ -4,34 +4,35 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.inputs.inheritanceTree; 12package cuchaz.enigma.inputs.inheritanceTree;
12 13
13// c extends a 14// c extends a
14public class SubclassB extends BaseClass { 15public class SubclassB extends BaseClass {
15 16
16 // a 17 // a
17 private int numThings; 18 private int numThings;
18 19
19 // <init>()V 20 // <init>()V
20 protected SubclassB() { 21 protected SubclassB() {
21 // a.<init>(Ljava/lang/String;)V 22 // a.<init>(Ljava/lang/String;)V
22 super("B"); 23 super("B");
23 24
24 // access to a 25 // access to a
25 numThings = 4; 26 numThings = 4;
26 } 27 }
27 28
28 @Override 29 @Override
29 // a()V 30 // a()V
30 public void doBaseThings() { 31 public void doBaseThings() {
31 // call to a.a()Ljava/lang/String; 32 // call to a.a()Ljava/lang/String;
32 System.out.println("Base things by B! " + getName()); 33 System.out.println("Base things by B! " + getName());
33 } 34 }
34 35
35 // b()V 36 // b()V
36 public void doBThings() { 37 public void doBThings() {
37 // access to a 38 // access to a
diff --git a/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubsubclassAA.java b/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubsubclassAA.java
index a5b25fd5..c5845702 100644
--- a/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubsubclassAA.java
+++ b/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubsubclassAA.java
@@ -4,27 +4,28 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.inputs.inheritanceTree; 12package cuchaz.enigma.inputs.inheritanceTree;
12 13
13// d extends b 14// d extends b
14public class SubsubclassAA extends SubclassA { 15public class SubsubclassAA extends SubclassA {
15 16
16 protected SubsubclassAA() { 17 protected SubsubclassAA() {
17 // call to b.<init>(Ljava/lang/String;)V 18 // call to b.<init>(Ljava/lang/String;)V
18 super("AA"); 19 super("AA");
19 } 20 }
20 21
21 @Override 22 @Override
22 // a()Ljava/lang/String; 23 // a()Ljava/lang/String;
23 public String getName() { 24 public String getName() {
24 // call to b.a()Ljava/lang/String; 25 // call to b.a()Ljava/lang/String;
25 return "subsub" + super.getName(); 26 return "subsub" + super.getName();
26 } 27 }
27 28
28 @Override 29 @Override
29 // a()V 30 // a()V
30 public void doBaseThings() { 31 public void doBaseThings() {
diff --git a/src/test/java/cuchaz/enigma/inputs/innerClasses/A_Anonymous.java b/src/test/java/cuchaz/enigma/inputs/innerClasses/A_Anonymous.java
index f6444396..f652d875 100644
--- a/src/test/java/cuchaz/enigma/inputs/innerClasses/A_Anonymous.java
+++ b/src/test/java/cuchaz/enigma/inputs/innerClasses/A_Anonymous.java
@@ -4,14 +4,15 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.inputs.innerClasses; 12package cuchaz.enigma.inputs.innerClasses;
12 13
13public class A_Anonymous { 14public class A_Anonymous {
14 15
15 public void foo() { 16 public void foo() {
16 Runnable runnable = new Runnable() { 17 Runnable runnable = new Runnable() {
17 @Override 18 @Override
diff --git a/src/test/java/cuchaz/enigma/inputs/innerClasses/B_AnonymousWithScopeArgs.java b/src/test/java/cuchaz/enigma/inputs/innerClasses/B_AnonymousWithScopeArgs.java
index d78be847..d1b7601f 100644
--- a/src/test/java/cuchaz/enigma/inputs/innerClasses/B_AnonymousWithScopeArgs.java
+++ b/src/test/java/cuchaz/enigma/inputs/innerClasses/B_AnonymousWithScopeArgs.java
@@ -4,14 +4,15 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.inputs.innerClasses; 12package cuchaz.enigma.inputs.innerClasses;
12 13
13public class B_AnonymousWithScopeArgs { 14public class B_AnonymousWithScopeArgs {
14 15
15 public static void foo(final D_Simple arg) { 16 public static void foo(final D_Simple arg) {
16 System.out.println(new Object() { 17 System.out.println(new Object() {
17 @Override 18 @Override
diff --git a/src/test/java/cuchaz/enigma/inputs/innerClasses/C_ConstructorArgs.java b/src/test/java/cuchaz/enigma/inputs/innerClasses/C_ConstructorArgs.java
index eb03489d..94061faa 100644
--- a/src/test/java/cuchaz/enigma/inputs/innerClasses/C_ConstructorArgs.java
+++ b/src/test/java/cuchaz/enigma/inputs/innerClasses/C_ConstructorArgs.java
@@ -4,27 +4,28 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.inputs.innerClasses; 12package cuchaz.enigma.inputs.innerClasses;
12 13
13@SuppressWarnings("unused") 14@SuppressWarnings("unused")
14public class C_ConstructorArgs { 15public class C_ConstructorArgs {
15 16
17 Inner i;
18
19 public void foo() {
20 i = new Inner(5);
21 }
22
16 class Inner { 23 class Inner {
17 24
18 private int a; 25 private int a;
19 26
20 public Inner(int a) { 27 public Inner(int a) {
21 this.a = a; 28 this.a = a;
22 } 29 }
23 } 30 }
24
25 Inner i;
26
27 public void foo() {
28 i = new Inner(5);
29 }
30} 31}
diff --git a/src/test/java/cuchaz/enigma/inputs/innerClasses/D_Simple.java b/src/test/java/cuchaz/enigma/inputs/innerClasses/D_Simple.java
index 0e9bf827..71b3a6d8 100644
--- a/src/test/java/cuchaz/enigma/inputs/innerClasses/D_Simple.java
+++ b/src/test/java/cuchaz/enigma/inputs/innerClasses/D_Simple.java
@@ -4,14 +4,15 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.inputs.innerClasses; 12package cuchaz.enigma.inputs.innerClasses;
12 13
13public class D_Simple { 14public class D_Simple {
14 15
15 class Inner { 16 class Inner {
16 // nothing to do 17 // nothing to do
17 } 18 }
diff --git a/src/test/java/cuchaz/enigma/inputs/innerClasses/E_AnonymousWithOuterAccess.java b/src/test/java/cuchaz/enigma/inputs/innerClasses/E_AnonymousWithOuterAccess.java
index 255434d1..976ec426 100644
--- a/src/test/java/cuchaz/enigma/inputs/innerClasses/E_AnonymousWithOuterAccess.java
+++ b/src/test/java/cuchaz/enigma/inputs/innerClasses/E_AnonymousWithOuterAccess.java
@@ -4,17 +4,18 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.inputs.innerClasses; 12package cuchaz.enigma.inputs.innerClasses;
12 13
13public class E_AnonymousWithOuterAccess { 14public class E_AnonymousWithOuterAccess {
14 15
15 // reproduction of error case documented at: 16 // reproduction of error case documented at:
16 // https://bitbucket.org/cuchaz/enigma/issue/61/stackoverflowerror-when-deobfuscating 17 // https://bitbucket.org/cuchaz/enigma/issue/61/stackoverflowerror-when-deobfuscating
17 18
18 public Object makeInner() { 19 public Object makeInner() {
19 outerMethod(); 20 outerMethod();
20 return new Object() { 21 return new Object() {
@@ -24,7 +25,7 @@ public class E_AnonymousWithOuterAccess {
24 } 25 }
25 }; 26 };
26 } 27 }
27 28
28 private String outerMethod() { 29 private String outerMethod() {
29 return "foo"; 30 return "foo";
30 } 31 }
diff --git a/src/test/java/cuchaz/enigma/inputs/innerClasses/F_ClassTree.java b/src/test/java/cuchaz/enigma/inputs/innerClasses/F_ClassTree.java
index 7d1dab41..b1de3c9a 100644
--- a/src/test/java/cuchaz/enigma/inputs/innerClasses/F_ClassTree.java
+++ b/src/test/java/cuchaz/enigma/inputs/innerClasses/F_ClassTree.java
@@ -4,25 +4,25 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11package cuchaz.enigma.inputs.innerClasses;
12 11
12package cuchaz.enigma.inputs.innerClasses;
13 13
14public class F_ClassTree { 14public class F_ClassTree {
15 15
16 public class Level1 { 16 public class Level1 {
17 17
18 public int f1; 18 public int f1;
19 19
20 public class Level2 { 20 public class Level2 {
21 21
22 public int f2; 22 public int f2;
23 23
24 public class Level3 { 24 public class Level3 {
25 25
26 public int f3; 26 public int f3;
27 } 27 }
28 } 28 }
diff --git a/src/test/java/cuchaz/enigma/inputs/loneClass/LoneClass.java b/src/test/java/cuchaz/enigma/inputs/loneClass/LoneClass.java
index d28ae97c..ddc4e319 100644
--- a/src/test/java/cuchaz/enigma/inputs/loneClass/LoneClass.java
+++ b/src/test/java/cuchaz/enigma/inputs/loneClass/LoneClass.java
@@ -4,20 +4,21 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.inputs.loneClass; 12package cuchaz.enigma.inputs.loneClass;
12 13
13public class LoneClass { 14public class LoneClass {
14 15
15 private String name; 16 private String name;
16 17
17 public LoneClass(String name) { 18 public LoneClass(String name) {
18 this.name = name; 19 this.name = name;
19 } 20 }
20 21
21 public String getName() { 22 public String getName() {
22 return name; 23 return name;
23 } 24 }
diff --git a/src/test/java/cuchaz/enigma/inputs/translation/A_Basic.java b/src/test/java/cuchaz/enigma/inputs/translation/A_Basic.java
index 26acac8a..26f3718c 100644
--- a/src/test/java/cuchaz/enigma/inputs/translation/A_Basic.java
+++ b/src/test/java/cuchaz/enigma/inputs/translation/A_Basic.java
@@ -4,28 +4,29 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.inputs.translation; 12package cuchaz.enigma.inputs.translation;
12 13
13public class A_Basic { 14public class A_Basic {
14 15
15 public int one; 16 public int one;
16 public float two; 17 public float two;
17 public String three; 18 public String three;
18 19
19 public void m1() { 20 public void m1() {
20 } 21 }
21 22
22 public int m2() { 23 public int m2() {
23 return 42; 24 return 42;
24 } 25 }
25 26
26 public void m3(int a1) { 27 public void m3(int a1) {
27 } 28 }
28 29
29 public int m4(int a1) { 30 public int m4(int a1) {
30 return 5; // chosen by fair die roll, guaranteed to be random 31 return 5; // chosen by fair die roll, guaranteed to be random
31 } 32 }
diff --git a/src/test/java/cuchaz/enigma/inputs/translation/B_BaseClass.java b/src/test/java/cuchaz/enigma/inputs/translation/B_BaseClass.java
index 035e3299..fd7f6e7e 100644
--- a/src/test/java/cuchaz/enigma/inputs/translation/B_BaseClass.java
+++ b/src/test/java/cuchaz/enigma/inputs/translation/B_BaseClass.java
@@ -4,21 +4,22 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.inputs.translation; 12package cuchaz.enigma.inputs.translation;
12 13
13public class B_BaseClass { 14public class B_BaseClass {
14 15
15 public int f1; 16 public int f1;
16 public char f2; 17 public char f2;
17 18
18 public int m1() { 19 public int m1() {
19 return 5; 20 return 5;
20 } 21 }
21 22
22 public int m2() { 23 public int m2() {
23 return 42; 24 return 42;
24 } 25 }
diff --git a/src/test/java/cuchaz/enigma/inputs/translation/C_SubClass.java b/src/test/java/cuchaz/enigma/inputs/translation/C_SubClass.java
index 6026a8d5..9d74e443 100644
--- a/src/test/java/cuchaz/enigma/inputs/translation/C_SubClass.java
+++ b/src/test/java/cuchaz/enigma/inputs/translation/C_SubClass.java
@@ -4,23 +4,24 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.inputs.translation; 12package cuchaz.enigma.inputs.translation;
12 13
13public class C_SubClass extends B_BaseClass { 14public class C_SubClass extends B_BaseClass {
14 15
15 public char f2; // shadows B_BaseClass.f2 16 public char f2; // shadows B_BaseClass.f2
16 public int f3; 17 public int f3;
17 public int f4; 18 public int f4;
18 19
19 @Override 20 @Override
20 public int m1() { 21 public int m1() {
21 return 32; 22 return 32;
22 } 23 }
23 24
24 public int m3() { 25 public int m3() {
25 return 7; 26 return 7;
26 } 27 }
diff --git a/src/test/java/cuchaz/enigma/inputs/translation/D_AnonymousTesting.java b/src/test/java/cuchaz/enigma/inputs/translation/D_AnonymousTesting.java
index a1827f98..99c83bbf 100644
--- a/src/test/java/cuchaz/enigma/inputs/translation/D_AnonymousTesting.java
+++ b/src/test/java/cuchaz/enigma/inputs/translation/D_AnonymousTesting.java
@@ -4,17 +4,18 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.inputs.translation; 12package cuchaz.enigma.inputs.translation;
12 13
13import java.util.ArrayList; 14import java.util.ArrayList;
14import java.util.List; 15import java.util.List;
15 16
16public class D_AnonymousTesting { 17public class D_AnonymousTesting {
17 18
18 public List<Object> getObjs() { 19 public List<Object> getObjs() {
19 List<Object> objs = new ArrayList<Object>(); 20 List<Object> objs = new ArrayList<Object>();
20 objs.add(new Object() { 21 objs.add(new Object() {
diff --git a/src/test/java/cuchaz/enigma/inputs/translation/E_Bridges.java b/src/test/java/cuchaz/enigma/inputs/translation/E_Bridges.java
index 769eb70e..0b8cf2a5 100644
--- a/src/test/java/cuchaz/enigma/inputs/translation/E_Bridges.java
+++ b/src/test/java/cuchaz/enigma/inputs/translation/E_Bridges.java
@@ -4,15 +4,15 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.inputs.translation; 12package cuchaz.enigma.inputs.translation;
12 13
13import java.util.Iterator; 14import java.util.Iterator;
14 15
15
16public class E_Bridges implements Iterator<Object> { 16public class E_Bridges implements Iterator<Object> {
17 17
18 @Override 18 @Override
diff --git a/src/test/java/cuchaz/enigma/inputs/translation/F_ObjectMethods.java b/src/test/java/cuchaz/enigma/inputs/translation/F_ObjectMethods.java
index 845d62b0..8a92792a 100644
--- a/src/test/java/cuchaz/enigma/inputs/translation/F_ObjectMethods.java
+++ b/src/test/java/cuchaz/enigma/inputs/translation/F_ObjectMethods.java
@@ -4,17 +4,18 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.inputs.translation; 12package cuchaz.enigma.inputs.translation;
12 13
13@SuppressWarnings("FinalizeCalledExplicitly") 14@SuppressWarnings("FinalizeCalledExplicitly")
14public class F_ObjectMethods { 15public class F_ObjectMethods {
15 16
16 public void callEmAll() 17 public void callEmAll()
17 throws Throwable { 18 throws Throwable {
18 clone(); 19 clone();
19 equals(this); 20 equals(this);
20 finalize(); 21 finalize();
diff --git a/src/test/java/cuchaz/enigma/inputs/translation/G_OuterClass.java b/src/test/java/cuchaz/enigma/inputs/translation/G_OuterClass.java
index a2e0dafb..a1e6a85c 100644
--- a/src/test/java/cuchaz/enigma/inputs/translation/G_OuterClass.java
+++ b/src/test/java/cuchaz/enigma/inputs/translation/G_OuterClass.java
@@ -4,30 +4,30 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11package cuchaz.enigma.inputs.translation;
12 11
12package cuchaz.enigma.inputs.translation;
13 13
14public class G_OuterClass { 14public class G_OuterClass {
15 15
16 public class A_InnerClass { 16 public class A_InnerClass {
17 17
18 public int f1; 18 public int f1;
19 public String f2; 19 public String f2;
20 20
21 public void m1() {} 21 public void m1() {}
22 22
23 public class A_InnerInnerClass { 23 public class A_InnerInnerClass {
24 24
25 public int f3; 25 public int f3;
26 26
27 public void m2() {} 27 public void m2() {}
28 } 28 }
29 } 29 }
30 30
31 public class B_NamelessClass { 31 public class B_NamelessClass {
32 public class A_NamedInnerClass { 32 public class A_NamedInnerClass {
33 public int f4; 33 public int f4;
diff --git a/src/test/java/cuchaz/enigma/inputs/translation/H_NamelessClass.java b/src/test/java/cuchaz/enigma/inputs/translation/H_NamelessClass.java
index 1b718a54..013c55ae 100644
--- a/src/test/java/cuchaz/enigma/inputs/translation/H_NamelessClass.java
+++ b/src/test/java/cuchaz/enigma/inputs/translation/H_NamelessClass.java
@@ -4,34 +4,36 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11package cuchaz.enigma.inputs.translation;
12 11
12package cuchaz.enigma.inputs.translation;
13 13
14public class H_NamelessClass { 14public class H_NamelessClass {
15 15
16 public class A_InnerClass { 16 public class A_InnerClass {
17 17
18 public int f1; 18 public int f1;
19 public String f2; 19 public String f2;
20 20
21 public void m1() {} 21 public void m1() {}
22 22
23 public class A_InnerInnerClass { 23 public class A_InnerInnerClass {
24 24
25 public int f3; 25 public int f3;
26 26
27 public void m2() {} 27 public void m2() {}
28 } 28 }
29 } 29 }
30 30
31 public class B_NamelessClass { 31 public class B_NamelessClass {
32 public class A_NamedInnerClass { 32 public class A_NamedInnerClass {
33 public int f4; 33 public int f4;
34
34 public class A_AnotherInnerClass {} 35 public class A_AnotherInnerClass {}
36
35 public class B_YetAnotherInnerClass {} 37 public class B_YetAnotherInnerClass {}
36 } 38 }
37 } 39 }
diff --git a/src/test/java/cuchaz/enigma/inputs/translation/I_Generics.java b/src/test/java/cuchaz/enigma/inputs/translation/I_Generics.java
index 3490f9d9..fd2ebdd5 100644
--- a/src/test/java/cuchaz/enigma/inputs/translation/I_Generics.java
+++ b/src/test/java/cuchaz/enigma/inputs/translation/I_Generics.java
@@ -4,32 +4,32 @@
4 * are made available under the terms of the GNU Lesser General Public 4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at 5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html 6 * http://www.gnu.org/licenses/lgpl.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.inputs.translation; 12package cuchaz.enigma.inputs.translation;
12 13
13import java.util.List; 14import java.util.List;
14import java.util.Map; 15import java.util.Map;
15 16
16
17public class I_Generics { 17public class I_Generics {
18 18
19 public class A_Type {
20 }
21
22 public List<Integer> f1; 19 public List<Integer> f1;
23 public List<A_Type> f2; 20 public List<A_Type> f2;
24 public Map<A_Type,A_Type> f3; 21 public Map<A_Type, A_Type> f3;
25 22 public B_Generic<Integer> f5;
23 public B_Generic<A_Type> f6;
24
25 public class A_Type {
26 }
27
26 public class B_Generic<T> { 28 public class B_Generic<T> {
27 public T f4; 29 public T f4;
30
28 public T m1() { 31 public T m1() {
29 return null; 32 return null;
30 } 33 }
31 } 34 }
32
33 public B_Generic<Integer> f5;
34 public B_Generic<A_Type> f6;
35} 35}