This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PING: Reflection doesn't work across interfaces


Bryce McKinlay writes:
 > Andrew Haley wrote:
 > 
 > > Subject:
 > > Reflection doesn't work across interfaces
 > >
 > >Yes, really.
 > >
 > >This is pretty amazing, but I've discovered that Method.invoke()
 > >doesn't work when the Method is in an interface.
 > >  
 > >
 > Ugh. I must have introduced this a few months back when I changed 
 > Method.invoke() to use vtables. Sorry about that.

Ahh, *that's* when it happened!  Okay, makes sense.

 > >--- 474,491 ----
 > >      {
 > >        _Jv_VTable *vtable = *(_Jv_VTable **) obj;
 > >!       if (iface == NULL)
 > >! 	ncode = vtable->get_method (meth->index);
 > >!       else
 > >! 	{
 > >! 	  /* Okay, here's how it goes.  We want to know the method
 > >! 	     offset in the list of methods declared by an interface,
 > >! 	     starting at 1.  The offset in the method is the vtable
 > >! 	     offset, not the offset in the interface, so we subtract
 > >! 	     that.  We add 1 because we count interface methods
 > >! 	     beginning at 1.  I think this is because of the initial
 > >! 	     gc descriptor in the vtable.  */
 > >! 	  jint offset = meth->index - JvGetFirstMethod (iface)->index + 1;
 > >! 	  ncode = _Jv_LookupInterfaceMethodIdx (vtable->clas, iface, offset);
 > >! 	}
 > >      }
 > >    else
 > >
 > I think it would be better to just have the compiler put the interface 
 > method's index in the meth->index field here, rather than have the 
 > runtime do fixups on a hypothetical vtable offset.

Seems reasonable.

 > How does the patch below look? Otherwise, your patch looks fine to
 > me. Obviously the invocation code has become a bit of a mess and
 > could really use some refactoring, for example to clearly separate
 > the lookup and argument prep/execution stages, but this looks ok
 > for now.

Okay.

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]