This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: PING: Reflection doesn't work across interfaces
- From: Andrew Haley <aph at redhat dot com>
- To: Bryce McKinlay <mckinlay at redhat dot com>
- Cc: java-patches at gcc dot gnu dot org
- Date: Wed, 14 Apr 2004 10:10:56 +0100
- Subject: Re: PING: Reflection doesn't work across interfaces
- References: <16490.51964.646352.831451@cuddles.cambridge.redhat.com><407B1B9C.8040807@redhat.com>
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.