>3. What is the difference in purpose between invokevirtual and
>invokeinterface ?

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
> On Thu, 20 Sep 2007 01:01:54 GMT, Joshua Cranmer
> <Pidgeot18@verizon.net> wrote, quoted or indirectly quoted someone who
[quoted text clipped - 9 lines]
> known. With an interface it may vary depending on which class is
> implementing the interface.
If I am understanding this correctly, then the two opcodes only differ
in functionality when it comes to locating the function pointer to call
in the vtable structure. That would mean that at logical level, the
method resolution lookup is identical.
(Hmmm... trying to put down in words the concept I envision in my head
is much more difficult than I thought it would be.)

Signature
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
Roedy Green - 21 Sep 2007 03:38 GMT
On Fri, 21 Sep 2007 01:48:32 GMT, Joshua Cranmer
<Pidgeot18@verizon.net> wrote, quoted or indirectly quoted someone who
said :
>If I am understanding this correctly, then the two opcodes only differ
>in functionality when it comes to locating the function pointer to call
[quoted text clipped - 3 lines]
>(Hmmm... trying to put down in words the concept I envision in my head
>is much more difficult than I thought it would be.)
The implementation is quite different. For InvokeVirtual, you take
the method index, index into the vtbl for the current object's class,
and that points you to the method.
For InvokeInterface, you need a cache of class-offset pairs that have
been discovered in past to invoke this method. You have to do a
miniature HashMap lookup of the class to get the offset. If you don't
find the class, you must examine the class object structure for the
current object, looking for a match for that method, then add it to
the cache. There may be cleverer, faster ways of implementing it, but
it is much hairier operation than InvokeVirtual.
This is why abstract classes work faster than interfaces.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com