In Fantom, I have been using invokespecial as poor-man's non-virtual
dispatch to avoid method naming conflicts between modules. But it
appears the Andriod's VM requires the ACC_SUPER flag and won't let you
call a method unless it is actually marked as private. So I need to
switch to invokevirtual, but still want to avoid that subclasses can
accidentally override a module scoped method in a base class.
Experimenting with Java, it appears that the JVM dispatches
invokevirtual correctly in the case of package scoped methods. That
is given these two classes:
package alpha;
public class A { String foo() { return "A.foo"; }
package beta;
public class B extends A { String foo() { return "B.foo"; }
It seems that calling A.foo on an instance of B will always correctly
dispatch to A.foo (B's version does not truly override A.foo). I
tried to find where this behavior is dictated by the JVM language
spec, but couldn't find any mention of it.
Is this the specified behavior that can be counted on across different
JVMs?
--
You received this message because you are subscribed to the Google Groups "JVM
Languages" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jvm-languages?hl=en.