diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/analysis')
| -rw-r--r-- | src/main/java/cuchaz/enigma/analysis/Access.java | 13 | ||||
| -rw-r--r-- | src/main/java/cuchaz/enigma/analysis/JarIndex.java | 11 |
2 files changed, 21 insertions, 3 deletions
diff --git a/src/main/java/cuchaz/enigma/analysis/Access.java b/src/main/java/cuchaz/enigma/analysis/Access.java index 877327f..b8aafaa 100644 --- a/src/main/java/cuchaz/enigma/analysis/Access.java +++ b/src/main/java/cuchaz/enigma/analysis/Access.java | |||
| @@ -19,6 +19,7 @@ public enum Access { | |||
| 19 | 19 | ||
| 20 | Public, | 20 | Public, |
| 21 | Protected, | 21 | Protected, |
| 22 | Package, | ||
| 22 | Private; | 23 | Private; |
| 23 | 24 | ||
| 24 | public static Access get(CtBehavior behavior) { | 25 | public static Access get(CtBehavior behavior) { |
| @@ -30,12 +31,18 @@ public enum Access { | |||
| 30 | } | 31 | } |
| 31 | 32 | ||
| 32 | public static Access get(int modifiers) { | 33 | public static Access get(int modifiers) { |
| 33 | if (Modifier.isPublic(modifiers)) { | 34 | boolean isPublic = Modifier.isPublic(modifiers); |
| 35 | boolean isProtected = Modifier.isProtected(modifiers); | ||
| 36 | boolean isPrivate = Modifier.isPrivate(modifiers); | ||
| 37 | |||
| 38 | if (isPublic && !isProtected && !isPrivate) { | ||
| 34 | return Public; | 39 | return Public; |
| 35 | } else if (Modifier.isProtected(modifiers)) { | 40 | } else if (!isPublic && isProtected && !isPrivate) { |
| 36 | return Protected; | 41 | return Protected; |
| 37 | } else if (Modifier.isPrivate(modifiers)) { | 42 | } else if (!isPublic && !isProtected && isPrivate) { |
| 38 | return Private; | 43 | return Private; |
| 44 | } else if (!isPublic && !isProtected && !isPrivate) { | ||
| 45 | return Package; | ||
| 39 | } | 46 | } |
| 40 | // assume public by default | 47 | // assume public by default |
| 41 | return Public; | 48 | return Public; |
diff --git a/src/main/java/cuchaz/enigma/analysis/JarIndex.java b/src/main/java/cuchaz/enigma/analysis/JarIndex.java index 851f3fa..e501540 100644 --- a/src/main/java/cuchaz/enigma/analysis/JarIndex.java +++ b/src/main/java/cuchaz/enigma/analysis/JarIndex.java | |||
| @@ -38,6 +38,7 @@ public class JarIndex { | |||
| 38 | private Map<ClassEntry, ClassEntry> outerClassesByInner; | 38 | private Map<ClassEntry, ClassEntry> outerClassesByInner; |
| 39 | private Map<ClassEntry, BehaviorEntry> anonymousClasses; | 39 | private Map<ClassEntry, BehaviorEntry> anonymousClasses; |
| 40 | private Map<MethodEntry, MethodEntry> bridgedMethods; | 40 | private Map<MethodEntry, MethodEntry> bridgedMethods; |
| 41 | private Set<MethodEntry> syntheticMethods; | ||
| 41 | 42 | ||
| 42 | public JarIndex() { | 43 | public JarIndex() { |
| 43 | this.obfClassEntries = Sets.newHashSet(); | 44 | this.obfClassEntries = Sets.newHashSet(); |
| @@ -52,6 +53,7 @@ public class JarIndex { | |||
| 52 | this.outerClassesByInner = Maps.newHashMap(); | 53 | this.outerClassesByInner = Maps.newHashMap(); |
| 53 | this.anonymousClasses = Maps.newHashMap(); | 54 | this.anonymousClasses = Maps.newHashMap(); |
| 54 | this.bridgedMethods = Maps.newHashMap(); | 55 | this.bridgedMethods = Maps.newHashMap(); |
| 56 | this.syntheticMethods = Sets.newHashSet(); | ||
| 55 | } | 57 | } |
| 56 | 58 | ||
| 57 | public void indexJar(JarFile jar, boolean buildInnerClasses) { | 59 | public void indexJar(JarFile jar, boolean buildInnerClasses) { |
| @@ -155,6 +157,11 @@ public class JarIndex { | |||
| 155 | if (behaviorEntry instanceof MethodEntry) { | 157 | if (behaviorEntry instanceof MethodEntry) { |
| 156 | MethodEntry methodEntry = (MethodEntry) behaviorEntry; | 158 | MethodEntry methodEntry = (MethodEntry) behaviorEntry; |
| 157 | 159 | ||
| 160 | // is synthetic | ||
| 161 | if ((behavior.getModifiers() & AccessFlag.SYNTHETIC) != 0) { | ||
| 162 | syntheticMethods.add(methodEntry); | ||
| 163 | } | ||
| 164 | |||
| 158 | // index implementation | 165 | // index implementation |
| 159 | this.methodImplementations.put(behaviorEntry.getClassName(), methodEntry); | 166 | this.methodImplementations.put(behaviorEntry.getClassName(), methodEntry); |
| 160 | 167 | ||
| @@ -720,6 +727,10 @@ public class JarIndex { | |||
| 720 | return this.anonymousClasses.containsKey(obfInnerClassEntry); | 727 | return this.anonymousClasses.containsKey(obfInnerClassEntry); |
| 721 | } | 728 | } |
| 722 | 729 | ||
| 730 | public boolean isSyntheticMethod(MethodEntry methodEntry) { | ||
| 731 | return this.syntheticMethods.contains(methodEntry); | ||
| 732 | } | ||
| 733 | |||
| 723 | public BehaviorEntry getAnonymousClassCaller(ClassEntry obfInnerClassName) { | 734 | public BehaviorEntry getAnonymousClassCaller(ClassEntry obfInnerClassName) { |
| 724 | return this.anonymousClasses.get(obfInnerClassName); | 735 | return this.anonymousClasses.get(obfInnerClassName); |
| 725 | } | 736 | } |