@@ -74,14 +74,6 @@ private static class InteropInfo {
74
74
}
75
75
};
76
76
77
- private int getInheritanceDepth (Class <?> klass ) {
78
- if (klass .getName ().equals ("java.lang.Object" )) {
79
- return 1 ;
80
- } else {
81
- return 1 + getInheritanceDepth (klass .getSuperclass ());
82
- }
83
- }
84
-
85
77
/**
86
78
* Override this to define per-class STables.
87
79
*/
@@ -332,9 +324,6 @@ protected ClassContext createAdaptor(Class<?> target) {
332
324
cc .cv = cw ;
333
325
cc .className = className ;
334
326
cc .target = target ;
335
- cc .inheritanceHiding = new HashMap <String , HidingInformation >();
336
-
337
- for (Method m : target .getMethods ()) analyzeMethodHiding (cc , m );
338
327
339
328
for (Method m : target .getMethods ()) createAdaptorMethod (cc , m );
340
329
for (Field f : target .getFields ()) createAdaptorField (cc , f );
@@ -347,32 +336,6 @@ protected ClassContext createAdaptor(Class<?> target) {
347
336
return cc ;
348
337
}
349
338
350
- protected void analyzeMethodHiding (ClassContext cc , Method m ) {
351
- String desc = Type .getMethodDescriptor (m );
352
- String name = m .getName ();
353
-
354
- int s2 = desc .indexOf (')' );
355
- String fragment = name + "/" + desc .substring (0 , s2 );
356
-
357
- Integer derivationDepth = getInheritanceDepth (m .getDeclaringClass ());
358
-
359
- if (cc .inheritanceHiding .containsKey (fragment )) {
360
- HidingInformation info = cc .inheritanceHiding .get (fragment );
361
-
362
- if (derivationDepth > info .inheritanceDepth ) {
363
- info .inheritanceDepth = derivationDepth ;
364
- info .mostSpecificSignature = desc ;
365
- }
366
- } else {
367
- HidingInformation info = new HidingInformation ();
368
-
369
- info .inheritanceDepth = derivationDepth ;
370
- info .mostSpecificSignature = desc ;
371
-
372
- cc .inheritanceHiding .put (fragment , info );
373
- }
374
- }
375
-
376
339
protected void createShorthandDispatchers (ClassContext c ) {
377
340
for (Iterator <Map .Entry <String , HashMap <Integer , List <String >>>> it = c .arities .entrySet ().iterator (); it .hasNext ();) {
378
341
Map .Entry <String , HashMap <Integer , List <String >>> ent = it .next ();
@@ -543,16 +506,16 @@ protected void createAdaptorMethod(ClassContext c, Method tobind) {
543
506
String name = tobind .getName ();
544
507
Integer arity = ptype .length ;
545
508
546
- int returnPos = desc .indexOf (')' );
547
- String fragment = name + "/" + desc .substring (0 , returnPos );
548
-
549
- if (c .inheritanceHiding .containsKey (fragment )) {
550
- if (!c .inheritanceHiding .get (fragment ).equals (desc )) {
551
- // this method is actually hidden by a more derived class
552
- System .out .println ("hiding the method " + name + " " + desc + " from the fragment " + fragment );
509
+ try {
510
+ if (!c .target .getMethod (name , ptype ).equals (tobind )) {
511
+ System .out .println ("hiding the method " + name + " " + desc );
553
512
return ;
554
513
}
555
514
}
515
+ catch (NoSuchMethodException ex ) {
516
+ System .err .println ("WTF, the method " + name + " magically disappeared?!" );
517
+ return ;
518
+ }
556
519
557
520
if (!c .arities .containsKey (name )) {
558
521
c .arities .put (name , new HashMap <Integer , List <String >>());
@@ -563,7 +526,7 @@ protected void createAdaptorMethod(ClassContext c, Method tobind) {
563
526
c .arities .get (name ).get (arity ).add (desc );
564
527
// stash the method away for later generation of shorthand methods.
565
528
c .methods .put (name + "/" + desc , tobind );
566
- MethodContext cc = startCallout (c , arity + 1 , "method/" + tobind . getName () + "/" + desc );
529
+ MethodContext cc = startCallout (c , arity + 1 , "method/" + name + "/" + desc );
567
530
568
531
int parix = 1 ;
569
532
preMarshalIn (cc , tobind .getReturnType (), 0 );
@@ -863,13 +826,6 @@ else if (what == ThreadContext.class) {
863
826
/** Type name of {@link ThreadContext}. */
864
827
protected static final Type TYPE_TC = Type .getType (ThreadContext .class );
865
828
866
- /** Store information needed to figure out which methods are hidden */
867
- protected class HidingInformation {
868
- /** How far away from java.lang.object are we? */
869
- public Integer inheritanceDepth ;
870
- /** Which signature has been the most derived version so far? */
871
- public String mostSpecificSignature ;
872
- }
873
829
/** Stores working information while building a class. */
874
830
protected static class ClassContext {
875
831
/** The ASM class writer. */
@@ -890,9 +846,6 @@ protected static class ClassContext {
890
846
public HashMap <String , AccessibleObject > methods = new HashMap < >();
891
847
/** The next qb_NNN index to use. */
892
848
public int nextCallout ;
893
- /** The signature of the method with the return type cut off points
894
- * to a record stating which specific override is the real one */
895
- public HashMap <String , HidingInformation > inheritanceHiding ;
896
849
}
897
850
898
851
/** Start an adaptor method and generate standard prologue. */
0 commit comments