diff options
| author | 2016-10-16 12:46:22 +0200 | |
|---|---|---|
| committer | 2016-10-16 12:46:22 +0200 | |
| commit | 0a77e12541330857d5e9801024b2503218f3385b (patch) | |
| tree | 775f4aa85caf4ae6dffff8053750a39252f55cc2 /src/main/java/cuchaz | |
| parent | Rewrite translate(ArgumentEntry in) logic (Fix #44) (diff) | |
| download | enigma-0a77e12541330857d5e9801024b2503218f3385b.tar.gz enigma-0a77e12541330857d5e9801024b2503218f3385b.tar.xz enigma-0a77e12541330857d5e9801024b2503218f3385b.zip | |
make Enigma check subclasses of method implementations for duplicate mapping names
Diffstat (limited to 'src/main/java/cuchaz')
| -rw-r--r-- | src/main/java/cuchaz/enigma/mapping/MappingsRenamer.java | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/main/java/cuchaz/enigma/mapping/MappingsRenamer.java b/src/main/java/cuchaz/enigma/mapping/MappingsRenamer.java index e35ef3e8..5c299e3e 100644 --- a/src/main/java/cuchaz/enigma/mapping/MappingsRenamer.java +++ b/src/main/java/cuchaz/enigma/mapping/MappingsRenamer.java | |||
| @@ -20,6 +20,7 @@ import java.util.zip.GZIPOutputStream; | |||
| 20 | 20 | ||
| 21 | import com.google.common.collect.Lists; | 21 | import com.google.common.collect.Lists; |
| 22 | import cuchaz.enigma.analysis.JarIndex; | 22 | import cuchaz.enigma.analysis.JarIndex; |
| 23 | import cuchaz.enigma.analysis.MethodImplementationsTreeNode; | ||
| 23 | import cuchaz.enigma.throwables.IllegalNameException; | 24 | import cuchaz.enigma.throwables.IllegalNameException; |
| 24 | import cuchaz.enigma.throwables.MappingConflict; | 25 | import cuchaz.enigma.throwables.MappingConflict; |
| 25 | 26 | ||
| @@ -107,23 +108,31 @@ public class MappingsRenamer { | |||
| 107 | classMapping.setFieldName(obf.getName(), obf.getType(), obf.getName()); | 108 | classMapping.setFieldName(obf.getName(), obf.getType(), obf.getName()); |
| 108 | } | 109 | } |
| 109 | 110 | ||
| 111 | private void validateMethodTreeName(MethodEntry entry, String deobfName) { | ||
| 112 | MethodEntry targetEntry = new MethodEntry(entry.getClassEntry(), deobfName, entry.getSignature()); | ||
| 113 | |||
| 114 | // TODO: Verify if I don't break things | ||
| 115 | ClassMapping classMapping = m_mappings.getClassByObf(entry.getClassEntry()); | ||
| 116 | if ((classMapping != null && classMapping.containsDeobfMethod(deobfName, entry.getSignature()) && classMapping.getMethodByObf(entry.getName(), entry.getSignature()) != classMapping.getMethodByDeobf(deobfName, entry.getSignature())) | ||
| 117 | || m_index.containsObfBehavior(targetEntry)) { | ||
| 118 | String deobfClassName = m_mappings.getTranslator(TranslationDirection.Deobfuscating, m_index.getTranslationIndex()).translateClass(entry.getClassName()); | ||
| 119 | if (deobfClassName == null) { | ||
| 120 | deobfClassName = entry.getClassName(); | ||
| 121 | } | ||
| 122 | throw new IllegalNameException(deobfName, "There is already a method with that name and signature in class " + deobfClassName); | ||
| 123 | } | ||
| 124 | |||
| 125 | for (ClassEntry child : m_index.getTranslationIndex().getSubclass(entry.getClassEntry())) { | ||
| 126 | validateMethodTreeName(entry.cloneToNewClass(child), deobfName); | ||
| 127 | } | ||
| 128 | } | ||
| 129 | |||
| 110 | public void setMethodTreeName(MethodEntry obf, String deobfName) { | 130 | public void setMethodTreeName(MethodEntry obf, String deobfName) { |
| 111 | Set<MethodEntry> implementations = m_index.getRelatedMethodImplementations(obf); | 131 | Set<MethodEntry> implementations = m_index.getRelatedMethodImplementations(obf); |
| 112 | 132 | ||
| 113 | deobfName = NameValidator.validateMethodName(deobfName); | 133 | deobfName = NameValidator.validateMethodName(deobfName); |
| 114 | for (MethodEntry entry : implementations) { | 134 | for (MethodEntry entry : implementations) { |
| 115 | MethodEntry targetEntry = new MethodEntry(entry.getClassEntry(), deobfName, entry.getSignature()); | 135 | validateMethodTreeName(entry, deobfName); |
| 116 | |||
| 117 | // TODO: Verify if I don't break things | ||
| 118 | ClassMapping classMapping = m_mappings.getClassByObf(entry.getClassEntry()); | ||
| 119 | if ((classMapping != null && classMapping.containsDeobfMethod(deobfName, entry.getSignature()) && classMapping.getMethodByObf(entry.getName(), entry.getSignature()) != classMapping.getMethodByDeobf(deobfName, entry.getSignature())) | ||
| 120 | || m_index.containsObfBehavior(targetEntry)) { | ||
| 121 | String deobfClassName = m_mappings.getTranslator(TranslationDirection.Deobfuscating, m_index.getTranslationIndex()).translateClass(entry.getClassName()); | ||
| 122 | if (deobfClassName == null) { | ||
| 123 | deobfClassName = entry.getClassName(); | ||
| 124 | } | ||
| 125 | throw new IllegalNameException(deobfName, "There is already a method with that name and signature in class " + deobfClassName); | ||
| 126 | } | ||
| 127 | } | 136 | } |
| 128 | 137 | ||
| 129 | for (MethodEntry entry : implementations) { | 138 | for (MethodEntry entry : implementations) { |