diff options
| -rw-r--r-- | src/cuchaz/enigma/bytecode/ClassTranslator.java | 28 | ||||
| -rw-r--r-- | src/cuchaz/enigma/mapping/EntryFactory.java | 4 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/cuchaz/enigma/bytecode/ClassTranslator.java b/src/cuchaz/enigma/bytecode/ClassTranslator.java index 7952577b..32518d9c 100644 --- a/src/cuchaz/enigma/bytecode/ClassTranslator.java +++ b/src/cuchaz/enigma/bytecode/ClassTranslator.java | |||
| @@ -16,6 +16,7 @@ import javassist.CtField; | |||
| 16 | import javassist.CtMethod; | 16 | import javassist.CtMethod; |
| 17 | import javassist.bytecode.ConstPool; | 17 | import javassist.bytecode.ConstPool; |
| 18 | import javassist.bytecode.Descriptor; | 18 | import javassist.bytecode.Descriptor; |
| 19 | import javassist.bytecode.EnclosingMethodAttribute; | ||
| 19 | import javassist.bytecode.SourceFileAttribute; | 20 | import javassist.bytecode.SourceFileAttribute; |
| 20 | import cuchaz.enigma.mapping.BehaviorEntry; | 21 | import cuchaz.enigma.mapping.BehaviorEntry; |
| 21 | import cuchaz.enigma.mapping.ClassEntry; | 22 | import cuchaz.enigma.mapping.ClassEntry; |
| @@ -115,6 +116,33 @@ public class ClassTranslator { | |||
| 115 | } | 116 | } |
| 116 | } | 117 | } |
| 117 | 118 | ||
| 119 | // translate the EnclosingMethod attribute | ||
| 120 | EnclosingMethodAttribute enclosingMethodAttr = (EnclosingMethodAttribute)c.getClassFile().getAttribute(EnclosingMethodAttribute.tag); | ||
| 121 | if (enclosingMethodAttr != null) { | ||
| 122 | |||
| 123 | if (enclosingMethodAttr.methodIndex() == 0) { | ||
| 124 | BehaviorEntry obfBehaviorEntry = EntryFactory.getBehaviorEntry(Descriptor.toJvmName(enclosingMethodAttr.className())); | ||
| 125 | BehaviorEntry deobfBehaviorEntry = m_translator.translateEntry(obfBehaviorEntry); | ||
| 126 | c.getClassFile().addAttribute(new EnclosingMethodAttribute( | ||
| 127 | constants, | ||
| 128 | deobfBehaviorEntry.getClassName() | ||
| 129 | )); | ||
| 130 | } else { | ||
| 131 | BehaviorEntry obfBehaviorEntry = EntryFactory.getBehaviorEntry( | ||
| 132 | Descriptor.toJvmName(enclosingMethodAttr.className()), | ||
| 133 | enclosingMethodAttr.methodName(), | ||
| 134 | enclosingMethodAttr.methodDescriptor() | ||
| 135 | ); | ||
| 136 | BehaviorEntry deobfBehaviorEntry = m_translator.translateEntry(obfBehaviorEntry); | ||
| 137 | c.getClassFile().addAttribute(new EnclosingMethodAttribute( | ||
| 138 | constants, | ||
| 139 | deobfBehaviorEntry.getClassName(), | ||
| 140 | deobfBehaviorEntry.getName(), | ||
| 141 | deobfBehaviorEntry.getSignature().toString() | ||
| 142 | )); | ||
| 143 | } | ||
| 144 | } | ||
| 145 | |||
| 118 | // translate all the class names referenced in the code | 146 | // translate all the class names referenced in the code |
| 119 | // the above code only changed method/field/reference names and types, but not the rest of the class references | 147 | // the above code only changed method/field/reference names and types, but not the rest of the class references |
| 120 | ClassRenamer.renameClasses(c, m_translator); | 148 | ClassRenamer.renameClasses(c, m_translator); |
diff --git a/src/cuchaz/enigma/mapping/EntryFactory.java b/src/cuchaz/enigma/mapping/EntryFactory.java index 4898e6de..69c1630f 100644 --- a/src/cuchaz/enigma/mapping/EntryFactory.java +++ b/src/cuchaz/enigma/mapping/EntryFactory.java | |||
| @@ -156,6 +156,10 @@ public class EntryFactory { | |||
| 156 | return getBehaviorEntry(new ClassEntry(className), behaviorName); | 156 | return getBehaviorEntry(new ClassEntry(className), behaviorName); |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | public static BehaviorEntry getBehaviorEntry(String className) { | ||
| 160 | return new ConstructorEntry(new ClassEntry(className)); | ||
| 161 | } | ||
| 162 | |||
| 159 | public static BehaviorEntry getBehaviorEntry(ClassEntry classEntry, String behaviorName, Signature behaviorSignature) { | 163 | public static BehaviorEntry getBehaviorEntry(ClassEntry classEntry, String behaviorName, Signature behaviorSignature) { |
| 160 | if (behaviorName.equals("<init>")) { | 164 | if (behaviorName.equals("<init>")) { |
| 161 | return new ConstructorEntry(classEntry, behaviorSignature); | 165 | return new ConstructorEntry(classEntry, behaviorSignature); |