summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/analysis/JarIndex.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/cuchaz/enigma/analysis/JarIndex.java')
-rw-r--r--src/cuchaz/enigma/analysis/JarIndex.java40
1 files changed, 6 insertions, 34 deletions
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;
44import cuchaz.enigma.bytecode.ClassRenamer; 44import cuchaz.enigma.bytecode.ClassRenamer;
45import cuchaz.enigma.mapping.ArgumentEntry; 45import cuchaz.enigma.mapping.ArgumentEntry;
46import cuchaz.enigma.mapping.BehaviorEntry; 46import cuchaz.enigma.mapping.BehaviorEntry;
47import cuchaz.enigma.mapping.BehaviorEntryFactory;
47import cuchaz.enigma.mapping.ClassEntry; 48import cuchaz.enigma.mapping.ClassEntry;
48import cuchaz.enigma.mapping.ConstructorEntry; 49import cuchaz.enigma.mapping.ConstructorEntry;
49import cuchaz.enigma.mapping.Entry; 50import cuchaz.enigma.mapping.Entry;
@@ -203,6 +204,7 @@ public class JarIndex
203 EntryRenamer.renameMethodsInMultimap( m_bridgeMethods, m_methodImplementations ); 204 EntryRenamer.renameMethodsInMultimap( m_bridgeMethods, m_methodImplementations );
204 EntryRenamer.renameMethodsInMultimap( m_bridgeMethods, m_behaviorReferences ); 205 EntryRenamer.renameMethodsInMultimap( m_bridgeMethods, m_behaviorReferences );
205 EntryRenamer.renameMethodsInMultimap( m_bridgeMethods, m_fieldReferences ); 206 EntryRenamer.renameMethodsInMultimap( m_bridgeMethods, m_fieldReferences );
207 EntryRenamer.renameMethodsInMap( m_bridgeMethods, m_access );
206 } 208 }
207 209
208 private void indexField( CtField field ) 210 private void indexField( CtField field )
@@ -224,21 +226,20 @@ public class JarIndex
224 private void indexBehavior( CtBehavior behavior ) 226 private void indexBehavior( CtBehavior behavior )
225 { 227 {
226 // get the behavior entry 228 // get the behavior entry
227 String className = Descriptor.toJvmName( behavior.getDeclaringClass().getName() ); 229 final BehaviorEntry behaviorEntry = BehaviorEntryFactory.create( behavior );
228 final BehaviorEntry behaviorEntry = getBehaviorEntry( behavior );
229 if( behaviorEntry instanceof MethodEntry ) 230 if( behaviorEntry instanceof MethodEntry )
230 { 231 {
231 MethodEntry methodEntry = (MethodEntry)behaviorEntry; 232 MethodEntry methodEntry = (MethodEntry)behaviorEntry;
232 233
233 // index implementation 234 // index implementation
234 m_methodImplementations.put( className, methodEntry ); 235 m_methodImplementations.put( behaviorEntry.getClassName(), methodEntry );
235 236
236 // look for bridge methods 237 // look for bridge methods
237 CtMethod bridgedMethod = getBridgedMethod( (CtMethod)behavior ); 238 CtMethod bridgedMethod = getBridgedMethod( (CtMethod)behavior );
238 if( bridgedMethod != null ) 239 if( bridgedMethod != null )
239 { 240 {
240 MethodEntry bridgedMethodEntry = new MethodEntry( 241 MethodEntry bridgedMethodEntry = new MethodEntry(
241 new ClassEntry( className ), 242 behaviorEntry.getClassEntry(),
242 bridgedMethod.getName(), 243 bridgedMethod.getName(),
243 bridgedMethod.getSignature() 244 bridgedMethod.getSignature()
244 ); 245 );
@@ -251,7 +252,7 @@ public class JarIndex
251 private void indexBehaviorReferences( CtBehavior behavior ) 252 private void indexBehaviorReferences( CtBehavior behavior )
252 { 253 {
253 // index method calls 254 // index method calls
254 final BehaviorEntry behaviorEntry = getBehaviorEntry( behavior ); 255 final BehaviorEntry behaviorEntry = BehaviorEntryFactory.create( behavior );
255 try 256 try
256 { 257 {
257 behavior.instrument( new ExprEditor( ) 258 behavior.instrument( new ExprEditor( )
@@ -344,35 +345,6 @@ public class JarIndex
344 } 345 }
345 } 346 }
346 347
347 private BehaviorEntry getBehaviorEntry( CtBehavior behavior )
348 {
349 String className = Descriptor.toJvmName( behavior.getDeclaringClass().getName() );
350 if( behavior instanceof CtMethod )
351 {
352 return new MethodEntry(
353 new ClassEntry( className ),
354 behavior.getName(),
355 behavior.getSignature()
356 );
357 }
358 else if( behavior instanceof CtConstructor )
359 {
360 boolean isStatic = behavior.getName().equals( "<clinit>" );
361 if( isStatic )
362 {
363 return new ConstructorEntry( new ClassEntry( className ) );
364 }
365 else
366 {
367 return new ConstructorEntry( new ClassEntry( className ), behavior.getSignature() );
368 }
369 }
370 else
371 {
372 throw new IllegalArgumentException( "behavior must be a method or a constructor!" );
373 }
374 }
375
376 public ClassEntry resolveEntryClass( Entry obfEntry ) 348 public ClassEntry resolveEntryClass( Entry obfEntry )
377 { 349 {
378 // this entry could refer to a method on a class where the method is not actually implemented 350 // this entry could refer to a method on a class where the method is not actually implemented