diff options
| author | 2018-06-25 09:39:39 +0200 | |
|---|---|---|
| committer | 2018-06-25 09:39:39 +0200 | |
| commit | 319c9aeed8d9d1b225eb3234b439f899d0054ec4 (patch) | |
| tree | 70e7a69dfa5951f1f1da1f83a8fdc49e28971b89 /src/main/java/cuchaz | |
| parent | Fix parsed local variable indexing (diff) | |
| download | enigma-319c9aeed8d9d1b225eb3234b439f899d0054ec4.tar.gz enigma-319c9aeed8d9d1b225eb3234b439f899d0054ec4.tar.xz enigma-319c9aeed8d9d1b225eb3234b439f899d0054ec4.zip | |
Fix stackoverflow on rebuilding method names
Diffstat (limited to 'src/main/java/cuchaz')
| -rw-r--r-- | src/main/java/cuchaz/enigma/analysis/JarIndex.java | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/main/java/cuchaz/enigma/analysis/JarIndex.java b/src/main/java/cuchaz/enigma/analysis/JarIndex.java index 27a8e07b..5917a32f 100644 --- a/src/main/java/cuchaz/enigma/analysis/JarIndex.java +++ b/src/main/java/cuchaz/enigma/analysis/JarIndex.java | |||
| @@ -35,7 +35,6 @@ public class JarIndex { | |||
| 35 | private Multimap<ClassEntry, ClassEntry> innerClassesByOuter; | 35 | private Multimap<ClassEntry, ClassEntry> innerClassesByOuter; |
| 36 | private Map<ClassEntry, ClassEntry> outerClassesByInner; | 36 | private Map<ClassEntry, ClassEntry> outerClassesByInner; |
| 37 | private Map<MethodEntry, MethodEntry> bridgedMethods; | 37 | private Map<MethodEntry, MethodEntry> bridgedMethods; |
| 38 | private Map<MethodEntry, MethodEntry> accessMethods; | ||
| 39 | private Set<MethodEntry> syntheticMethods; | 38 | private Set<MethodEntry> syntheticMethods; |
| 40 | 39 | ||
| 41 | public JarIndex(ReferencedEntryPool entryPool) { | 40 | public JarIndex(ReferencedEntryPool entryPool) { |
| @@ -52,7 +51,6 @@ public class JarIndex { | |||
| 52 | this.innerClassesByOuter = HashMultimap.create(); | 51 | this.innerClassesByOuter = HashMultimap.create(); |
| 53 | this.outerClassesByInner = Maps.newHashMap(); | 52 | this.outerClassesByInner = Maps.newHashMap(); |
| 54 | this.bridgedMethods = Maps.newHashMap(); | 53 | this.bridgedMethods = Maps.newHashMap(); |
| 55 | this.accessMethods = Maps.newHashMap(); | ||
| 56 | this.syntheticMethods = Sets.newHashSet(); | 54 | this.syntheticMethods = Sets.newHashSet(); |
| 57 | } | 55 | } |
| 58 | 56 | ||
| @@ -72,7 +70,6 @@ public class JarIndex { | |||
| 72 | // look for access and bridged methods | 70 | // look for access and bridged methods |
| 73 | MethodEntry accessedMethod = findAccessMethod(methodEntry); | 71 | MethodEntry accessedMethod = findAccessMethod(methodEntry); |
| 74 | if (accessedMethod != null) { | 72 | if (accessedMethod != null) { |
| 75 | this.accessMethods.put(methodEntry, accessedMethod); | ||
| 76 | if (isBridgedMethod(accessedMethod, methodEntry)) { | 73 | if (isBridgedMethod(accessedMethod, methodEntry)) { |
| 77 | this.bridgedMethods.put(methodEntry, accessedMethod); | 74 | this.bridgedMethods.put(methodEntry, accessedMethod); |
| 78 | } | 75 | } |
| @@ -333,17 +330,20 @@ public class JarIndex { | |||
| 333 | 330 | ||
| 334 | private void getRelatedMethodImplementations(Set<MethodEntry> methodEntries, MethodInheritanceTreeNode node) { | 331 | private void getRelatedMethodImplementations(Set<MethodEntry> methodEntries, MethodInheritanceTreeNode node) { |
| 335 | MethodEntry methodEntry = node.getMethodEntry(); | 332 | MethodEntry methodEntry = node.getMethodEntry(); |
| 333 | if (methodEntries.contains(methodEntry)) { | ||
| 334 | return; | ||
| 335 | } | ||
| 336 | 336 | ||
| 337 | if (containsObfMethod(methodEntry)) { | 337 | if (containsObfMethod(methodEntry)) { |
| 338 | // collect the entry | 338 | // collect the entry |
| 339 | methodEntries.add(methodEntry); | 339 | methodEntries.add(methodEntry); |
| 340 | } | 340 | } |
| 341 | 341 | ||
| 342 | // look at access methods! | 342 | // look at bridge methods! |
| 343 | MethodEntry accessMethod = getAccessMethod(methodEntry); | 343 | MethodEntry bridgedMethod = getBridgedMethod(methodEntry); |
| 344 | while (accessMethod != null) { | 344 | while (bridgedMethod != null) { |
| 345 | methodEntries.addAll(getRelatedMethodImplementations(accessMethod)); | 345 | methodEntries.addAll(getRelatedMethodImplementations(bridgedMethod)); |
| 346 | accessMethod = getAccessMethod(accessMethod); | 346 | bridgedMethod = getBridgedMethod(bridgedMethod); |
| 347 | } | 347 | } |
| 348 | 348 | ||
| 349 | // look at interface methods too | 349 | // look at interface methods too |
| @@ -364,11 +364,11 @@ public class JarIndex { | |||
| 364 | methodEntries.add(methodEntry); | 364 | methodEntries.add(methodEntry); |
| 365 | } | 365 | } |
| 366 | 366 | ||
| 367 | // look at access methods! | 367 | // look at bridge methods! |
| 368 | MethodEntry accessMethod = getAccessMethod(methodEntry); | 368 | MethodEntry bridgedMethod = getBridgedMethod(methodEntry); |
| 369 | while (accessMethod != null) { | 369 | while (bridgedMethod != null) { |
| 370 | methodEntries.addAll(getRelatedMethodImplementations(accessMethod)); | 370 | methodEntries.addAll(getRelatedMethodImplementations(bridgedMethod)); |
| 371 | accessMethod = getAccessMethod(accessMethod); | 371 | bridgedMethod = getBridgedMethod(bridgedMethod); |
| 372 | } | 372 | } |
| 373 | 373 | ||
| 374 | // recurse | 374 | // recurse |
| @@ -491,10 +491,6 @@ public class JarIndex { | |||
| 491 | return this.bridgedMethods.get(bridgeMethodEntry); | 491 | return this.bridgedMethods.get(bridgeMethodEntry); |
| 492 | } | 492 | } |
| 493 | 493 | ||
| 494 | public MethodEntry getAccessMethod(MethodEntry bridgeMethodEntry) { | ||
| 495 | return this.accessMethods.get(bridgeMethodEntry); | ||
| 496 | } | ||
| 497 | |||
| 498 | public List<ClassEntry> getObfClassChain(ClassEntry obfClassEntry) { | 494 | public List<ClassEntry> getObfClassChain(ClassEntry obfClassEntry) { |
| 499 | 495 | ||
| 500 | // build class chain in inner-to-outer order | 496 | // build class chain in inner-to-outer order |