PING: Reflection doesn't work across interfaces
Bryce McKinlay
mckinlay@redhat.com
Mon Apr 12 23:14:00 GMT 2004
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.
>--- 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. 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.
Regards
Bryce.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: iface-index.patch
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20040412/afacf02d/attachment.ksh>
More information about the Java-patches
mailing list