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/TestTokensConstructors.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/TestTokensConstructors.java')
| -rw-r--r-- | src/test/java/cuchaz/enigma/TestTokensConstructors.java | 90 |
1 files changed, 43 insertions, 47 deletions
diff --git a/src/test/java/cuchaz/enigma/TestTokensConstructors.java b/src/test/java/cuchaz/enigma/TestTokensConstructors.java index e40d5fd..0e98da7 100644 --- a/src/test/java/cuchaz/enigma/TestTokensConstructors.java +++ b/src/test/java/cuchaz/enigma/TestTokensConstructors.java | |||
| @@ -11,131 +11,127 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma; | 12 | package cuchaz.enigma; |
| 13 | 13 | ||
| 14 | import cuchaz.enigma.mapping.BehaviorEntry; | 14 | import cuchaz.enigma.mapping.entry.MethodEntry; |
| 15 | import org.junit.Test; | 15 | import org.junit.Test; |
| 16 | 16 | ||
| 17 | import java.util.jar.JarFile; | 17 | import java.util.jar.JarFile; |
| 18 | 18 | ||
| 19 | import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByConstructor; | ||
| 20 | import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByMethod; | 19 | import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByMethod; |
| 21 | import static cuchaz.enigma.TestEntryFactory.newConstructor; | 20 | import static cuchaz.enigma.TestEntryFactory.newMethod; |
| 22 | import static org.hamcrest.MatcherAssert.assertThat; | 21 | import static org.hamcrest.MatcherAssert.assertThat; |
| 23 | import static org.hamcrest.Matchers.containsInAnyOrder; | 22 | import static org.hamcrest.Matchers.*; |
| 24 | import static org.hamcrest.Matchers.empty; | ||
| 25 | import static org.hamcrest.Matchers.is; | ||
| 26 | import static org.hamcrest.Matchers.nullValue; | ||
| 27 | 23 | ||
| 28 | public class TestTokensConstructors extends TokenChecker { | 24 | public class TestTokensConstructors extends TokenChecker { |
| 29 | 25 | ||
| 30 | public TestTokensConstructors() | 26 | public TestTokensConstructors() |
| 31 | throws Exception { | 27 | throws Exception { |
| 32 | super(new JarFile("build/test-obf/constructors.jar")); | 28 | super(new JarFile("build/test-obf/constructors.jar")); |
| 33 | } | 29 | } |
| 34 | 30 | ||
| 35 | @Test | 31 | @Test |
| 36 | public void baseDeclarations() { | 32 | public void baseDeclarations() { |
| 37 | assertThat(getDeclarationToken(newConstructor("a", "()V")), is("a")); | 33 | assertThat(getDeclarationToken(newMethod("a", "<init>", "()V")), is("a")); |
| 38 | assertThat(getDeclarationToken(newConstructor("a", "(I)V")), is("a")); | 34 | assertThat(getDeclarationToken(newMethod("a", "<init>", "(I)V")), is("a")); |
| 39 | } | 35 | } |
| 40 | 36 | ||
| 41 | @Test | 37 | @Test |
| 42 | public void subDeclarations() { | 38 | public void subDeclarations() { |
| 43 | assertThat(getDeclarationToken(newConstructor("d", "()V")), is("d")); | 39 | assertThat(getDeclarationToken(newMethod("d", "<init>", "()V")), is("d")); |
| 44 | assertThat(getDeclarationToken(newConstructor("d", "(I)V")), is("d")); | 40 | assertThat(getDeclarationToken(newMethod("d", "<init>", "(I)V")), is("d")); |
| 45 | assertThat(getDeclarationToken(newConstructor("d", "(II)V")), is("d")); | 41 | assertThat(getDeclarationToken(newMethod("d", "<init>", "(II)V")), is("d")); |
| 46 | assertThat(getDeclarationToken(newConstructor("d", "(III)V")), is("d")); | 42 | assertThat(getDeclarationToken(newMethod("d", "<init>", "(III)V")), is("d")); |
| 47 | } | 43 | } |
| 48 | 44 | ||
| 49 | @Test | 45 | @Test |
| 50 | public void subsubDeclarations() { | 46 | public void subsubDeclarations() { |
| 51 | assertThat(getDeclarationToken(newConstructor("e", "(I)V")), is("e")); | 47 | assertThat(getDeclarationToken(newMethod("e", "<init>", "(I)V")), is("e")); |
| 52 | } | 48 | } |
| 53 | 49 | ||
| 54 | @Test | 50 | @Test |
| 55 | public void defaultDeclarations() { | 51 | public void defaultDeclarations() { |
| 56 | assertThat(getDeclarationToken(newConstructor("c", "()V")), nullValue()); | 52 | assertThat(getDeclarationToken(newMethod("c", "<init>", "()V")), nullValue()); |
| 57 | } | 53 | } |
| 58 | 54 | ||
| 59 | @Test | 55 | @Test |
| 60 | public void baseDefaultReferences() { | 56 | public void baseDefaultReferences() { |
| 61 | BehaviorEntry source = newConstructor("a", "()V"); | 57 | MethodEntry source = newMethod("a", "<init>", "()V"); |
| 62 | assertThat( | 58 | assertThat( |
| 63 | getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "a", "()V")), | 59 | getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "a", "()V")), |
| 64 | containsInAnyOrder("a") | 60 | containsInAnyOrder("a") |
| 65 | ); | 61 | ); |
| 66 | assertThat( | 62 | assertThat( |
| 67 | getReferenceTokens(newBehaviorReferenceByConstructor(source, "d", "()V")), | 63 | getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "<init>", "()V")), |
| 68 | is(empty()) // implicit call, not decompiled to token | 64 | is(empty()) // implicit call, not decompiled to token |
| 69 | ); | 65 | ); |
| 70 | assertThat( | 66 | assertThat( |
| 71 | getReferenceTokens(newBehaviorReferenceByConstructor(source, "d", "(III)V")), | 67 | getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "<init>", "(III)V")), |
| 72 | is(empty()) // implicit call, not decompiled to token | 68 | is(empty()) // implicit call, not decompiled to token |
| 73 | ); | 69 | ); |
| 74 | } | 70 | } |
| 75 | 71 | ||
| 76 | @Test | 72 | @Test |
| 77 | public void baseIntReferences() { | 73 | public void baseIntReferences() { |
| 78 | BehaviorEntry source = newConstructor("a", "(I)V"); | 74 | MethodEntry source = newMethod("a", "<init>", "(I)V"); |
| 79 | assertThat( | 75 | assertThat( |
| 80 | getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "b", "()V")), | 76 | getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "b", "()V")), |
| 81 | containsInAnyOrder("a") | 77 | containsInAnyOrder("a") |
| 82 | ); | 78 | ); |
| 83 | } | 79 | } |
| 84 | 80 | ||
| 85 | @Test | 81 | @Test |
| 86 | public void subDefaultReferences() { | 82 | public void subDefaultReferences() { |
| 87 | BehaviorEntry source = newConstructor("d", "()V"); | 83 | MethodEntry source = newMethod("d", "<init>", "()V"); |
| 88 | assertThat( | 84 | assertThat( |
| 89 | getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "c", "()V")), | 85 | getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "c", "()V")), |
| 90 | containsInAnyOrder("d") | 86 | containsInAnyOrder("d") |
| 91 | ); | 87 | ); |
| 92 | assertThat( | 88 | assertThat( |
| 93 | getReferenceTokens(newBehaviorReferenceByConstructor(source, "d", "(I)V")), | 89 | getReferenceTokens(newBehaviorReferenceByMethod(source, "d", "<init>", "(I)V")), |
| 94 | containsInAnyOrder("this") | 90 | containsInAnyOrder("this") |
| 95 | ); | 91 | ); |
| 96 | } | 92 | } |
| 97 | 93 | ||
| 98 | @Test | 94 | @Test |
| 99 | public void subIntReferences() { | 95 | public void subIntReferences() { |
| 100 | BehaviorEntry source = newConstructor("d", "(I)V"); | 96 | MethodEntry source = newMethod("d", "<init>", "(I)V"); |
| 101 | assertThat(getReferenceTokens( | 97 | assertThat(getReferenceTokens( |
| 102 | newBehaviorReferenceByMethod(source, "b", "d", "()V")), | 98 | newBehaviorReferenceByMethod(source, "b", "d", "()V")), |
| 103 | containsInAnyOrder("d") | 99 | containsInAnyOrder("d") |
| 104 | ); | 100 | ); |
| 105 | assertThat(getReferenceTokens( | 101 | assertThat(getReferenceTokens( |
| 106 | newBehaviorReferenceByConstructor(source, "d", "(II)V")), | 102 | newBehaviorReferenceByMethod(source, "d", "<init>", "(II)V")), |
| 107 | containsInAnyOrder("this") | 103 | containsInAnyOrder("this") |
| 108 | ); | 104 | ); |
| 109 | assertThat(getReferenceTokens( | 105 | assertThat(getReferenceTokens( |
| 110 | newBehaviorReferenceByConstructor(source, "e", "(I)V")), | 106 | newBehaviorReferenceByMethod(source, "e", "<init>", "(I)V")), |
| 111 | containsInAnyOrder("super") | 107 | containsInAnyOrder("super") |
| 112 | ); | 108 | ); |
| 113 | } | 109 | } |
| 114 | 110 | ||
| 115 | @Test | 111 | @Test |
| 116 | public void subIntIntReferences() { | 112 | public void subIntIntReferences() { |
| 117 | BehaviorEntry source = newConstructor("d", "(II)V"); | 113 | MethodEntry source = newMethod("d", "<init>", "(II)V"); |
| 118 | assertThat( | 114 | assertThat( |
| 119 | getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "e", "()V")), | 115 | getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "e", "()V")), |
| 120 | containsInAnyOrder("d") | 116 | containsInAnyOrder("d") |
| 121 | ); | 117 | ); |
| 122 | } | 118 | } |
| 123 | 119 | ||
| 124 | @Test | 120 | @Test |
| 125 | public void subsubIntReferences() { | 121 | public void subsubIntReferences() { |
| 126 | BehaviorEntry source = newConstructor("e", "(I)V"); | 122 | MethodEntry source = newMethod("e", "<init>", "(I)V"); |
| 127 | assertThat( | 123 | assertThat( |
| 128 | getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "f", "()V")), | 124 | getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "f", "()V")), |
| 129 | containsInAnyOrder("e") | 125 | containsInAnyOrder("e") |
| 130 | ); | 126 | ); |
| 131 | } | 127 | } |
| 132 | 128 | ||
| 133 | @Test | 129 | @Test |
| 134 | public void defaultConstructableReferences() { | 130 | public void defaultConstructableReferences() { |
| 135 | BehaviorEntry source = newConstructor("c", "()V"); | 131 | MethodEntry source = newMethod("c", "<init>", "()V"); |
| 136 | assertThat( | 132 | assertThat( |
| 137 | getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "g", "()V")), | 133 | getReferenceTokens(newBehaviorReferenceByMethod(source, "b", "g", "()V")), |
| 138 | containsInAnyOrder("c") | 134 | containsInAnyOrder("c") |
| 139 | ); | 135 | ); |
| 140 | } | 136 | } |
| 141 | } | 137 | } |