From 9c736848fb7aa82d295b3aa2946e6cd132ee998f Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Wed, 14 Sep 2022 13:12:55 +0100 Subject: Add checkstyle (#460) --- enigma/src/test/java/cuchaz/enigma/ConfigTest.java | 32 ++---- .../cuchaz/enigma/PackageVisibilityIndexTest.java | 43 ++++---- .../src/test/java/cuchaz/enigma/TestDeobfed.java | 54 +++------- .../test/java/cuchaz/enigma/TestDeobfuscator.java | 30 +++--- .../test/java/cuchaz/enigma/TestEntryFactory.java | 22 ++-- .../test/java/cuchaz/enigma/TestInnerClasses.java | 49 ++++----- .../enigma/TestJarIndexConstructorReferences.java | 79 ++++++-------- .../cuchaz/enigma/TestJarIndexInheritanceTree.java | 114 +++++++------------- .../java/cuchaz/enigma/TestJarIndexLoneClass.java | 69 ++++++------ .../java/cuchaz/enigma/TestMethodDescriptor.java | 116 ++++++++------------- .../java/cuchaz/enigma/TestTokensConstructors.java | 98 ++++++----------- .../test/java/cuchaz/enigma/TestTranslator.java | 31 +++--- .../java/cuchaz/enigma/TestTypeDescriptor.java | 29 +++--- .../src/test/java/cuchaz/enigma/TokenChecker.java | 40 ++++--- .../src/test/java/cuchaz/enigma/inputs/Keep.java | 18 ++-- .../enigma/inputs/constructors/BaseClass.java | 19 ++-- .../cuchaz/enigma/inputs/constructors/Caller.java | 19 ++-- .../inputs/constructors/DefaultConstructable.java | 18 ++-- .../enigma/inputs/constructors/SubClass.java | 19 ++-- .../enigma/inputs/constructors/SubSubClass.java | 19 ++-- .../enigma/inputs/inheritanceTree/BaseClass.java | 19 ++-- .../enigma/inputs/inheritanceTree/SubclassA.java | 19 ++-- .../enigma/inputs/inheritanceTree/SubclassB.java | 19 ++-- .../inputs/inheritanceTree/SubsubclassAA.java | 19 ++-- .../enigma/inputs/innerClasses/A_Anonymous.java | 19 ++-- .../innerClasses/B_AnonymousWithScopeArgs.java | 19 ++-- .../inputs/innerClasses/C_ConstructorArgs.java | 22 ++-- .../enigma/inputs/innerClasses/D_Simple.java | 19 ++-- .../innerClasses/E_AnonymousWithOuterAccess.java | 19 ++-- .../enigma/inputs/innerClasses/F_ClassTree.java | 22 ++-- .../cuchaz/enigma/inputs/loneClass/LoneClass.java | 19 ++-- .../inputs/packageAccess/SamePackageChild.java | 1 - .../packageAccess/sub/OtherPackageChild.java | 1 - .../cuchaz/enigma/inputs/translation/A_Basic.java | 19 ++-- .../enigma/inputs/translation/B_BaseClass.java | 19 ++-- .../enigma/inputs/translation/C_SubClass.java | 19 ++-- .../inputs/translation/D_AnonymousTesting.java | 19 ++-- .../enigma/inputs/translation/E_Bridges.java | 19 ++-- .../enigma/inputs/translation/F_ObjectMethods.java | 22 ++-- .../enigma/inputs/translation/G_OuterClass.java | 27 +++-- .../enigma/inputs/translation/H_NamelessClass.java | 33 +++--- .../enigma/inputs/translation/I_Generics.java | 19 ++-- .../enigma/translation/mapping/TestComments.java | 38 ++++--- .../translation/mapping/TestReadWriteCycle.java | 43 +++----- .../mapping/TestTinyV2InnerClasses.java | 27 +++-- .../enigma/translation/mapping/TestV2Main.java | 6 +- .../translation/mapping/serde/recaf/TestRecaf.java | 52 ++++----- 47 files changed, 653 insertions(+), 844 deletions(-) (limited to 'enigma/src/test') diff --git a/enigma/src/test/java/cuchaz/enigma/ConfigTest.java b/enigma/src/test/java/cuchaz/enigma/ConfigTest.java index a44f037..95689f8 100644 --- a/enigma/src/test/java/cuchaz/enigma/ConfigTest.java +++ b/enigma/src/test/java/cuchaz/enigma/ConfigTest.java @@ -1,13 +1,12 @@ package cuchaz.enigma; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import cuchaz.enigma.config.ConfigContainer; -import static org.junit.Assert.assertEquals; - public class ConfigTest { - @Test public void serialize() { ConfigContainer cc = new ConfigContainer(); @@ -17,15 +16,7 @@ public class ConfigTest { cc.data().section("a").section("b").section("c").setInt("c", 5); cc.data().section("a").section("b").section("c").setDouble("d", 3.5); cc.data().section("a").section("b").section("c").setRgbColor("e", 0x123456); - assertEquals("a=a\n" + - "\n" + - "[a][b][c]\n" + - "a=abcd\n" + - "b=true\n" + - "c=5\n" + - "d=3.5\n" + - "e=#123456\n", - cc.serialize()); + assertEquals("a=a\n" + "\n" + "[a][b][c]\n" + "a=abcd\n" + "b=true\n" + "c=5\n" + "d=3.5\n" + "e=#123456\n", cc.serialize()); } @Test @@ -37,14 +28,7 @@ public class ConfigTest { cc.data().section("a").section("b").section("c").setInt("c", 5); cc.data().section("a").section("b").section("c").setDouble("d", 3.5); cc.data().section("a").section("b").section("c").setRgbColor("e", 0x123456); - assertEquals(ConfigContainer.parse("a=a\n" + - "\n" + - "[a][b][c]\n" + - "a=abcd\n" + - "b=true\n" + - "c=5\n" + - "d=3.5\n" + - "e=#123456\n").data(), cc.data()); + assertEquals(ConfigContainer.parse("a=a\n" + "\n" + "[a][b][c]\n" + "a=abcd\n" + "b=true\n" + "c=5\n" + "d=3.5\n" + "e=#123456\n").data(), cc.data()); } @Test @@ -52,12 +36,10 @@ public class ConfigTest { ConfigContainer cc = new ConfigContainer(); String thing = "\\[],\\,./'\"`~!@#$%^&*()_+-=|}{\n\\\\\r\b\u0000\uffff\u1234"; cc.data().section(thing).setString(thing, thing); - cc.data().section(thing).setArray("arr", new String[] { thing, thing, thing, thing }); + cc.data().section(thing).setArray("arr", new String[]{thing, thing, thing, thing}); assertEquals( - "[\\\\[\\],\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234]\n" + - "\\\\\\[],\\\\,./'\"`~!@#$%^&*()_+-\\=|}{\\n\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234=\\\\[],\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234\n" + - "arr=\\\\\\\\[]\\\\,\\\\\\\\\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234,\\\\\\\\[]\\\\,\\\\\\\\\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234,\\\\\\\\[]\\\\,\\\\\\\\\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234,\\\\\\\\[]\\\\,\\\\\\\\\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234\n", + "[\\\\[\\],\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234]\n" + "\\\\\\[],\\\\,./'\"`~!@#$%^&*()_+-\\=|}{\\n\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234=\\\\[],\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234\n" + "arr=\\\\\\\\[]\\\\,\\\\\\\\\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234,\\\\\\\\[]\\\\,\\\\\\\\\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234,\\\\\\\\[]\\\\,\\\\\\\\\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234,\\\\\\\\[]\\\\,\\\\\\\\\\\\,./'\"`~!@#$%^&*()_+-=|}{\\n\\\\\\\\\\\\\\\\\\u000d\\u0008\\u0000\\uffff\\u1234\n", cc.serialize()); ConfigContainer cc1 = ConfigContainer.parse(cc.serialize()); @@ -77,10 +59,8 @@ public class ConfigTest { assertEquals("", ConfigContainer.parse("[").serialize()); assertEquals("[a]\na=b\nc=d\n", ConfigContainer.parse("[a]\na=b\n[\nc=d").serialize()); - // not technically syntax errors but never something that gets generated assertEquals("", ConfigContainer.parse("[a]").serialize()); assertEquals("", ConfigContainer.parse("[a]\n[b]").serialize()); } - } diff --git a/enigma/src/test/java/cuchaz/enigma/PackageVisibilityIndexTest.java b/enigma/src/test/java/cuchaz/enigma/PackageVisibilityIndexTest.java index 1251535..1678f59 100644 --- a/enigma/src/test/java/cuchaz/enigma/PackageVisibilityIndexTest.java +++ b/enigma/src/test/java/cuchaz/enigma/PackageVisibilityIndexTest.java @@ -1,30 +1,31 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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.index.JarIndex; -import cuchaz.enigma.analysis.index.PackageVisibilityIndex; -import cuchaz.enigma.classprovider.JarClassProvider; -import cuchaz.enigma.translation.representation.entry.ClassEntry; -import org.junit.Test; - -import java.nio.file.Path; -import java.nio.file.Paths; - import static cuchaz.enigma.TestEntryFactory.newClass; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsInAnyOrder; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.Test; + +import cuchaz.enigma.analysis.index.JarIndex; +import cuchaz.enigma.analysis.index.PackageVisibilityIndex; +import cuchaz.enigma.classprovider.JarClassProvider; +import cuchaz.enigma.translation.representation.entry.ClassEntry; + public class PackageVisibilityIndexTest { public static final Path JAR = Paths.get("build/test-obf/packageAccess.jar"); private static final ClassEntry KEEP = newClass("cuchaz/enigma/inputs/Keep"); @@ -46,10 +47,6 @@ public class PackageVisibilityIndexTest { PackageVisibilityIndex visibilityIndex = jarIndex.getPackageVisibilityIndex(); assertThat(visibilityIndex.getPartition(BASE), containsInAnyOrder(BASE, SAME_PACKAGE_CHILD, SAME_PACKAGE_CHILD_INNER)); System.out.println(visibilityIndex.getPartitions()); - assertThat(visibilityIndex.getPartitions(), containsInAnyOrder( - containsInAnyOrder(BASE, SAME_PACKAGE_CHILD, SAME_PACKAGE_CHILD_INNER), - containsInAnyOrder(OTHER_PACKAGE_CHILD, OTHER_PACKAGE_CHILD_INNER), - contains(KEEP) - )); + assertThat(visibilityIndex.getPartitions(), containsInAnyOrder(containsInAnyOrder(BASE, SAME_PACKAGE_CHILD, SAME_PACKAGE_CHILD_INNER), containsInAnyOrder(OTHER_PACKAGE_CHILD, OTHER_PACKAGE_CHILD_INNER), contains(KEEP))); } } diff --git a/enigma/src/test/java/cuchaz/enigma/TestDeobfed.java b/enigma/src/test/java/cuchaz/enigma/TestDeobfed.java index 2584d58..b19aa77 100644 --- a/enigma/src/test/java/cuchaz/enigma/TestDeobfed.java +++ b/enigma/src/test/java/cuchaz/enigma/TestDeobfed.java @@ -1,16 +1,20 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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.newClass; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsInAnyOrder; + import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -23,10 +27,6 @@ import cuchaz.enigma.source.Decompiler; import cuchaz.enigma.source.Decompilers; import cuchaz.enigma.source.SourceSettings; -import static cuchaz.enigma.TestEntryFactory.newClass; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.containsInAnyOrder; - public class TestDeobfed { public static final Path OBF = Paths.get("build/test-obf/translation.jar"); public static final Path DEOBF = Paths.get("build/test-deobf/translation.jar"); @@ -45,31 +45,9 @@ public class TestDeobfed { @Test public void obfEntries() { - assertThat(deobfProject.getJarIndex().getEntryIndex().getClasses(), containsInAnyOrder( - newClass("cuchaz/enigma/inputs/Keep"), - newClass("a"), - newClass("b"), - newClass("c"), - newClass("d"), - newClass("d$1"), - newClass("e"), - newClass("f"), - newClass("g"), - newClass("g$a"), - newClass("g$a$a"), - newClass("g$b"), - newClass("g$b$a"), - newClass("h"), - newClass("h$a"), - newClass("h$a$a"), - newClass("h$b"), - newClass("h$b$a"), - newClass("h$b$a$a"), - newClass("h$b$a$b"), - newClass("i"), - newClass("i$a"), - newClass("i$b") - )); + assertThat(deobfProject.getJarIndex().getEntryIndex().getClasses(), + containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), newClass("a"), newClass("b"), newClass("c"), newClass("d"), newClass("d$1"), newClass("e"), newClass("f"), newClass("g"), newClass("g$a"), newClass("g$a$a"), newClass("g$b"), newClass("g$b$a"), newClass("h"), + newClass("h$a"), newClass("h$a$a"), newClass("h$b"), newClass("h$b$a"), newClass("h$b$a$a"), newClass("h$b$a$b"), newClass("i"), newClass("i$a"), newClass("i$b"))); } @Test diff --git a/enigma/src/test/java/cuchaz/enigma/TestDeobfuscator.java b/enigma/src/test/java/cuchaz/enigma/TestDeobfuscator.java index 38940ca..587494e 100644 --- a/enigma/src/test/java/cuchaz/enigma/TestDeobfuscator.java +++ b/enigma/src/test/java/cuchaz/enigma/TestDeobfuscator.java @@ -1,24 +1,25 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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.nio.file.Paths; + +import org.junit.Test; + import cuchaz.enigma.classprovider.ClasspathClassProvider; import cuchaz.enigma.source.Decompiler; import cuchaz.enigma.source.Decompilers; import cuchaz.enigma.source.SourceSettings; -import org.junit.Test; - -import java.io.IOException; -import java.nio.file.Paths; public class TestDeobfuscator { private EnigmaProject openProject() throws IOException { @@ -27,8 +28,7 @@ public class TestDeobfuscator { } @Test - public void loadJar() - throws Exception { + public void loadJar() throws Exception { openProject(); } diff --git a/enigma/src/test/java/cuchaz/enigma/TestEntryFactory.java b/enigma/src/test/java/cuchaz/enigma/TestEntryFactory.java index 9e1425a..833e217 100644 --- a/enigma/src/test/java/cuchaz/enigma/TestEntryFactory.java +++ b/enigma/src/test/java/cuchaz/enigma/TestEntryFactory.java @@ -1,24 +1,24 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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.translation.representation.*; +import cuchaz.enigma.translation.representation.MethodDescriptor; +import cuchaz.enigma.translation.representation.TypeDescriptor; import cuchaz.enigma.translation.representation.entry.ClassEntry; import cuchaz.enigma.translation.representation.entry.FieldEntry; import cuchaz.enigma.translation.representation.entry.MethodEntry; public class TestEntryFactory { - public static ClassEntry newClass(String name) { return new ClassEntry(name); } diff --git a/enigma/src/test/java/cuchaz/enigma/TestInnerClasses.java b/enigma/src/test/java/cuchaz/enigma/TestInnerClasses.java index 6b60994..46086e5 100644 --- a/enigma/src/test/java/cuchaz/enigma/TestInnerClasses.java +++ b/enigma/src/test/java/cuchaz/enigma/TestInnerClasses.java @@ -1,16 +1,25 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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.newClass; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.Test; + import cuchaz.enigma.analysis.index.JarIndex; import cuchaz.enigma.classprovider.CachingClassProvider; import cuchaz.enigma.classprovider.JarClassProvider; @@ -18,17 +27,8 @@ import cuchaz.enigma.source.Decompiler; import cuchaz.enigma.source.Decompilers; import cuchaz.enigma.source.SourceSettings; import cuchaz.enigma.translation.representation.entry.ClassEntry; -import org.junit.Test; - -import java.nio.file.Path; -import java.nio.file.Paths; - -import static cuchaz.enigma.TestEntryFactory.newClass; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; public class TestInnerClasses { - private static final ClassEntry SimpleOuter = newClass("d"); private static final ClassEntry SimpleInner = newClass("d$a"); private static final ClassEntry ConstructorArgsOuter = newClass("c"); @@ -61,26 +61,19 @@ public class TestInnerClasses { @Test public void classTree() { - // root level assertThat(index.getEntryIndex().hasClass(ClassTreeRoot), is(true)); // level 1 - ClassEntry fullClassEntry = new ClassEntry(ClassTreeRoot.getName() - + "$" + ClassTreeLevel1.getSimpleName()); + ClassEntry fullClassEntry = new ClassEntry(ClassTreeRoot.getName() + "$" + ClassTreeLevel1.getSimpleName()); assertThat(index.getEntryIndex().hasClass(fullClassEntry), is(true)); // level 2 - fullClassEntry = new ClassEntry(ClassTreeRoot.getName() - + "$" + ClassTreeLevel1.getSimpleName() - + "$" + ClassTreeLevel2.getSimpleName()); + fullClassEntry = new ClassEntry(ClassTreeRoot.getName() + "$" + ClassTreeLevel1.getSimpleName() + "$" + ClassTreeLevel2.getSimpleName()); assertThat(index.getEntryIndex().hasClass(fullClassEntry), is(true)); // level 3 - fullClassEntry = new ClassEntry(ClassTreeRoot.getName() - + "$" + ClassTreeLevel1.getSimpleName() - + "$" + ClassTreeLevel2.getSimpleName() - + "$" + ClassTreeLevel3.getSimpleName()); + fullClassEntry = new ClassEntry(ClassTreeRoot.getName() + "$" + ClassTreeLevel1.getSimpleName() + "$" + ClassTreeLevel2.getSimpleName() + "$" + ClassTreeLevel3.getSimpleName()); assertThat(index.getEntryIndex().hasClass(fullClassEntry), is(true)); } diff --git a/enigma/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java b/enigma/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java index 0790193..05565b6 100644 --- a/enigma/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java +++ b/enigma/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java @@ -1,16 +1,30 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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.newBehaviorReferenceByMethod; +import static cuchaz.enigma.TestEntryFactory.newClass; +import static cuchaz.enigma.TestEntryFactory.newMethod; +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 java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Collection; + +import org.junit.Test; + import cuchaz.enigma.analysis.EntryReference; import cuchaz.enigma.analysis.index.JarIndex; import cuchaz.enigma.classprovider.CachingClassProvider; @@ -18,18 +32,8 @@ import cuchaz.enigma.classprovider.JarClassProvider; import cuchaz.enigma.translation.representation.entry.ClassEntry; import cuchaz.enigma.translation.representation.entry.MethodDefEntry; import cuchaz.enigma.translation.representation.entry.MethodEntry; -import org.junit.Test; - -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Collection; - -import static cuchaz.enigma.TestEntryFactory.*; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; public class TestJarIndexConstructorReferences { - public static final Path JAR = Paths.get("build/test-obf/constructors.jar"); private JarIndex index; @@ -47,8 +51,7 @@ public class TestJarIndexConstructorReferences { @Test public void obfEntries() { - assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), baseClass, - subClass, subsubClass, defaultClass, callerClass)); + assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), baseClass, subClass, subsubClass, defaultClass, callerClass)); } @Test @@ -56,50 +59,36 @@ public class TestJarIndexConstructorReferences { public void baseDefault() { MethodEntry source = newMethod(baseClass, "", "()V"); Collection> references = index.getReferenceIndex().getReferencesToMethod(source); - assertThat(references, containsInAnyOrder( - newBehaviorReferenceByMethod(source, callerClass.getName(), "a", "()V"), - newBehaviorReferenceByMethod(source, subClass.getName(), "", "()V"), - newBehaviorReferenceByMethod(source, subClass.getName(), "", "(III)V") - )); + assertThat(references, containsInAnyOrder(newBehaviorReferenceByMethod(source, callerClass.getName(), "a", "()V"), newBehaviorReferenceByMethod(source, subClass.getName(), "", "()V"), newBehaviorReferenceByMethod(source, subClass.getName(), "", "(III)V"))); } @Test @SuppressWarnings("unchecked") public void baseInt() { MethodEntry source = newMethod(baseClass, "", "(I)V"); - assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( - newBehaviorReferenceByMethod(source, callerClass.getName(), "b", "()V") - )); + assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder(newBehaviorReferenceByMethod(source, callerClass.getName(), "b", "()V"))); } @Test @SuppressWarnings("unchecked") public void subDefault() { MethodEntry source = newMethod(subClass, "", "()V"); - assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( - newBehaviorReferenceByMethod(source, callerClass.getName(), "c", "()V"), - newBehaviorReferenceByMethod(source, subClass.getName(), "", "(I)V") - )); + assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder(newBehaviorReferenceByMethod(source, callerClass.getName(), "c", "()V"), newBehaviorReferenceByMethod(source, subClass.getName(), "", "(I)V"))); } @Test @SuppressWarnings("unchecked") public void subInt() { MethodEntry source = newMethod(subClass, "", "(I)V"); - assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( - newBehaviorReferenceByMethod(source, callerClass.getName(), "d", "()V"), - newBehaviorReferenceByMethod(source, subClass.getName(), "", "(II)V"), - newBehaviorReferenceByMethod(source, subsubClass.getName(), "", "(I)V") - )); + assertThat(index.getReferenceIndex().getReferencesToMethod(source), + containsInAnyOrder(newBehaviorReferenceByMethod(source, callerClass.getName(), "d", "()V"), newBehaviorReferenceByMethod(source, subClass.getName(), "", "(II)V"), newBehaviorReferenceByMethod(source, subsubClass.getName(), "", "(I)V"))); } @Test @SuppressWarnings("unchecked") public void subIntInt() { MethodEntry source = newMethod(subClass, "", "(II)V"); - assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( - newBehaviorReferenceByMethod(source, callerClass.getName(), "e", "()V") - )); + assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder(newBehaviorReferenceByMethod(source, callerClass.getName(), "e", "()V"))); } @Test @@ -112,17 +101,13 @@ public class TestJarIndexConstructorReferences { @SuppressWarnings("unchecked") public void subsubInt() { MethodEntry source = newMethod(subsubClass, "", "(I)V"); - assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( - newBehaviorReferenceByMethod(source, callerClass.getName(), "f", "()V") - )); + assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder(newBehaviorReferenceByMethod(source, callerClass.getName(), "f", "()V"))); } @Test @SuppressWarnings("unchecked") public void defaultConstructable() { MethodEntry source = newMethod(defaultClass, "", "()V"); - assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder( - newBehaviorReferenceByMethod(source, callerClass.getName(), "g", "()V") - )); + assertThat(index.getReferenceIndex().getReferencesToMethod(source), containsInAnyOrder(newBehaviorReferenceByMethod(source, callerClass.getName(), "g", "()V"))); } } diff --git a/enigma/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java b/enigma/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java index a9045f9..3f6f151 100644 --- a/enigma/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java +++ b/enigma/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java @@ -1,16 +1,34 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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.newClass; +import static cuchaz.enigma.TestEntryFactory.newField; +import static cuchaz.enigma.TestEntryFactory.newMethod; +import static cuchaz.enigma.TestEntryFactory.newFieldReferenceByMethod; +import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByMethod; +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.nio.file.Path; +import java.nio.file.Paths; +import java.util.Collection; + +import org.junit.Test; +import org.objectweb.asm.Opcodes; + import cuchaz.enigma.analysis.EntryReference; import cuchaz.enigma.analysis.index.EntryIndex; import cuchaz.enigma.analysis.index.InheritanceIndex; @@ -24,19 +42,8 @@ import cuchaz.enigma.translation.representation.entry.ClassEntry; import cuchaz.enigma.translation.representation.entry.FieldEntry; import cuchaz.enigma.translation.representation.entry.MethodDefEntry; import cuchaz.enigma.translation.representation.entry.MethodEntry; -import org.junit.Test; -import org.objectweb.asm.Opcodes; - -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Collection; - -import static cuchaz.enigma.TestEntryFactory.*; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; public class TestJarIndexInheritanceTree { - public static final Path JAR = Paths.get("build/test-obf/inheritanceTree.jar"); private JarIndex index; @@ -55,21 +62,17 @@ public class TestJarIndexInheritanceTree { @Test public void obfEntries() { - assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder( - newClass("cuchaz/enigma/inputs/Keep"), baseClass, subClassA, subClassAA, subClassB - )); + assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), baseClass, subClassA, subClassAA, subClassB)); } @Test public void translationIndex() { - InheritanceIndex index = this.index.getInheritanceIndex(); // base class assertThat(index.getParents(baseClass), is(empty())); assertThat(index.getAncestors(baseClass), is(empty())); - assertThat(index.getChildren(baseClass), containsInAnyOrder(subClassA, subClassB - )); + assertThat(index.getChildren(baseClass), containsInAnyOrder(subClassA, subClassB)); // subclass a assertThat(index.getParents(subClassA), contains(baseClass)); @@ -95,41 +98,22 @@ public class TestJarIndexInheritanceTree { @Test public void relatedMethodImplementations() { - Collection entries; EntryResolver resolver = new IndexEntryResolver(index); // getName() entries = resolver.resolveEquivalentMethods(newMethod(baseClass, "a", "()Ljava/lang/String;")); - assertThat(entries, containsInAnyOrder( - newMethod(baseClass, "a", "()Ljava/lang/String;"), - newMethod(subClassAA, "a", "()Ljava/lang/String;") - )); + assertThat(entries, containsInAnyOrder(newMethod(baseClass, "a", "()Ljava/lang/String;"), newMethod(subClassAA, "a", "()Ljava/lang/String;"))); entries = resolver.resolveEquivalentMethods(newMethod(subClassAA, "a", "()Ljava/lang/String;")); - assertThat(entries, containsInAnyOrder( - newMethod(baseClass, "a", "()Ljava/lang/String;"), - newMethod(subClassAA, "a", "()Ljava/lang/String;") - )); + assertThat(entries, containsInAnyOrder(newMethod(baseClass, "a", "()Ljava/lang/String;"), newMethod(subClassAA, "a", "()Ljava/lang/String;"))); // doBaseThings() entries = resolver.resolveEquivalentMethods(newMethod(baseClass, "a", "()V")); - assertThat(entries, containsInAnyOrder( - newMethod(baseClass, "a", "()V"), - newMethod(subClassAA, "a", "()V"), - newMethod(subClassB, "a", "()V") - )); + assertThat(entries, containsInAnyOrder(newMethod(baseClass, "a", "()V"), newMethod(subClassAA, "a", "()V"), newMethod(subClassB, "a", "()V"))); entries = resolver.resolveEquivalentMethods(newMethod(subClassAA, "a", "()V")); - assertThat(entries, containsInAnyOrder( - newMethod(baseClass, "a", "()V"), - newMethod(subClassAA, "a", "()V"), - newMethod(subClassB, "a", "()V") - )); + assertThat(entries, containsInAnyOrder(newMethod(baseClass, "a", "()V"), newMethod(subClassAA, "a", "()V"), newMethod(subClassB, "a", "()V"))); entries = resolver.resolveEquivalentMethods(newMethod(subClassB, "a", "()V")); - assertThat(entries, containsInAnyOrder( - newMethod(baseClass, "a", "()V"), - newMethod(subClassAA, "a", "()V"), - newMethod(subClassB, "a", "()V") - )); + assertThat(entries, containsInAnyOrder(newMethod(baseClass, "a", "()V"), newMethod(subClassAA, "a", "()V"), newMethod(subClassB, "a", "()V"))); // doBThings entries = resolver.resolveEquivalentMethods(newMethod(subClassB, "b", "()V")); @@ -143,55 +127,38 @@ public class TestJarIndexInheritanceTree { // name references = index.getReferenceIndex().getReferencesToField(nameField); - assertThat(references, containsInAnyOrder( - newFieldReferenceByMethod(nameField, baseClass.getName(), "", "(Ljava/lang/String;)V"), - newFieldReferenceByMethod(nameField, baseClass.getName(), "a", "()Ljava/lang/String;") - )); + assertThat(references, containsInAnyOrder(newFieldReferenceByMethod(nameField, baseClass.getName(), "", "(Ljava/lang/String;)V"), newFieldReferenceByMethod(nameField, baseClass.getName(), "a", "()Ljava/lang/String;"))); // numThings references = index.getReferenceIndex().getReferencesToField(numThingsField); - assertThat(references, containsInAnyOrder( - newFieldReferenceByMethod(numThingsField, subClassB.getName(), "", "()V"), - newFieldReferenceByMethod(numThingsField, subClassB.getName(), "b", "()V") - )); + assertThat(references, containsInAnyOrder(newFieldReferenceByMethod(numThingsField, subClassB.getName(), "", "()V"), newFieldReferenceByMethod(numThingsField, subClassB.getName(), "b", "()V"))); } @Test @SuppressWarnings("unchecked") public void behaviorReferences() { - MethodEntry source; Collection> references; // baseClass constructor source = newMethod(baseClass, "", "(Ljava/lang/String;)V"); references = index.getReferenceIndex().getReferencesToMethod(source); - assertThat(references, containsInAnyOrder( - newBehaviorReferenceByMethod(source, subClassA.getName(), "", "(Ljava/lang/String;)V"), - newBehaviorReferenceByMethod(source, subClassB.getName(), "", "()V") - )); + assertThat(references, containsInAnyOrder(newBehaviorReferenceByMethod(source, subClassA.getName(), "", "(Ljava/lang/String;)V"), newBehaviorReferenceByMethod(source, subClassB.getName(), "", "()V"))); // subClassA constructor source = newMethod(subClassA, "", "(Ljava/lang/String;)V"); references = index.getReferenceIndex().getReferencesToMethod(source); - assertThat(references, containsInAnyOrder( - newBehaviorReferenceByMethod(source, subClassAA.getName(), "", "()V") - )); + assertThat(references, containsInAnyOrder(newBehaviorReferenceByMethod(source, subClassAA.getName(), "", "()V"))); // baseClass.getName() source = newMethod(baseClass, "a", "()Ljava/lang/String;"); references = index.getReferenceIndex().getReferencesToMethod(source); - assertThat(references, containsInAnyOrder( - newBehaviorReferenceByMethod(source, subClassAA.getName(), "a", "()Ljava/lang/String;"), - newBehaviorReferenceByMethod(source, subClassB.getName(), "a", "()V") - )); + assertThat(references, containsInAnyOrder(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.getReferenceIndex().getReferencesToMethod(source); - assertThat(references, containsInAnyOrder( - newBehaviorReferenceByMethod(source, subClassAA.getName(), "a", "()V") - )); + assertThat(references, containsInAnyOrder(newBehaviorReferenceByMethod(source, subClassAA.getName(), "a", "()V"))); } @Test @@ -225,6 +192,5 @@ public class TestJarIndexInheritanceTree { assertThat(entryIndex.hasMethod(newMethod(subClassA, "b", "()V")), is(false)); assertThat(entryIndex.hasMethod(newMethod(subClassAA, "b", "()V")), is(false)); assertThat(entryIndex.hasMethod(newMethod(subClassB, "b", "()V")), is(true)); - } } diff --git a/enigma/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java b/enigma/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java index 6e3755c..dcbe95f 100644 --- a/enigma/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java +++ b/enigma/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java @@ -1,17 +1,41 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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.*; +import static cuchaz.enigma.TestEntryFactory.newClass; +import static cuchaz.enigma.TestEntryFactory.newField; +import static cuchaz.enigma.TestEntryFactory.newFieldReferenceByMethod; +import static cuchaz.enigma.TestEntryFactory.newMethod; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.nullValue; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Collection; +import java.util.List; + +import org.junit.Test; + +import cuchaz.enigma.analysis.ClassImplementationsTreeNode; +import cuchaz.enigma.analysis.ClassInheritanceTreeNode; +import cuchaz.enigma.analysis.EntryReference; +import cuchaz.enigma.analysis.IndexTreeBuilder; +import cuchaz.enigma.analysis.MethodImplementationsTreeNode; +import cuchaz.enigma.analysis.MethodInheritanceTreeNode; import cuchaz.enigma.analysis.index.EntryIndex; import cuchaz.enigma.analysis.index.InheritanceIndex; import cuchaz.enigma.analysis.index.JarIndex; @@ -23,19 +47,8 @@ import cuchaz.enigma.translation.representation.entry.ClassEntry; import cuchaz.enigma.translation.representation.entry.FieldEntry; import cuchaz.enigma.translation.representation.entry.MethodDefEntry; import cuchaz.enigma.translation.representation.entry.MethodEntry; -import org.junit.Test; - -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Collection; -import java.util.List; - -import static cuchaz.enigma.TestEntryFactory.*; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; public class TestJarIndexLoneClass { - public static final Path JAR = Paths.get("build/test-obf/loneClass.jar"); private JarIndex index; @@ -47,10 +60,7 @@ public class TestJarIndexLoneClass { @Test public void obfEntries() { - assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder( - newClass("cuchaz/enigma/inputs/Keep"), - newClass("a") - )); + assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), newClass("a"))); } @Test @@ -112,9 +122,7 @@ public class TestJarIndexLoneClass { @Test public void relatedMethodImplementations() { Collection entries = index.getEntryResolver().resolveEquivalentMethods(newMethod("a", "a", "()Ljava/lang/String;")); - assertThat(entries, containsInAnyOrder( - newMethod("a", "a", "()Ljava/lang/String;") - )); + assertThat(entries, containsInAnyOrder(newMethod("a", "a", "()Ljava/lang/String;"))); } @Test @@ -122,10 +130,7 @@ public class TestJarIndexLoneClass { public void fieldReferences() { FieldEntry source = newField("a", "a", "Ljava/lang/String;"); Collection> references = index.getReferenceIndex().getReferencesToField(source); - assertThat(references, containsInAnyOrder( - newFieldReferenceByMethod(source, "a", "", "(Ljava/lang/String;)V"), - newFieldReferenceByMethod(source, "a", "a", "()Ljava/lang/String;") - )); + assertThat(references, containsInAnyOrder(newFieldReferenceByMethod(source, "a", "", "(Ljava/lang/String;)V"), newFieldReferenceByMethod(source, "a", "a", "()Ljava/lang/String;"))); } @Test diff --git a/enigma/src/test/java/cuchaz/enigma/TestMethodDescriptor.java b/enigma/src/test/java/cuchaz/enigma/TestMethodDescriptor.java index a73880d..918466b 100644 --- a/enigma/src/test/java/cuchaz/enigma/TestMethodDescriptor.java +++ b/enigma/src/test/java/cuchaz/enigma/TestMethodDescriptor.java @@ -1,25 +1,28 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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.translation.representation.MethodDescriptor; -import cuchaz.enigma.translation.representation.TypeDescriptor; +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; + import org.junit.Test; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; +import cuchaz.enigma.translation.representation.MethodDescriptor; +import cuchaz.enigma.translation.representation.TypeDescriptor; public class TestMethodDescriptor { - @Test public void easiest() { final MethodDescriptor sig = new MethodDescriptor("()V"); @@ -31,26 +34,19 @@ public class TestMethodDescriptor { public void primitives() { { final MethodDescriptor sig = new MethodDescriptor("(I)V"); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("I") - )); + assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("I"))); assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V"))); } + { final MethodDescriptor sig = new MethodDescriptor("(I)I"); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("I") - )); + assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("I"))); assertThat(sig.getReturnDesc(), is(new TypeDescriptor("I"))); } + { final MethodDescriptor sig = new MethodDescriptor("(IBCJ)Z"); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("I"), - new TypeDescriptor("B"), - new TypeDescriptor("C"), - new TypeDescriptor("J") - )); + assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("I"), new TypeDescriptor("B"), new TypeDescriptor("C"), new TypeDescriptor("J"))); assertThat(sig.getReturnDesc(), is(new TypeDescriptor("Z"))); } } @@ -63,20 +59,16 @@ public class TestMethodDescriptor { assertThat(sig.getArgumentDescs().get(0), is(new TypeDescriptor("[LFoo;"))); assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V"))); } + { final MethodDescriptor sig = new MethodDescriptor("(LFoo;)LBar;"); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("LFoo;") - )); + assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("LFoo;"))); assertThat(sig.getReturnDesc(), is(new TypeDescriptor("LBar;"))); } + { final MethodDescriptor sig = new MethodDescriptor("(LFoo;LMoo;LZoo;)LBar;"); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("LFoo;"), - new TypeDescriptor("LMoo;"), - new TypeDescriptor("LZoo;") - )); + assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("LFoo;"), new TypeDescriptor("LMoo;"), new TypeDescriptor("LZoo;"))); assertThat(sig.getReturnDesc(), is(new TypeDescriptor("LBar;"))); } } @@ -85,25 +77,19 @@ public class TestMethodDescriptor { public void arrays() { { final MethodDescriptor sig = new MethodDescriptor("([I)V"); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("[I") - )); + assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("[I"))); assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V"))); } + { final MethodDescriptor sig = new MethodDescriptor("([I)[J"); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("[I") - )); + assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("[I"))); assertThat(sig.getReturnDesc(), is(new TypeDescriptor("[J"))); } + { final MethodDescriptor sig = new MethodDescriptor("([I[Z[F)[D"); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("[I"), - new TypeDescriptor("[Z"), - new TypeDescriptor("[F") - )); + assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("[I"), new TypeDescriptor("[Z"), new TypeDescriptor("[F"))); assertThat(sig.getReturnDesc(), is(new TypeDescriptor("[D"))); } } @@ -112,20 +98,13 @@ public class TestMethodDescriptor { public void mixed() { { final MethodDescriptor sig = new MethodDescriptor("(I[JLFoo;)Z"); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("I"), - new TypeDescriptor("[J"), - new TypeDescriptor("LFoo;") - )); + assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("I"), new TypeDescriptor("[J"), new TypeDescriptor("LFoo;"))); assertThat(sig.getReturnDesc(), is(new TypeDescriptor("Z"))); } + { final MethodDescriptor sig = new MethodDescriptor("(III)[LFoo;"); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("I"), - new TypeDescriptor("I"), - new TypeDescriptor("I") - )); + assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("I"), new TypeDescriptor("I"), new TypeDescriptor("I"))); assertThat(sig.getReturnDesc(), is(new TypeDescriptor("[LFoo;"))); } } @@ -138,42 +117,37 @@ public class TestMethodDescriptor { assertThat(sig.getArgumentDescs(), is(empty())); assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V"))); } + { final MethodDescriptor oldSig = new MethodDescriptor("(IJLFoo;)V"); final MethodDescriptor sig = oldSig.remap(s -> null); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("I"), - new TypeDescriptor("J"), - new TypeDescriptor("LFoo;") - )); + assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("I"), new TypeDescriptor("J"), new TypeDescriptor("LFoo;"))); assertThat(sig.getReturnDesc(), is(new TypeDescriptor("V"))); } + { final MethodDescriptor oldSig = new MethodDescriptor("(LFoo;LBar;)LMoo;"); final MethodDescriptor sig = oldSig.remap(s -> { if (s.equals("Foo")) { return "Bar"; } + return null; }); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("LBar;"), - new TypeDescriptor("LBar;") - )); + assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("LBar;"), new TypeDescriptor("LBar;"))); assertThat(sig.getReturnDesc(), is(new TypeDescriptor("LMoo;"))); } + { final MethodDescriptor oldSig = new MethodDescriptor("(LFoo;LBar;)LMoo;"); final MethodDescriptor sig = oldSig.remap(s -> { if (s.equals("Moo")) { return "Cow"; } + return null; }); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("LFoo;"), - new TypeDescriptor("LBar;") - )); + assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("LFoo;"), new TypeDescriptor("LBar;"))); assertThat(sig.getReturnDesc(), is(new TypeDescriptor("LCow;"))); } } @@ -188,18 +162,16 @@ public class TestMethodDescriptor { } else if (s.equals("Bar")) { return "Beer"; } + return null; }); - assertThat(sig.getArgumentDescs(), contains( - new TypeDescriptor("[LFood;") - )); + assertThat(sig.getArgumentDescs(), contains(new TypeDescriptor("[LFood;"))); assertThat(sig.getReturnDesc(), is(new TypeDescriptor("[[[LBeer;"))); } } @Test public void equals() { - // base assertThat(new MethodDescriptor("()V"), is(new MethodDescriptor("()V"))); diff --git a/enigma/src/test/java/cuchaz/enigma/TestTokensConstructors.java b/enigma/src/test/java/cuchaz/enigma/TestTokensConstructors.java index a5e8367..8017ab6 100644 --- a/enigma/src/test/java/cuchaz/enigma/TestTokensConstructors.java +++ b/enigma/src/test/java/cuchaz/enigma/TestTokensConstructors.java @@ -1,31 +1,33 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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.translation.representation.entry.MethodEntry; -import org.junit.Ignore; -import org.junit.Test; - -import java.nio.file.Paths; - import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByMethod; import static cuchaz.enigma.TestEntryFactory.newMethod; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; +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 { +import java.nio.file.Paths; + +import org.junit.Ignore; +import org.junit.Test; + +import cuchaz.enigma.translation.representation.entry.MethodEntry; - public TestTokensConstructors() - throws Exception { +public class TestTokensConstructors extends TokenChecker { + public TestTokensConstructors() throws Exception { super(Paths.get("build/test-obf/constructors.jar")); } @@ -57,17 +59,10 @@ public class TestTokensConstructors extends TokenChecker { @Ignore // TODO needs fixing, broke when compiling against J16 public void baseDefaultReferences() { MethodEntry source = newMethod("a", "", "()V"); - assertThat( - getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "a", "()V")), - containsInAnyOrder("a") - ); - assertThat( - getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "", "()V")), - is(empty()) // implicit call, not decompiled to token + assertThat(getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "a", "()V")), containsInAnyOrder("a")); + assertThat(getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "", "()V")), is(empty()) // implicit call, not decompiled to token ); - assertThat( - getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "", "(III)V")), - is(empty()) // implicit call, not decompiled to token + assertThat(getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "", "(III)V")), is(empty()) // implicit call, not decompiled to token ); } @@ -75,71 +70,44 @@ public class TestTokensConstructors extends TokenChecker { @Ignore // TODO needs fixing, broke when compiling against J16 public void baseIntReferences() { MethodEntry source = newMethod("a", "", "(I)V"); - assertThat( - getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "b", "()V")), - containsInAnyOrder("a") - ); + assertThat(getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "b", "()V")), containsInAnyOrder("a")); } @Test @Ignore // TODO needs fixing, broke when compiling against J16 public void subDefaultReferences() { MethodEntry source = newMethod("d", "", "()V"); - assertThat( - getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "c", "()V")), - containsInAnyOrder("d") - ); - assertThat( - getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "", "(I)V")), - containsInAnyOrder("this") - ); + assertThat(getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "c", "()V")), containsInAnyOrder("d")); + assertThat(getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "", "(I)V")), containsInAnyOrder("this")); } @Test @Ignore // TODO needs fixing, broke when compiling against J16 public void subIntReferences() { MethodEntry source = newMethod("d", "", "(I)V"); - assertThat(getReferenceTokens( - newBehaviorReferenceByMethod(source, "b", "d", "()V")), - containsInAnyOrder("d") - ); - assertThat(getReferenceTokens( - newBehaviorReferenceByMethod(source, "d", "", "(II)V")), - containsInAnyOrder("this") - ); - assertThat(getReferenceTokens( - newBehaviorReferenceByMethod(source, "e", "", "(I)V")), - containsInAnyOrder("super") - ); + assertThat(getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "d", "()V")), containsInAnyOrder("d")); + assertThat(getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "", "(II)V")), containsInAnyOrder("this")); + assertThat(getReferenceTokens(newBehaviorReferenceByMethod(source, "e", "", "(I)V")), containsInAnyOrder("super")); } @Test @Ignore // TODO needs fixing, broke when compiling against J16 public void subIntIntReferences() { MethodEntry source = newMethod("d", "", "(II)V"); - assertThat( - getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "e", "()V")), - containsInAnyOrder("d") - ); + assertThat(getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "e", "()V")), containsInAnyOrder("d")); } @Test @Ignore // TODO needs fixing, broke when compiling against J16 public void subsubIntReferences() { MethodEntry source = newMethod("e", "", "(I)V"); - assertThat( - getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "f", "()V")), - containsInAnyOrder("e") - ); + assertThat(getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "f", "()V")), containsInAnyOrder("e")); } @Test @Ignore // TODO needs fixing, broke when compiling against J16 public void defaultConstructableReferences() { MethodEntry source = newMethod("c", "", "()V"); - assertThat( - getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "g", "()V")), - containsInAnyOrder("c") - ); + assertThat(getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "g", "()V")), containsInAnyOrder("c")); } } diff --git a/enigma/src/test/java/cuchaz/enigma/TestTranslator.java b/enigma/src/test/java/cuchaz/enigma/TestTranslator.java index a420afe..93b7017 100644 --- a/enigma/src/test/java/cuchaz/enigma/TestTranslator.java +++ b/enigma/src/test/java/cuchaz/enigma/TestTranslator.java @@ -1,27 +1,28 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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.translation.representation.entry.Entry; +import static cuchaz.enigma.TestEntryFactory.newClass; +import static cuchaz.enigma.TestEntryFactory.newField; +import static cuchaz.enigma.TestEntryFactory.newMethod; + import org.junit.BeforeClass; import org.junit.Test; -import static cuchaz.enigma.TestEntryFactory.*; +import cuchaz.enigma.translation.representation.entry.Entry; public class TestTranslator { - @BeforeClass - public static void beforeClass() - throws Exception { + public static void beforeClass() throws Exception { //TODO FIx //deobfuscator = new Enigma(new JarFile("build/test-obf/translation.jar")); //try (InputStream in = TestTranslator.class.getResourceAsStream("/cuchaz/enigma/resources/translation.mappings")) { @@ -94,7 +95,6 @@ public class TestTranslator { @Test public void innerClasses() { - // classes assertMapping(newClass("g"), newClass("deobf/G_OuterClass")); assertMapping(newClass("g$a"), newClass("deobf/G_OuterClass$A_InnerClass")); @@ -120,7 +120,6 @@ public class TestTranslator { @Test public void testGenerics() { - // classes assertMapping(newClass("i"), newClass("deobf/I_Generics")); assertMapping(newClass("i$a"), newClass("deobf/I_Generics$A_Type")); diff --git a/enigma/src/test/java/cuchaz/enigma/TestTypeDescriptor.java b/enigma/src/test/java/cuchaz/enigma/TestTypeDescriptor.java index b9ebe55..280dadc 100644 --- a/enigma/src/test/java/cuchaz/enigma/TestTypeDescriptor.java +++ b/enigma/src/test/java/cuchaz/enigma/TestTypeDescriptor.java @@ -1,26 +1,26 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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.translation.representation.TypeDescriptor; -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 TestTypeDescriptor { +import org.junit.Test; +import cuchaz.enigma.translation.representation.TypeDescriptor; + +public class TestTypeDescriptor { @Test public void isVoid() { assertThat(new TypeDescriptor("V").isVoid(), is(true)); @@ -161,6 +161,7 @@ public class TestTypeDescriptor { assertThat(TypeDescriptor.parseFirst("LFoo;LFoo;"), is(answer)); assertThat(TypeDescriptor.parseFirst("LFoo;[LFoo;"), is(answer)); } + { final String answer = "Ljava/lang/String;"; assertThat(TypeDescriptor.parseFirst("Ljava/lang/String;"), is(answer)); @@ -182,6 +183,7 @@ public class TestTypeDescriptor { assertThat(TypeDescriptor.parseFirst("[I[I"), is(answer)); assertThat(TypeDescriptor.parseFirst("[ILFoo;"), is(answer)); } + { final String answer = "[[I"; assertThat(TypeDescriptor.parseFirst("[[I"), is(answer)); @@ -190,6 +192,7 @@ public class TestTypeDescriptor { assertThat(TypeDescriptor.parseFirst("[[I[I"), is(answer)); assertThat(TypeDescriptor.parseFirst("[[ILFoo;"), is(answer)); } + { final String answer = "[LFoo;"; assertThat(TypeDescriptor.parseFirst("[LFoo;"), is(answer)); diff --git a/enigma/src/test/java/cuchaz/enigma/TokenChecker.java b/enigma/src/test/java/cuchaz/enigma/TokenChecker.java index fb3a8da..5f510a4 100644 --- a/enigma/src/test/java/cuchaz/enigma/TokenChecker.java +++ b/enigma/src/test/java/cuchaz/enigma/TokenChecker.java @@ -1,28 +1,34 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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.nio.file.Path; +import java.util.Collection; +import java.util.List; + import com.google.common.collect.Lists; + import cuchaz.enigma.analysis.EntryReference; import cuchaz.enigma.classprovider.CachingClassProvider; import cuchaz.enigma.classprovider.JarClassProvider; -import cuchaz.enigma.source.*; +import cuchaz.enigma.source.Decompiler; +import cuchaz.enigma.source.Decompilers; +import cuchaz.enigma.source.Source; +import cuchaz.enigma.source.SourceIndex; +import cuchaz.enigma.source.SourceSettings; +import cuchaz.enigma.source.Token; import cuchaz.enigma.translation.representation.entry.Entry; -import java.io.IOException; -import java.nio.file.Path; -import java.util.Collection; -import java.util.List; - public class TokenChecker { private final Decompiler decompiler; @@ -41,9 +47,11 @@ public class TokenChecker { // get the token value Token token = index.getDeclarationToken(entry); + if (token == null) { return null; } + return string.substring(token.start, token.end); } @@ -56,9 +64,11 @@ public class TokenChecker { // get the token values List values = Lists.newArrayList(); + for (Token token : index.getReferenceTokens((EntryReference, Entry>) reference)) { values.add(string.substring(token.start, token.end)); } + return values; } } diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/Keep.java b/enigma/src/test/java/cuchaz/enigma/inputs/Keep.java index 4dbe8e2..46d5380 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/Keep.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/Keep.java @@ -1,13 +1,13 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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; diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/constructors/BaseClass.java b/enigma/src/test/java/cuchaz/enigma/inputs/constructors/BaseClass.java index f07e1f8..a82db77 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/constructors/BaseClass.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/constructors/BaseClass.java @@ -1,19 +1,18 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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"); diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/constructors/Caller.java b/enigma/src/test/java/cuchaz/enigma/inputs/constructors/Caller.java index 71439fd..e81df1b 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/constructors/Caller.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/constructors/Caller.java @@ -1,19 +1,18 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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 diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/constructors/DefaultConstructable.java b/enigma/src/test/java/cuchaz/enigma/inputs/constructors/DefaultConstructable.java index c3d4170..55aa767 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/constructors/DefaultConstructable.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/constructors/DefaultConstructable.java @@ -1,13 +1,13 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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; diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/constructors/SubClass.java b/enigma/src/test/java/cuchaz/enigma/inputs/constructors/SubClass.java index bc56b3b..1a90eba 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/constructors/SubClass.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/constructors/SubClass.java @@ -1,19 +1,18 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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 diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/constructors/SubSubClass.java b/enigma/src/test/java/cuchaz/enigma/inputs/constructors/SubSubClass.java index 87b69d3..ec5ac44 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/constructors/SubSubClass.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/constructors/SubSubClass.java @@ -1,19 +1,18 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/BaseClass.java b/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/BaseClass.java index b9c4929..87e849f 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/BaseClass.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/BaseClass.java @@ -1,19 +1,18 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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; diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassA.java b/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassA.java index 50e963c..ba8c1b7 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassA.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassA.java @@ -1,19 +1,18 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassB.java b/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassB.java index d0dd664..cfc696a 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassB.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubclassB.java @@ -1,19 +1,18 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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; diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubsubclassAA.java b/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubsubclassAA.java index c584570..d3bb62e 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubsubclassAA.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/inheritanceTree/SubsubclassAA.java @@ -1,19 +1,18 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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"); diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/A_Anonymous.java b/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/A_Anonymous.java index f652d87..515205a 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/A_Anonymous.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/A_Anonymous.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/B_AnonymousWithScopeArgs.java b/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/B_AnonymousWithScopeArgs.java index d1b7601..6ec27ac 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/B_AnonymousWithScopeArgs.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/B_AnonymousWithScopeArgs.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/C_ConstructorArgs.java b/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/C_ConstructorArgs.java index 94061fa..223c424 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/C_ConstructorArgs.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/C_ConstructorArgs.java @@ -1,19 +1,18 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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() { @@ -21,10 +20,9 @@ public class C_ConstructorArgs { } class Inner { - private int a; - public Inner(int a) { + Inner(int a) { this.a = a; } } diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/D_Simple.java b/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/D_Simple.java index 71b3a6d..f401d5f 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/D_Simple.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/D_Simple.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/E_AnonymousWithOuterAccess.java b/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/E_AnonymousWithOuterAccess.java index 976ec42..0056bc6 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/E_AnonymousWithOuterAccess.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/E_AnonymousWithOuterAccess.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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 diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/F_ClassTree.java b/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/F_ClassTree.java index b1de3c9..b2e9e2d 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/F_ClassTree.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/innerClasses/F_ClassTree.java @@ -1,28 +1,24 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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 F_ClassTree { - public class Level1 { - public int f1; public class Level2 { - public int f2; public class Level3 { - public int f3; } } diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/loneClass/LoneClass.java b/enigma/src/test/java/cuchaz/enigma/inputs/loneClass/LoneClass.java index ddc4e31..e50d37f 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/loneClass/LoneClass.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/loneClass/LoneClass.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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) { diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/packageAccess/SamePackageChild.java b/enigma/src/test/java/cuchaz/enigma/inputs/packageAccess/SamePackageChild.java index cf0f657..aa8de19 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/packageAccess/SamePackageChild.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/packageAccess/SamePackageChild.java @@ -1,7 +1,6 @@ package cuchaz.enigma.inputs.packageAccess; public class SamePackageChild extends Base { - class Inner { final int value; diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/packageAccess/sub/OtherPackageChild.java b/enigma/src/test/java/cuchaz/enigma/inputs/packageAccess/sub/OtherPackageChild.java index 19fb19c..5bcb763 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/packageAccess/sub/OtherPackageChild.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/packageAccess/sub/OtherPackageChild.java @@ -3,7 +3,6 @@ package cuchaz.enigma.inputs.packageAccess.sub; import cuchaz.enigma.inputs.packageAccess.Base; public class OtherPackageChild extends Base { - class Inner { final int value; diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/translation/A_Basic.java b/enigma/src/test/java/cuchaz/enigma/inputs/translation/A_Basic.java index 26f3718..b411e0a 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/translation/A_Basic.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/translation/A_Basic.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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; diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/translation/B_BaseClass.java b/enigma/src/test/java/cuchaz/enigma/inputs/translation/B_BaseClass.java index fd7f6e7..d5e9a25 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/translation/B_BaseClass.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/translation/B_BaseClass.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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; diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/translation/C_SubClass.java b/enigma/src/test/java/cuchaz/enigma/inputs/translation/C_SubClass.java index 9d74e44..fd9e217 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/translation/C_SubClass.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/translation/C_SubClass.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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; diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/translation/D_AnonymousTesting.java b/enigma/src/test/java/cuchaz/enigma/inputs/translation/D_AnonymousTesting.java index 99c83bb..56cccc7 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/translation/D_AnonymousTesting.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/translation/D_AnonymousTesting.java @@ -1,13 +1,13 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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; @@ -15,7 +15,6 @@ 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/enigma/src/test/java/cuchaz/enigma/inputs/translation/E_Bridges.java b/enigma/src/test/java/cuchaz/enigma/inputs/translation/E_Bridges.java index 0b8cf2a..f44bdbf 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/translation/E_Bridges.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/translation/E_Bridges.java @@ -1,20 +1,19 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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 public boolean hasNext() { return false; diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/translation/F_ObjectMethods.java b/enigma/src/test/java/cuchaz/enigma/inputs/translation/F_ObjectMethods.java index 8a92792..ac1d7b5 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/translation/F_ObjectMethods.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/translation/F_ObjectMethods.java @@ -1,21 +1,19 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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 { + public void callEmAll() throws Throwable { clone(); equals(this); finalize(); diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/translation/G_OuterClass.java b/enigma/src/test/java/cuchaz/enigma/inputs/translation/G_OuterClass.java index a1e6a85..4d99235 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/translation/G_OuterClass.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/translation/G_OuterClass.java @@ -1,30 +1,29 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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 G_OuterClass { - public class A_InnerClass { - public int f1; public String f2; - public void m1() {} + public void m1() { + } public class A_InnerInnerClass { - public int f3; - public void m2() {} + public void m2() { + } } } diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/translation/H_NamelessClass.java b/enigma/src/test/java/cuchaz/enigma/inputs/translation/H_NamelessClass.java index 013c55a..d996dc8 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/translation/H_NamelessClass.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/translation/H_NamelessClass.java @@ -1,30 +1,29 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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 H_NamelessClass { - public class A_InnerClass { - public int f1; public String f2; - public void m1() {} + public void m1() { + } public class A_InnerInnerClass { - public int f3; - public void m2() {} + public void m2() { + } } } @@ -32,9 +31,11 @@ public class H_NamelessClass { public class A_NamedInnerClass { public int f4; - public class A_AnotherInnerClass {} + public class A_AnotherInnerClass { + } - public class B_YetAnotherInnerClass {} + public class B_YetAnotherInnerClass { + } } } } diff --git a/enigma/src/test/java/cuchaz/enigma/inputs/translation/I_Generics.java b/enigma/src/test/java/cuchaz/enigma/inputs/translation/I_Generics.java index fd2ebdd..9a9048c 100644 --- a/enigma/src/test/java/cuchaz/enigma/inputs/translation/I_Generics.java +++ b/enigma/src/test/java/cuchaz/enigma/inputs/translation/I_Generics.java @@ -1,13 +1,13 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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; @@ -15,7 +15,6 @@ import java.util.List; import java.util.Map; public class I_Generics { - public List f1; public List f2; public Map f3; diff --git a/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestComments.java b/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestComments.java index e831943..15ec44e 100644 --- a/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestComments.java +++ b/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestComments.java @@ -5,6 +5,8 @@ import java.net.URISyntaxException; import java.nio.file.Path; import java.nio.file.Paths; +import org.junit.Test; + import cuchaz.enigma.ProgressListener; import cuchaz.enigma.translation.mapping.serde.MappingFileNameFormat; import cuchaz.enigma.translation.mapping.serde.MappingParseException; @@ -12,28 +14,24 @@ import cuchaz.enigma.translation.mapping.serde.MappingSaveParameters; import cuchaz.enigma.translation.mapping.serde.enigma.EnigmaMappingsReader; import cuchaz.enigma.translation.mapping.serde.tinyv2.TinyV2Writer; import cuchaz.enigma.translation.mapping.tree.EntryTree; -import org.junit.Test; public class TestComments { - private static Path DIRECTORY; - - static { - try { - DIRECTORY = Paths.get(TestTinyV2InnerClasses.class.getResource("/comments/").toURI()); - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - } + private static Path DIRECTORY; - @Test - public void testParseAndWrite() throws IOException, MappingParseException { - ProgressListener progressListener = ProgressListener.none(); - MappingSaveParameters params = new MappingSaveParameters(MappingFileNameFormat.BY_DEOBF); - EntryTree mappings = EnigmaMappingsReader.DIRECTORY.read( - DIRECTORY, progressListener, params); + static { + try { + DIRECTORY = Paths.get(TestTinyV2InnerClasses.class.getResource("/comments/").toURI()); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + } - new TinyV2Writer("intermediary", "named") - .write(mappings, DIRECTORY.resolve("convertedtiny.tiny"), progressListener, params); - } + @Test + public void testParseAndWrite() throws IOException, MappingParseException { + ProgressListener progressListener = ProgressListener.none(); + MappingSaveParameters params = new MappingSaveParameters(MappingFileNameFormat.BY_DEOBF); + EntryTree mappings = EnigmaMappingsReader.DIRECTORY.read(DIRECTORY, progressListener, params); -} \ No newline at end of file + new TinyV2Writer("intermediary", "named").write(mappings, DIRECTORY.resolve("convertedtiny.tiny"), progressListener, params); + } +} diff --git a/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestReadWriteCycle.java b/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestReadWriteCycle.java index 510dd3c..681fd3f 100644 --- a/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestReadWriteCycle.java +++ b/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestReadWriteCycle.java @@ -1,5 +1,11 @@ package cuchaz.enigma.translation.mapping; +import java.io.File; +import java.io.IOException; + +import org.junit.Assert; +import org.junit.Test; + import cuchaz.enigma.ProgressListener; import cuchaz.enigma.translation.mapping.serde.MappingFileNameFormat; import cuchaz.enigma.translation.mapping.serde.MappingFormat; @@ -12,46 +18,25 @@ import cuchaz.enigma.translation.representation.entry.Entry; import cuchaz.enigma.translation.representation.entry.FieldEntry; import cuchaz.enigma.translation.representation.entry.MethodEntry; import cuchaz.enigma.utils.Pair; -import org.junit.Assert; -import org.junit.Test; - -import java.io.File; -import java.io.IOException; /** * Tests that a MappingFormat can write out a fixed set of mappings and read them back without losing any information. * Javadoc skipped for Tiny (v1) as it doesn't support them. */ public class TestReadWriteCycle { - private final MappingSaveParameters parameters = new MappingSaveParameters(MappingFileNameFormat.BY_DEOBF); - private final Pair testClazz = new Pair<>( - new ClassEntry("a/b/c"), - new EntryMapping("alpha/beta/charlie", "this is a test class") - ); + private final Pair testClazz = new Pair<>(new ClassEntry("a/b/c"), new EntryMapping("alpha/beta/charlie", "this is a test class")); - private final Pair testField1 = new Pair<>( - FieldEntry.parse("a/b/c", "field1", "I"), - new EntryMapping("mapped1", "this is field 1") - ); + private final Pair testField1 = new Pair<>(FieldEntry.parse("a/b/c", "field1", "I"), new EntryMapping("mapped1", "this is field 1")); - private final Pair testField2 = new Pair<>( - FieldEntry.parse("a/b/c", "field2", "I"), - new EntryMapping("mapped2", "this is field 2") - ); + private final Pair testField2 = new Pair<>(FieldEntry.parse("a/b/c", "field2", "I"), new EntryMapping("mapped2", "this is field 2")); - private final Pair testMethod1 = new Pair<>( - MethodEntry.parse("a/b/c", "method1", "()V"), - new EntryMapping("mapped3", "this is method1") - ); + private final Pair testMethod1 = new Pair<>(MethodEntry.parse("a/b/c", "method1", "()V"), new EntryMapping("mapped3", "this is method1")); - private final Pair testMethod2 = new Pair<>( - MethodEntry.parse("a/b/c", "method2", "()V"), - new EntryMapping("mapped4", "this is method 2") - ); + private final Pair testMethod2 = new Pair<>(MethodEntry.parse("a/b/c", "method2", "()V"), new EntryMapping("mapped4", "this is method 2")); - private void insertMapping(EntryTree mappings, Pair, EntryMapping> mappingPair){ + private void insertMapping(EntryTree mappings, Pair, EntryMapping> mappingPair) { mappings.insert(mappingPair.a, mappingPair.b); } @@ -71,8 +56,8 @@ public class TestReadWriteCycle { Assert.assertTrue("Test mapping insertion failed: testMethod2", testMappings.contains(testMethod2.a)); File tempFile = File.createTempFile("readWriteCycle", tmpNameSuffix); - tempFile.delete();//remove the auto created file - + //remove the auto created file + tempFile.delete(); mappingFormat.write(testMappings, tempFile.toPath(), ProgressListener.none(), parameters); Assert.assertTrue("Written file not created", tempFile.exists()); diff --git a/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestTinyV2InnerClasses.java b/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestTinyV2InnerClasses.java index 60c70b7..659ac53 100644 --- a/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestTinyV2InnerClasses.java +++ b/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestTinyV2InnerClasses.java @@ -1,25 +1,25 @@ /******************************************************************************* - * Copyright (c) 2015 Jeff Martin. - * All rights reserved. This program and the accompanying materials - * 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 - ******************************************************************************/ +* Copyright (c) 2015 Jeff Martin. +* All rights reserved. This program and the accompanying materials +* 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.translation.mapping; +import java.nio.file.Path; +import java.nio.file.Paths; + import cuchaz.enigma.Enigma; import cuchaz.enigma.EnigmaProject; import cuchaz.enigma.ProgressListener; import cuchaz.enigma.classprovider.ClasspathClassProvider; import cuchaz.enigma.translation.mapping.serde.enigma.EnigmaMappingsReader; -import java.nio.file.Path; -import java.nio.file.Paths; - public final class TestTinyV2InnerClasses { private Path jar; private Path mappings; @@ -29,10 +29,9 @@ public final class TestTinyV2InnerClasses { mappings = Paths.get(TestTinyV2InnerClasses.class.getResource("/tinyV2InnerClasses/").toURI()); } -// @Test + // @Test public void testMappings() throws Exception { EnigmaProject project = Enigma.create().openJar(jar, new ClasspathClassProvider(), ProgressListener.none()); project.setMappings(EnigmaMappingsReader.DIRECTORY.read(mappings, ProgressListener.none(), project.getEnigma().getProfile().getMappingSaveParameters())); - } } diff --git a/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestV2Main.java b/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestV2Main.java index 6e4d7b9..cc08b85 100644 --- a/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestV2Main.java +++ b/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestV2Main.java @@ -1,5 +1,8 @@ package cuchaz.enigma.translation.mapping; +import java.nio.file.Path; +import java.nio.file.Paths; + import cuchaz.enigma.ProgressListener; import cuchaz.enigma.translation.mapping.serde.MappingFileNameFormat; import cuchaz.enigma.translation.mapping.serde.MappingSaveParameters; @@ -7,9 +10,6 @@ import cuchaz.enigma.translation.mapping.serde.enigma.EnigmaMappingsReader; import cuchaz.enigma.translation.mapping.serde.tinyv2.TinyV2Writer; import cuchaz.enigma.translation.mapping.tree.EntryTree; -import java.nio.file.Path; -import java.nio.file.Paths; - public final class TestV2Main { public static void main(String... args) throws Exception { Path path = Paths.get(TestV2Main.class.getResource("/tinyV2InnerClasses/").toURI()); diff --git a/enigma/src/test/java/cuchaz/enigma/translation/mapping/serde/recaf/TestRecaf.java b/enigma/src/test/java/cuchaz/enigma/translation/mapping/serde/recaf/TestRecaf.java index 1026f57..bd1ec20 100644 --- a/enigma/src/test/java/cuchaz/enigma/translation/mapping/serde/recaf/TestRecaf.java +++ b/enigma/src/test/java/cuchaz/enigma/translation/mapping/serde/recaf/TestRecaf.java @@ -1,11 +1,6 @@ package cuchaz.enigma.translation.mapping.serde.recaf; -import com.google.common.collect.Sets; -import com.google.common.jimfs.Jimfs; -import cuchaz.enigma.ProgressListener; -import cuchaz.enigma.translation.mapping.EntryMapping; -import cuchaz.enigma.translation.mapping.tree.EntryTree; -import org.junit.Test; +import static org.junit.Assert.assertEquals; import java.io.InputStream; import java.nio.charset.StandardCharsets; @@ -15,32 +10,37 @@ import java.nio.file.Path; import java.util.HashSet; import java.util.Set; -import static org.junit.Assert.assertEquals; +import com.google.common.collect.Sets; +import com.google.common.jimfs.Jimfs; +import org.junit.Test; -public class TestRecaf { +import cuchaz.enigma.ProgressListener; +import cuchaz.enigma.translation.mapping.EntryMapping; +import cuchaz.enigma.translation.mapping.tree.EntryTree; - @Test - public void testIntegrity() throws Exception { - Set contents; - try (InputStream in = getClass().getResourceAsStream("/recaf.mappings")) { - contents = Sets.newHashSet(new String(in.readAllBytes(), StandardCharsets.UTF_8).split("\\R")); - } +public class TestRecaf { + @Test + public void testIntegrity() throws Exception { + Set contents; - try (FileSystem fs = Jimfs.newFileSystem()) { + try (InputStream in = getClass().getResourceAsStream("/recaf.mappings")) { + contents = Sets.newHashSet(new String(in.readAllBytes(), StandardCharsets.UTF_8).split("\\R")); + } - Path path = fs.getPath("recaf.mappings"); - Files.writeString(path, String.join("\n", contents)); + try (FileSystem fs = Jimfs.newFileSystem()) { + Path path = fs.getPath("recaf.mappings"); + Files.writeString(path, String.join("\n", contents)); - RecafMappingsWriter writer = RecafMappingsWriter.INSTANCE; - RecafMappingsReader reader = RecafMappingsReader.INSTANCE; + RecafMappingsWriter writer = RecafMappingsWriter.INSTANCE; + RecafMappingsReader reader = RecafMappingsReader.INSTANCE; - EntryTree mappings = reader.read(path, ProgressListener.none(), null); - writer.write(mappings, path, ProgressListener.none(), null); + EntryTree mappings = reader.read(path, ProgressListener.none(), null); + writer.write(mappings, path, ProgressListener.none(), null); - reader.read(path, ProgressListener.none(), null); - Set newContents = new HashSet<>(Files.readAllLines(path)); + reader.read(path, ProgressListener.none(), null); + Set newContents = new HashSet<>(Files.readAllLines(path)); - assertEquals(contents, newContents); - } - } + assertEquals(contents, newContents); + } + } } -- cgit v1.2.3