From 7defa283eb2c6d4c540f7cdf94f862c93775c8a4 Mon Sep 17 00:00:00 2001 From: asiekierka Date: Wed, 17 Aug 2016 19:54:22 +0200 Subject: Fix #4, at least to the extent we currently need it --- src/main/java/cuchaz/enigma/ConvertMain.java | 5 +---- src/main/java/cuchaz/enigma/convert/MappingsConverter.java | 10 ++++++++-- src/main/java/cuchaz/enigma/mapping/ClassEntry.java | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/cuchaz/enigma/ConvertMain.java b/src/main/java/cuchaz/enigma/ConvertMain.java index 4c6be7fd..67baeae9 100644 --- a/src/main/java/cuchaz/enigma/ConvertMain.java +++ b/src/main/java/cuchaz/enigma/ConvertMain.java @@ -308,11 +308,8 @@ public class ConvertMain { System.out.println("WARNING: Broken behavior entry " + mapping.getKey() + " (" + mapping.getValue().getDeobfName() + ")"); } - //TODO Fix // write out the converted mappings -// try (FileWriter out = new FileWriter(outMappingsFile)) { -// new MappingsWriter().write(out, newMappings); -// } + new MappingsEnigmaWriter().write(outMappingsFile, newMappings, true); System.out.println("Wrote converted mappings to:\n\t" + outMappingsFile.getAbsolutePath()); } diff --git a/src/main/java/cuchaz/enigma/convert/MappingsConverter.java b/src/main/java/cuchaz/enigma/convert/MappingsConverter.java index 61b0e7ef..4b4bb812 100644 --- a/src/main/java/cuchaz/enigma/convert/MappingsConverter.java +++ b/src/main/java/cuchaz/enigma/convert/MappingsConverter.java @@ -117,13 +117,19 @@ public class MappingsConverter { Collections.sort(chainSizes); for (int chainSize : chainSizes) { for (java.util.Map.Entry match : matchesByDestChainSize.get(chainSize)) { - // get class info ClassEntry obfSourceClassEntry = match.getKey(); ClassEntry obfDestClassEntry = match.getValue(); List destClassChain = destDeobfuscator.getJarIndex().getObfClassChain(obfDestClassEntry); - ClassMapping sourceMapping = sourceDeobfuscator.getMappings().getClassByObf(obfSourceClassEntry); + ClassMapping sourceMapping; + if (obfSourceClassEntry.isInnerClass()) { + List srcClassChain = sourceDeobfuscator.getMappings().getClassMappingChain(obfSourceClassEntry); + sourceMapping = srcClassChain.get(srcClassChain.size() - 1); + } else { + sourceMapping = sourceDeobfuscator.getMappings().getClassByObf(obfSourceClassEntry); + } + if (sourceMapping == null) { // if this class was never deobfuscated, don't try to match it continue; diff --git a/src/main/java/cuchaz/enigma/mapping/ClassEntry.java b/src/main/java/cuchaz/enigma/mapping/ClassEntry.java index a58d0548..398b1355 100644 --- a/src/main/java/cuchaz/enigma/mapping/ClassEntry.java +++ b/src/main/java/cuchaz/enigma/mapping/ClassEntry.java @@ -68,7 +68,7 @@ public class ClassEntry implements Entry { } public boolean equals(ClassEntry other) { - return this.name.equals(other.name); + return other != null && this.name.equals(other.name); } @Override -- cgit v1.2.3