summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/mapping/FieldMapping.java
diff options
context:
space:
mode:
authorGravatar gegy10002018-07-17 19:14:08 +0200
committerGravatar GitHub2018-07-17 19:14:08 +0200
commita88175ffc95792b88a8724f66db6dda2b8cc32ee (patch)
tree65895bbc6cf1766f4ca01e1257619ab1993e71dc /src/main/java/cuchaz/enigma/mapping/FieldMapping.java
parentMerge pull request #3 from thiakil/src-jar (diff)
downloadenigma-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/main/java/cuchaz/enigma/mapping/FieldMapping.java')
-rw-r--r--src/main/java/cuchaz/enigma/mapping/FieldMapping.java38
1 files changed, 16 insertions, 22 deletions
diff --git a/src/main/java/cuchaz/enigma/mapping/FieldMapping.java b/src/main/java/cuchaz/enigma/mapping/FieldMapping.java
index cd761b4..8fbe095 100644
--- a/src/main/java/cuchaz/enigma/mapping/FieldMapping.java
+++ b/src/main/java/cuchaz/enigma/mapping/FieldMapping.java
@@ -11,32 +11,27 @@
11 11
12package cuchaz.enigma.mapping; 12package cuchaz.enigma.mapping;
13 13
14import cuchaz.enigma.mapping.entry.ClassEntry;
15import cuchaz.enigma.mapping.entry.FieldEntry;
14import cuchaz.enigma.throwables.IllegalNameException; 16import cuchaz.enigma.throwables.IllegalNameException;
15 17
16public class FieldMapping implements Comparable<FieldMapping>, MemberMapping<FieldEntry> { 18public class FieldMapping implements Comparable<FieldMapping>, MemberMapping<FieldEntry> {
17 19
18 private String obfName; 20 private String obfName;
19 private String deobfName; 21 private String deobfName;
20 private Type obfType; 22 private TypeDescriptor obfDesc;
21 private Mappings.EntryModifier modifier; 23 private Mappings.EntryModifier modifier;
22 24
23 public FieldMapping(String obfName, Type obfType, String deobfName, Mappings.EntryModifier modifier) { 25 public FieldMapping(String obfName, TypeDescriptor obfDesc, String deobfName, Mappings.EntryModifier modifier) {
24 this.obfName = obfName; 26 this.obfName = obfName;
25 this.deobfName = NameValidator.validateFieldName(deobfName); 27 this.deobfName = NameValidator.validateFieldName(deobfName);
26 this.obfType = obfType; 28 this.obfDesc = obfDesc;
27 this.modifier = modifier; 29 this.modifier = modifier;
28 } 30 }
29 31
30 public FieldMapping(FieldMapping other, ClassNameReplacer obfClassNameReplacer) {
31 this.obfName = other.obfName;
32 this.deobfName = other.deobfName;
33 this.modifier = other.modifier;
34 this.obfType = new Type(other.obfType, obfClassNameReplacer);
35 }
36
37 @Override 32 @Override
38 public FieldEntry getObfEntry(ClassEntry classEntry) { 33 public FieldEntry getObfEntry(ClassEntry classEntry) {
39 return new FieldEntry(classEntry, this.obfName, this.obfType); 34 return new FieldEntry(classEntry, this.obfName, this.obfDesc);
40 } 35 }
41 36
42 @Override 37 @Override
@@ -65,12 +60,12 @@ public class FieldMapping implements Comparable<FieldMapping>, MemberMapping<Fie
65 this.deobfName = NameValidator.validateFieldName(val); 60 this.deobfName = NameValidator.validateFieldName(val);
66 } 61 }
67 62
68 public Type getObfType() { 63 public TypeDescriptor getObfDesc() {
69 return this.obfType; 64 return this.obfDesc;
70 } 65 }
71 66
72 public void setObfType(Type val) { 67 public void setObfDesc(TypeDescriptor val) {
73 this.obfType = val; 68 this.obfDesc = val;
74 } 69 }
75 70
76 public Mappings.EntryModifier getModifier() { 71 public Mappings.EntryModifier getModifier() {
@@ -83,21 +78,20 @@ public class FieldMapping implements Comparable<FieldMapping>, MemberMapping<Fie
83 78
84 @Override 79 @Override
85 public int compareTo(FieldMapping other) { 80 public int compareTo(FieldMapping other) {
86 return (this.obfName + this.obfType).compareTo(other.obfName + other.obfType); 81 return (this.obfName + this.obfDesc).compareTo(other.obfName + other.obfDesc);
87 } 82 }
88 83
89 public boolean renameObfClass(final String oldObfClassName, final String newObfClassName) { 84 public boolean renameObfClass(final String oldObfClassName, final String newObfClassName) {
90 // rename obf classes in the type 85 // rename obf classes in the desc
91 Type newType = new Type(this.obfType, className -> 86 TypeDescriptor newDesc = this.obfDesc.remap(className -> {
92 {
93 if (className.equals(oldObfClassName)) { 87 if (className.equals(oldObfClassName)) {
94 return newObfClassName; 88 return newObfClassName;
95 } 89 }
96 return null; 90 return className;
97 }); 91 });
98 92
99 if (!newType.equals(this.obfType)) { 93 if (!newDesc.equals(this.obfDesc)) {
100 this.obfType = newType; 94 this.obfDesc = newDesc;
101 return true; 95 return true;
102 } 96 }
103 return false; 97 return false;