summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/convert/MappingsConverter.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cuchaz/enigma/convert/MappingsConverter.java')
-rw-r--r--src/main/java/cuchaz/enigma/convert/MappingsConverter.java53
1 files changed, 22 insertions, 31 deletions
diff --git a/src/main/java/cuchaz/enigma/convert/MappingsConverter.java b/src/main/java/cuchaz/enigma/convert/MappingsConverter.java
index 929c89f..a5ded67 100644
--- a/src/main/java/cuchaz/enigma/convert/MappingsConverter.java
+++ b/src/main/java/cuchaz/enigma/convert/MappingsConverter.java
@@ -11,7 +11,6 @@
11package cuchaz.enigma.convert; 11package cuchaz.enigma.convert;
12 12
13import com.google.common.collect.*; 13import com.google.common.collect.*;
14import cuchaz.enigma.Constants;
15import cuchaz.enigma.Deobfuscator; 14import cuchaz.enigma.Deobfuscator;
16import cuchaz.enigma.TranslatingTypeLoader; 15import cuchaz.enigma.TranslatingTypeLoader;
17import cuchaz.enigma.analysis.JarIndex; 16import cuchaz.enigma.analysis.JarIndex;
@@ -24,7 +23,6 @@ import javassist.NotFoundException;
24import javassist.bytecode.BadBytecode; 23import javassist.bytecode.BadBytecode;
25import javassist.bytecode.CodeAttribute; 24import javassist.bytecode.CodeAttribute;
26import javassist.bytecode.CodeIterator; 25import javassist.bytecode.CodeIterator;
27import javassist.bytecode.MethodInfo;
28 26
29import java.util.*; 27import java.util.*;
30import java.util.jar.JarFile; 28import java.util.jar.JarFile;
@@ -174,15 +172,13 @@ public class MappingsConverter {
174 172
175 private static ClassMapping migrateClassMapping(ClassEntry newObfClass, ClassMapping oldClassMapping, final ClassMatches matches, boolean useSimpleName) { 173 private static ClassMapping migrateClassMapping(ClassEntry newObfClass, ClassMapping oldClassMapping, final ClassMatches matches, boolean useSimpleName) {
176 174
177 ClassNameReplacer replacer = new ClassNameReplacer() { 175 ClassNameReplacer replacer = className ->
178 @Override 176 {
179 public String replace(String className) { 177 ClassEntry newClassEntry = matches.getUniqueMatches().get(new ClassEntry(className));
180 ClassEntry newClassEntry = matches.getUniqueMatches().get(new ClassEntry(className)); 178 if (newClassEntry != null) {
181 if (newClassEntry != null) { 179 return newClassEntry.getName();
182 return newClassEntry.getName();
183 }
184 return null;
185 } 180 }
181 return null;
186 }; 182 };
187 183
188 ClassMapping newClassMapping; 184 ClassMapping newClassMapping;
@@ -434,13 +430,12 @@ public class MappingsConverter {
434 // Empty method body, ignore! 430 // Empty method body, ignore!
435 if (sourceAttribute == null) 431 if (sourceAttribute == null)
436 return null; 432 return null;
437 Iterator<BehaviorEntry> it = obfDestEntries.iterator(); 433 for (BehaviorEntry desEntry : obfDestEntries)
438 while (it.hasNext())
439 { 434 {
440 BehaviorEntry desEntry = it.next();
441 try 435 try
442 { 436 {
443 CtMethod destCtClassMethod = destCtClass.getMethod(desEntry.getName(), desEntry.getSignature().toString()); 437 CtMethod destCtClassMethod = destCtClass
438 .getMethod(desEntry.getName(), desEntry.getSignature().toString());
444 CodeAttribute destAttribute = destCtClassMethod.getMethodInfo().getCodeAttribute(); 439 CodeAttribute destAttribute = destCtClassMethod.getMethodInfo().getCodeAttribute();
445 440
446 // Ignore empty body methods 441 // Ignore empty body methods
@@ -533,7 +528,7 @@ public class MappingsConverter {
533 528
534 public static <T extends Entry> MemberMatches<T> computeMemberMatches(Deobfuscator destDeobfuscator, Mappings destMappings, ClassMatches classMatches, Doer<T> doer) { 529 public static <T extends Entry> MemberMatches<T> computeMemberMatches(Deobfuscator destDeobfuscator, Mappings destMappings, ClassMatches classMatches, Doer<T> doer) {
535 530
536 MemberMatches<T> memberMatches = new MemberMatches<T>(); 531 MemberMatches<T> memberMatches = new MemberMatches<>();
537 532
538 // unmatched source fields are easy 533 // unmatched source fields are easy
539 MappingsChecker checker = new MappingsChecker(destDeobfuscator.getJarIndex()); 534 MappingsChecker checker = new MappingsChecker(destDeobfuscator.getJarIndex());
@@ -624,15 +619,13 @@ public class MappingsConverter {
624 } 619 }
625 620
626 private static Type translate(Type type, final BiMap<ClassEntry, ClassEntry> map) { 621 private static Type translate(Type type, final BiMap<ClassEntry, ClassEntry> map) {
627 return new Type(type, new ClassNameReplacer() { 622 return new Type(type, inClassName ->
628 @Override 623 {
629 public String replace(String inClassName) { 624 ClassEntry outClassEntry = map.get(new ClassEntry(inClassName));
630 ClassEntry outClassEntry = map.get(new ClassEntry(inClassName)); 625 if (outClassEntry == null) {
631 if (outClassEntry == null) { 626 return null;
632 return null;
633 }
634 return outClassEntry.getName();
635 } 627 }
628 return outClassEntry.getName();
636 }); 629 });
637 } 630 }
638 631
@@ -640,15 +633,13 @@ public class MappingsConverter {
640 if (signature == null) { 633 if (signature == null) {
641 return null; 634 return null;
642 } 635 }
643 return new Signature(signature, new ClassNameReplacer() { 636 return new Signature(signature, inClassName ->
644 @Override 637 {
645 public String replace(String inClassName) { 638 ClassEntry outClassEntry = map.get(new ClassEntry(inClassName));
646 ClassEntry outClassEntry = map.get(new ClassEntry(inClassName)); 639 if (outClassEntry == null) {
647 if (outClassEntry == null) { 640 return null;
648 return null;
649 }
650 return outClassEntry.getName();
651 } 641 }
642 return outClassEntry.getName();
652 }); 643 });
653 } 644 }
654 645