From 6e464ea251cab63c776ece0b2a356f1498ffa294 Mon Sep 17 00:00:00 2001 From: Thog Date: Wed, 8 Mar 2017 08:17:04 +0100 Subject: Follow Fabric guidelines --- src/test/java/cuchaz/enigma/TestDeobfed.java | 28 +++-- src/test/java/cuchaz/enigma/TestDeobfuscator.java | 29 +++-- src/test/java/cuchaz/enigma/TestEntryFactory.java | 49 ++++----- src/test/java/cuchaz/enigma/TestInnerClasses.java | 53 +++++----- .../enigma/TestJarIndexConstructorReferences.java | 63 ++++++----- .../cuchaz/enigma/TestJarIndexInheritanceTree.java | 117 ++++++++++----------- .../java/cuchaz/enigma/TestJarIndexLoneClass.java | 67 +++++------- src/test/java/cuchaz/enigma/TestSignature.java | 40 +++---- src/test/java/cuchaz/enigma/TestSourceIndex.java | 30 +++--- .../java/cuchaz/enigma/TestTokensConstructors.java | 45 ++++---- src/test/java/cuchaz/enigma/TestTranslator.java | 19 ++-- src/test/java/cuchaz/enigma/TestType.java | 46 ++++---- src/test/java/cuchaz/enigma/TokenChecker.java | 32 +++--- src/test/java/cuchaz/enigma/inputs/Keep.java | 3 +- .../enigma/inputs/constructors/BaseClass.java | 7 +- .../cuchaz/enigma/inputs/constructors/Caller.java | 17 +-- .../inputs/constructors/DefaultConstructable.java | 3 +- .../enigma/inputs/constructors/SubClass.java | 11 +- .../enigma/inputs/constructors/SubSubClass.java | 5 +- .../enigma/inputs/inheritanceTree/BaseClass.java | 11 +- .../enigma/inputs/inheritanceTree/SubclassA.java | 5 +- .../enigma/inputs/inheritanceTree/SubclassB.java | 13 +-- .../inputs/inheritanceTree/SubsubclassAA.java | 9 +- .../enigma/inputs/innerClasses/A_Anonymous.java | 5 +- .../innerClasses/B_AnonymousWithScopeArgs.java | 5 +- .../inputs/innerClasses/C_ConstructorArgs.java | 21 ++-- .../enigma/inputs/innerClasses/D_Simple.java | 5 +- .../innerClasses/E_AnonymousWithOuterAccess.java | 9 +- .../enigma/inputs/innerClasses/F_ClassTree.java | 16 +-- .../cuchaz/enigma/inputs/loneClass/LoneClass.java | 9 +- .../cuchaz/enigma/inputs/translation/A_Basic.java | 13 +-- .../enigma/inputs/translation/B_BaseClass.java | 9 +- .../enigma/inputs/translation/C_SubClass.java | 9 +- .../inputs/translation/D_AnonymousTesting.java | 5 +- .../enigma/inputs/translation/E_Bridges.java | 4 +- .../enigma/inputs/translation/F_ObjectMethods.java | 7 +- .../enigma/inputs/translation/G_OuterClass.java | 18 ++-- .../enigma/inputs/translation/H_NamelessClass.java | 20 ++-- .../enigma/inputs/translation/I_Generics.java | 22 ++-- 39 files changed, 444 insertions(+), 435 deletions(-) (limited to 'src/test') 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ -package cuchaz.enigma; - - -import static cuchaz.enigma.TestEntryFactory.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; -import java.util.jar.JarFile; +package cuchaz.enigma; +import cuchaz.enigma.analysis.JarIndex; import org.junit.BeforeClass; import org.junit.Test; -import cuchaz.enigma.analysis.JarIndex; +import java.util.jar.JarFile; +import static cuchaz.enigma.TestEntryFactory.newClass; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsInAnyOrder; public class TestDeobfed { - private static JarFile jar; + private static JarFile jar; private static JarIndex index; - + @BeforeClass public static void beforeClass() - throws Exception { + throws Exception { jar = new JarFile("build/test-deobf/translation.jar"); index = new JarIndex(); index.indexJar(jar, true); } - + @Test public void obfEntries() { assertThat(index.getObfClassEntries(), containsInAnyOrder( @@ -64,10 +62,10 @@ public class TestDeobfed { newClass("i$b") )); } - + @Test public void decompile() - throws Exception { + throws Exception { Deobfuscator deobfuscator = new Deobfuscator(jar); deobfuscator.getSourceTree("a"); 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma; -import static org.junit.Assert.*; +import com.google.common.collect.Lists; +import cuchaz.enigma.mapping.ClassEntry; +import org.junit.Test; import java.io.IOException; import java.util.List; import java.util.jar.JarFile; -import org.junit.Test; - -import com.google.common.collect.Lists; - -import cuchaz.enigma.mapping.ClassEntry; +import static org.junit.Assert.assertEquals; public class TestDeobfuscator { - + private Deobfuscator getDeobfuscator() - throws IOException { + throws IOException { return new Deobfuscator(new JarFile("build/test-obf/loneClass.jar")); } - + @Test public void loadJar() - throws Exception { + throws Exception { getDeobfuscator(); } - + @Test public void getClasses() - throws Exception { + throws Exception { Deobfuscator deobfuscator = getDeobfuscator(); List obfClasses = Lists.newArrayList(); List deobfClasses = Lists.newArrayList(); @@ -47,10 +46,10 @@ public class TestDeobfuscator { assertEquals(1, deobfClasses.size()); assertEquals("cuchaz/enigma/inputs/Keep", deobfClasses.get(0).getName()); } - + @Test public void decompileClass() - throws Exception { + throws Exception { Deobfuscator deobfuscator = getDeobfuscator(); deobfuscator.getSource(deobfuscator.getSourceTree("a")); } 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma; import cuchaz.enigma.analysis.EntryReference; -import cuchaz.enigma.mapping.BehaviorEntry; -import cuchaz.enigma.mapping.ClassEntry; -import cuchaz.enigma.mapping.ConstructorEntry; -import cuchaz.enigma.mapping.FieldEntry; -import cuchaz.enigma.mapping.MethodEntry; -import cuchaz.enigma.mapping.Signature; -import cuchaz.enigma.mapping.Type; +import cuchaz.enigma.mapping.*; public class TestEntryFactory { - + public static ClassEntry newClass(String name) { return new ClassEntry(name); } - + public static FieldEntry newField(String className, String fieldName, String fieldType) { return newField(newClass(className), fieldName, fieldType); } - + public static FieldEntry newField(ClassEntry classEntry, String fieldName, String fieldType) { return new FieldEntry(classEntry, fieldName, new Type(fieldType)); } - + public static MethodEntry newMethod(String className, String methodName, String methodSignature) { return newMethod(newClass(className), methodName, methodSignature); } - + public static MethodEntry newMethod(ClassEntry classEntry, String methodName, String methodSignature) { return new MethodEntry(classEntry, methodName, new Signature(methodSignature)); } - + public static ConstructorEntry newConstructor(String className, String signature) { return newConstructor(newClass(className), signature); } - + public static ConstructorEntry newConstructor(ClassEntry classEntry, String signature) { return new ConstructorEntry(classEntry, new Signature(signature)); } - - public static EntryReference newFieldReferenceByMethod(FieldEntry fieldEntry, String callerClassName, String callerName, String callerSignature) { - return new EntryReference(fieldEntry, "", newMethod(callerClassName, callerName, callerSignature)); + + public static EntryReference newFieldReferenceByMethod(FieldEntry fieldEntry, String callerClassName, String callerName, String callerSignature) { + return new EntryReference(fieldEntry, "", newMethod(callerClassName, callerName, callerSignature)); } - - public static EntryReference newFieldReferenceByConstructor(FieldEntry fieldEntry, String callerClassName, String callerSignature) { - return new EntryReference(fieldEntry, "", newConstructor(callerClassName, callerSignature)); + + public static EntryReference newFieldReferenceByConstructor(FieldEntry fieldEntry, String callerClassName, String callerSignature) { + return new EntryReference(fieldEntry, "", newConstructor(callerClassName, callerSignature)); } - - public static EntryReference newBehaviorReferenceByMethod(BehaviorEntry behaviorEntry, String callerClassName, String callerName, String callerSignature) { - return new EntryReference(behaviorEntry, "", newMethod(callerClassName, callerName, callerSignature)); + + public static EntryReference newBehaviorReferenceByMethod(BehaviorEntry behaviorEntry, String callerClassName, String callerName, String callerSignature) { + return new EntryReference(behaviorEntry, "", newMethod(callerClassName, callerName, callerSignature)); } - - public static EntryReference newBehaviorReferenceByConstructor(BehaviorEntry behaviorEntry, String callerClassName, String callerSignature) { - return new EntryReference(behaviorEntry, "", newConstructor(callerClassName, callerSignature)); + + public static EntryReference newBehaviorReferenceByConstructor(BehaviorEntry behaviorEntry, String callerClassName, String callerSignature) { + return new EntryReference(behaviorEntry, "", newConstructor(callerClassName, callerSignature)); } } 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ -package cuchaz.enigma; - -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; -import java.util.jar.JarFile; +package cuchaz.enigma; +import cuchaz.enigma.analysis.JarIndex; +import cuchaz.enigma.mapping.ClassEntry; import org.junit.Test; -import static cuchaz.enigma.TestEntryFactory.*; +import java.util.jar.JarFile; -import cuchaz.enigma.analysis.JarIndex; -import cuchaz.enigma.mapping.ClassEntry; +import static cuchaz.enigma.TestEntryFactory.newClass; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; public class TestInnerClasses { - - private JarIndex index; - private Deobfuscator deobfuscator; - + private static final ClassEntry AnonymousOuter = newClass("a"); private static final ClassEntry AnonymousInner = newClass("a$1"); private static final ClassEntry SimpleOuter = newClass("d"); @@ -41,15 +40,17 @@ public class TestInnerClasses { private static final ClassEntry ClassTreeLevel1 = newClass("f$a"); private static final ClassEntry ClassTreeLevel2 = newClass("f$a$a"); private static final ClassEntry ClassTreeLevel3 = newClass("f$a$a$a"); - + private JarIndex index; + private Deobfuscator deobfuscator; + public TestInnerClasses() - throws Exception { + throws Exception { index = new JarIndex(); JarFile jar = new JarFile("build/test-obf/innerClasses.jar"); index.indexJar(jar, true); deobfuscator = new Deobfuscator(jar); } - + @Test public void simple() { assertThat(index.getOuterClass(SimpleInner), is(SimpleOuter)); @@ -57,7 +58,7 @@ public class TestInnerClasses { assertThat(index.isAnonymousClass(SimpleInner), is(false)); decompile(SimpleOuter); } - + @Test public void anonymous() { assertThat(index.getOuterClass(AnonymousInner), is(AnonymousOuter)); @@ -65,7 +66,7 @@ public class TestInnerClasses { assertThat(index.isAnonymousClass(AnonymousInner), is(true)); decompile(AnonymousOuter); } - + @Test public void constructorArgs() { assertThat(index.getOuterClass(ConstructorArgsInner), is(ConstructorArgsOuter)); @@ -73,7 +74,7 @@ public class TestInnerClasses { assertThat(index.isAnonymousClass(ConstructorArgsInner), is(false)); decompile(ConstructorArgsOuter); } - + @Test public void anonymousWithScopeArgs() { assertThat(index.getOuterClass(AnonymousWithScopeArgsInner), is(AnonymousWithScopeArgsOuter)); @@ -81,7 +82,7 @@ public class TestInnerClasses { assertThat(index.isAnonymousClass(AnonymousWithScopeArgsInner), is(true)); decompile(AnonymousWithScopeArgsOuter); } - + @Test public void anonymousWithOuterAccess() { assertThat(index.getOuterClass(AnonymousWithOuterAccessInner), is(AnonymousWithOuterAccessOuter)); @@ -89,15 +90,15 @@ public class TestInnerClasses { assertThat(index.isAnonymousClass(AnonymousWithOuterAccessInner), is(true)); decompile(AnonymousWithOuterAccessOuter); } - + @Test public void classTree() { - + // root level assertThat(index.containsObfClass(ClassTreeRoot), is(true)); assertThat(index.getOuterClass(ClassTreeRoot), is(nullValue())); assertThat(index.getInnerClasses(ClassTreeRoot), containsInAnyOrder(ClassTreeLevel1)); - + // level 1 ClassEntry fullClassEntry = new ClassEntry(ClassTreeRoot.getName() + "$" + ClassTreeLevel1.getInnermostClassName() @@ -105,7 +106,7 @@ public class TestInnerClasses { assertThat(index.containsObfClass(fullClassEntry), is(true)); assertThat(index.getOuterClass(ClassTreeLevel1), is(ClassTreeRoot)); assertThat(index.getInnerClasses(ClassTreeLevel1), containsInAnyOrder(ClassTreeLevel2)); - + // level 2 fullClassEntry = new ClassEntry(ClassTreeRoot.getName() + "$" + ClassTreeLevel1.getInnermostClassName() @@ -114,7 +115,7 @@ public class TestInnerClasses { assertThat(index.containsObfClass(fullClassEntry), is(true)); assertThat(index.getOuterClass(ClassTreeLevel2), is(ClassTreeLevel1)); assertThat(index.getInnerClasses(ClassTreeLevel2), containsInAnyOrder(ClassTreeLevel3)); - + // level 3 fullClassEntry = new ClassEntry(ClassTreeRoot.getName() + "$" + ClassTreeLevel1.getInnermostClassName() @@ -125,7 +126,7 @@ public class TestInnerClasses { assertThat(index.getOuterClass(ClassTreeLevel3), is(ClassTreeLevel2)); assertThat(index.getInnerClasses(ClassTreeLevel3), is(empty())); } - + private void decompile(ClassEntry classEntry) { deobfuscator.getSourceTree(classEntry.getName()); } 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma; -import static cuchaz.enigma.TestEntryFactory.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import cuchaz.enigma.analysis.EntryReference; +import cuchaz.enigma.analysis.JarIndex; +import cuchaz.enigma.mapping.BehaviorEntry; +import cuchaz.enigma.mapping.ClassEntry; +import org.junit.Test; import java.io.File; import java.util.Collection; import java.util.jar.JarFile; -import org.junit.Test; - -import cuchaz.enigma.analysis.EntryReference; -import cuchaz.enigma.analysis.JarIndex; -import cuchaz.enigma.mapping.BehaviorEntry; -import cuchaz.enigma.mapping.ClassEntry; +import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByConstructor; +import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByMethod; +import static cuchaz.enigma.TestEntryFactory.newClass; +import static cuchaz.enigma.TestEntryFactory.newConstructor; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.is; public class TestJarIndexConstructorReferences { - + private JarIndex index; - - private ClassEntry baseClass = newClass("a"); - private ClassEntry subClass = newClass("d"); - private ClassEntry subsubClass = newClass("e"); + + private ClassEntry baseClass = newClass("a"); + private ClassEntry subClass = newClass("d"); + private ClassEntry subsubClass = newClass("e"); private ClassEntry defaultClass = newClass("c"); - private ClassEntry callerClass = newClass("b"); - + private ClassEntry callerClass = newClass("b"); + public TestJarIndexConstructorReferences() - throws Exception { + throws Exception { File jarFile = new File("build/test-obf/constructors.jar"); index = new JarIndex(); index.indexJar(new JarFile(jarFile), false); } - + @Test public void obfEntries() { assertThat(index.getObfClassEntries(), containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), baseClass, - subClass, subsubClass, defaultClass, callerClass)); + subClass, subsubClass, defaultClass, callerClass)); } - + @Test @SuppressWarnings("unchecked") public void baseDefault() { BehaviorEntry source = newConstructor(baseClass, "()V"); - Collection> references = index.getBehaviorReferences(source); + Collection> references = index.getBehaviorReferences(source); assertThat(references, containsInAnyOrder( newBehaviorReferenceByMethod(source, callerClass.getName(), "a", "()V"), newBehaviorReferenceByConstructor(source, subClass.getName(), "()V"), newBehaviorReferenceByConstructor(source, subClass.getName(), "(III)V") )); } - + @Test @SuppressWarnings("unchecked") public void baseInt() { @@ -68,7 +73,7 @@ public class TestJarIndexConstructorReferences { newBehaviorReferenceByMethod(source, callerClass.getName(), "b", "()V") )); } - + @Test @SuppressWarnings("unchecked") public void subDefault() { @@ -78,7 +83,7 @@ public class TestJarIndexConstructorReferences { newBehaviorReferenceByConstructor(source, subClass.getName(), "(I)V") )); } - + @Test @SuppressWarnings("unchecked") public void subInt() { @@ -89,7 +94,7 @@ public class TestJarIndexConstructorReferences { newBehaviorReferenceByConstructor(source, subsubClass.getName(), "(I)V") )); } - + @Test @SuppressWarnings("unchecked") public void subIntInt() { @@ -98,13 +103,13 @@ public class TestJarIndexConstructorReferences { newBehaviorReferenceByMethod(source, callerClass.getName(), "e", "()V") )); } - + @Test public void subIntIntInt() { BehaviorEntry source = newConstructor(subClass, "(III)V"); assertThat(index.getBehaviorReferences(source), is(empty())); } - + @Test @SuppressWarnings("unchecked") public void subsubInt() { @@ -113,7 +118,7 @@ public class TestJarIndexConstructorReferences { newBehaviorReferenceByMethod(source, callerClass.getName(), "f", "()V") )); } - + @Test @SuppressWarnings("unchecked") 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ -package cuchaz.enigma; - -import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByConstructor; -import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByMethod; -import static cuchaz.enigma.TestEntryFactory.newClass; -import static cuchaz.enigma.TestEntryFactory.newConstructor; -import static cuchaz.enigma.TestEntryFactory.newField; -import static cuchaz.enigma.TestEntryFactory.newFieldReferenceByConstructor; -import static cuchaz.enigma.TestEntryFactory.newFieldReferenceByMethod; -import static cuchaz.enigma.TestEntryFactory.newMethod; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.hamcrest.Matchers.empty; -import static org.hamcrest.Matchers.is; -import java.util.Collection; -import java.util.Set; -import java.util.jar.JarFile; - -import org.junit.Test; +package cuchaz.enigma; import cuchaz.enigma.analysis.Access; import cuchaz.enigma.analysis.EntryReference; @@ -38,70 +19,82 @@ import cuchaz.enigma.mapping.BehaviorEntry; import cuchaz.enigma.mapping.ClassEntry; import cuchaz.enigma.mapping.FieldEntry; import cuchaz.enigma.mapping.MethodEntry; +import org.junit.Test; + +import java.util.Collection; +import java.util.Set; +import java.util.jar.JarFile; + +import static cuchaz.enigma.TestEntryFactory.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.is; public class TestJarIndexInheritanceTree { - + private JarIndex index; - - private ClassEntry objectClass = newClass("java/lang/Object"); - private ClassEntry baseClass = newClass("a"); - private ClassEntry subClassA = newClass("b"); - private ClassEntry subClassAA = newClass("d"); - private ClassEntry subClassB = newClass("c"); - private FieldEntry nameField = newField(baseClass, "a", "Ljava/lang/String;"); + + private ClassEntry objectClass = newClass("java/lang/Object"); + private ClassEntry baseClass = newClass("a"); + private ClassEntry subClassA = newClass("b"); + private ClassEntry subClassAA = newClass("d"); + private ClassEntry subClassB = newClass("c"); + private FieldEntry nameField = newField(baseClass, "a", "Ljava/lang/String;"); private FieldEntry numThingsField = newField(subClassB, "a", "I"); - + public TestJarIndexInheritanceTree() - throws Exception { + throws Exception { index = new JarIndex(); index.indexJar(new JarFile("build/test-obf/inheritanceTree.jar"), false); } - + @Test public void obfEntries() { assertThat(index.getObfClassEntries(), containsInAnyOrder( newClass("cuchaz/enigma/inputs/Keep"), baseClass, subClassA, subClassAA, subClassB )); } - + @Test public void translationIndex() { - + TranslationIndex index = this.index.getTranslationIndex(); - + // base class assertThat(index.getSuperclass(baseClass), is(objectClass)); assertThat(index.getAncestry(baseClass), contains(objectClass)); assertThat(index.getSubclass(baseClass), containsInAnyOrder(subClassA, subClassB )); - + // subclass a assertThat(index.getSuperclass(subClassA), is(baseClass)); assertThat(index.getAncestry(subClassA), contains(baseClass, objectClass)); assertThat(index.getSubclass(subClassA), contains(subClassAA)); - + // subclass aa assertThat(index.getSuperclass(subClassAA), is(subClassA)); assertThat(index.getAncestry(subClassAA), contains(subClassA, baseClass, objectClass)); assertThat(index.getSubclass(subClassAA), is(empty())); - + // subclass b assertThat(index.getSuperclass(subClassB), is(baseClass)); assertThat(index.getAncestry(subClassB), contains(baseClass, objectClass)); assertThat(index.getSubclass(subClassB), is(empty())); } - + @Test public void access() { assertThat(index.getAccess(nameField), is(Access.PRIVATE)); assertThat(index.getAccess(numThingsField), is(Access.PRIVATE)); } - + @Test public void relatedMethodImplementations() { - + Set entries; - + // getName() entries = index.getRelatedMethodImplementations(newMethod(baseClass, "a", "()Ljava/lang/String;")); assertThat(entries, containsInAnyOrder( @@ -113,7 +106,7 @@ public class TestJarIndexInheritanceTree { newMethod(baseClass, "a", "()Ljava/lang/String;"), newMethod(subClassAA, "a", "()Ljava/lang/String;") )); - + // doBaseThings() entries = index.getRelatedMethodImplementations(newMethod(baseClass, "a", "()V")); assertThat(entries, containsInAnyOrder( @@ -133,24 +126,24 @@ public class TestJarIndexInheritanceTree { newMethod(subClassAA, "a", "()V"), newMethod(subClassB, "a", "()V") )); - + // doBThings entries = index.getRelatedMethodImplementations(newMethod(subClassB, "b", "()V")); assertThat(entries, containsInAnyOrder(newMethod(subClassB, "b", "()V"))); } - + @Test @SuppressWarnings("unchecked") public void fieldReferences() { - Collection> references; - + Collection> references; + // name references = index.getFieldReferences(nameField); assertThat(references, containsInAnyOrder( newFieldReferenceByConstructor(nameField, baseClass.getName(), "(Ljava/lang/String;)V"), newFieldReferenceByMethod(nameField, baseClass.getName(), "a", "()Ljava/lang/String;") )); - + // numThings references = index.getFieldReferences(numThingsField); assertThat(references, containsInAnyOrder( @@ -158,14 +151,14 @@ public class TestJarIndexInheritanceTree { newFieldReferenceByMethod(numThingsField, subClassB.getName(), "b", "()V") )); } - + @Test @SuppressWarnings("unchecked") public void behaviorReferences() { - + BehaviorEntry source; - Collection> references; - + Collection> references; + // baseClass constructor source = newConstructor(baseClass, "(Ljava/lang/String;)V"); references = index.getBehaviorReferences(source); @@ -173,14 +166,14 @@ public class TestJarIndexInheritanceTree { newBehaviorReferenceByConstructor(source, subClassA.getName(), "(Ljava/lang/String;)V"), newBehaviorReferenceByConstructor(source, subClassB.getName(), "()V") )); - + // subClassA constructor source = newConstructor(subClassA, "(Ljava/lang/String;)V"); references = index.getBehaviorReferences(source); assertThat(references, containsInAnyOrder( newBehaviorReferenceByConstructor(source, subClassAA.getName(), "()V") )); - + // baseClass.getName() source = newMethod(baseClass, "a", "()Ljava/lang/String;"); references = index.getBehaviorReferences(source); @@ -188,7 +181,7 @@ public class TestJarIndexInheritanceTree { newBehaviorReferenceByMethod(source, subClassAA.getName(), "a", "()Ljava/lang/String;"), newBehaviorReferenceByMethod(source, subClassB.getName(), "a", "()V") )); - + // subclassAA.getName() source = newMethod(subClassAA, "a", "()Ljava/lang/String;"); references = index.getBehaviorReferences(source); @@ -196,38 +189,38 @@ public class TestJarIndexInheritanceTree { newBehaviorReferenceByMethod(source, subClassAA.getName(), "a", "()V") )); } - + @Test public void containsEntries() { - + // classes assertThat(index.containsObfClass(baseClass), is(true)); assertThat(index.containsObfClass(subClassA), is(true)); assertThat(index.containsObfClass(subClassAA), is(true)); assertThat(index.containsObfClass(subClassB), is(true)); - + // fields assertThat(index.containsObfField(nameField), is(true)); assertThat(index.containsObfField(numThingsField), is(true)); - + // methods // getName() assertThat(index.containsObfBehavior(newMethod(baseClass, "a", "()Ljava/lang/String;")), is(true)); assertThat(index.containsObfBehavior(newMethod(subClassA, "a", "()Ljava/lang/String;")), is(false)); assertThat(index.containsObfBehavior(newMethod(subClassAA, "a", "()Ljava/lang/String;")), is(true)); assertThat(index.containsObfBehavior(newMethod(subClassB, "a", "()Ljava/lang/String;")), is(false)); - + // doBaseThings() assertThat(index.containsObfBehavior(newMethod(baseClass, "a", "()V")), is(true)); assertThat(index.containsObfBehavior(newMethod(subClassA, "a", "()V")), is(false)); assertThat(index.containsObfBehavior(newMethod(subClassAA, "a", "()V")), is(true)); assertThat(index.containsObfBehavior(newMethod(subClassB, "a", "()V")), is(true)); - + // doBThings() assertThat(index.containsObfBehavior(newMethod(baseClass, "b", "()V")), is(false)); assertThat(index.containsObfBehavior(newMethod(subClassA, "b", "()V")), is(false)); assertThat(index.containsObfBehavior(newMethod(subClassAA, "b", "()V")), is(false)); assertThat(index.containsObfBehavior(newMethod(subClassB, "b", "()V")), is(true)); - + } } 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma; -import static cuchaz.enigma.TestEntryFactory.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import cuchaz.enigma.analysis.*; +import cuchaz.enigma.mapping.*; +import org.junit.Test; import java.util.Collection; import java.util.Set; import java.util.jar.JarFile; -import org.junit.Test; - -import cuchaz.enigma.analysis.Access; -import cuchaz.enigma.analysis.ClassImplementationsTreeNode; -import cuchaz.enigma.analysis.ClassInheritanceTreeNode; -import cuchaz.enigma.analysis.EntryReference; -import cuchaz.enigma.analysis.JarIndex; -import cuchaz.enigma.analysis.MethodInheritanceTreeNode; -import cuchaz.enigma.mapping.BehaviorEntry; -import cuchaz.enigma.mapping.ClassEntry; -import cuchaz.enigma.mapping.FieldEntry; -import cuchaz.enigma.mapping.MethodEntry; -import cuchaz.enigma.mapping.Translator; +import static cuchaz.enigma.TestEntryFactory.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; public class TestJarIndexLoneClass { - + private JarIndex index; - + public TestJarIndexLoneClass() - throws Exception { + throws Exception { index = new JarIndex(); index.indexJar(new JarFile("build/test-obf/loneClass.jar"), false); } - + @Test public void obfEntries() { assertThat(index.getObfClassEntries(), containsInAnyOrder( @@ -49,7 +40,7 @@ public class TestJarIndexLoneClass { newClass("a") )); } - + @Test public void translationIndex() { assertThat(index.getTranslationIndex().getSuperclass(new ClassEntry("a")), is(new ClassEntry("java/lang/Object"))); @@ -59,7 +50,7 @@ public class TestJarIndexLoneClass { assertThat(index.getTranslationIndex().getSubclass(new ClassEntry("a")), is(empty())); assertThat(index.getTranslationIndex().getSubclass(new ClassEntry("cuchaz/enigma/inputs/Keep")), is(empty())); } - + @Test public void access() { assertThat(index.getAccess(newField("a", "a", "Ljava/lang/String;")), is(Access.PRIVATE)); @@ -67,7 +58,7 @@ public class TestJarIndexLoneClass { assertThat(index.getAccess(newField("a", "b", "Ljava/lang/String;")), is(nullValue())); assertThat(index.getAccess(newField("a", "a", "LFoo;")), is(nullValue())); } - + @Test public void classInheritance() { ClassInheritanceTreeNode node = index.getClassInheritance(new Translator(), newClass("a")); @@ -75,7 +66,7 @@ public class TestJarIndexLoneClass { assertThat(node.getObfClassName(), is("a")); assertThat(node.getChildCount(), is(0)); } - + @Test public void methodInheritance() { MethodEntry source = newMethod("a", "a", "()Ljava/lang/String;"); @@ -84,19 +75,19 @@ public class TestJarIndexLoneClass { assertThat(node.getMethodEntry(), is(source)); assertThat(node.getChildCount(), is(0)); } - + @Test public void classImplementations() { ClassImplementationsTreeNode node = index.getClassImplementations(new Translator(), newClass("a")); assertThat(node, is(nullValue())); } - + @Test public void methodImplementations() { MethodEntry source = newMethod("a", "a", "()Ljava/lang/String;"); assertThat(index.getMethodImplementations(new Translator(), source), is(empty())); } - + @Test public void relatedMethodImplementations() { Set entries = index.getRelatedMethodImplementations(newMethod("a", "a", "()Ljava/lang/String;")); @@ -104,53 +95,53 @@ public class TestJarIndexLoneClass { newMethod("a", "a", "()Ljava/lang/String;") )); } - + @Test @SuppressWarnings("unchecked") public void fieldReferences() { FieldEntry source = newField("a", "a", "Ljava/lang/String;"); - Collection> references = index.getFieldReferences(source); + Collection> references = index.getFieldReferences(source); assertThat(references, containsInAnyOrder( newFieldReferenceByConstructor(source, "a", "(Ljava/lang/String;)V"), newFieldReferenceByMethod(source, "a", "a", "()Ljava/lang/String;") )); } - + @Test public void behaviorReferences() { assertThat(index.getBehaviorReferences(newMethod("a", "a", "()Ljava/lang/String;")), is(empty())); } - + @Test public void innerClasses() { assertThat(index.getInnerClasses(newClass("a")), is(empty())); } - + @Test public void outerClass() { assertThat(index.getOuterClass(newClass("a")), is(nullValue())); } - + @Test public void isAnonymousClass() { assertThat(index.isAnonymousClass(newClass("a")), is(false)); } - + @Test public void interfaces() { assertThat(index.getInterfaces("a"), is(empty())); } - + @Test public void implementingClasses() { assertThat(index.getImplementingClasses("a"), is(empty())); } - + @Test public void isInterface() { assertThat(index.isInterface("a"), is(false)); } - + @Test public void testContains() { 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ -package cuchaz.enigma; - -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; -import org.junit.Test; +package cuchaz.enigma; import cuchaz.enigma.mapping.ClassNameReplacer; import cuchaz.enigma.mapping.Signature; import cuchaz.enigma.mapping.Type; +import org.junit.Test; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; public class TestSignature { - + @Test public void easiest() { final Signature sig = new Signature("()V"); assertThat(sig.getArgumentTypes(), is(empty())); assertThat(sig.getReturnType(), is(new Type("V"))); } - + @Test public void primitives() { { @@ -56,7 +58,7 @@ public class TestSignature { assertThat(sig.getReturnType(), is(new Type("Z"))); } } - + @Test public void classes() { { @@ -82,7 +84,7 @@ public class TestSignature { assertThat(sig.getReturnType(), is(new Type("LBar;"))); } } - + @Test public void arrays() { { @@ -109,7 +111,7 @@ public class TestSignature { assertThat(sig.getReturnType(), is(new Type("[D"))); } } - + @Test public void mixed() { { @@ -131,7 +133,7 @@ public class TestSignature { assertThat(sig.getReturnType(), is(new Type("[LFoo;"))); } } - + @Test public void replaceClasses() { { @@ -195,7 +197,7 @@ public class TestSignature { assertThat(sig.getReturnType(), is(new Type("LCow;"))); } } - + @Test public void replaceArrayClasses() { { @@ -217,13 +219,13 @@ public class TestSignature { assertThat(sig.getReturnType(), is(new Type("[[[LBeer;"))); } } - + @Test public void equals() { - + // base assertThat(new Signature("()V"), is(new Signature("()V"))); - + // arguments assertThat(new Signature("(I)V"), is(new Signature("(I)V"))); assertThat(new Signature("(ZIZ)V"), is(new Signature("(ZIZ)V"))); @@ -238,7 +240,7 @@ public class TestSignature { assertThat(new Signature("([[Z)V"), is(not(new Signature("([[LFoo;)V")))); assertThat(new Signature("(LFoo;LBar;)V"), is(not(new Signature("(LFoo;LCow;)V")))); assertThat(new Signature("([LFoo;LBar;)V"), is(not(new Signature("(LFoo;LCow;)V")))); - + // return type assertThat(new Signature("()I"), is(new Signature("()I"))); assertThat(new Signature("()Z"), is(new Signature("()Z"))); @@ -246,7 +248,7 @@ public class TestSignature { assertThat(new Signature("()[[[Z"), is(new Signature("()[[[Z"))); assertThat(new Signature("()LFoo;"), is(new Signature("()LFoo;"))); assertThat(new Signature("()[LFoo;"), is(new Signature("()[LFoo;"))); - + assertThat(new Signature("()I"), is(not(new Signature("()Z")))); assertThat(new Signature("()Z"), is(not(new Signature("()I")))); assertThat(new Signature("()[D"), is(not(new Signature("()[J")))); @@ -254,7 +256,7 @@ public class TestSignature { assertThat(new Signature("()LFoo;"), is(not(new Signature("()LBar;")))); assertThat(new Signature("()[LFoo;"), is(not(new Signature("()[LBar;")))); } - + @Test public void testToString() { 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ -package cuchaz.enigma; - -import java.io.File; -import java.util.Set; -import java.util.jar.JarFile; -import org.junit.Test; +package cuchaz.enigma; import com.google.common.collect.Sets; import com.strobel.decompiler.languages.java.ast.CompilationUnit; - import cuchaz.enigma.mapping.ClassEntry; +import org.junit.Test; + +import java.io.File; +import java.util.Set; +import java.util.jar.JarFile; public class TestSourceIndex { @Test public void indexEverything() - throws Exception { + throws Exception { // Figure out where Minecraft is... final String mcDir = System.getProperty("enigma.test.minecraftdir"); File mcJar = null; @@ -32,20 +31,17 @@ public class TestSourceIndex { String osname = System.getProperty("os.name").toLowerCase(); if (osname.contains("nix") || osname.contains("nux") || osname.contains("solaris")) { mcJar = new File(System.getProperty("user.home"), ".minecraft/versions/1.8.3/1.8.3.jar"); - } - else if (osname.contains("mac") || osname.contains("darwin")) { + } else if (osname.contains("mac") || osname.contains("darwin")) { mcJar = new File(System.getProperty("user.home"), "Library/Application Support/minecraft/versions/1.8.3/1.8.3.jar"); - } - else if (osname.contains("win")) { + } else if (osname.contains("win")) { mcJar = new File(System.getenv("AppData"), ".minecraft/versions/1.8.3/1.8.3.jar"); } - } - else { + } else { mcJar = new File(mcDir, "versions/1.8.3/1.8.3.jar"); } Deobfuscator deobfuscator = new Deobfuscator(new JarFile(mcJar)); - + // get all classes that aren't inner classes Set classEntries = Sets.newHashSet(); for (ClassEntry obfClassEntry : deobfuscator.getJarIndex().getObfClassEntries()) { @@ -53,7 +49,7 @@ public class TestSourceIndex { classEntries.add(obfClassEntry); } } - + for (ClassEntry obfClassEntry : classEntries) { try { 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma; -import static cuchaz.enigma.TestEntryFactory.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; +import cuchaz.enigma.mapping.BehaviorEntry; +import org.junit.Test; import java.util.jar.JarFile; -import org.junit.Test; - -import cuchaz.enigma.mapping.BehaviorEntry; +import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByConstructor; +import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByMethod; +import static cuchaz.enigma.TestEntryFactory.newConstructor; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; public class TestTokensConstructors extends TokenChecker { - + public TestTokensConstructors() - throws Exception { + throws Exception { super(new JarFile("build/test-obf/constructors.jar")); } - + @Test public void baseDeclarations() { assertThat(getDeclarationToken(newConstructor("a", "()V")), is("a")); assertThat(getDeclarationToken(newConstructor("a", "(I)V")), is("a")); } - + @Test public void subDeclarations() { assertThat(getDeclarationToken(newConstructor("d", "()V")), is("d")); @@ -40,17 +45,17 @@ public class TestTokensConstructors extends TokenChecker { assertThat(getDeclarationToken(newConstructor("d", "(II)V")), is("d")); assertThat(getDeclarationToken(newConstructor("d", "(III)V")), is("d")); } - + @Test public void subsubDeclarations() { assertThat(getDeclarationToken(newConstructor("e", "(I)V")), is("e")); } - + @Test public void defaultDeclarations() { assertThat(getDeclarationToken(newConstructor("c", "()V")), nullValue()); } - + @Test public void baseDefaultReferences() { BehaviorEntry source = newConstructor("a", "()V"); @@ -67,7 +72,7 @@ public class TestTokensConstructors extends TokenChecker { is(empty()) // implicit call, not decompiled to token ); } - + @Test public void baseIntReferences() { BehaviorEntry source = newConstructor("a", "(I)V"); @@ -76,7 +81,7 @@ public class TestTokensConstructors extends TokenChecker { containsInAnyOrder("a") ); } - + @Test public void subDefaultReferences() { BehaviorEntry source = newConstructor("d", "()V"); @@ -89,7 +94,7 @@ public class TestTokensConstructors extends TokenChecker { containsInAnyOrder("this") ); } - + @Test public void subIntReferences() { BehaviorEntry source = newConstructor("d", "(I)V"); @@ -106,7 +111,7 @@ public class TestTokensConstructors extends TokenChecker { containsInAnyOrder("super") ); } - + @Test public void subIntIntReferences() { BehaviorEntry source = newConstructor("d", "(II)V"); @@ -115,7 +120,7 @@ public class TestTokensConstructors extends TokenChecker { containsInAnyOrder("d") ); } - + @Test public void subsubIntReferences() { BehaviorEntry source = newConstructor("e", "(I)V"); @@ -124,7 +129,7 @@ public class TestTokensConstructors extends TokenChecker { containsInAnyOrder("e") ); } - + @Test public void defaultConstructableReferences() { 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 @@ * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ -package cuchaz.enigma; - -import static cuchaz.enigma.TestEntryFactory.*; -import org.junit.BeforeClass; -import org.junit.Test; +package cuchaz.enigma; import cuchaz.enigma.mapping.Entry; import cuchaz.enigma.mapping.Mappings; import cuchaz.enigma.mapping.Translator; +import org.junit.BeforeClass; +import org.junit.Test; +import static cuchaz.enigma.TestEntryFactory.newClass; +import static cuchaz.enigma.TestEntryFactory.newField; +import static cuchaz.enigma.TestEntryFactory.newMethod; public class TestTranslator { private static Deobfuscator deobfuscator; - private static Mappings mappings; - private static Translator deobfTranslator; - private static Translator obfTranslator; + private static Mappings mappings; + private static Translator deobfTranslator; + private static Translator obfTranslator; @BeforeClass public static void beforeClass() - throws Exception { + throws Exception { //TODO FIx //deobfuscator = new Deobfuscator(new JarFile("build/test-obf/translation.jar")); //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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ -package cuchaz.enigma; - -import static cuchaz.enigma.TestEntryFactory.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; -import org.junit.Test; +package cuchaz.enigma; import cuchaz.enigma.mapping.Type; +import org.junit.Test; +import static cuchaz.enigma.TestEntryFactory.newClass; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; public class TestType { - + @Test public void isVoid() { assertThat(new Type("V").isVoid(), is(true)); @@ -34,7 +34,7 @@ public class TestType { assertThat(new Type("LFoo;").isVoid(), is(false)); assertThat(new Type("[I").isVoid(), is(false)); } - + @Test public void isPrimitive() { assertThat(new Type("V").isPrimitive(), is(false)); @@ -48,7 +48,7 @@ public class TestType { assertThat(new Type("LFoo;").isPrimitive(), is(false)); assertThat(new Type("[I").isPrimitive(), is(false)); } - + @Test public void getPrimitive() { assertThat(new Type("Z").getPrimitive(), is(Type.Primitive.Boolean)); @@ -59,7 +59,7 @@ public class TestType { assertThat(new Type("F").getPrimitive(), is(Type.Primitive.Float)); assertThat(new Type("D").getPrimitive(), is(Type.Primitive.Double)); } - + @Test public void isClass() { assertThat(new Type("V").isClass(), is(false)); @@ -73,19 +73,19 @@ public class TestType { assertThat(new Type("LFoo;").isClass(), is(true)); assertThat(new Type("[I").isClass(), is(false)); } - + @Test public void getClassEntry() { assertThat(new Type("LFoo;").getClassEntry(), is(newClass("Foo"))); assertThat(new Type("Ljava/lang/String;").getClassEntry(), is(newClass("java/lang/String"))); } - + @Test public void getArrayClassEntry() { assertThat(new Type("[LFoo;").getClassEntry(), is(newClass("Foo"))); assertThat(new Type("[[[Ljava/lang/String;").getClassEntry(), is(newClass("java/lang/String"))); } - + @Test public void isArray() { assertThat(new Type("V").isArray(), is(false)); @@ -99,14 +99,14 @@ public class TestType { assertThat(new Type("LFoo;").isArray(), is(false)); assertThat(new Type("[I").isArray(), is(true)); } - + @Test public void getArrayDimension() { assertThat(new Type("[I").getArrayDimension(), is(1)); assertThat(new Type("[[I").getArrayDimension(), is(2)); assertThat(new Type("[[[I").getArrayDimension(), is(3)); } - + @Test public void getArrayType() { assertThat(new Type("[I").getArrayType(), is(new Type("I"))); @@ -114,7 +114,7 @@ public class TestType { assertThat(new Type("[[[I").getArrayType(), is(new Type("I"))); assertThat(new Type("[Ljava/lang/String;").getArrayType(), is(new Type("Ljava/lang/String;"))); } - + @Test public void hasClass() { assertThat(new Type("LFoo;").hasClass(), is(true)); @@ -127,7 +127,7 @@ public class TestType { assertThat(new Type("[[[I").hasClass(), is(false)); assertThat(new Type("Z").hasClass(), is(false)); } - + @Test public void parseVoid() { final String answer = "V"; @@ -138,7 +138,7 @@ public class TestType { assertThat(Type.parseFirst("VLFoo;"), is(answer)); assertThat(Type.parseFirst("V[LFoo;"), is(answer)); } - + @Test public void parsePrimitive() { final String answer = "I"; @@ -149,7 +149,7 @@ public class TestType { assertThat(Type.parseFirst("ILFoo;"), is(answer)); assertThat(Type.parseFirst("I[LFoo;"), is(answer)); } - + @Test public void parseClass() { { @@ -199,7 +199,7 @@ public class TestType { assertThat(Type.parseFirst("[LFoo;LFoo;"), is(answer)); } } - + @Test public void equals() { assertThat(new Type("V"), is(new Type("V"))); @@ -214,7 +214,7 @@ public class TestType { assertThat(new Type("[I"), is(new Type("[I"))); assertThat(new Type("[[[I"), is(new Type("[[[I"))); assertThat(new Type("[LFoo;"), is(new Type("[LFoo;"))); - + assertThat(new Type("V"), is(not(new Type("I")))); assertThat(new Type("I"), is(not(new Type("J")))); assertThat(new Type("I"), is(not(new Type("LBar;")))); @@ -224,7 +224,7 @@ public class TestType { assertThat(new Type("[[[I"), is(not(new Type("[I")))); assertThat(new Type("[LFoo;"), is(not(new Type("[LBar;")))); } - + @Test public void testToString() { 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ -package cuchaz.enigma; -import java.io.IOException; -import java.util.Collection; -import java.util.List; -import java.util.jar.JarFile; +package cuchaz.enigma; import com.google.common.collect.Lists; import com.strobel.decompiler.languages.java.ast.CompilationUnit; - import cuchaz.enigma.analysis.EntryReference; import cuchaz.enigma.analysis.SourceIndex; import cuchaz.enigma.analysis.Token; import cuchaz.enigma.mapping.Entry; +import java.io.IOException; +import java.util.Collection; +import java.util.List; +import java.util.jar.JarFile; + public class TokenChecker { - + private Deobfuscator deobfuscator; - + protected TokenChecker(JarFile jarFile) - throws IOException { + throws IOException { deobfuscator = new Deobfuscator(jarFile); } - + protected String getDeclarationToken(Entry entry) { // decompile the class CompilationUnit tree = deobfuscator.getSourceTree(entry.getClassName()); @@ -39,7 +39,7 @@ public class TokenChecker { // tree.acceptVisitor( new TreeDumpVisitor( new File( "tree." + entry.getClassName().replace( '/', '.' ) + ".txt" ) ), null ); String source = deobfuscator.getSource(tree); SourceIndex index = deobfuscator.getSourceIndex(tree, source); - + // get the token value Token token = index.getDeclarationToken(entry); if (token == null) { @@ -47,17 +47,17 @@ public class TokenChecker { } return source.substring(token.start, token.end); } - + @SuppressWarnings("unchecked") - protected Collection getReferenceTokens(EntryReference reference) { + protected Collection getReferenceTokens(EntryReference reference) { // decompile the class CompilationUnit tree = deobfuscator.getSourceTree(reference.context.getClassName()); String source = deobfuscator.getSource(tree); SourceIndex index = deobfuscator.getSourceIndex(tree, source); - + // get the token values List values = Lists.newArrayList(); - for (Token token : index.getReferenceTokens((EntryReference)reference)) { + for (Token token : index.getReferenceTokens((EntryReference) reference)) { values.add(source.substring(token.start, token.end)); } 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma.inputs; public 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma.inputs.constructors; // a public class BaseClass { - + // ()V public BaseClass() { System.out.println("Default constructor"); } - + // (I)V public BaseClass(int i) { 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma.inputs.constructors; // b public class Caller { - + // a()V public void callBaseDefault() { // a.()V System.out.println(new BaseClass()); } - + // b()V public void callBaseInt() { // a.(I)V System.out.println(new BaseClass(5)); } - + // c()V public void callSubDefault() { // d.()V System.out.println(new SubClass()); } - + // d()V public void callSubInt() { // d.(I)V System.out.println(new SubClass(6)); } - + // e()V public void callSubIntInt() { // d.(II)V System.out.println(new SubClass(4, 2)); } - + // f()V public void callSubSubInt() { // e.(I)V System.out.println(new SubSubClass(3)); } - + // g()V public void callDefaultConstructable() { // c.()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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma.inputs.constructors; public 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma.inputs.constructors; // d extends a public class SubClass extends BaseClass { - + // ()V public SubClass() { // a.()V } - + // (I)V public SubClass(int num) { // ()V this(); System.out.println("SubClass " + num); } - + // (II)V public SubClass(int a, int b) { // (I)V this(a + b); } - + // (III)V public SubClass(int a, int b, int c) { // a.()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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma.inputs.constructors; // e extends d public class SubSubClass extends SubClass { - + // (I)V public SubSubClass(int i) { // c.(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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma.inputs.inheritanceTree; // a public abstract class BaseClass { - + // a private String name; - + // (Ljava/lang/String;)V protected BaseClass(String name) { this.name = name; } - + // a()Ljava/lang/String; public String getName() { return name; } - + // a()V public abstract void doBaseThings(); } 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma.inputs.inheritanceTree; // b extends a public abstract class SubclassA extends BaseClass { - + // (Ljava/lang/String;)V protected SubclassA(String name) { // call to a.(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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma.inputs.inheritanceTree; // c extends a public class SubclassB extends BaseClass { - + // a private int numThings; - + // ()V protected SubclassB() { // a.(Ljava/lang/String;)V super("B"); - + // access to a numThings = 4; } - + @Override // a()V public void doBaseThings() { // call to a.a()Ljava/lang/String; System.out.println("Base things by B! " + getName()); } - + // b()V public void doBThings() { // 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma.inputs.inheritanceTree; // d extends b public class SubsubclassAA extends SubclassA { - + protected SubsubclassAA() { // call to b.(Ljava/lang/String;)V super("AA"); } - + @Override // a()Ljava/lang/String; public String getName() { // call to b.a()Ljava/lang/String; return "subsub" + super.getName(); } - + @Override // a()V 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma.inputs.innerClasses; public class A_Anonymous { - + public void foo() { Runnable runnable = new Runnable() { @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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma.inputs.innerClasses; public class B_AnonymousWithScopeArgs { - + public static void foo(final D_Simple arg) { System.out.println(new Object() { @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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma.inputs.innerClasses; @SuppressWarnings("unused") public class C_ConstructorArgs { - + + Inner i; + + public void foo() { + i = new Inner(5); + } + class Inner { - + private int a; - + public Inner(int a) { this.a = a; } } - - Inner i; - - public void foo() { - i = new Inner(5); - } } 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma.inputs.innerClasses; public class D_Simple { - + class Inner { // nothing to do } 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma.inputs.innerClasses; public class E_AnonymousWithOuterAccess { - + // reproduction of error case documented at: // https://bitbucket.org/cuchaz/enigma/issue/61/stackoverflowerror-when-deobfuscating - + public Object makeInner() { outerMethod(); return new Object() { @@ -24,7 +25,7 @@ public class E_AnonymousWithOuterAccess { } }; } - + private String outerMethod() { return "foo"; } 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ -package cuchaz.enigma.inputs.innerClasses; +package cuchaz.enigma.inputs.innerClasses; public class F_ClassTree { - + public class Level1 { - + public int f1; - + public class Level2 { - + public int f2; - + public class Level3 { - + public int f3; } } 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma.inputs.loneClass; public class LoneClass { - + private String name; - + public LoneClass(String name) { this.name = name; } - + public String getName() { return name; } 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma.inputs.translation; public class A_Basic { - + public int one; public float two; public String three; - + public void m1() { } - + public int m2() { return 42; } - + public void m3(int a1) { } - + public int m4(int a1) { return 5; // chosen by fair die roll, guaranteed to be random } 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma.inputs.translation; public class B_BaseClass { - + public int f1; public char f2; - + public int m1() { return 5; } - + public int m2() { return 42; } 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma.inputs.translation; public class C_SubClass extends B_BaseClass { - + public char f2; // shadows B_BaseClass.f2 public int f3; public int f4; - + @Override public int m1() { return 32; } - + public int m3() { return 7; } 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma.inputs.translation; import java.util.ArrayList; import java.util.List; public class D_AnonymousTesting { - + public List getObjs() { List objs = new ArrayList(); 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma.inputs.translation; import java.util.Iterator; - public class E_Bridges implements Iterator { @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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma.inputs.translation; @SuppressWarnings("FinalizeCalledExplicitly") public class F_ObjectMethods { - + public void callEmAll() - throws Throwable { + throws Throwable { clone(); equals(this); 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ -package cuchaz.enigma.inputs.translation; +package cuchaz.enigma.inputs.translation; public class G_OuterClass { - + public class A_InnerClass { - + public int f1; public String f2; - + public void m1() {} - + public class A_InnerInnerClass { - + public int f3; - + public void m2() {} } } - + public class B_NamelessClass { public class A_NamedInnerClass { 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ -package cuchaz.enigma.inputs.translation; +package cuchaz.enigma.inputs.translation; public class H_NamelessClass { - + public class A_InnerClass { - + public int f1; public String f2; - + public void m1() {} - + public class A_InnerInnerClass { - + public int f3; - + public void m2() {} } } - + public class B_NamelessClass { public class A_NamedInnerClass { public int f4; + public class A_AnotherInnerClass {} + public class B_YetAnotherInnerClass {} } } 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 @@ * are made available under the terms of the GNU Lesser General Public * License v3.0 which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html - * + * * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma.inputs.translation; import java.util.List; import java.util.Map; - public class I_Generics { - - public class A_Type { - } - + public List f1; public List f2; - public Map f3; - + public Map f3; + public B_Generic f5; + public B_Generic f6; + + public class A_Type { + } + public class B_Generic { public T f4; + public T m1() { return null; } } - - public B_Generic f5; - public B_Generic f6; } -- cgit v1.2.3