diff options
| author | 2015-02-25 22:42:34 -0500 | |
|---|---|---|
| committer | 2015-02-25 22:42:34 -0500 | |
| commit | 9809078524bd3bd40fbf7aa411f6e0dca02fd009 (patch) | |
| tree | 19f9ee0613231c747e728bc61f8a1b6ffa58e5b7 /src/cuchaz/enigma/analysis/JarIndex.java | |
| parent | more work getting inner class trees working in obf'd and deobf'd land (diff) | |
| download | enigma-fork-9809078524bd3bd40fbf7aa411f6e0dca02fd009.tar.gz enigma-fork-9809078524bd3bd40fbf7aa411f6e0dca02fd009.tar.xz enigma-fork-9809078524bd3bd40fbf7aa411f6e0dca02fd009.zip | |
fixed lots of issues with inner class reconstruction, particularly for inner class trees
also fixed lots of issues with reading jars that aren't Minecraft. =P
Diffstat (limited to 'src/cuchaz/enigma/analysis/JarIndex.java')
| -rw-r--r-- | src/cuchaz/enigma/analysis/JarIndex.java | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/cuchaz/enigma/analysis/JarIndex.java b/src/cuchaz/enigma/analysis/JarIndex.java index 1afcb76..e0a8bf5 100644 --- a/src/cuchaz/enigma/analysis/JarIndex.java +++ b/src/cuchaz/enigma/analysis/JarIndex.java | |||
| @@ -12,6 +12,7 @@ package cuchaz.enigma.analysis; | |||
| 12 | 12 | ||
| 13 | import java.lang.reflect.Modifier; | 13 | import java.lang.reflect.Modifier; |
| 14 | import java.util.Collection; | 14 | import java.util.Collection; |
| 15 | import java.util.Collections; | ||
| 15 | import java.util.HashSet; | 16 | import java.util.HashSet; |
| 16 | import java.util.List; | 17 | import java.util.List; |
| 17 | import java.util.Map; | 18 | import java.util.Map; |
| @@ -156,11 +157,8 @@ public class JarIndex { | |||
| 156 | 157 | ||
| 157 | // step 6: update other indices with inner class info | 158 | // step 6: update other indices with inner class info |
| 158 | Map<String,String> renames = Maps.newHashMap(); | 159 | Map<String,String> renames = Maps.newHashMap(); |
| 159 | for (Map.Entry<ClassEntry,ClassEntry> mapEntry : m_innerClassesByOuter.entries()) { | 160 | for (ClassEntry innerClassEntry : m_innerClassesByOuter.values()) { |
| 160 | ClassEntry outerClassEntry = mapEntry.getKey(); | 161 | String newName = innerClassEntry.buildClassEntry(getObfClassChain(innerClassEntry)).getName(); |
| 161 | ClassEntry innerClassEntry = mapEntry.getValue(); | ||
| 162 | outerClassEntry = EntryFactory.getChainedOuterClassName(this, outerClassEntry); | ||
| 163 | String newName = outerClassEntry.getName() + "$" + innerClassEntry.getSimpleName(); | ||
| 164 | if (!innerClassEntry.getName().equals(newName)) { | 162 | if (!innerClassEntry.getName().equals(newName)) { |
| 165 | // DEBUG | 163 | // DEBUG |
| 166 | //System.out.println("REPLACE: " + innerClassEntry.getName() + " WITH " + newName); | 164 | //System.out.println("REPLACE: " + innerClassEntry.getName() + " WITH " + newName); |
| @@ -780,4 +778,25 @@ public class JarIndex { | |||
| 780 | public MethodEntry getBridgedMethod(MethodEntry bridgeMethodEntry) { | 778 | public MethodEntry getBridgedMethod(MethodEntry bridgeMethodEntry) { |
| 781 | return m_bridgedMethods.get(bridgeMethodEntry); | 779 | return m_bridgedMethods.get(bridgeMethodEntry); |
| 782 | } | 780 | } |
| 781 | |||
| 782 | public List<ClassEntry> getObfClassChain(ClassEntry obfClassEntry) { | ||
| 783 | |||
| 784 | // build class chain in inner-to-outer order | ||
| 785 | List<ClassEntry> obfClassChain = Lists.newArrayList(obfClassEntry); | ||
| 786 | ClassEntry checkClassEntry = obfClassEntry; | ||
| 787 | while (true) { | ||
| 788 | ClassEntry obfOuterClassEntry = getOuterClass(checkClassEntry); | ||
| 789 | if (obfOuterClassEntry != null) { | ||
| 790 | obfClassChain.add(obfOuterClassEntry); | ||
| 791 | checkClassEntry = obfOuterClassEntry; | ||
| 792 | } else { | ||
| 793 | break; | ||
| 794 | } | ||
| 795 | } | ||
| 796 | |||
| 797 | // switch to outer-to-inner order | ||
| 798 | Collections.reverse(obfClassChain); | ||
| 799 | |||
| 800 | return obfClassChain; | ||
| 801 | } | ||
| 783 | } | 802 | } |