diff options
| author | 2018-07-17 19:14:08 +0200 | |
|---|---|---|
| committer | 2018-07-17 19:14:08 +0200 | |
| commit | a88175ffc95792b88a8724f66db6dda2b8cc32ee (patch) | |
| tree | 65895bbc6cf1766f4ca01e1257619ab1993e71dc /src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java | |
| parent | Merge pull request #3 from thiakil/src-jar (diff) | |
| download | enigma-fork-a88175ffc95792b88a8724f66db6dda2b8cc32ee.tar.gz enigma-fork-a88175ffc95792b88a8724f66db6dda2b8cc32ee.tar.xz enigma-fork-a88175ffc95792b88a8724f66db6dda2b8cc32ee.zip | |
ASM Based Class Translator (#1)
* Initial port to ASM
* Package updates
* Annotation + inner class translation
* Fix inner class mapping
* More bytecode translation
* Signature refactoring
* Fix highlighting of mapped names
* Fix parameter name offset
* Fix anonymous class generation
* Fix issues with inner class signature transformation
* Fix bridged method detection
* Fix compile issues
* Resolve all failed tests
* Apply deobfuscated name to transformed classes
* Fix class signatures not being translated
* Fix frame array type translation
* Fix frame array type translation
* Fix array translation in method calls
* Fix method reference and bridge detection
* Fix handling of null deobf mappings
* Parameter translation in interfaces
* Fix enum parameter index offset
* Fix parsed local variable indexing
* Fix stackoverflow on rebuilding method names
* Ignore invalid decompiled variable indices
* basic source jar
* Output directly to file on source export
* Make decompile parallel
* fix incorrect super calls
* Use previous save state to delete old mapping files
* Fix old mappings not properly being removed
* Fix old mappings not properly being removed
* make isMethodProvider public
(cherry picked from commit ebad6a9)
* speed up Deobfuscator's getSources by using a single TranslatingTypeloader and caching the ClassLoaderTypeloader
* ignore .idea project folders
* move SynchronizedTypeLoader to a non-inner
* fix signature remap of inners for now
* index & resolve method/field references for usages view
* Allow reader/writer subclasses to provide the underlying file operations
* fix giving obf classes a name not removing them from the panel
* buffer the ParsedJar class entry inputstream, allow use with a jarinputstream
* make CachingClasspathTypeLoader public
* make CachingClasspathTypeLoader public
* support enum switches with obfuscated SwitchMaps
Diffstat (limited to 'src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java')
| -rw-r--r-- | src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java b/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java index 6cab1c8..b4529dd 100644 --- a/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java +++ b/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java | |||
| @@ -13,6 +13,7 @@ package cuchaz.enigma; | |||
| 13 | 13 | ||
| 14 | import cuchaz.enigma.analysis.*; | 14 | import cuchaz.enigma.analysis.*; |
| 15 | import cuchaz.enigma.mapping.*; | 15 | import cuchaz.enigma.mapping.*; |
| 16 | import cuchaz.enigma.mapping.entry.*; | ||
| 16 | import org.junit.Test; | 17 | import org.junit.Test; |
| 17 | 18 | ||
| 18 | import java.util.Collection; | 19 | import java.util.Collection; |
| @@ -28,16 +29,16 @@ public class TestJarIndexLoneClass { | |||
| 28 | private JarIndex index; | 29 | private JarIndex index; |
| 29 | 30 | ||
| 30 | public TestJarIndexLoneClass() | 31 | public TestJarIndexLoneClass() |
| 31 | throws Exception { | 32 | throws Exception { |
| 32 | index = new JarIndex(); | 33 | index = new JarIndex(new ReferencedEntryPool()); |
| 33 | index.indexJar(new JarFile("build/test-obf/loneClass.jar"), false); | 34 | index.indexJar(new ParsedJar(new JarFile("build/test-obf/loneClass.jar")), false); |
| 34 | } | 35 | } |
| 35 | 36 | ||
| 36 | @Test | 37 | @Test |
| 37 | public void obfEntries() { | 38 | public void obfEntries() { |
| 38 | assertThat(index.getObfClassEntries(), containsInAnyOrder( | 39 | assertThat(index.getObfClassEntries(), containsInAnyOrder( |
| 39 | newClass("cuchaz/enigma/inputs/Keep"), | 40 | newClass("cuchaz/enigma/inputs/Keep"), |
| 40 | newClass("a") | 41 | newClass("a") |
| 41 | )); | 42 | )); |
| 42 | } | 43 | } |
| 43 | 44 | ||
| @@ -61,7 +62,7 @@ public class TestJarIndexLoneClass { | |||
| 61 | 62 | ||
| 62 | @Test | 63 | @Test |
| 63 | public void classInheritance() { | 64 | public void classInheritance() { |
| 64 | ClassInheritanceTreeNode node = index.getClassInheritance(new Translator(), newClass("a")); | 65 | ClassInheritanceTreeNode node = index.getClassInheritance(new DirectionalTranslator(new ReferencedEntryPool()), newClass("a")); |
| 65 | assertThat(node, is(not(nullValue()))); | 66 | assertThat(node, is(not(nullValue()))); |
| 66 | assertThat(node.getObfClassName(), is("a")); | 67 | assertThat(node.getObfClassName(), is("a")); |
| 67 | assertThat(node.getChildCount(), is(0)); | 68 | assertThat(node.getChildCount(), is(0)); |
| @@ -70,7 +71,7 @@ public class TestJarIndexLoneClass { | |||
| 70 | @Test | 71 | @Test |
| 71 | public void methodInheritance() { | 72 | public void methodInheritance() { |
| 72 | MethodEntry source = newMethod("a", "a", "()Ljava/lang/String;"); | 73 | MethodEntry source = newMethod("a", "a", "()Ljava/lang/String;"); |
| 73 | MethodInheritanceTreeNode node = index.getMethodInheritance(new Translator(), source); | 74 | MethodInheritanceTreeNode node = index.getMethodInheritance(new DirectionalTranslator(new ReferencedEntryPool()), source); |
| 74 | assertThat(node, is(not(nullValue()))); | 75 | assertThat(node, is(not(nullValue()))); |
| 75 | assertThat(node.getMethodEntry(), is(source)); | 76 | assertThat(node.getMethodEntry(), is(source)); |
| 76 | assertThat(node.getChildCount(), is(0)); | 77 | assertThat(node.getChildCount(), is(0)); |
| @@ -78,21 +79,21 @@ public class TestJarIndexLoneClass { | |||
| 78 | 79 | ||
| 79 | @Test | 80 | @Test |
| 80 | public void classImplementations() { | 81 | public void classImplementations() { |
| 81 | ClassImplementationsTreeNode node = index.getClassImplementations(new Translator(), newClass("a")); | 82 | ClassImplementationsTreeNode node = index.getClassImplementations(new DirectionalTranslator(new ReferencedEntryPool()), newClass("a")); |
| 82 | assertThat(node, is(nullValue())); | 83 | assertThat(node, is(nullValue())); |
| 83 | } | 84 | } |
| 84 | 85 | ||
| 85 | @Test | 86 | @Test |
| 86 | public void methodImplementations() { | 87 | public void methodImplementations() { |
| 87 | MethodEntry source = newMethod("a", "a", "()Ljava/lang/String;"); | 88 | MethodEntry source = newMethod("a", "a", "()Ljava/lang/String;"); |
| 88 | assertThat(index.getMethodImplementations(new Translator(), source), is(empty())); | 89 | assertThat(index.getMethodImplementations(new DirectionalTranslator(new ReferencedEntryPool()), source), is(empty())); |
| 89 | } | 90 | } |
| 90 | 91 | ||
| 91 | @Test | 92 | @Test |
| 92 | public void relatedMethodImplementations() { | 93 | public void relatedMethodImplementations() { |
| 93 | Set<MethodEntry> entries = index.getRelatedMethodImplementations(newMethod("a", "a", "()Ljava/lang/String;")); | 94 | Set<MethodEntry> entries = index.getRelatedMethodImplementations(newMethod("a", "a", "()Ljava/lang/String;")); |
| 94 | assertThat(entries, containsInAnyOrder( | 95 | assertThat(entries, containsInAnyOrder( |
| 95 | newMethod("a", "a", "()Ljava/lang/String;") | 96 | newMethod("a", "a", "()Ljava/lang/String;") |
| 96 | )); | 97 | )); |
| 97 | } | 98 | } |
| 98 | 99 | ||
| @@ -100,16 +101,16 @@ public class TestJarIndexLoneClass { | |||
| 100 | @SuppressWarnings("unchecked") | 101 | @SuppressWarnings("unchecked") |
| 101 | public void fieldReferences() { | 102 | public void fieldReferences() { |
| 102 | FieldEntry source = newField("a", "a", "Ljava/lang/String;"); | 103 | FieldEntry source = newField("a", "a", "Ljava/lang/String;"); |
| 103 | Collection<EntryReference<FieldEntry, BehaviorEntry>> references = index.getFieldReferences(source); | 104 | Collection<EntryReference<FieldEntry, MethodDefEntry>> references = index.getFieldReferences(source); |
| 104 | assertThat(references, containsInAnyOrder( | 105 | assertThat(references, containsInAnyOrder( |
| 105 | newFieldReferenceByConstructor(source, "a", "(Ljava/lang/String;)V"), | 106 | newFieldReferenceByMethod(source, "a", "<init>", "(Ljava/lang/String;)V"), |
| 106 | newFieldReferenceByMethod(source, "a", "a", "()Ljava/lang/String;") | 107 | newFieldReferenceByMethod(source, "a", "a", "()Ljava/lang/String;") |
| 107 | )); | 108 | )); |
| 108 | } | 109 | } |
| 109 | 110 | ||
| 110 | @Test | 111 | @Test |
| 111 | public void behaviorReferences() { | 112 | public void behaviorReferences() { |
| 112 | assertThat(index.getBehaviorReferences(newMethod("a", "a", "()Ljava/lang/String;")), is(empty())); | 113 | assertThat(index.getMethodsReferencing(newMethod("a", "a", "()Ljava/lang/String;")), is(empty())); |
| 113 | } | 114 | } |
| 114 | 115 | ||
| 115 | @Test | 116 | @Test |
| @@ -123,11 +124,6 @@ public class TestJarIndexLoneClass { | |||
| 123 | } | 124 | } |
| 124 | 125 | ||
| 125 | @Test | 126 | @Test |
| 126 | public void isAnonymousClass() { | ||
| 127 | assertThat(index.isAnonymousClass(newClass("a")), is(false)); | ||
| 128 | } | ||
| 129 | |||
| 130 | @Test | ||
| 131 | public void interfaces() { | 127 | public void interfaces() { |
| 132 | assertThat(index.getInterfaces("a"), is(empty())); | 128 | assertThat(index.getInterfaces("a"), is(empty())); |
| 133 | } | 129 | } |
| @@ -149,7 +145,7 @@ public class TestJarIndexLoneClass { | |||
| 149 | assertThat(index.containsObfField(newField("a", "a", "Ljava/lang/String;")), is(true)); | 145 | assertThat(index.containsObfField(newField("a", "a", "Ljava/lang/String;")), is(true)); |
| 150 | assertThat(index.containsObfField(newField("a", "b", "Ljava/lang/String;")), is(false)); | 146 | assertThat(index.containsObfField(newField("a", "b", "Ljava/lang/String;")), is(false)); |
| 151 | assertThat(index.containsObfField(newField("a", "a", "LFoo;")), is(false)); | 147 | assertThat(index.containsObfField(newField("a", "a", "LFoo;")), is(false)); |
| 152 | assertThat(index.containsObfBehavior(newMethod("a", "a", "()Ljava/lang/String;")), is(true)); | 148 | assertThat(index.containsObfMethod(newMethod("a", "a", "()Ljava/lang/String;")), is(true)); |
| 153 | assertThat(index.containsObfBehavior(newMethod("a", "b", "()Ljava/lang/String;")), is(false)); | 149 | assertThat(index.containsObfMethod(newMethod("a", "b", "()Ljava/lang/String;")), is(false)); |
| 154 | } | 150 | } |
| 155 | } | 151 | } |