diff options
| author | 2015-03-16 19:22:22 -0400 | |
|---|---|---|
| committer | 2015-03-16 19:22:22 -0400 | |
| commit | 5e3743a0aca3529eacf9be400c8b8d7547f66e7f (patch) | |
| tree | ea601747547f78e1b83ab828650932126440e221 /src/cuchaz/enigma/analysis/JarIndex.java | |
| parent | update to new javassist version to (hopefully) get bug fixes (diff) | |
| download | enigma-fork-5e3743a0aca3529eacf9be400c8b8d7547f66e7f.tar.gz enigma-fork-5e3743a0aca3529eacf9be400c8b8d7547f66e7f.tar.xz enigma-fork-5e3743a0aca3529eacf9be400c8b8d7547f66e7f.zip | |
started adding minimal support for generics
fixed mark-as-deobfuscated issue
Diffstat (limited to 'src/cuchaz/enigma/analysis/JarIndex.java')
| -rw-r--r-- | src/cuchaz/enigma/analysis/JarIndex.java | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/cuchaz/enigma/analysis/JarIndex.java b/src/cuchaz/enigma/analysis/JarIndex.java index 7ebbd97..e255468 100644 --- a/src/cuchaz/enigma/analysis/JarIndex.java +++ b/src/cuchaz/enigma/analysis/JarIndex.java | |||
| @@ -28,6 +28,7 @@ import javassist.CtMethod; | |||
| 28 | import javassist.NotFoundException; | 28 | import javassist.NotFoundException; |
| 29 | import javassist.bytecode.AccessFlag; | 29 | import javassist.bytecode.AccessFlag; |
| 30 | import javassist.bytecode.Descriptor; | 30 | import javassist.bytecode.Descriptor; |
| 31 | import javassist.bytecode.EnclosingMethodAttribute; | ||
| 31 | import javassist.bytecode.FieldInfo; | 32 | import javassist.bytecode.FieldInfo; |
| 32 | import javassist.bytecode.InnerClassesAttribute; | 33 | import javassist.bytecode.InnerClassesAttribute; |
| 33 | import javassist.expr.ConstructorCall; | 34 | import javassist.expr.ConstructorCall; |
| @@ -314,15 +315,6 @@ public class JarIndex { | |||
| 314 | if (classEntry.isInnerClass()) { | 315 | if (classEntry.isInnerClass()) { |
| 315 | return classEntry.getOuterClassEntry(); | 316 | return classEntry.getOuterClassEntry(); |
| 316 | } | 317 | } |
| 317 | InnerClassesAttribute innerClassesAttribute = (InnerClassesAttribute)c.getClassFile().getAttribute(InnerClassesAttribute.tag); | ||
| 318 | if (innerClassesAttribute != null) { | ||
| 319 | for (int i=0; i<innerClassesAttribute.tableLength(); i++) { | ||
| 320 | ClassEntry innerClassEntry = new ClassEntry(Descriptor.toJvmName(innerClassesAttribute.innerClass(i))); | ||
| 321 | if (classEntry.equals(innerClassEntry)) { | ||
| 322 | return new ClassEntry(Descriptor.toJvmName(innerClassesAttribute.outerClass(i))); | ||
| 323 | } | ||
| 324 | } | ||
| 325 | } | ||
| 326 | 318 | ||
| 327 | // inner classes: | 319 | // inner classes: |
| 328 | // have constructors that can (illegally) set synthetic fields | 320 | // have constructors that can (illegally) set synthetic fields |
| @@ -481,6 +473,27 @@ public class JarIndex { | |||
| 481 | 473 | ||
| 482 | private BehaviorEntry isAnonymousClass(CtClass c, ClassEntry outerClassEntry) { | 474 | private BehaviorEntry isAnonymousClass(CtClass c, ClassEntry outerClassEntry) { |
| 483 | 475 | ||
| 476 | // is this class already marked anonymous? | ||
| 477 | EnclosingMethodAttribute enclosingMethodAttribute = (EnclosingMethodAttribute)c.getClassFile().getAttribute(EnclosingMethodAttribute.tag); | ||
| 478 | if (enclosingMethodAttribute != null) { | ||
| 479 | if (enclosingMethodAttribute.methodIndex() > 0) { | ||
| 480 | return EntryFactory.getBehaviorEntry( | ||
| 481 | Descriptor.toJvmName(enclosingMethodAttribute.className()), | ||
| 482 | enclosingMethodAttribute.methodName(), | ||
| 483 | enclosingMethodAttribute.methodDescriptor() | ||
| 484 | ); | ||
| 485 | } else { | ||
| 486 | // an attribute but no method? assume not anonymous | ||
| 487 | return null; | ||
| 488 | } | ||
| 489 | } | ||
| 490 | |||
| 491 | // if there's an inner class attribute, but not an enclosing method attribute, then it's not anonymous | ||
| 492 | InnerClassesAttribute innerClassesAttribute = (InnerClassesAttribute)c.getClassFile().getAttribute(InnerClassesAttribute.tag); | ||
| 493 | if (innerClassesAttribute != null) { | ||
| 494 | return null; | ||
| 495 | } | ||
| 496 | |||
| 484 | ClassEntry innerClassEntry = new ClassEntry(Descriptor.toJvmName(c.getName())); | 497 | ClassEntry innerClassEntry = new ClassEntry(Descriptor.toJvmName(c.getName())); |
| 485 | 498 | ||
| 486 | // anonymous classes: | 499 | // anonymous classes: |