From 064fe6a628f23f21eb2c8f584215f439e54cfaec Mon Sep 17 00:00:00 2001 From: jeff Date: Wed, 24 Sep 2014 20:32:19 -0400 Subject: fixed in-jar detection for bridge-related methods --- src/cuchaz/enigma/analysis/JarIndex.java | 40 +++++--------------------------- 1 file changed, 6 insertions(+), 34 deletions(-) (limited to 'src/cuchaz/enigma/analysis/JarIndex.java') diff --git a/src/cuchaz/enigma/analysis/JarIndex.java b/src/cuchaz/enigma/analysis/JarIndex.java index 9f309ce..a2f6bf3 100644 --- a/src/cuchaz/enigma/analysis/JarIndex.java +++ b/src/cuchaz/enigma/analysis/JarIndex.java @@ -44,6 +44,7 @@ import cuchaz.enigma.Constants; import cuchaz.enigma.bytecode.ClassRenamer; import cuchaz.enigma.mapping.ArgumentEntry; import cuchaz.enigma.mapping.BehaviorEntry; +import cuchaz.enigma.mapping.BehaviorEntryFactory; import cuchaz.enigma.mapping.ClassEntry; import cuchaz.enigma.mapping.ConstructorEntry; import cuchaz.enigma.mapping.Entry; @@ -203,6 +204,7 @@ public class JarIndex EntryRenamer.renameMethodsInMultimap( m_bridgeMethods, m_methodImplementations ); EntryRenamer.renameMethodsInMultimap( m_bridgeMethods, m_behaviorReferences ); EntryRenamer.renameMethodsInMultimap( m_bridgeMethods, m_fieldReferences ); + EntryRenamer.renameMethodsInMap( m_bridgeMethods, m_access ); } private void indexField( CtField field ) @@ -224,21 +226,20 @@ public class JarIndex private void indexBehavior( CtBehavior behavior ) { // get the behavior entry - String className = Descriptor.toJvmName( behavior.getDeclaringClass().getName() ); - final BehaviorEntry behaviorEntry = getBehaviorEntry( behavior ); + final BehaviorEntry behaviorEntry = BehaviorEntryFactory.create( behavior ); if( behaviorEntry instanceof MethodEntry ) { MethodEntry methodEntry = (MethodEntry)behaviorEntry; // index implementation - m_methodImplementations.put( className, methodEntry ); + m_methodImplementations.put( behaviorEntry.getClassName(), methodEntry ); // look for bridge methods CtMethod bridgedMethod = getBridgedMethod( (CtMethod)behavior ); if( bridgedMethod != null ) { MethodEntry bridgedMethodEntry = new MethodEntry( - new ClassEntry( className ), + behaviorEntry.getClassEntry(), bridgedMethod.getName(), bridgedMethod.getSignature() ); @@ -251,7 +252,7 @@ public class JarIndex private void indexBehaviorReferences( CtBehavior behavior ) { // index method calls - final BehaviorEntry behaviorEntry = getBehaviorEntry( behavior ); + final BehaviorEntry behaviorEntry = BehaviorEntryFactory.create( behavior ); try { behavior.instrument( new ExprEditor( ) @@ -344,35 +345,6 @@ public class JarIndex } } - private BehaviorEntry getBehaviorEntry( CtBehavior behavior ) - { - String className = Descriptor.toJvmName( behavior.getDeclaringClass().getName() ); - if( behavior instanceof CtMethod ) - { - return new MethodEntry( - new ClassEntry( className ), - behavior.getName(), - behavior.getSignature() - ); - } - else if( behavior instanceof CtConstructor ) - { - boolean isStatic = behavior.getName().equals( "" ); - if( isStatic ) - { - return new ConstructorEntry( new ClassEntry( className ) ); - } - else - { - return new ConstructorEntry( new ClassEntry( className ), behavior.getSignature() ); - } - } - else - { - throw new IllegalArgumentException( "behavior must be a method or a constructor!" ); - } - } - public ClassEntry resolveEntryClass( Entry obfEntry ) { // this entry could refer to a method on a class where the method is not actually implemented -- cgit v1.2.3