diff options
| author | 2016-07-02 18:04:57 +1000 | |
|---|---|---|
| committer | 2016-07-02 18:04:57 +1000 | |
| commit | 64c359d3c1d2347001e5c6becb1d7561457f52cc (patch) | |
| tree | bc2f37325b770475237437d204e95254dbfa0b3d /src/main/java/cuchaz/enigma/analysis | |
| parent | Fixed Null.json and #4 (diff) | |
| download | enigma-fork-64c359d3c1d2347001e5c6becb1d7561457f52cc.tar.gz enigma-fork-64c359d3c1d2347001e5c6becb1d7561457f52cc.tar.xz enigma-fork-64c359d3c1d2347001e5c6becb1d7561457f52cc.zip | |
Renamed Fields
Diffstat (limited to 'src/main/java/cuchaz/enigma/analysis')
16 files changed, 279 insertions, 316 deletions
diff --git a/src/main/java/cuchaz/enigma/analysis/BehaviorReferenceTreeNode.java b/src/main/java/cuchaz/enigma/analysis/BehaviorReferenceTreeNode.java index 776f090..39ff449 100644 --- a/src/main/java/cuchaz/enigma/analysis/BehaviorReferenceTreeNode.java +++ b/src/main/java/cuchaz/enigma/analysis/BehaviorReferenceTreeNode.java | |||
| @@ -31,50 +31,50 @@ public class BehaviorReferenceTreeNode extends DefaultMutableTreeNode implements | |||
| 31 | private Access m_access; | 31 | private Access m_access; |
| 32 | 32 | ||
| 33 | public BehaviorReferenceTreeNode(Translator deobfuscatingTranslator, BehaviorEntry entry) { | 33 | public BehaviorReferenceTreeNode(Translator deobfuscatingTranslator, BehaviorEntry entry) { |
| 34 | m_deobfuscatingTranslator = deobfuscatingTranslator; | 34 | this.m_deobfuscatingTranslator = deobfuscatingTranslator; |
| 35 | m_entry = entry; | 35 | this.m_entry = entry; |
| 36 | m_reference = null; | 36 | this.m_reference = null; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | public BehaviorReferenceTreeNode(Translator deobfuscatingTranslator, EntryReference<BehaviorEntry, BehaviorEntry> reference, Access access) { | 39 | public BehaviorReferenceTreeNode(Translator deobfuscatingTranslator, EntryReference<BehaviorEntry, BehaviorEntry> reference, Access access) { |
| 40 | m_deobfuscatingTranslator = deobfuscatingTranslator; | 40 | this.m_deobfuscatingTranslator = deobfuscatingTranslator; |
| 41 | m_entry = reference.entry; | 41 | this.m_entry = reference.entry; |
| 42 | m_reference = reference; | 42 | this.m_reference = reference; |
| 43 | m_access = access; | 43 | this.m_access = access; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | @Override | 46 | @Override |
| 47 | public BehaviorEntry getEntry() { | 47 | public BehaviorEntry getEntry() { |
| 48 | return m_entry; | 48 | return this.m_entry; |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | @Override | 51 | @Override |
| 52 | public EntryReference<BehaviorEntry, BehaviorEntry> getReference() { | 52 | public EntryReference<BehaviorEntry, BehaviorEntry> getReference() { |
| 53 | return m_reference; | 53 | return this.m_reference; |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | @Override | 56 | @Override |
| 57 | public String toString() { | 57 | public String toString() { |
| 58 | if (m_reference != null) { | 58 | if (this.m_reference != null) { |
| 59 | return String.format("%s (%s)", m_deobfuscatingTranslator.translateEntry(m_reference.context), m_access); | 59 | return String.format("%s (%s)", this.m_deobfuscatingTranslator.translateEntry(this.m_reference.context), this.m_access); |
| 60 | } | 60 | } |
| 61 | return m_deobfuscatingTranslator.translateEntry(m_entry).toString(); | 61 | return this.m_deobfuscatingTranslator.translateEntry(this.m_entry).toString(); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | public void load(JarIndex index, boolean recurse) { | 64 | public void load(JarIndex index, boolean recurse) { |
| 65 | // get all the child nodes | 65 | // get all the child nodes |
| 66 | for (EntryReference<BehaviorEntry, BehaviorEntry> reference : index.getBehaviorReferences(m_entry)) { | 66 | for (EntryReference<BehaviorEntry, BehaviorEntry> reference : index.getBehaviorReferences(this.m_entry)) { |
| 67 | add(new BehaviorReferenceTreeNode(m_deobfuscatingTranslator, reference, index.getAccess(m_entry))); | 67 | add(new BehaviorReferenceTreeNode(this.m_deobfuscatingTranslator, reference, index.getAccess(this.m_entry))); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | if (recurse && children != null) { | 70 | if (recurse && this.children != null) { |
| 71 | for (Object child : children) { | 71 | for (Object child : this.children) { |
| 72 | if (child instanceof BehaviorReferenceTreeNode) { | 72 | if (child instanceof BehaviorReferenceTreeNode) { |
| 73 | BehaviorReferenceTreeNode node = (BehaviorReferenceTreeNode) child; | 73 | BehaviorReferenceTreeNode node = (BehaviorReferenceTreeNode) child; |
| 74 | 74 | ||
| 75 | // don't recurse into ancestor | 75 | // don't recurse into ancestor |
| 76 | Set<Entry> ancestors = Sets.newHashSet(); | 76 | Set<Entry> ancestors = Sets.newHashSet(); |
| 77 | TreeNode n = (TreeNode) node; | 77 | TreeNode n = node; |
| 78 | while (n.getParent() != null) { | 78 | while (n.getParent() != null) { |
| 79 | n = n.getParent(); | 79 | n = n.getParent(); |
| 80 | if (n instanceof BehaviorReferenceTreeNode) { | 80 | if (n instanceof BehaviorReferenceTreeNode) { |
diff --git a/src/main/java/cuchaz/enigma/analysis/BridgeMarker.java b/src/main/java/cuchaz/enigma/analysis/BridgeMarker.java index 1df7625..cd18584 100644 --- a/src/main/java/cuchaz/enigma/analysis/BridgeMarker.java +++ b/src/main/java/cuchaz/enigma/analysis/BridgeMarker.java | |||
| @@ -21,7 +21,7 @@ public class BridgeMarker { | |||
| 21 | private JarIndex m_jarIndex; | 21 | private JarIndex m_jarIndex; |
| 22 | 22 | ||
| 23 | public BridgeMarker(JarIndex jarIndex) { | 23 | public BridgeMarker(JarIndex jarIndex) { |
| 24 | m_jarIndex = jarIndex; | 24 | this.m_jarIndex = jarIndex; |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | public void markBridges(CtClass c) { | 27 | public void markBridges(CtClass c) { |
| @@ -30,7 +30,7 @@ public class BridgeMarker { | |||
| 30 | MethodEntry methodEntry = EntryFactory.getMethodEntry(method); | 30 | MethodEntry methodEntry = EntryFactory.getMethodEntry(method); |
| 31 | 31 | ||
| 32 | // is this a bridge method? | 32 | // is this a bridge method? |
| 33 | MethodEntry bridgedMethodEntry = m_jarIndex.getBridgedMethod(methodEntry); | 33 | MethodEntry bridgedMethodEntry = this.m_jarIndex.getBridgedMethod(methodEntry); |
| 34 | if (bridgedMethodEntry != null) { | 34 | if (bridgedMethodEntry != null) { |
| 35 | 35 | ||
| 36 | // it's a bridge method! add the bridge flag | 36 | // it's a bridge method! add the bridge flag |
diff --git a/src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java b/src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java index 8f8986c..3420cd6 100644 --- a/src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java +++ b/src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java | |||
| @@ -24,27 +24,27 @@ public class ClassImplementationsTreeNode extends DefaultMutableTreeNode { | |||
| 24 | 24 | ||
| 25 | private static final long serialVersionUID = 3112703459157851912L; | 25 | private static final long serialVersionUID = 3112703459157851912L; |
| 26 | 26 | ||
| 27 | private Translator m_deobfuscatingTranslator; | 27 | private Translator deobfuscatingTranslator; |
| 28 | private ClassEntry m_entry; | 28 | private ClassEntry entry; |
| 29 | 29 | ||
| 30 | public ClassImplementationsTreeNode(Translator deobfuscatingTranslator, ClassEntry entry) { | 30 | public ClassImplementationsTreeNode(Translator deobfuscatingTranslator, ClassEntry entry) { |
| 31 | m_deobfuscatingTranslator = deobfuscatingTranslator; | 31 | this.deobfuscatingTranslator = deobfuscatingTranslator; |
| 32 | m_entry = entry; | 32 | this.entry = entry; |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | public ClassEntry getClassEntry() { | 35 | public ClassEntry getClassEntry() { |
| 36 | return m_entry; | 36 | return this.entry; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | public String getDeobfClassName() { | 39 | public String getDeobfClassName() { |
| 40 | return m_deobfuscatingTranslator.translateClass(m_entry.getClassName()); | 40 | return this.deobfuscatingTranslator.translateClass(this.entry.getClassName()); |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | @Override | 43 | @Override |
| 44 | public String toString() { | 44 | public String toString() { |
| 45 | String className = getDeobfClassName(); | 45 | String className = getDeobfClassName(); |
| 46 | if (className == null) { | 46 | if (className == null) { |
| 47 | className = m_entry.getClassName(); | 47 | className = this.entry.getClassName(); |
| 48 | } | 48 | } |
| 49 | return className; | 49 | return className; |
| 50 | } | 50 | } |
| @@ -52,8 +52,8 @@ public class ClassImplementationsTreeNode extends DefaultMutableTreeNode { | |||
| 52 | public void load(JarIndex index) { | 52 | public void load(JarIndex index) { |
| 53 | // get all method implementations | 53 | // get all method implementations |
| 54 | List<ClassImplementationsTreeNode> nodes = Lists.newArrayList(); | 54 | List<ClassImplementationsTreeNode> nodes = Lists.newArrayList(); |
| 55 | for (String implementingClassName : index.getImplementingClasses(m_entry.getClassName())) { | 55 | for (String implementingClassName : index.getImplementingClasses(this.entry.getClassName())) { |
| 56 | nodes.add(new ClassImplementationsTreeNode(m_deobfuscatingTranslator, new ClassEntry(implementingClassName))); | 56 | nodes.add(new ClassImplementationsTreeNode(this.deobfuscatingTranslator, new ClassEntry(implementingClassName))); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | // add them to this node | 59 | // add them to this node |
| @@ -62,7 +62,7 @@ public class ClassImplementationsTreeNode extends DefaultMutableTreeNode { | |||
| 62 | 62 | ||
| 63 | public static ClassImplementationsTreeNode findNode(ClassImplementationsTreeNode node, MethodEntry entry) { | 63 | public static ClassImplementationsTreeNode findNode(ClassImplementationsTreeNode node, MethodEntry entry) { |
| 64 | // is this the node? | 64 | // is this the node? |
| 65 | if (node.m_entry.equals(entry)) { | 65 | if (node.entry.equals(entry)) { |
| 66 | return node; | 66 | return node; |
| 67 | } | 67 | } |
| 68 | 68 | ||
diff --git a/src/main/java/cuchaz/enigma/analysis/ClassInheritanceTreeNode.java b/src/main/java/cuchaz/enigma/analysis/ClassInheritanceTreeNode.java index ca2b821..beac9d5 100644 --- a/src/main/java/cuchaz/enigma/analysis/ClassInheritanceTreeNode.java +++ b/src/main/java/cuchaz/enigma/analysis/ClassInheritanceTreeNode.java | |||
| @@ -23,20 +23,20 @@ public class ClassInheritanceTreeNode extends DefaultMutableTreeNode { | |||
| 23 | 23 | ||
| 24 | private static final long serialVersionUID = 4432367405826178490L; | 24 | private static final long serialVersionUID = 4432367405826178490L; |
| 25 | 25 | ||
| 26 | private Translator m_deobfuscatingTranslator; | 26 | private Translator deobfuscatingTranslator; |
| 27 | private String m_obfClassName; | 27 | private String obfClassName; |
| 28 | 28 | ||
| 29 | public ClassInheritanceTreeNode(Translator deobfuscatingTranslator, String obfClassName) { | 29 | public ClassInheritanceTreeNode(Translator deobfuscatingTranslator, String obfClassName) { |
| 30 | m_deobfuscatingTranslator = deobfuscatingTranslator; | 30 | this.deobfuscatingTranslator = deobfuscatingTranslator; |
| 31 | m_obfClassName = obfClassName; | 31 | this.obfClassName = obfClassName; |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | public String getObfClassName() { | 34 | public String getObfClassName() { |
| 35 | return m_obfClassName; | 35 | return this.obfClassName; |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | public String getDeobfClassName() { | 38 | public String getDeobfClassName() { |
| 39 | return m_deobfuscatingTranslator.translateClass(m_obfClassName); | 39 | return this.deobfuscatingTranslator.translateClass(this.obfClassName); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | @Override | 42 | @Override |
| @@ -45,14 +45,14 @@ public class ClassInheritanceTreeNode extends DefaultMutableTreeNode { | |||
| 45 | if (deobfClassName != null) { | 45 | if (deobfClassName != null) { |
| 46 | return deobfClassName; | 46 | return deobfClassName; |
| 47 | } | 47 | } |
| 48 | return m_obfClassName; | 48 | return this.obfClassName; |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | public void load(TranslationIndex ancestries, boolean recurse) { | 51 | public void load(TranslationIndex ancestries, boolean recurse) { |
| 52 | // get all the child nodes | 52 | // get all the child nodes |
| 53 | List<ClassInheritanceTreeNode> nodes = Lists.newArrayList(); | 53 | List<ClassInheritanceTreeNode> nodes = Lists.newArrayList(); |
| 54 | for (ClassEntry subclassEntry : ancestries.getSubclass(new ClassEntry(m_obfClassName))) { | 54 | for (ClassEntry subclassEntry : ancestries.getSubclass(new ClassEntry(this.obfClassName))) { |
| 55 | nodes.add(new ClassInheritanceTreeNode(m_deobfuscatingTranslator, subclassEntry.getName())); | 55 | nodes.add(new ClassInheritanceTreeNode(this.deobfuscatingTranslator, subclassEntry.getName())); |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | // add them to this node | 58 | // add them to this node |
diff --git a/src/main/java/cuchaz/enigma/analysis/EntryReference.java b/src/main/java/cuchaz/enigma/analysis/EntryReference.java index eb58388..6a7a4bf 100644 --- a/src/main/java/cuchaz/enigma/analysis/EntryReference.java +++ b/src/main/java/cuchaz/enigma/analysis/EntryReference.java | |||
| @@ -24,7 +24,7 @@ public class EntryReference<E extends Entry, C extends Entry> { | |||
| 24 | public E entry; | 24 | public E entry; |
| 25 | public C context; | 25 | public C context; |
| 26 | 26 | ||
| 27 | private boolean m_isNamed; | 27 | private boolean sourceName; |
| 28 | 28 | ||
| 29 | public EntryReference(E entry, String sourceName) { | 29 | public EntryReference(E entry, String sourceName) { |
| 30 | this(entry, sourceName, null); | 30 | this(entry, sourceName, null); |
| @@ -38,16 +38,16 @@ public class EntryReference<E extends Entry, C extends Entry> { | |||
| 38 | this.entry = entry; | 38 | this.entry = entry; |
| 39 | this.context = context; | 39 | this.context = context; |
| 40 | 40 | ||
| 41 | m_isNamed = sourceName != null && sourceName.length() > 0; | 41 | this.sourceName = sourceName != null && sourceName.length() > 0; |
| 42 | if (entry instanceof ConstructorEntry && ConstructorNonNames.contains(sourceName)) { | 42 | if (entry instanceof ConstructorEntry && ConstructorNonNames.contains(sourceName)) { |
| 43 | m_isNamed = false; | 43 | this.sourceName = false; |
| 44 | } | 44 | } |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | public EntryReference(E entry, C context, EntryReference<E, C> other) { | 47 | public EntryReference(E entry, C context, EntryReference<E, C> other) { |
| 48 | this.entry = entry; | 48 | this.entry = entry; |
| 49 | this.context = context; | 49 | this.context = context; |
| 50 | m_isNamed = other.m_isNamed; | 50 | this.sourceName = other.sourceName; |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | public ClassEntry getLocationClassEntry() { | 53 | public ClassEntry getLocationClassEntry() { |
| @@ -58,7 +58,7 @@ public class EntryReference<E extends Entry, C extends Entry> { | |||
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | public boolean isNamed() { | 60 | public boolean isNamed() { |
| 61 | return m_isNamed; | 61 | return this.sourceName; |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | public Entry getNameableEntry() { | 64 | public Entry getNameableEntry() { |
| @@ -91,10 +91,7 @@ public class EntryReference<E extends Entry, C extends Entry> { | |||
| 91 | 91 | ||
| 92 | @Override | 92 | @Override |
| 93 | public boolean equals(Object other) { | 93 | public boolean equals(Object other) { |
| 94 | if (other instanceof EntryReference) { | 94 | return other instanceof EntryReference && equals((EntryReference<?, ?>) other); |
| 95 | return equals((EntryReference<?, ?>) other); | ||
| 96 | } | ||
| 97 | return false; | ||
| 98 | } | 95 | } |
| 99 | 96 | ||
| 100 | public boolean equals(EntryReference<?, ?> other) { | 97 | public boolean equals(EntryReference<?, ?> other) { |
diff --git a/src/main/java/cuchaz/enigma/analysis/EntryRenamer.java b/src/main/java/cuchaz/enigma/analysis/EntryRenamer.java index b99537c..9c3d051 100644 --- a/src/main/java/cuchaz/enigma/analysis/EntryRenamer.java +++ b/src/main/java/cuchaz/enigma/analysis/EntryRenamer.java | |||
| @@ -36,7 +36,7 @@ public class EntryRenamer { | |||
| 36 | // for each key/value pair... | 36 | // for each key/value pair... |
| 37 | Set<Map.Entry<Key, Val>> entriesToAdd = Sets.newHashSet(); | 37 | Set<Map.Entry<Key, Val>> entriesToAdd = Sets.newHashSet(); |
| 38 | for (Map.Entry<Key, Val> entry : map.entrySet()) { | 38 | for (Map.Entry<Key, Val> entry : map.entrySet()) { |
| 39 | entriesToAdd.add(new AbstractMap.SimpleEntry<Key, Val>( | 39 | entriesToAdd.add(new AbstractMap.SimpleEntry<>( |
| 40 | renameClassesInThing(renames, entry.getKey()), | 40 | renameClassesInThing(renames, entry.getKey()), |
| 41 | renameClassesInThing(renames, entry.getValue()) | 41 | renameClassesInThing(renames, entry.getValue()) |
| 42 | )); | 42 | )); |
| @@ -51,7 +51,7 @@ public class EntryRenamer { | |||
| 51 | // for each key/value pair... | 51 | // for each key/value pair... |
| 52 | Set<Map.Entry<Key, Val>> entriesToAdd = Sets.newHashSet(); | 52 | Set<Map.Entry<Key, Val>> entriesToAdd = Sets.newHashSet(); |
| 53 | for (Map.Entry<Key, Val> entry : map.entries()) { | 53 | for (Map.Entry<Key, Val> entry : map.entries()) { |
| 54 | entriesToAdd.add(new AbstractMap.SimpleEntry<Key, Val>( | 54 | entriesToAdd.add(new AbstractMap.SimpleEntry<>( |
| 55 | renameClassesInThing(renames, entry.getKey()), | 55 | renameClassesInThing(renames, entry.getKey()), |
| 56 | renameClassesInThing(renames, entry.getValue()) | 56 | renameClassesInThing(renames, entry.getValue()) |
| 57 | )); | 57 | )); |
| @@ -66,7 +66,7 @@ public class EntryRenamer { | |||
| 66 | // for each key/value pair... | 66 | // for each key/value pair... |
| 67 | Set<Map.Entry<Key, Val>> entriesToAdd = Sets.newHashSet(); | 67 | Set<Map.Entry<Key, Val>> entriesToAdd = Sets.newHashSet(); |
| 68 | for (Map.Entry<Key, Val> entry : map.entries()) { | 68 | for (Map.Entry<Key, Val> entry : map.entries()) { |
| 69 | entriesToAdd.add(new AbstractMap.SimpleEntry<Key, Val>( | 69 | entriesToAdd.add(new AbstractMap.SimpleEntry<>( |
| 70 | renameMethodsInThing(renames, entry.getKey()), | 70 | renameMethodsInThing(renames, entry.getKey()), |
| 71 | renameMethodsInThing(renames, entry.getValue()) | 71 | renameMethodsInThing(renames, entry.getValue()) |
| 72 | )); | 72 | )); |
| @@ -81,7 +81,7 @@ public class EntryRenamer { | |||
| 81 | // for each key/value pair... | 81 | // for each key/value pair... |
| 82 | Set<Map.Entry<Key, Val>> entriesToAdd = Sets.newHashSet(); | 82 | Set<Map.Entry<Key, Val>> entriesToAdd = Sets.newHashSet(); |
| 83 | for (Map.Entry<Key, Val> entry : map.entrySet()) { | 83 | for (Map.Entry<Key, Val> entry : map.entrySet()) { |
| 84 | entriesToAdd.add(new AbstractMap.SimpleEntry<Key, Val>( | 84 | entriesToAdd.add(new AbstractMap.SimpleEntry<>( |
| 85 | renameMethodsInThing(renames, entry.getKey()), | 85 | renameMethodsInThing(renames, entry.getKey()), |
| 86 | renameMethodsInThing(renames, entry.getValue()) | 86 | renameMethodsInThing(renames, entry.getValue()) |
| 87 | )); | 87 | )); |
| @@ -164,19 +164,9 @@ public class EntryRenamer { | |||
| 164 | reference.context = renameClassesInThing(renames, reference.context); | 164 | reference.context = renameClassesInThing(renames, reference.context); |
| 165 | return thing; | 165 | return thing; |
| 166 | } else if (thing instanceof Signature) { | 166 | } else if (thing instanceof Signature) { |
| 167 | return (T) new Signature((Signature) thing, new ClassNameReplacer() { | 167 | return (T) new Signature((Signature) thing, className -> renameClassesInThing(renames, className)); |
| 168 | @Override | ||
| 169 | public String replace(String className) { | ||
| 170 | return renameClassesInThing(renames, className); | ||
| 171 | } | ||
| 172 | }); | ||
| 173 | } else if (thing instanceof Type) { | 168 | } else if (thing instanceof Type) { |
| 174 | return (T) new Type((Type) thing, new ClassNameReplacer() { | 169 | return (T) new Type((Type) thing, className -> renameClassesInThing(renames, className)); |
| 175 | @Override | ||
| 176 | public String replace(String className) { | ||
| 177 | return renameClassesInThing(renames, className); | ||
| 178 | } | ||
| 179 | }); | ||
| 180 | } | 170 | } |
| 181 | 171 | ||
| 182 | return thing; | 172 | return thing; |
diff --git a/src/main/java/cuchaz/enigma/analysis/FieldReferenceTreeNode.java b/src/main/java/cuchaz/enigma/analysis/FieldReferenceTreeNode.java index 4b302e0..05d9c13 100644 --- a/src/main/java/cuchaz/enigma/analysis/FieldReferenceTreeNode.java +++ b/src/main/java/cuchaz/enigma/analysis/FieldReferenceTreeNode.java | |||
| @@ -20,51 +20,51 @@ public class FieldReferenceTreeNode extends DefaultMutableTreeNode implements Re | |||
| 20 | 20 | ||
| 21 | private static final long serialVersionUID = -7934108091928699835L; | 21 | private static final long serialVersionUID = -7934108091928699835L; |
| 22 | 22 | ||
| 23 | private Translator m_deobfuscatingTranslator; | 23 | private Translator deobfuscatingTranslator; |
| 24 | private FieldEntry m_entry; | 24 | private FieldEntry entry; |
| 25 | private EntryReference<FieldEntry, BehaviorEntry> m_reference; | 25 | private EntryReference<FieldEntry, BehaviorEntry> reference; |
| 26 | private Access m_access; | 26 | private Access access; |
| 27 | 27 | ||
| 28 | public FieldReferenceTreeNode(Translator deobfuscatingTranslator, FieldEntry entry) { | 28 | public FieldReferenceTreeNode(Translator deobfuscatingTranslator, FieldEntry entry) { |
| 29 | m_deobfuscatingTranslator = deobfuscatingTranslator; | 29 | this.deobfuscatingTranslator = deobfuscatingTranslator; |
| 30 | m_entry = entry; | 30 | this.entry = entry; |
| 31 | m_reference = null; | 31 | this.reference = null; |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | private FieldReferenceTreeNode(Translator deobfuscatingTranslator, EntryReference<FieldEntry, BehaviorEntry> reference, Access access) { | 34 | private FieldReferenceTreeNode(Translator deobfuscatingTranslator, EntryReference<FieldEntry, BehaviorEntry> reference, Access access) { |
| 35 | m_deobfuscatingTranslator = deobfuscatingTranslator; | 35 | this.deobfuscatingTranslator = deobfuscatingTranslator; |
| 36 | m_entry = reference.entry; | 36 | this.entry = reference.entry; |
| 37 | m_reference = reference; | 37 | this.reference = reference; |
| 38 | m_access = access; | 38 | this.access = access; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | @Override | 41 | @Override |
| 42 | public FieldEntry getEntry() { | 42 | public FieldEntry getEntry() { |
| 43 | return m_entry; | 43 | return this.entry; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | @Override | 46 | @Override |
| 47 | public EntryReference<FieldEntry, BehaviorEntry> getReference() { | 47 | public EntryReference<FieldEntry, BehaviorEntry> getReference() { |
| 48 | return m_reference; | 48 | return this.reference; |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | @Override | 51 | @Override |
| 52 | public String toString() { | 52 | public String toString() { |
| 53 | if (m_reference != null) { | 53 | if (this.reference != null) { |
| 54 | return String.format("%s (%s)", m_deobfuscatingTranslator.translateEntry(m_reference.context), m_access); | 54 | return String.format("%s (%s)", this.deobfuscatingTranslator.translateEntry(this.reference.context), this.access); |
| 55 | } | 55 | } |
| 56 | return m_deobfuscatingTranslator.translateEntry(m_entry).toString(); | 56 | return this.deobfuscatingTranslator.translateEntry(this.entry).toString(); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | public void load(JarIndex index, boolean recurse) { | 59 | public void load(JarIndex index, boolean recurse) { |
| 60 | // get all the child nodes | 60 | // get all the child nodes |
| 61 | if (m_reference == null) { | 61 | if (this.reference == null) { |
| 62 | for (EntryReference<FieldEntry, BehaviorEntry> reference : index.getFieldReferences(m_entry)) { | 62 | for (EntryReference<FieldEntry, BehaviorEntry> reference : index.getFieldReferences(this.entry)) { |
| 63 | add(new FieldReferenceTreeNode(m_deobfuscatingTranslator, reference, index.getAccess(m_entry))); | 63 | add(new FieldReferenceTreeNode(this.deobfuscatingTranslator, reference, index.getAccess(this.entry))); |
| 64 | } | 64 | } |
| 65 | } else { | 65 | } else { |
| 66 | for (EntryReference<BehaviorEntry, BehaviorEntry> reference : index.getBehaviorReferences(m_reference.context)) { | 66 | for (EntryReference<BehaviorEntry, BehaviorEntry> reference : index.getBehaviorReferences(this.reference.context)) { |
| 67 | add(new BehaviorReferenceTreeNode(m_deobfuscatingTranslator, reference, index.getAccess(m_reference.context))); | 67 | add(new BehaviorReferenceTreeNode(this.deobfuscatingTranslator, reference, index.getAccess(this.reference.context))); |
| 68 | } | 68 | } |
| 69 | } | 69 | } |
| 70 | 70 | ||
diff --git a/src/main/java/cuchaz/enigma/analysis/JarClassIterator.java b/src/main/java/cuchaz/enigma/analysis/JarClassIterator.java index 17a1715..0400427 100644 --- a/src/main/java/cuchaz/enigma/analysis/JarClassIterator.java +++ b/src/main/java/cuchaz/enigma/analysis/JarClassIterator.java | |||
| @@ -31,15 +31,15 @@ import javassist.bytecode.Descriptor; | |||
| 31 | 31 | ||
| 32 | public class JarClassIterator implements Iterator<CtClass> { | 32 | public class JarClassIterator implements Iterator<CtClass> { |
| 33 | 33 | ||
| 34 | private JarFile m_jar; | 34 | private JarFile jar; |
| 35 | private Iterator<JarEntry> m_iter; | 35 | private Iterator<JarEntry> iter; |
| 36 | 36 | ||
| 37 | public JarClassIterator(JarFile jar) { | 37 | public JarClassIterator(JarFile jar) { |
| 38 | m_jar = jar; | 38 | this.jar = jar; |
| 39 | 39 | ||
| 40 | // get the jar entries that correspond to classes | 40 | // get the jar entries that correspond to classes |
| 41 | List<JarEntry> classEntries = Lists.newArrayList(); | 41 | List<JarEntry> classEntries = Lists.newArrayList(); |
| 42 | Enumeration<JarEntry> entries = m_jar.entries(); | 42 | Enumeration<JarEntry> entries = this.jar.entries(); |
| 43 | while (entries.hasMoreElements()) { | 43 | while (entries.hasMoreElements()) { |
| 44 | JarEntry entry = entries.nextElement(); | 44 | JarEntry entry = entries.nextElement(); |
| 45 | 45 | ||
| @@ -48,19 +48,19 @@ public class JarClassIterator implements Iterator<CtClass> { | |||
| 48 | classEntries.add(entry); | 48 | classEntries.add(entry); |
| 49 | } | 49 | } |
| 50 | } | 50 | } |
| 51 | m_iter = classEntries.iterator(); | 51 | this.iter = classEntries.iterator(); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | @Override | 54 | @Override |
| 55 | public boolean hasNext() { | 55 | public boolean hasNext() { |
| 56 | return m_iter.hasNext(); | 56 | return this.iter.hasNext(); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | @Override | 59 | @Override |
| 60 | public CtClass next() { | 60 | public CtClass next() { |
| 61 | JarEntry entry = m_iter.next(); | 61 | JarEntry entry = this.iter.next(); |
| 62 | try { | 62 | try { |
| 63 | return getClass(m_jar, entry); | 63 | return getClass(this.jar, entry); |
| 64 | } catch (IOException | NotFoundException ex) { | 64 | } catch (IOException | NotFoundException ex) { |
| 65 | throw new Error("Unable to load class: " + entry.getName()); | 65 | throw new Error("Unable to load class: " + entry.getName()); |
| 66 | } | 66 | } |
| @@ -86,12 +86,7 @@ public class JarClassIterator implements Iterator<CtClass> { | |||
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | public static Iterable<CtClass> classes(final JarFile jar) { | 88 | public static Iterable<CtClass> classes(final JarFile jar) { |
| 89 | return new Iterable<CtClass>() { | 89 | return () -> new JarClassIterator(jar); |
| 90 | @Override | ||
| 91 | public Iterator<CtClass> iterator() { | ||
| 92 | return new JarClassIterator(jar); | ||
| 93 | } | ||
| 94 | }; | ||
| 95 | } | 90 | } |
| 96 | 91 | ||
| 97 | public static CtClass getClass(JarFile jar, ClassEntry classEntry) { | 92 | public static CtClass getClass(JarFile jar, ClassEntry classEntry) { |
diff --git a/src/main/java/cuchaz/enigma/analysis/JarIndex.java b/src/main/java/cuchaz/enigma/analysis/JarIndex.java index 848d851..8b30f9e 100644 --- a/src/main/java/cuchaz/enigma/analysis/JarIndex.java +++ b/src/main/java/cuchaz/enigma/analysis/JarIndex.java | |||
| @@ -26,32 +26,32 @@ import javassist.expr.*; | |||
| 26 | 26 | ||
| 27 | public class JarIndex { | 27 | public class JarIndex { |
| 28 | 28 | ||
| 29 | private Set<ClassEntry> m_obfClassEntries; | 29 | private Set<ClassEntry> obfClassEntries; |
| 30 | private TranslationIndex m_translationIndex; | 30 | private TranslationIndex translationIndex; |
| 31 | private Map<Entry, Access> m_access; | 31 | private Map<Entry, Access> access; |
| 32 | private Multimap<ClassEntry, FieldEntry> m_fields; | 32 | private Multimap<ClassEntry, FieldEntry> fields; |
| 33 | private Multimap<ClassEntry, BehaviorEntry> m_behaviors; | 33 | private Multimap<ClassEntry, BehaviorEntry> behaviors; |
| 34 | private Multimap<String, MethodEntry> m_methodImplementations; | 34 | private Multimap<String, MethodEntry> methodImplementations; |
| 35 | private Multimap<BehaviorEntry, EntryReference<BehaviorEntry, BehaviorEntry>> m_behaviorReferences; | 35 | private Multimap<BehaviorEntry, EntryReference<BehaviorEntry, BehaviorEntry>> behaviorReferences; |
| 36 | private Multimap<FieldEntry, EntryReference<FieldEntry, BehaviorEntry>> m_fieldReferences; | 36 | private Multimap<FieldEntry, EntryReference<FieldEntry, BehaviorEntry>> fieldReferences; |
| 37 | private Multimap<ClassEntry, ClassEntry> m_innerClassesByOuter; | 37 | private Multimap<ClassEntry, ClassEntry> innerClassesByOuter; |
| 38 | private Map<ClassEntry, ClassEntry> m_outerClassesByInner; | 38 | private Map<ClassEntry, ClassEntry> outerClassesByInner; |
| 39 | private Map<ClassEntry, BehaviorEntry> m_anonymousClasses; | 39 | private Map<ClassEntry, BehaviorEntry> anonymousClasses; |
| 40 | private Map<MethodEntry, MethodEntry> m_bridgedMethods; | 40 | private Map<MethodEntry, MethodEntry> bridgedMethods; |
| 41 | 41 | ||
| 42 | public JarIndex() { | 42 | public JarIndex() { |
| 43 | m_obfClassEntries = Sets.newHashSet(); | 43 | this.obfClassEntries = Sets.newHashSet(); |
| 44 | m_translationIndex = new TranslationIndex(); | 44 | this.translationIndex = new TranslationIndex(); |
| 45 | m_access = Maps.newHashMap(); | 45 | this.access = Maps.newHashMap(); |
| 46 | m_fields = HashMultimap.create(); | 46 | this.fields = HashMultimap.create(); |
| 47 | m_behaviors = HashMultimap.create(); | 47 | this.behaviors = HashMultimap.create(); |
| 48 | m_methodImplementations = HashMultimap.create(); | 48 | this.methodImplementations = HashMultimap.create(); |
| 49 | m_behaviorReferences = HashMultimap.create(); | 49 | this.behaviorReferences = HashMultimap.create(); |
| 50 | m_fieldReferences = HashMultimap.create(); | 50 | this.fieldReferences = HashMultimap.create(); |
| 51 | m_innerClassesByOuter = HashMultimap.create(); | 51 | this.innerClassesByOuter = HashMultimap.create(); |
| 52 | m_outerClassesByInner = Maps.newHashMap(); | 52 | this.outerClassesByInner = Maps.newHashMap(); |
| 53 | m_anonymousClasses = Maps.newHashMap(); | 53 | this.anonymousClasses = Maps.newHashMap(); |
| 54 | m_bridgedMethods = Maps.newHashMap(); | 54 | this.bridgedMethods = Maps.newHashMap(); |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | public void indexJar(JarFile jar, boolean buildInnerClasses) { | 57 | public void indexJar(JarFile jar, boolean buildInnerClasses) { |
| @@ -62,7 +62,7 @@ public class JarIndex { | |||
| 62 | // move out of default package | 62 | // move out of default package |
| 63 | classEntry = new ClassEntry(Constants.NonePackage + "/" + classEntry.getName()); | 63 | classEntry = new ClassEntry(Constants.NonePackage + "/" + classEntry.getName()); |
| 64 | } | 64 | } |
| 65 | m_obfClassEntries.add(classEntry); | 65 | this.obfClassEntries.add(classEntry); |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | // step 2: index field/method/constructor access | 68 | // step 2: index field/method/constructor access |
| @@ -70,20 +70,20 @@ public class JarIndex { | |||
| 70 | ClassRenamer.moveAllClassesOutOfDefaultPackage(c, Constants.NonePackage); | 70 | ClassRenamer.moveAllClassesOutOfDefaultPackage(c, Constants.NonePackage); |
| 71 | for (CtField field : c.getDeclaredFields()) { | 71 | for (CtField field : c.getDeclaredFields()) { |
| 72 | FieldEntry fieldEntry = EntryFactory.getFieldEntry(field); | 72 | FieldEntry fieldEntry = EntryFactory.getFieldEntry(field); |
| 73 | m_access.put(fieldEntry, Access.get(field)); | 73 | this.access.put(fieldEntry, Access.get(field)); |
| 74 | m_fields.put(fieldEntry.getClassEntry(), fieldEntry); | 74 | this.fields.put(fieldEntry.getClassEntry(), fieldEntry); |
| 75 | } | 75 | } |
| 76 | for (CtBehavior behavior : c.getDeclaredBehaviors()) { | 76 | for (CtBehavior behavior : c.getDeclaredBehaviors()) { |
| 77 | BehaviorEntry behaviorEntry = EntryFactory.getBehaviorEntry(behavior); | 77 | BehaviorEntry behaviorEntry = EntryFactory.getBehaviorEntry(behavior); |
| 78 | m_access.put(behaviorEntry, Access.get(behavior)); | 78 | this.access.put(behaviorEntry, Access.get(behavior)); |
| 79 | m_behaviors.put(behaviorEntry.getClassEntry(), behaviorEntry); | 79 | this.behaviors.put(behaviorEntry.getClassEntry(), behaviorEntry); |
| 80 | } | 80 | } |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | // step 3: index extends, implements, fields, and methods | 83 | // step 3: index extends, implements, fields, and methods |
| 84 | for (CtClass c : JarClassIterator.classes(jar)) { | 84 | for (CtClass c : JarClassIterator.classes(jar)) { |
| 85 | ClassRenamer.moveAllClassesOutOfDefaultPackage(c, Constants.NonePackage); | 85 | ClassRenamer.moveAllClassesOutOfDefaultPackage(c, Constants.NonePackage); |
| 86 | m_translationIndex.indexClass(c); | 86 | this.translationIndex.indexClass(c); |
| 87 | String className = Descriptor.toJvmName(c.getName()); | 87 | String className = Descriptor.toJvmName(c.getName()); |
| 88 | for (String interfaceName : c.getClassFile().getInterfaces()) { | 88 | for (String interfaceName : c.getClassFile().getInterfaces()) { |
| 89 | className = Descriptor.toJvmName(className); | 89 | className = Descriptor.toJvmName(className); |
| @@ -113,13 +113,13 @@ public class JarIndex { | |||
| 113 | ClassEntry innerClassEntry = EntryFactory.getClassEntry(c); | 113 | ClassEntry innerClassEntry = EntryFactory.getClassEntry(c); |
| 114 | ClassEntry outerClassEntry = findOuterClass(c); | 114 | ClassEntry outerClassEntry = findOuterClass(c); |
| 115 | if (outerClassEntry != null) { | 115 | if (outerClassEntry != null) { |
| 116 | m_innerClassesByOuter.put(outerClassEntry, innerClassEntry); | 116 | this.innerClassesByOuter.put(outerClassEntry, innerClassEntry); |
| 117 | boolean innerWasAdded = m_outerClassesByInner.put(innerClassEntry, outerClassEntry) == null; | 117 | boolean innerWasAdded = this.outerClassesByInner.put(innerClassEntry, outerClassEntry) == null; |
| 118 | assert (innerWasAdded); | 118 | assert (innerWasAdded); |
| 119 | 119 | ||
| 120 | BehaviorEntry enclosingBehavior = isAnonymousClass(c, outerClassEntry); | 120 | BehaviorEntry enclosingBehavior = isAnonymousClass(c, outerClassEntry); |
| 121 | if (enclosingBehavior != null) { | 121 | if (enclosingBehavior != null) { |
| 122 | m_anonymousClasses.put(innerClassEntry, enclosingBehavior); | 122 | this.anonymousClasses.put(innerClassEntry, enclosingBehavior); |
| 123 | 123 | ||
| 124 | // DEBUG | 124 | // DEBUG |
| 125 | //System.out.println("ANONYMOUS: " + outerClassEntry.getName() + "$" + innerClassEntry.getSimpleName()); | 125 | //System.out.println("ANONYMOUS: " + outerClassEntry.getName() + "$" + innerClassEntry.getSimpleName()); |
| @@ -132,7 +132,7 @@ public class JarIndex { | |||
| 132 | 132 | ||
| 133 | // step 6: update other indices with inner class info | 133 | // step 6: update other indices with inner class info |
| 134 | Map<String, String> renames = Maps.newHashMap(); | 134 | Map<String, String> renames = Maps.newHashMap(); |
| 135 | for (ClassEntry innerClassEntry : m_innerClassesByOuter.values()) { | 135 | for (ClassEntry innerClassEntry : this.innerClassesByOuter.values()) { |
| 136 | String newName = innerClassEntry.buildClassEntry(getObfClassChain(innerClassEntry)).getName(); | 136 | String newName = innerClassEntry.buildClassEntry(getObfClassChain(innerClassEntry)).getName(); |
| 137 | if (!innerClassEntry.getName().equals(newName)) { | 137 | if (!innerClassEntry.getName().equals(newName)) { |
| 138 | // DEBUG | 138 | // DEBUG |
| @@ -140,12 +140,12 @@ public class JarIndex { | |||
| 140 | renames.put(innerClassEntry.getName(), newName); | 140 | renames.put(innerClassEntry.getName(), newName); |
| 141 | } | 141 | } |
| 142 | } | 142 | } |
| 143 | EntryRenamer.renameClassesInSet(renames, m_obfClassEntries); | 143 | EntryRenamer.renameClassesInSet(renames, this.obfClassEntries); |
| 144 | m_translationIndex.renameClasses(renames); | 144 | this.translationIndex.renameClasses(renames); |
| 145 | EntryRenamer.renameClassesInMultimap(renames, m_methodImplementations); | 145 | EntryRenamer.renameClassesInMultimap(renames, this.methodImplementations); |
| 146 | EntryRenamer.renameClassesInMultimap(renames, m_behaviorReferences); | 146 | EntryRenamer.renameClassesInMultimap(renames, this.behaviorReferences); |
| 147 | EntryRenamer.renameClassesInMultimap(renames, m_fieldReferences); | 147 | EntryRenamer.renameClassesInMultimap(renames, this.fieldReferences); |
| 148 | EntryRenamer.renameClassesInMap(renames, m_access); | 148 | EntryRenamer.renameClassesInMap(renames, this.access); |
| 149 | } | 149 | } |
| 150 | } | 150 | } |
| 151 | 151 | ||
| @@ -156,12 +156,12 @@ public class JarIndex { | |||
| 156 | MethodEntry methodEntry = (MethodEntry) behaviorEntry; | 156 | MethodEntry methodEntry = (MethodEntry) behaviorEntry; |
| 157 | 157 | ||
| 158 | // index implementation | 158 | // index implementation |
| 159 | m_methodImplementations.put(behaviorEntry.getClassName(), methodEntry); | 159 | this.methodImplementations.put(behaviorEntry.getClassName(), methodEntry); |
| 160 | 160 | ||
| 161 | // look for bridge and bridged methods | 161 | // look for bridge and bridged methods |
| 162 | CtMethod bridgedMethod = getBridgedMethod((CtMethod) behavior); | 162 | CtMethod bridgedMethod = getBridgedMethod((CtMethod) behavior); |
| 163 | if (bridgedMethod != null) { | 163 | if (bridgedMethod != null) { |
| 164 | m_bridgedMethods.put(methodEntry, EntryFactory.getMethodEntry(bridgedMethod)); | 164 | this.bridgedMethods.put(methodEntry, EntryFactory.getMethodEntry(bridgedMethod)); |
| 165 | } | 165 | } |
| 166 | } | 166 | } |
| 167 | // looks like we don't care about constructors here | 167 | // looks like we don't care about constructors here |
| @@ -175,7 +175,7 @@ public class JarIndex { | |||
| 175 | @Override | 175 | @Override |
| 176 | public void edit(MethodCall call) { | 176 | public void edit(MethodCall call) { |
| 177 | MethodEntry calledMethodEntry = EntryFactory.getMethodEntry(call); | 177 | MethodEntry calledMethodEntry = EntryFactory.getMethodEntry(call); |
| 178 | ClassEntry resolvedClassEntry = m_translationIndex.resolveEntryClass(calledMethodEntry); | 178 | ClassEntry resolvedClassEntry = translationIndex.resolveEntryClass(calledMethodEntry); |
| 179 | if (resolvedClassEntry != null && !resolvedClassEntry.equals(calledMethodEntry.getClassEntry())) { | 179 | if (resolvedClassEntry != null && !resolvedClassEntry.equals(calledMethodEntry.getClassEntry())) { |
| 180 | calledMethodEntry = new MethodEntry( | 180 | calledMethodEntry = new MethodEntry( |
| 181 | resolvedClassEntry, | 181 | resolvedClassEntry, |
| @@ -188,13 +188,13 @@ public class JarIndex { | |||
| 188 | call.getMethodName(), | 188 | call.getMethodName(), |
| 189 | behaviorEntry | 189 | behaviorEntry |
| 190 | ); | 190 | ); |
| 191 | m_behaviorReferences.put(calledMethodEntry, reference); | 191 | behaviorReferences.put(calledMethodEntry, reference); |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | @Override | 194 | @Override |
| 195 | public void edit(FieldAccess call) { | 195 | public void edit(FieldAccess call) { |
| 196 | FieldEntry calledFieldEntry = EntryFactory.getFieldEntry(call); | 196 | FieldEntry calledFieldEntry = EntryFactory.getFieldEntry(call); |
| 197 | ClassEntry resolvedClassEntry = m_translationIndex.resolveEntryClass(calledFieldEntry); | 197 | ClassEntry resolvedClassEntry = translationIndex.resolveEntryClass(calledFieldEntry); |
| 198 | if (resolvedClassEntry != null && !resolvedClassEntry.equals(calledFieldEntry.getClassEntry())) { | 198 | if (resolvedClassEntry != null && !resolvedClassEntry.equals(calledFieldEntry.getClassEntry())) { |
| 199 | calledFieldEntry = new FieldEntry(calledFieldEntry, resolvedClassEntry); | 199 | calledFieldEntry = new FieldEntry(calledFieldEntry, resolvedClassEntry); |
| 200 | } | 200 | } |
| @@ -203,7 +203,7 @@ public class JarIndex { | |||
| 203 | call.getFieldName(), | 203 | call.getFieldName(), |
| 204 | behaviorEntry | 204 | behaviorEntry |
| 205 | ); | 205 | ); |
| 206 | m_fieldReferences.put(calledFieldEntry, reference); | 206 | fieldReferences.put(calledFieldEntry, reference); |
| 207 | } | 207 | } |
| 208 | 208 | ||
| 209 | @Override | 209 | @Override |
| @@ -214,7 +214,7 @@ public class JarIndex { | |||
| 214 | call.getMethodName(), | 214 | call.getMethodName(), |
| 215 | behaviorEntry | 215 | behaviorEntry |
| 216 | ); | 216 | ); |
| 217 | m_behaviorReferences.put(calledConstructorEntry, reference); | 217 | behaviorReferences.put(calledConstructorEntry, reference); |
| 218 | } | 218 | } |
| 219 | 219 | ||
| 220 | @Override | 220 | @Override |
| @@ -225,7 +225,7 @@ public class JarIndex { | |||
| 225 | call.getClassName(), | 225 | call.getClassName(), |
| 226 | behaviorEntry | 226 | behaviorEntry |
| 227 | ); | 227 | ); |
| 228 | m_behaviorReferences.put(calledConstructorEntry, reference); | 228 | behaviorReferences.put(calledConstructorEntry, reference); |
| 229 | } | 229 | } |
| 230 | }); | 230 | }); |
| 231 | } catch (CannotCompileException ex) { | 231 | } catch (CannotCompileException ex) { |
| @@ -314,7 +314,7 @@ public class JarIndex { | |||
| 314 | 314 | ||
| 315 | // is the entry a superclass of the context? | 315 | // is the entry a superclass of the context? |
| 316 | ClassEntry calledClassEntry = reference.entry.getClassEntry(); | 316 | ClassEntry calledClassEntry = reference.entry.getClassEntry(); |
| 317 | ClassEntry superclassEntry = m_translationIndex.getSuperclass(reference.context.getClassEntry()); | 317 | ClassEntry superclassEntry = this.translationIndex.getSuperclass(reference.context.getClassEntry()); |
| 318 | if (superclassEntry != null && superclassEntry.equals(calledClassEntry)) { | 318 | if (superclassEntry != null && superclassEntry.equals(calledClassEntry)) { |
| 319 | // it's a super call, skip | 319 | // it's a super call, skip |
| 320 | continue; | 320 | continue; |
| @@ -360,7 +360,7 @@ public class JarIndex { | |||
| 360 | } | 360 | } |
| 361 | 361 | ||
| 362 | // is the outer class in the jar? | 362 | // is the outer class in the jar? |
| 363 | return m_obfClassEntries.contains(outerClassEntry); | 363 | return this.obfClassEntries.contains(outerClassEntry); |
| 364 | 364 | ||
| 365 | } | 365 | } |
| 366 | 366 | ||
| @@ -500,31 +500,31 @@ public class JarIndex { | |||
| 500 | } | 500 | } |
| 501 | 501 | ||
| 502 | public Set<ClassEntry> getObfClassEntries() { | 502 | public Set<ClassEntry> getObfClassEntries() { |
| 503 | return m_obfClassEntries; | 503 | return this.obfClassEntries; |
| 504 | } | 504 | } |
| 505 | 505 | ||
| 506 | public Collection<FieldEntry> getObfFieldEntries() { | 506 | public Collection<FieldEntry> getObfFieldEntries() { |
| 507 | return m_fields.values(); | 507 | return this.fields.values(); |
| 508 | } | 508 | } |
| 509 | 509 | ||
| 510 | public Collection<FieldEntry> getObfFieldEntries(ClassEntry classEntry) { | 510 | public Collection<FieldEntry> getObfFieldEntries(ClassEntry classEntry) { |
| 511 | return m_fields.get(classEntry); | 511 | return this.fields.get(classEntry); |
| 512 | } | 512 | } |
| 513 | 513 | ||
| 514 | public Collection<BehaviorEntry> getObfBehaviorEntries() { | 514 | public Collection<BehaviorEntry> getObfBehaviorEntries() { |
| 515 | return m_behaviors.values(); | 515 | return this.behaviors.values(); |
| 516 | } | 516 | } |
| 517 | 517 | ||
| 518 | public Collection<BehaviorEntry> getObfBehaviorEntries(ClassEntry classEntry) { | 518 | public Collection<BehaviorEntry> getObfBehaviorEntries(ClassEntry classEntry) { |
| 519 | return m_behaviors.get(classEntry); | 519 | return this.behaviors.get(classEntry); |
| 520 | } | 520 | } |
| 521 | 521 | ||
| 522 | public TranslationIndex getTranslationIndex() { | 522 | public TranslationIndex getTranslationIndex() { |
| 523 | return m_translationIndex; | 523 | return this.translationIndex; |
| 524 | } | 524 | } |
| 525 | 525 | ||
| 526 | public Access getAccess(Entry entry) { | 526 | public Access getAccess(Entry entry) { |
| 527 | return m_access.get(entry); | 527 | return this.access.get(entry); |
| 528 | } | 528 | } |
| 529 | 529 | ||
| 530 | public ClassInheritanceTreeNode getClassInheritance(Translator deobfuscatingTranslator, ClassEntry obfClassEntry) { | 530 | public ClassInheritanceTreeNode getClassInheritance(Translator deobfuscatingTranslator, ClassEntry obfClassEntry) { |
| @@ -532,7 +532,7 @@ public class JarIndex { | |||
| 532 | // get the root node | 532 | // get the root node |
| 533 | List<String> ancestry = Lists.newArrayList(); | 533 | List<String> ancestry = Lists.newArrayList(); |
| 534 | ancestry.add(obfClassEntry.getName()); | 534 | ancestry.add(obfClassEntry.getName()); |
| 535 | for (ClassEntry classEntry : m_translationIndex.getAncestry(obfClassEntry)) { | 535 | for (ClassEntry classEntry : this.translationIndex.getAncestry(obfClassEntry)) { |
| 536 | if (containsObfClass(classEntry)) { | 536 | if (containsObfClass(classEntry)) { |
| 537 | ancestry.add(classEntry.getName()); | 537 | ancestry.add(classEntry.getName()); |
| 538 | } | 538 | } |
| @@ -543,7 +543,7 @@ public class JarIndex { | |||
| 543 | ); | 543 | ); |
| 544 | 544 | ||
| 545 | // expand all children recursively | 545 | // expand all children recursively |
| 546 | rootNode.load(m_translationIndex, true); | 546 | rootNode.load(this.translationIndex, true); |
| 547 | 547 | ||
| 548 | return rootNode; | 548 | return rootNode; |
| 549 | } | 549 | } |
| @@ -563,7 +563,7 @@ public class JarIndex { | |||
| 563 | 563 | ||
| 564 | // travel to the ancestor implementation | 564 | // travel to the ancestor implementation |
| 565 | ClassEntry baseImplementationClassEntry = obfMethodEntry.getClassEntry(); | 565 | ClassEntry baseImplementationClassEntry = obfMethodEntry.getClassEntry(); |
| 566 | for (ClassEntry ancestorClassEntry : m_translationIndex.getAncestry(obfMethodEntry.getClassEntry())) { | 566 | for (ClassEntry ancestorClassEntry : this.translationIndex.getAncestry(obfMethodEntry.getClassEntry())) { |
| 567 | MethodEntry ancestorMethodEntry = new MethodEntry( | 567 | MethodEntry ancestorMethodEntry = new MethodEntry( |
| 568 | new ClassEntry(ancestorClassEntry), | 568 | new ClassEntry(ancestorClassEntry), |
| 569 | obfMethodEntry.getName(), | 569 | obfMethodEntry.getName(), |
| @@ -664,13 +664,13 @@ public class JarIndex { | |||
| 664 | } | 664 | } |
| 665 | 665 | ||
| 666 | public Collection<EntryReference<FieldEntry, BehaviorEntry>> getFieldReferences(FieldEntry fieldEntry) { | 666 | public Collection<EntryReference<FieldEntry, BehaviorEntry>> getFieldReferences(FieldEntry fieldEntry) { |
| 667 | return m_fieldReferences.get(fieldEntry); | 667 | return this.fieldReferences.get(fieldEntry); |
| 668 | } | 668 | } |
| 669 | 669 | ||
| 670 | public Collection<FieldEntry> getReferencedFields(BehaviorEntry behaviorEntry) { | 670 | public Collection<FieldEntry> getReferencedFields(BehaviorEntry behaviorEntry) { |
| 671 | // linear search is fast enough for now | 671 | // linear search is fast enough for now |
| 672 | Set<FieldEntry> fieldEntries = Sets.newHashSet(); | 672 | Set<FieldEntry> fieldEntries = Sets.newHashSet(); |
| 673 | for (EntryReference<FieldEntry, BehaviorEntry> reference : m_fieldReferences.values()) { | 673 | for (EntryReference<FieldEntry, BehaviorEntry> reference : this.fieldReferences.values()) { |
| 674 | if (reference.context == behaviorEntry) { | 674 | if (reference.context == behaviorEntry) { |
| 675 | fieldEntries.add(reference.entry); | 675 | fieldEntries.add(reference.entry); |
| 676 | } | 676 | } |
| @@ -679,13 +679,13 @@ public class JarIndex { | |||
| 679 | } | 679 | } |
| 680 | 680 | ||
| 681 | public Collection<EntryReference<BehaviorEntry, BehaviorEntry>> getBehaviorReferences(BehaviorEntry behaviorEntry) { | 681 | public Collection<EntryReference<BehaviorEntry, BehaviorEntry>> getBehaviorReferences(BehaviorEntry behaviorEntry) { |
| 682 | return m_behaviorReferences.get(behaviorEntry); | 682 | return this.behaviorReferences.get(behaviorEntry); |
| 683 | } | 683 | } |
| 684 | 684 | ||
| 685 | public Collection<BehaviorEntry> getReferencedBehaviors(BehaviorEntry behaviorEntry) { | 685 | public Collection<BehaviorEntry> getReferencedBehaviors(BehaviorEntry behaviorEntry) { |
| 686 | // linear search is fast enough for now | 686 | // linear search is fast enough for now |
| 687 | Set<BehaviorEntry> behaviorEntries = Sets.newHashSet(); | 687 | Set<BehaviorEntry> behaviorEntries = Sets.newHashSet(); |
| 688 | for (EntryReference<BehaviorEntry, BehaviorEntry> reference : m_behaviorReferences.values()) { | 688 | for (EntryReference<BehaviorEntry, BehaviorEntry> reference : this.behaviorReferences.values()) { |
| 689 | if (reference.context == behaviorEntry) { | 689 | if (reference.context == behaviorEntry) { |
| 690 | behaviorEntries.add(reference.entry); | 690 | behaviorEntries.add(reference.entry); |
| 691 | } | 691 | } |
| @@ -694,27 +694,27 @@ public class JarIndex { | |||
| 694 | } | 694 | } |
| 695 | 695 | ||
| 696 | public Collection<ClassEntry> getInnerClasses(ClassEntry obfOuterClassEntry) { | 696 | public Collection<ClassEntry> getInnerClasses(ClassEntry obfOuterClassEntry) { |
| 697 | return m_innerClassesByOuter.get(obfOuterClassEntry); | 697 | return this.innerClassesByOuter.get(obfOuterClassEntry); |
| 698 | } | 698 | } |
| 699 | 699 | ||
| 700 | public ClassEntry getOuterClass(ClassEntry obfInnerClassEntry) { | 700 | public ClassEntry getOuterClass(ClassEntry obfInnerClassEntry) { |
| 701 | return m_outerClassesByInner.get(obfInnerClassEntry); | 701 | return this.outerClassesByInner.get(obfInnerClassEntry); |
| 702 | } | 702 | } |
| 703 | 703 | ||
| 704 | public boolean isAnonymousClass(ClassEntry obfInnerClassEntry) { | 704 | public boolean isAnonymousClass(ClassEntry obfInnerClassEntry) { |
| 705 | return m_anonymousClasses.containsKey(obfInnerClassEntry); | 705 | return this.anonymousClasses.containsKey(obfInnerClassEntry); |
| 706 | } | 706 | } |
| 707 | 707 | ||
| 708 | public BehaviorEntry getAnonymousClassCaller(ClassEntry obfInnerClassName) { | 708 | public BehaviorEntry getAnonymousClassCaller(ClassEntry obfInnerClassName) { |
| 709 | return m_anonymousClasses.get(obfInnerClassName); | 709 | return this.anonymousClasses.get(obfInnerClassName); |
| 710 | } | 710 | } |
| 711 | 711 | ||
| 712 | public Set<ClassEntry> getInterfaces(String className) { | 712 | public Set<ClassEntry> getInterfaces(String className) { |
| 713 | ClassEntry classEntry = new ClassEntry(className); | 713 | ClassEntry classEntry = new ClassEntry(className); |
| 714 | Set<ClassEntry> interfaces = new HashSet<ClassEntry>(); | 714 | Set<ClassEntry> interfaces = new HashSet<ClassEntry>(); |
| 715 | interfaces.addAll(m_translationIndex.getInterfaces(classEntry)); | 715 | interfaces.addAll(this.translationIndex.getInterfaces(classEntry)); |
| 716 | for (ClassEntry ancestor : m_translationIndex.getAncestry(classEntry)) { | 716 | for (ClassEntry ancestor : this.translationIndex.getAncestry(classEntry)) { |
| 717 | interfaces.addAll(m_translationIndex.getInterfaces(ancestor)); | 717 | interfaces.addAll(this.translationIndex.getInterfaces(ancestor)); |
| 718 | } | 718 | } |
| 719 | return interfaces; | 719 | return interfaces; |
| 720 | } | 720 | } |
| @@ -723,31 +723,31 @@ public class JarIndex { | |||
| 723 | 723 | ||
| 724 | // linear search is fast enough for now | 724 | // linear search is fast enough for now |
| 725 | Set<String> classNames = Sets.newHashSet(); | 725 | Set<String> classNames = Sets.newHashSet(); |
| 726 | for (Map.Entry<ClassEntry, ClassEntry> entry : m_translationIndex.getClassInterfaces()) { | 726 | for (Map.Entry<ClassEntry, ClassEntry> entry : this.translationIndex.getClassInterfaces()) { |
| 727 | ClassEntry classEntry = entry.getKey(); | 727 | ClassEntry classEntry = entry.getKey(); |
| 728 | ClassEntry interfaceEntry = entry.getValue(); | 728 | ClassEntry interfaceEntry = entry.getValue(); |
| 729 | if (interfaceEntry.getName().equals(targetInterfaceName)) { | 729 | if (interfaceEntry.getName().equals(targetInterfaceName)) { |
| 730 | classNames.add(classEntry.getClassName()); | 730 | classNames.add(classEntry.getClassName()); |
| 731 | m_translationIndex.getSubclassNamesRecursively(classNames, classEntry); | 731 | this.translationIndex.getSubclassNamesRecursively(classNames, classEntry); |
| 732 | } | 732 | } |
| 733 | } | 733 | } |
| 734 | return classNames; | 734 | return classNames; |
| 735 | } | 735 | } |
| 736 | 736 | ||
| 737 | public boolean isInterface(String className) { | 737 | public boolean isInterface(String className) { |
| 738 | return m_translationIndex.isInterface(new ClassEntry(className)); | 738 | return this.translationIndex.isInterface(new ClassEntry(className)); |
| 739 | } | 739 | } |
| 740 | 740 | ||
| 741 | public boolean containsObfClass(ClassEntry obfClassEntry) { | 741 | public boolean containsObfClass(ClassEntry obfClassEntry) { |
| 742 | return m_obfClassEntries.contains(obfClassEntry); | 742 | return this.obfClassEntries.contains(obfClassEntry); |
| 743 | } | 743 | } |
| 744 | 744 | ||
| 745 | public boolean containsObfField(FieldEntry obfFieldEntry) { | 745 | public boolean containsObfField(FieldEntry obfFieldEntry) { |
| 746 | return m_access.containsKey(obfFieldEntry); | 746 | return this.access.containsKey(obfFieldEntry); |
| 747 | } | 747 | } |
| 748 | 748 | ||
| 749 | public boolean containsObfBehavior(BehaviorEntry obfBehaviorEntry) { | 749 | public boolean containsObfBehavior(BehaviorEntry obfBehaviorEntry) { |
| 750 | return m_access.containsKey(obfBehaviorEntry); | 750 | return this.access.containsKey(obfBehaviorEntry); |
| 751 | } | 751 | } |
| 752 | 752 | ||
| 753 | public boolean containsObfArgument(ArgumentEntry obfArgumentEntry) { | 753 | public boolean containsObfArgument(ArgumentEntry obfArgumentEntry) { |
| @@ -776,7 +776,7 @@ public class JarIndex { | |||
| 776 | } | 776 | } |
| 777 | 777 | ||
| 778 | public MethodEntry getBridgedMethod(MethodEntry bridgeMethodEntry) { | 778 | public MethodEntry getBridgedMethod(MethodEntry bridgeMethodEntry) { |
| 779 | return m_bridgedMethods.get(bridgeMethodEntry); | 779 | return this.bridgedMethods.get(bridgeMethodEntry); |
| 780 | } | 780 | } |
| 781 | 781 | ||
| 782 | public List<ClassEntry> getObfClassChain(ClassEntry obfClassEntry) { | 782 | public List<ClassEntry> getObfClassChain(ClassEntry obfClassEntry) { |
diff --git a/src/main/java/cuchaz/enigma/analysis/MethodImplementationsTreeNode.java b/src/main/java/cuchaz/enigma/analysis/MethodImplementationsTreeNode.java index 2ee3ec1..1cf80d9 100644 --- a/src/main/java/cuchaz/enigma/analysis/MethodImplementationsTreeNode.java +++ b/src/main/java/cuchaz/enigma/analysis/MethodImplementationsTreeNode.java | |||
| @@ -24,40 +24,40 @@ public class MethodImplementationsTreeNode extends DefaultMutableTreeNode { | |||
| 24 | 24 | ||
| 25 | private static final long serialVersionUID = 3781080657461899915L; | 25 | private static final long serialVersionUID = 3781080657461899915L; |
| 26 | 26 | ||
| 27 | private Translator m_deobfuscatingTranslator; | 27 | private Translator deobfuscatingTranslator; |
| 28 | private MethodEntry m_entry; | 28 | private MethodEntry entry; |
| 29 | 29 | ||
| 30 | public MethodImplementationsTreeNode(Translator deobfuscatingTranslator, MethodEntry entry) { | 30 | public MethodImplementationsTreeNode(Translator deobfuscatingTranslator, MethodEntry entry) { |
| 31 | if (entry == null) { | 31 | if (entry == null) { |
| 32 | throw new IllegalArgumentException("entry cannot be null!"); | 32 | throw new IllegalArgumentException("Entry cannot be null!"); |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | m_deobfuscatingTranslator = deobfuscatingTranslator; | 35 | this.deobfuscatingTranslator = deobfuscatingTranslator; |
| 36 | m_entry = entry; | 36 | this.entry = entry; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | public MethodEntry getMethodEntry() { | 39 | public MethodEntry getMethodEntry() { |
| 40 | return m_entry; | 40 | return this.entry; |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | public String getDeobfClassName() { | 43 | public String getDeobfClassName() { |
| 44 | return m_deobfuscatingTranslator.translateClass(m_entry.getClassName()); | 44 | return this.deobfuscatingTranslator.translateClass(this.entry.getClassName()); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | public String getDeobfMethodName() { | 47 | public String getDeobfMethodName() { |
| 48 | return m_deobfuscatingTranslator.translate(m_entry); | 48 | return this.deobfuscatingTranslator.translate(this.entry); |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | @Override | 51 | @Override |
| 52 | public String toString() { | 52 | public String toString() { |
| 53 | String className = getDeobfClassName(); | 53 | String className = getDeobfClassName(); |
| 54 | if (className == null) { | 54 | if (className == null) { |
| 55 | className = m_entry.getClassName(); | 55 | className = this.entry.getClassName(); |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | String methodName = getDeobfMethodName(); | 58 | String methodName = getDeobfMethodName(); |
| 59 | if (methodName == null) { | 59 | if (methodName == null) { |
| 60 | methodName = m_entry.getName(); | 60 | methodName = this.entry.getName(); |
| 61 | } | 61 | } |
| 62 | return className + "." + methodName + "()"; | 62 | return className + "." + methodName + "()"; |
| 63 | } | 63 | } |
| @@ -66,14 +66,11 @@ public class MethodImplementationsTreeNode extends DefaultMutableTreeNode { | |||
| 66 | 66 | ||
| 67 | // get all method implementations | 67 | // get all method implementations |
| 68 | List<MethodImplementationsTreeNode> nodes = Lists.newArrayList(); | 68 | List<MethodImplementationsTreeNode> nodes = Lists.newArrayList(); |
| 69 | for (String implementingClassName : index.getImplementingClasses(m_entry.getClassName())) { | 69 | for (String implementingClassName : index.getImplementingClasses(this.entry.getClassName())) { |
| 70 | MethodEntry methodEntry = new MethodEntry( | 70 | MethodEntry methodEntry = new MethodEntry(new ClassEntry(implementingClassName), this.entry.getName(), this.entry.getSignature() |
| 71 | new ClassEntry(implementingClassName), | ||
| 72 | m_entry.getName(), | ||
| 73 | m_entry.getSignature() | ||
| 74 | ); | 71 | ); |
| 75 | if (index.containsObfBehavior(methodEntry)) { | 72 | if (index.containsObfBehavior(methodEntry)) { |
| 76 | nodes.add(new MethodImplementationsTreeNode(m_deobfuscatingTranslator, methodEntry)); | 73 | nodes.add(new MethodImplementationsTreeNode(this.deobfuscatingTranslator, methodEntry)); |
| 77 | } | 74 | } |
| 78 | } | 75 | } |
| 79 | 76 | ||
diff --git a/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java b/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java index cf42ac7..a3bed6e 100644 --- a/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java +++ b/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java | |||
| @@ -24,45 +24,45 @@ public class MethodInheritanceTreeNode extends DefaultMutableTreeNode { | |||
| 24 | 24 | ||
| 25 | private static final long serialVersionUID = 1096677030991810007L; | 25 | private static final long serialVersionUID = 1096677030991810007L; |
| 26 | 26 | ||
| 27 | private Translator m_deobfuscatingTranslator; | 27 | private Translator deobfuscatingTranslator; |
| 28 | private MethodEntry m_entry; | 28 | private MethodEntry entry; |
| 29 | private boolean m_isImplemented; | 29 | private boolean isImplemented; |
| 30 | 30 | ||
| 31 | public MethodInheritanceTreeNode(Translator deobfuscatingTranslator, MethodEntry entry, boolean isImplemented) { | 31 | public MethodInheritanceTreeNode(Translator deobfuscatingTranslator, MethodEntry entry, boolean isImplemented) { |
| 32 | m_deobfuscatingTranslator = deobfuscatingTranslator; | 32 | this.deobfuscatingTranslator = deobfuscatingTranslator; |
| 33 | m_entry = entry; | 33 | this.entry = entry; |
| 34 | m_isImplemented = isImplemented; | 34 | this.isImplemented = isImplemented; |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | public MethodEntry getMethodEntry() { | 37 | public MethodEntry getMethodEntry() { |
| 38 | return m_entry; | 38 | return this.entry; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | public String getDeobfClassName() { | 41 | public String getDeobfClassName() { |
| 42 | return m_deobfuscatingTranslator.translateClass(m_entry.getClassName()); | 42 | return this.deobfuscatingTranslator.translateClass(this.entry.getClassName()); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | public String getDeobfMethodName() { | 45 | public String getDeobfMethodName() { |
| 46 | return m_deobfuscatingTranslator.translate(m_entry); | 46 | return this.deobfuscatingTranslator.translate(this.entry); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | public boolean isImplemented() { | 49 | public boolean isImplemented() { |
| 50 | return m_isImplemented; | 50 | return this.isImplemented; |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | @Override | 53 | @Override |
| 54 | public String toString() { | 54 | public String toString() { |
| 55 | String className = getDeobfClassName(); | 55 | String className = getDeobfClassName(); |
| 56 | if (className == null) { | 56 | if (className == null) { |
| 57 | className = m_entry.getClassName(); | 57 | className = this.entry.getClassName(); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | if (!m_isImplemented) { | 60 | if (!this.isImplemented) { |
| 61 | return className; | 61 | return className; |
| 62 | } else { | 62 | } else { |
| 63 | String methodName = getDeobfMethodName(); | 63 | String methodName = getDeobfMethodName(); |
| 64 | if (methodName == null) { | 64 | if (methodName == null) { |
| 65 | methodName = m_entry.getName(); | 65 | methodName = this.entry.getName(); |
| 66 | } | 66 | } |
| 67 | return className + "." + methodName + "()"; | 67 | return className + "." + methodName + "()"; |
| 68 | } | 68 | } |
| @@ -71,16 +71,10 @@ public class MethodInheritanceTreeNode extends DefaultMutableTreeNode { | |||
| 71 | public void load(JarIndex index, boolean recurse) { | 71 | public void load(JarIndex index, boolean recurse) { |
| 72 | // get all the child nodes | 72 | // get all the child nodes |
| 73 | List<MethodInheritanceTreeNode> nodes = Lists.newArrayList(); | 73 | List<MethodInheritanceTreeNode> nodes = Lists.newArrayList(); |
| 74 | for (ClassEntry subclassEntry : index.getTranslationIndex().getSubclass(m_entry.getClassEntry())) { | 74 | for (ClassEntry subclassEntry : index.getTranslationIndex().getSubclass(this.entry.getClassEntry())) { |
| 75 | MethodEntry methodEntry = new MethodEntry( | 75 | MethodEntry methodEntry = new MethodEntry(subclassEntry, this.entry.getName(), this.entry.getSignature() |
| 76 | subclassEntry, | ||
| 77 | m_entry.getName(), | ||
| 78 | m_entry.getSignature() | ||
| 79 | ); | 76 | ); |
| 80 | nodes.add(new MethodInheritanceTreeNode( | 77 | nodes.add(new MethodInheritanceTreeNode(this.deobfuscatingTranslator, methodEntry, index.containsObfBehavior(methodEntry) |
| 81 | m_deobfuscatingTranslator, | ||
| 82 | methodEntry, | ||
| 83 | index.containsObfBehavior(methodEntry) | ||
| 84 | )); | 78 | )); |
| 85 | } | 79 | } |
| 86 | 80 | ||
diff --git a/src/main/java/cuchaz/enigma/analysis/SourceIndex.java b/src/main/java/cuchaz/enigma/analysis/SourceIndex.java index a20fbb4..cbc2945 100644 --- a/src/main/java/cuchaz/enigma/analysis/SourceIndex.java +++ b/src/main/java/cuchaz/enigma/analysis/SourceIndex.java | |||
| @@ -28,36 +28,36 @@ import cuchaz.enigma.mapping.Entry; | |||
| 28 | 28 | ||
| 29 | public class SourceIndex { | 29 | public class SourceIndex { |
| 30 | 30 | ||
| 31 | private String m_source; | 31 | private String source; |
| 32 | private TreeMap<Token, EntryReference<Entry, Entry>> m_tokenToReference; | 32 | private TreeMap<Token, EntryReference<Entry, Entry>> tokenToReference; |
| 33 | private Multimap<EntryReference<Entry, Entry>, Token> m_referenceToTokens; | 33 | private Multimap<EntryReference<Entry, Entry>, Token> referenceToTokens; |
| 34 | private Map<Entry, Token> m_declarationToToken; | 34 | private Map<Entry, Token> declarationToToken; |
| 35 | private List<Integer> m_lineOffsets; | 35 | private List<Integer> lineOffsets; |
| 36 | private boolean m_ignoreBadTokens; | 36 | private boolean ignoreBadTokens; |
| 37 | 37 | ||
| 38 | public SourceIndex(String source) { | 38 | public SourceIndex(String source) { |
| 39 | this(source, true); | 39 | this(source, true); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | public SourceIndex(String source, boolean ignoreBadTokens) { | 42 | public SourceIndex(String source, boolean ignoreBadTokens) { |
| 43 | m_source = source; | 43 | this.source = source; |
| 44 | m_ignoreBadTokens = ignoreBadTokens; | 44 | this.ignoreBadTokens = ignoreBadTokens; |
| 45 | m_tokenToReference = Maps.newTreeMap(); | 45 | this.tokenToReference = Maps.newTreeMap(); |
| 46 | m_referenceToTokens = HashMultimap.create(); | 46 | this.referenceToTokens = HashMultimap.create(); |
| 47 | m_declarationToToken = Maps.newHashMap(); | 47 | this.declarationToToken = Maps.newHashMap(); |
| 48 | m_lineOffsets = Lists.newArrayList(); | 48 | this.lineOffsets = Lists.newArrayList(); |
| 49 | 49 | ||
| 50 | // count the lines | 50 | // count the lines |
| 51 | m_lineOffsets.add(0); | 51 | this.lineOffsets.add(0); |
| 52 | for (int i = 0; i < source.length(); i++) { | 52 | for (int i = 0; i < source.length(); i++) { |
| 53 | if (source.charAt(i) == '\n') { | 53 | if (source.charAt(i) == '\n') { |
| 54 | m_lineOffsets.add(i + 1); | 54 | this.lineOffsets.add(i + 1); |
| 55 | } | 55 | } |
| 56 | } | 56 | } |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | public String getSource() { | 59 | public String getSource() { |
| 60 | return m_source; | 60 | return this.source; |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | public Token getToken(AstNode node) { | 63 | public Token getToken(AstNode node) { |
| @@ -75,11 +75,7 @@ public class SourceIndex { | |||
| 75 | System.err.println(String.format("WARNING: %s \"%s\" has invalid region: %s", node.getNodeType(), name, region)); | 75 | System.err.println(String.format("WARNING: %s \"%s\" has invalid region: %s", node.getNodeType(), name, region)); |
| 76 | return null; | 76 | return null; |
| 77 | } | 77 | } |
| 78 | Token token = new Token( | 78 | Token token = new Token(toPos(region.getBeginLine(), region.getBeginColumn()), toPos(region.getEndLine(), region.getEndColumn()), this.source); |
| 79 | toPos(region.getBeginLine(), region.getBeginColumn()), | ||
| 80 | toPos(region.getEndLine(), region.getEndColumn()), | ||
| 81 | m_source | ||
| 82 | ); | ||
| 83 | if (token.start == 0) { | 79 | if (token.start == 0) { |
| 84 | // DEBUG | 80 | // DEBUG |
| 85 | System.err.println(String.format("WARNING: %s \"%s\" has invalid start: %s", node.getNodeType(), name, region)); | 81 | System.err.println(String.format("WARNING: %s \"%s\" has invalid start: %s", node.getNodeType(), name, region)); |
| @@ -90,7 +86,7 @@ public class SourceIndex { | |||
| 90 | // System.out.println( String.format( "%s \"%s\" region: %s", node.getNodeType(), name, region ) ); | 86 | // System.out.println( String.format( "%s \"%s\" region: %s", node.getNodeType(), name, region ) ); |
| 91 | 87 | ||
| 92 | // if the token has a $ in it, something's wrong. Ignore this token | 88 | // if the token has a $ in it, something's wrong. Ignore this token |
| 93 | if (name.lastIndexOf('$') >= 0 && m_ignoreBadTokens) { | 89 | if (name.lastIndexOf('$') >= 0 && this.ignoreBadTokens) { |
| 94 | // DEBUG | 90 | // DEBUG |
| 95 | System.err.println(String.format("WARNING: %s \"%s\" is probably a bad token. It was ignored", node.getNodeType(), name)); | 91 | System.err.println(String.format("WARNING: %s \"%s\" is probably a bad token. It was ignored", node.getNodeType(), name)); |
| 96 | return null; | 92 | return null; |
| @@ -103,8 +99,8 @@ public class SourceIndex { | |||
| 103 | Token token = getToken(node); | 99 | Token token = getToken(node); |
| 104 | if (token != null) { | 100 | if (token != null) { |
| 105 | EntryReference<Entry, Entry> deobfReference = new EntryReference<Entry, Entry>(deobfEntry, token.text, deobfContext); | 101 | EntryReference<Entry, Entry> deobfReference = new EntryReference<Entry, Entry>(deobfEntry, token.text, deobfContext); |
| 106 | m_tokenToReference.put(token, deobfReference); | 102 | this.tokenToReference.put(token, deobfReference); |
| 107 | m_referenceToTokens.put(deobfReference, token); | 103 | this.referenceToTokens.put(deobfReference, token); |
| 108 | } | 104 | } |
| 109 | } | 105 | } |
| 110 | 106 | ||
| @@ -112,14 +108,14 @@ public class SourceIndex { | |||
| 112 | Token token = getToken(node); | 108 | Token token = getToken(node); |
| 113 | if (token != null) { | 109 | if (token != null) { |
| 114 | EntryReference<Entry, Entry> reference = new EntryReference<Entry, Entry>(deobfEntry, token.text); | 110 | EntryReference<Entry, Entry> reference = new EntryReference<Entry, Entry>(deobfEntry, token.text); |
| 115 | m_tokenToReference.put(token, reference); | 111 | this.tokenToReference.put(token, reference); |
| 116 | m_referenceToTokens.put(reference, token); | 112 | this.referenceToTokens.put(reference, token); |
| 117 | m_declarationToToken.put(deobfEntry, token); | 113 | this.declarationToToken.put(deobfEntry, token); |
| 118 | } | 114 | } |
| 119 | } | 115 | } |
| 120 | 116 | ||
| 121 | public Token getReferenceToken(int pos) { | 117 | public Token getReferenceToken(int pos) { |
| 122 | Token token = m_tokenToReference.floorKey(new Token(pos, pos, null)); | 118 | Token token = this.tokenToReference.floorKey(new Token(pos, pos, null)); |
| 123 | if (token != null && token.contains(pos)) { | 119 | if (token != null && token.contains(pos)) { |
| 124 | return token; | 120 | return token; |
| 125 | } | 121 | } |
| @@ -127,44 +123,44 @@ public class SourceIndex { | |||
| 127 | } | 123 | } |
| 128 | 124 | ||
| 129 | public Collection<Token> getReferenceTokens(EntryReference<Entry, Entry> deobfReference) { | 125 | public Collection<Token> getReferenceTokens(EntryReference<Entry, Entry> deobfReference) { |
| 130 | return m_referenceToTokens.get(deobfReference); | 126 | return this.referenceToTokens.get(deobfReference); |
| 131 | } | 127 | } |
| 132 | 128 | ||
| 133 | public EntryReference<Entry, Entry> getDeobfReference(Token token) { | 129 | public EntryReference<Entry, Entry> getDeobfReference(Token token) { |
| 134 | if (token == null) { | 130 | if (token == null) { |
| 135 | return null; | 131 | return null; |
| 136 | } | 132 | } |
| 137 | return m_tokenToReference.get(token); | 133 | return this.tokenToReference.get(token); |
| 138 | } | 134 | } |
| 139 | 135 | ||
| 140 | public void replaceDeobfReference(Token token, EntryReference<Entry, Entry> newDeobfReference) { | 136 | public void replaceDeobfReference(Token token, EntryReference<Entry, Entry> newDeobfReference) { |
| 141 | EntryReference<Entry, Entry> oldDeobfReference = m_tokenToReference.get(token); | 137 | EntryReference<Entry, Entry> oldDeobfReference = this.tokenToReference.get(token); |
| 142 | m_tokenToReference.put(token, newDeobfReference); | 138 | this.tokenToReference.put(token, newDeobfReference); |
| 143 | Collection<Token> tokens = m_referenceToTokens.get(oldDeobfReference); | 139 | Collection<Token> tokens = this.referenceToTokens.get(oldDeobfReference); |
| 144 | m_referenceToTokens.removeAll(oldDeobfReference); | 140 | this.referenceToTokens.removeAll(oldDeobfReference); |
| 145 | m_referenceToTokens.putAll(newDeobfReference, tokens); | 141 | this.referenceToTokens.putAll(newDeobfReference, tokens); |
| 146 | } | 142 | } |
| 147 | 143 | ||
| 148 | public Iterable<Token> referenceTokens() { | 144 | public Iterable<Token> referenceTokens() { |
| 149 | return m_tokenToReference.keySet(); | 145 | return this.tokenToReference.keySet(); |
| 150 | } | 146 | } |
| 151 | 147 | ||
| 152 | public Iterable<Token> declarationTokens() { | 148 | public Iterable<Token> declarationTokens() { |
| 153 | return m_declarationToToken.values(); | 149 | return this.declarationToToken.values(); |
| 154 | } | 150 | } |
| 155 | 151 | ||
| 156 | public Iterable<Entry> declarations() { | 152 | public Iterable<Entry> declarations() { |
| 157 | return m_declarationToToken.keySet(); | 153 | return this.declarationToToken.keySet(); |
| 158 | } | 154 | } |
| 159 | 155 | ||
| 160 | public Token getDeclarationToken(Entry deobfEntry) { | 156 | public Token getDeclarationToken(Entry deobfEntry) { |
| 161 | return m_declarationToToken.get(deobfEntry); | 157 | return this.declarationToToken.get(deobfEntry); |
| 162 | } | 158 | } |
| 163 | 159 | ||
| 164 | public int getLineNumber(int pos) { | 160 | public int getLineNumber(int pos) { |
| 165 | // line number is 1-based | 161 | // line number is 1-based |
| 166 | int line = 0; | 162 | int line = 0; |
| 167 | for (Integer offset : m_lineOffsets) { | 163 | for (Integer offset : this.lineOffsets) { |
| 168 | if (offset > pos) { | 164 | if (offset > pos) { |
| 169 | break; | 165 | break; |
| 170 | } | 166 | } |
| @@ -175,11 +171,11 @@ public class SourceIndex { | |||
| 175 | 171 | ||
| 176 | public int getColumnNumber(int pos) { | 172 | public int getColumnNumber(int pos) { |
| 177 | // column number is 1-based | 173 | // column number is 1-based |
| 178 | return pos - m_lineOffsets.get(getLineNumber(pos) - 1) + 1; | 174 | return pos - this.lineOffsets.get(getLineNumber(pos) - 1) + 1; |
| 179 | } | 175 | } |
| 180 | 176 | ||
| 181 | private int toPos(int line, int col) { | 177 | private int toPos(int line, int col) { |
| 182 | // line and col are 1-based | 178 | // line and col are 1-based |
| 183 | return m_lineOffsets.get(line - 1) + col - 1; | 179 | return this.lineOffsets.get(line - 1) + col - 1; |
| 184 | } | 180 | } |
| 185 | } | 181 | } |
diff --git a/src/main/java/cuchaz/enigma/analysis/SourceIndexBehaviorVisitor.java b/src/main/java/cuchaz/enigma/analysis/SourceIndexBehaviorVisitor.java index e2b567e..4a468e7 100644 --- a/src/main/java/cuchaz/enigma/analysis/SourceIndexBehaviorVisitor.java +++ b/src/main/java/cuchaz/enigma/analysis/SourceIndexBehaviorVisitor.java | |||
| @@ -14,16 +14,16 @@ import com.strobel.assembler.metadata.*; | |||
| 14 | import com.strobel.decompiler.languages.TextLocation; | 14 | import com.strobel.decompiler.languages.TextLocation; |
| 15 | import com.strobel.decompiler.languages.java.ast.*; | 15 | import com.strobel.decompiler.languages.java.ast.*; |
| 16 | 16 | ||
| 17 | import cuchaz.enigma.mapping.*; | ||
| 18 | |||
| 19 | import java.lang.Error; | 17 | import java.lang.Error; |
| 20 | 18 | ||
| 19 | import cuchaz.enigma.mapping.*; | ||
| 20 | |||
| 21 | public class SourceIndexBehaviorVisitor extends SourceIndexVisitor { | 21 | public class SourceIndexBehaviorVisitor extends SourceIndexVisitor { |
| 22 | 22 | ||
| 23 | private BehaviorEntry m_behaviorEntry; | 23 | private BehaviorEntry behaviorEntry; |
| 24 | 24 | ||
| 25 | public SourceIndexBehaviorVisitor(BehaviorEntry behaviorEntry) { | 25 | public SourceIndexBehaviorVisitor(BehaviorEntry behaviorEntry) { |
| 26 | m_behaviorEntry = behaviorEntry; | 26 | this.behaviorEntry = behaviorEntry; |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | @Override | 29 | @Override |
| @@ -54,7 +54,7 @@ public class SourceIndexBehaviorVisitor extends SourceIndexVisitor { | |||
| 54 | tokenNode = node.getTarget(); | 54 | tokenNode = node.getTarget(); |
| 55 | } | 55 | } |
| 56 | if (tokenNode != null) { | 56 | if (tokenNode != null) { |
| 57 | index.addReference(tokenNode, behaviorEntry, m_behaviorEntry); | 57 | index.addReference(tokenNode, behaviorEntry, this.behaviorEntry); |
| 58 | } | 58 | } |
| 59 | } | 59 | } |
| 60 | 60 | ||
| @@ -72,7 +72,7 @@ public class SourceIndexBehaviorVisitor extends SourceIndexVisitor { | |||
| 72 | 72 | ||
| 73 | ClassEntry classEntry = new ClassEntry(ref.getDeclaringType().getInternalName()); | 73 | ClassEntry classEntry = new ClassEntry(ref.getDeclaringType().getInternalName()); |
| 74 | FieldEntry fieldEntry = new FieldEntry(classEntry, ref.getName(), new Type(ref.getErasedSignature())); | 74 | FieldEntry fieldEntry = new FieldEntry(classEntry, ref.getName(), new Type(ref.getErasedSignature())); |
| 75 | index.addReference(node.getMemberNameToken(), fieldEntry, m_behaviorEntry); | 75 | index.addReference(node.getMemberNameToken(), fieldEntry, this.behaviorEntry); |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | return recurse(node, index); | 78 | return recurse(node, index); |
| @@ -83,7 +83,7 @@ public class SourceIndexBehaviorVisitor extends SourceIndexVisitor { | |||
| 83 | TypeReference ref = node.getUserData(Keys.TYPE_REFERENCE); | 83 | TypeReference ref = node.getUserData(Keys.TYPE_REFERENCE); |
| 84 | if (node.getIdentifierToken().getStartLocation() != TextLocation.EMPTY) { | 84 | if (node.getIdentifierToken().getStartLocation() != TextLocation.EMPTY) { |
| 85 | ClassEntry classEntry = new ClassEntry(ref.getInternalName()); | 85 | ClassEntry classEntry = new ClassEntry(ref.getInternalName()); |
| 86 | index.addReference(node.getIdentifierToken(), classEntry, m_behaviorEntry); | 86 | index.addReference(node.getIdentifierToken(), classEntry, this.behaviorEntry); |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | return recurse(node, index); | 89 | return recurse(node, index); |
| @@ -108,7 +108,7 @@ public class SourceIndexBehaviorVisitor extends SourceIndexVisitor { | |||
| 108 | if (ref != null) { | 108 | if (ref != null) { |
| 109 | ClassEntry classEntry = new ClassEntry(ref.getDeclaringType().getInternalName()); | 109 | ClassEntry classEntry = new ClassEntry(ref.getDeclaringType().getInternalName()); |
| 110 | FieldEntry fieldEntry = new FieldEntry(classEntry, ref.getName(), new Type(ref.getErasedSignature())); | 110 | FieldEntry fieldEntry = new FieldEntry(classEntry, ref.getName(), new Type(ref.getErasedSignature())); |
| 111 | index.addReference(node.getIdentifierToken(), fieldEntry, m_behaviorEntry); | 111 | index.addReference(node.getIdentifierToken(), fieldEntry, this.behaviorEntry); |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | return recurse(node, index); | 114 | return recurse(node, index); |
| @@ -122,7 +122,7 @@ public class SourceIndexBehaviorVisitor extends SourceIndexVisitor { | |||
| 122 | ConstructorEntry constructorEntry = new ConstructorEntry(classEntry, new Signature(ref.getErasedSignature())); | 122 | ConstructorEntry constructorEntry = new ConstructorEntry(classEntry, new Signature(ref.getErasedSignature())); |
| 123 | if (node.getType() instanceof SimpleType) { | 123 | if (node.getType() instanceof SimpleType) { |
| 124 | SimpleType simpleTypeNode = (SimpleType) node.getType(); | 124 | SimpleType simpleTypeNode = (SimpleType) node.getType(); |
| 125 | index.addReference(simpleTypeNode.getIdentifierToken(), constructorEntry, m_behaviorEntry); | 125 | index.addReference(simpleTypeNode.getIdentifierToken(), constructorEntry, this.behaviorEntry); |
| 126 | } | 126 | } |
| 127 | } | 127 | } |
| 128 | 128 | ||
diff --git a/src/main/java/cuchaz/enigma/analysis/SourceIndexClassVisitor.java b/src/main/java/cuchaz/enigma/analysis/SourceIndexClassVisitor.java index 0a3bad5..06ce042 100644 --- a/src/main/java/cuchaz/enigma/analysis/SourceIndexClassVisitor.java +++ b/src/main/java/cuchaz/enigma/analysis/SourceIndexClassVisitor.java | |||
| @@ -21,10 +21,10 @@ import cuchaz.enigma.mapping.*; | |||
| 21 | 21 | ||
| 22 | public class SourceIndexClassVisitor extends SourceIndexVisitor { | 22 | public class SourceIndexClassVisitor extends SourceIndexVisitor { |
| 23 | 23 | ||
| 24 | private ClassEntry m_classEntry; | 24 | private ClassEntry classEntry; |
| 25 | 25 | ||
| 26 | public SourceIndexClassVisitor(ClassEntry classEntry) { | 26 | public SourceIndexClassVisitor(ClassEntry classEntry) { |
| 27 | m_classEntry = classEntry; | 27 | this.classEntry = classEntry; |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | @Override | 30 | @Override |
| @@ -32,7 +32,7 @@ public class SourceIndexClassVisitor extends SourceIndexVisitor { | |||
| 32 | // is this this class, or a subtype? | 32 | // is this this class, or a subtype? |
| 33 | TypeDefinition def = node.getUserData(Keys.TYPE_DEFINITION); | 33 | TypeDefinition def = node.getUserData(Keys.TYPE_DEFINITION); |
| 34 | ClassEntry classEntry = new ClassEntry(def.getInternalName()); | 34 | ClassEntry classEntry = new ClassEntry(def.getInternalName()); |
| 35 | if (!classEntry.equals(m_classEntry)) { | 35 | if (!classEntry.equals(this.classEntry)) { |
| 36 | // it's a sub-type, recurse | 36 | // it's a sub-type, recurse |
| 37 | index.addDeclaration(node.getNameToken(), classEntry); | 37 | index.addDeclaration(node.getNameToken(), classEntry); |
| 38 | return node.acceptVisitor(new SourceIndexClassVisitor(classEntry), index); | 38 | return node.acceptVisitor(new SourceIndexClassVisitor(classEntry), index); |
| @@ -46,7 +46,7 @@ public class SourceIndexClassVisitor extends SourceIndexVisitor { | |||
| 46 | TypeReference ref = node.getUserData(Keys.TYPE_REFERENCE); | 46 | TypeReference ref = node.getUserData(Keys.TYPE_REFERENCE); |
| 47 | if (node.getIdentifierToken().getStartLocation() != TextLocation.EMPTY) { | 47 | if (node.getIdentifierToken().getStartLocation() != TextLocation.EMPTY) { |
| 48 | ClassEntry classEntry = new ClassEntry(ref.getInternalName()); | 48 | ClassEntry classEntry = new ClassEntry(ref.getInternalName()); |
| 49 | index.addReference(node.getIdentifierToken(), classEntry, m_classEntry); | 49 | index.addReference(node.getIdentifierToken(), classEntry, this.classEntry); |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | return recurse(node, index); | 52 | return recurse(node, index); |
diff --git a/src/main/java/cuchaz/enigma/analysis/Token.java b/src/main/java/cuchaz/enigma/analysis/Token.java index 0103df2..575c373 100644 --- a/src/main/java/cuchaz/enigma/analysis/Token.java +++ b/src/main/java/cuchaz/enigma/analysis/Token.java | |||
| @@ -39,10 +39,7 @@ public class Token implements Comparable<Token> { | |||
| 39 | 39 | ||
| 40 | @Override | 40 | @Override |
| 41 | public boolean equals(Object other) { | 41 | public boolean equals(Object other) { |
| 42 | if (other instanceof Token) { | 42 | return other instanceof Token && equals((Token) other); |
| 43 | return equals((Token) other); | ||
| 44 | } | ||
| 45 | return false; | ||
| 46 | } | 43 | } |
| 47 | 44 | ||
| 48 | public boolean equals(Token other) { | 45 | public boolean equals(Token other) { |
diff --git a/src/main/java/cuchaz/enigma/analysis/TranslationIndex.java b/src/main/java/cuchaz/enigma/analysis/TranslationIndex.java index 0261a96..f020ae2 100644 --- a/src/main/java/cuchaz/enigma/analysis/TranslationIndex.java +++ b/src/main/java/cuchaz/enigma/analysis/TranslationIndex.java | |||
| @@ -30,50 +30,47 @@ public class TranslationIndex implements Serializable { | |||
| 30 | 30 | ||
| 31 | private static final long serialVersionUID = 738687982126844179L; | 31 | private static final long serialVersionUID = 738687982126844179L; |
| 32 | 32 | ||
| 33 | private Map<ClassEntry, ClassEntry> m_superclasses; | 33 | private Map<ClassEntry, ClassEntry> superclasses; |
| 34 | private Multimap<ClassEntry, FieldEntry> m_fieldEntries; | 34 | private Multimap<ClassEntry, FieldEntry> fieldEntries; |
| 35 | private Multimap<ClassEntry, BehaviorEntry> m_behaviorEntries; | 35 | private Multimap<ClassEntry, BehaviorEntry> behaviorEntries; |
| 36 | private Multimap<ClassEntry, ClassEntry> m_interfaces; | 36 | private Multimap<ClassEntry, ClassEntry> interfaces; |
| 37 | 37 | ||
| 38 | public TranslationIndex() { | 38 | public TranslationIndex() { |
| 39 | m_superclasses = Maps.newHashMap(); | 39 | this.superclasses = Maps.newHashMap(); |
| 40 | m_fieldEntries = HashMultimap.create(); | 40 | this.fieldEntries = HashMultimap.create(); |
| 41 | m_behaviorEntries = HashMultimap.create(); | 41 | this.behaviorEntries = HashMultimap.create(); |
| 42 | m_interfaces = HashMultimap.create(); | 42 | this.interfaces = HashMultimap.create(); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | public TranslationIndex(TranslationIndex other, Translator translator) { | 45 | public TranslationIndex(TranslationIndex other, Translator translator) { |
| 46 | 46 | ||
| 47 | // translate the superclasses | 47 | // translate the superclasses |
| 48 | m_superclasses = Maps.newHashMap(); | 48 | this.superclasses = Maps.newHashMap(); |
| 49 | for (Map.Entry<ClassEntry, ClassEntry> mapEntry : other.m_superclasses.entrySet()) { | 49 | for (Map.Entry<ClassEntry, ClassEntry> mapEntry : other.superclasses.entrySet()) { |
| 50 | m_superclasses.put( | 50 | this.superclasses.put(translator.translateEntry(mapEntry.getKey()), translator.translateEntry(mapEntry.getValue())); |
| 51 | translator.translateEntry(mapEntry.getKey()), | ||
| 52 | translator.translateEntry(mapEntry.getValue()) | ||
| 53 | ); | ||
| 54 | } | 51 | } |
| 55 | 52 | ||
| 56 | // translate the interfaces | 53 | // translate the interfaces |
| 57 | m_interfaces = HashMultimap.create(); | 54 | this.interfaces = HashMultimap.create(); |
| 58 | for (Map.Entry<ClassEntry, ClassEntry> mapEntry : other.m_interfaces.entries()) { | 55 | for (Map.Entry<ClassEntry, ClassEntry> mapEntry : other.interfaces.entries()) { |
| 59 | m_interfaces.put( | 56 | this.interfaces.put( |
| 60 | translator.translateEntry(mapEntry.getKey()), | 57 | translator.translateEntry(mapEntry.getKey()), |
| 61 | translator.translateEntry(mapEntry.getValue()) | 58 | translator.translateEntry(mapEntry.getValue()) |
| 62 | ); | 59 | ); |
| 63 | } | 60 | } |
| 64 | 61 | ||
| 65 | // translate the fields | 62 | // translate the fields |
| 66 | m_fieldEntries = HashMultimap.create(); | 63 | this.fieldEntries = HashMultimap.create(); |
| 67 | for (Map.Entry<ClassEntry, FieldEntry> mapEntry : other.m_fieldEntries.entries()) { | 64 | for (Map.Entry<ClassEntry, FieldEntry> mapEntry : other.fieldEntries.entries()) { |
| 68 | m_fieldEntries.put( | 65 | this.fieldEntries.put( |
| 69 | translator.translateEntry(mapEntry.getKey()), | 66 | translator.translateEntry(mapEntry.getKey()), |
| 70 | translator.translateEntry(mapEntry.getValue()) | 67 | translator.translateEntry(mapEntry.getValue()) |
| 71 | ); | 68 | ); |
| 72 | } | 69 | } |
| 73 | 70 | ||
| 74 | m_behaviorEntries = HashMultimap.create(); | 71 | this.behaviorEntries = HashMultimap.create(); |
| 75 | for (Map.Entry<ClassEntry, BehaviorEntry> mapEntry : other.m_behaviorEntries.entries()) { | 72 | for (Map.Entry<ClassEntry, BehaviorEntry> mapEntry : other.behaviorEntries.entries()) { |
| 76 | m_behaviorEntries.put( | 73 | this.behaviorEntries.put( |
| 77 | translator.translateEntry(mapEntry.getKey()), | 74 | translator.translateEntry(mapEntry.getKey()), |
| 78 | translator.translateEntry(mapEntry.getValue()) | 75 | translator.translateEntry(mapEntry.getValue()) |
| 79 | ); | 76 | ); |
| @@ -94,14 +91,14 @@ public class TranslationIndex implements Serializable { | |||
| 94 | // add the superclass | 91 | // add the superclass |
| 95 | ClassEntry superclassEntry = EntryFactory.getSuperclassEntry(c); | 92 | ClassEntry superclassEntry = EntryFactory.getSuperclassEntry(c); |
| 96 | if (superclassEntry != null) { | 93 | if (superclassEntry != null) { |
| 97 | m_superclasses.put(classEntry, superclassEntry); | 94 | this.superclasses.put(classEntry, superclassEntry); |
| 98 | } | 95 | } |
| 99 | 96 | ||
| 100 | // add the interfaces | 97 | // add the interfaces |
| 101 | for (String interfaceClassName : c.getClassFile().getInterfaces()) { | 98 | for (String interfaceClassName : c.getClassFile().getInterfaces()) { |
| 102 | ClassEntry interfaceClassEntry = new ClassEntry(Descriptor.toJvmName(interfaceClassName)); | 99 | ClassEntry interfaceClassEntry = new ClassEntry(Descriptor.toJvmName(interfaceClassName)); |
| 103 | if (!isJre(interfaceClassEntry)) { | 100 | if (!isJre(interfaceClassEntry)) { |
| 104 | m_interfaces.put(classEntry, interfaceClassEntry); | 101 | this.interfaces.put(classEntry, interfaceClassEntry); |
| 105 | } | 102 | } |
| 106 | } | 103 | } |
| 107 | 104 | ||
| @@ -109,25 +106,25 @@ public class TranslationIndex implements Serializable { | |||
| 109 | // add fields | 106 | // add fields |
| 110 | for (CtField field : c.getDeclaredFields()) { | 107 | for (CtField field : c.getDeclaredFields()) { |
| 111 | FieldEntry fieldEntry = EntryFactory.getFieldEntry(field); | 108 | FieldEntry fieldEntry = EntryFactory.getFieldEntry(field); |
| 112 | m_fieldEntries.put(fieldEntry.getClassEntry(), fieldEntry); | 109 | this.fieldEntries.put(fieldEntry.getClassEntry(), fieldEntry); |
| 113 | } | 110 | } |
| 114 | 111 | ||
| 115 | // add behaviors | 112 | // add behaviors |
| 116 | for (CtBehavior behavior : c.getDeclaredBehaviors()) { | 113 | for (CtBehavior behavior : c.getDeclaredBehaviors()) { |
| 117 | BehaviorEntry behaviorEntry = EntryFactory.getBehaviorEntry(behavior); | 114 | BehaviorEntry behaviorEntry = EntryFactory.getBehaviorEntry(behavior); |
| 118 | m_behaviorEntries.put(behaviorEntry.getClassEntry(), behaviorEntry); | 115 | this.behaviorEntries.put(behaviorEntry.getClassEntry(), behaviorEntry); |
| 119 | } | 116 | } |
| 120 | } | 117 | } |
| 121 | } | 118 | } |
| 122 | 119 | ||
| 123 | public void renameClasses(Map<String, String> renames) { | 120 | public void renameClasses(Map<String, String> renames) { |
| 124 | EntryRenamer.renameClassesInMap(renames, m_superclasses); | 121 | EntryRenamer.renameClassesInMap(renames, this.superclasses); |
| 125 | EntryRenamer.renameClassesInMultimap(renames, m_fieldEntries); | 122 | EntryRenamer.renameClassesInMultimap(renames,this.fieldEntries); |
| 126 | EntryRenamer.renameClassesInMultimap(renames, m_behaviorEntries); | 123 | EntryRenamer.renameClassesInMultimap(renames, this.behaviorEntries); |
| 127 | } | 124 | } |
| 128 | 125 | ||
| 129 | public ClassEntry getSuperclass(ClassEntry classEntry) { | 126 | public ClassEntry getSuperclass(ClassEntry classEntry) { |
| 130 | return m_superclasses.get(classEntry); | 127 | return this.superclasses.get(classEntry); |
| 131 | } | 128 | } |
| 132 | 129 | ||
| 133 | public List<ClassEntry> getAncestry(ClassEntry classEntry) { | 130 | public List<ClassEntry> getAncestry(ClassEntry classEntry) { |
| @@ -145,7 +142,7 @@ public class TranslationIndex implements Serializable { | |||
| 145 | 142 | ||
| 146 | // linear search is fast enough for now | 143 | // linear search is fast enough for now |
| 147 | List<ClassEntry> subclasses = Lists.newArrayList(); | 144 | List<ClassEntry> subclasses = Lists.newArrayList(); |
| 148 | for (Map.Entry<ClassEntry, ClassEntry> entry : m_superclasses.entrySet()) { | 145 | for (Map.Entry<ClassEntry, ClassEntry> entry : this.superclasses.entrySet()) { |
| 149 | ClassEntry subclass = entry.getKey(); | 146 | ClassEntry subclass = entry.getKey(); |
| 150 | ClassEntry superclass = entry.getValue(); | 147 | ClassEntry superclass = entry.getValue(); |
| 151 | if (classEntry.equals(superclass)) { | 148 | if (classEntry.equals(superclass)) { |
| @@ -170,15 +167,15 @@ public class TranslationIndex implements Serializable { | |||
| 170 | } | 167 | } |
| 171 | 168 | ||
| 172 | public Collection<Map.Entry<ClassEntry, ClassEntry>> getClassInterfaces() { | 169 | public Collection<Map.Entry<ClassEntry, ClassEntry>> getClassInterfaces() { |
| 173 | return m_interfaces.entries(); | 170 | return this.interfaces.entries(); |
| 174 | } | 171 | } |
| 175 | 172 | ||
| 176 | public Collection<ClassEntry> getInterfaces(ClassEntry classEntry) { | 173 | public Collection<ClassEntry> getInterfaces(ClassEntry classEntry) { |
| 177 | return m_interfaces.get(classEntry); | 174 | return this.interfaces.get(classEntry); |
| 178 | } | 175 | } |
| 179 | 176 | ||
| 180 | public boolean isInterface(ClassEntry classEntry) { | 177 | public boolean isInterface(ClassEntry classEntry) { |
| 181 | return m_interfaces.containsValue(classEntry); | 178 | return this.interfaces.containsValue(classEntry); |
| 182 | } | 179 | } |
| 183 | 180 | ||
| 184 | public boolean entryExists(Entry entry) { | 181 | public boolean entryExists(Entry entry) { |
| @@ -193,11 +190,11 @@ public class TranslationIndex implements Serializable { | |||
| 193 | } | 190 | } |
| 194 | 191 | ||
| 195 | public boolean fieldExists(FieldEntry fieldEntry) { | 192 | public boolean fieldExists(FieldEntry fieldEntry) { |
| 196 | return m_fieldEntries.containsEntry(fieldEntry.getClassEntry(), fieldEntry); | 193 | return this.fieldEntries.containsEntry(fieldEntry.getClassEntry(), fieldEntry); |
| 197 | } | 194 | } |
| 198 | 195 | ||
| 199 | public boolean behaviorExists(BehaviorEntry behaviorEntry) { | 196 | public boolean behaviorExists(BehaviorEntry behaviorEntry) { |
| 200 | return m_behaviorEntries.containsEntry(behaviorEntry.getClassEntry(), behaviorEntry); | 197 | return this.behaviorEntries.containsEntry(behaviorEntry.getClassEntry(), behaviorEntry); |
| 201 | } | 198 | } |
| 202 | 199 | ||
| 203 | public ClassEntry resolveEntryClass(Entry entry) { | 200 | public ClassEntry resolveEntryClass(Entry entry) { |
| @@ -243,7 +240,7 @@ public class TranslationIndex implements Serializable { | |||
| 243 | 240 | ||
| 244 | // the interfaces for any class is a forest | 241 | // the interfaces for any class is a forest |
| 245 | // so let's look at all the trees | 242 | // so let's look at all the trees |
| 246 | for (ClassEntry interfaceEntry : m_interfaces.get(entry.getClassEntry())) { | 243 | for (ClassEntry interfaceEntry : this.interfaces.get(entry.getClassEntry())) { |
| 247 | ClassEntry resolvedClassEntry = resolveSuperclass(entry.cloneToNewClass(interfaceEntry)); | 244 | ClassEntry resolvedClassEntry = resolveSuperclass(entry.cloneToNewClass(interfaceEntry)); |
| 248 | if (resolvedClassEntry != null) { | 245 | if (resolvedClassEntry != null) { |
| 249 | return resolvedClassEntry; | 246 | return resolvedClassEntry; |
| @@ -261,9 +258,9 @@ public class TranslationIndex implements Serializable { | |||
| 261 | throws IOException { | 258 | throws IOException { |
| 262 | GZIPOutputStream gzipout = new GZIPOutputStream(out); | 259 | GZIPOutputStream gzipout = new GZIPOutputStream(out); |
| 263 | ObjectOutputStream oout = new ObjectOutputStream(gzipout); | 260 | ObjectOutputStream oout = new ObjectOutputStream(gzipout); |
| 264 | oout.writeObject(m_superclasses); | 261 | oout.writeObject(this.superclasses); |
| 265 | oout.writeObject(m_fieldEntries); | 262 | oout.writeObject(this.fieldEntries); |
| 266 | oout.writeObject(m_behaviorEntries); | 263 | oout.writeObject(this.behaviorEntries); |
| 267 | gzipout.finish(); | 264 | gzipout.finish(); |
| 268 | } | 265 | } |
| 269 | 266 | ||
| @@ -272,9 +269,9 @@ public class TranslationIndex implements Serializable { | |||
| 272 | throws IOException { | 269 | throws IOException { |
| 273 | try { | 270 | try { |
| 274 | ObjectInputStream oin = new ObjectInputStream(new GZIPInputStream(in)); | 271 | ObjectInputStream oin = new ObjectInputStream(new GZIPInputStream(in)); |
| 275 | m_superclasses = (HashMap<ClassEntry, ClassEntry>) oin.readObject(); | 272 | this.superclasses = (HashMap<ClassEntry, ClassEntry>) oin.readObject(); |
| 276 | m_fieldEntries = (HashMultimap<ClassEntry, FieldEntry>) oin.readObject(); | 273 | this.fieldEntries = (HashMultimap<ClassEntry, FieldEntry>) oin.readObject(); |
| 277 | m_behaviorEntries = (HashMultimap<ClassEntry, BehaviorEntry>) oin.readObject(); | 274 | this.behaviorEntries = (HashMultimap<ClassEntry, BehaviorEntry>) oin.readObject(); |
| 278 | } catch (ClassNotFoundException ex) { | 275 | } catch (ClassNotFoundException ex) { |
| 279 | throw new Error(ex); | 276 | throw new Error(ex); |
| 280 | } | 277 | } |