This is the mail archive of the
java-discuss@sourceware.cygnus.com
mailing list for the Java project.
Re: interface dispatch
- To: Godmar Back <gback at cs dot utah dot edu>
- Subject: Re: interface dispatch
- From: Per Bothner <per at bothner dot com>
- Date: 24 Oct 1999 11:45:59 -0700
- Cc: java-discuss at sourceware dot cygnus dot com
- References: <199910241638.KAA13228@faith.cs.utah.edu>
Godmar Back <gback@cs.utah.edu> writes:
> > > interface A {}
> > > f(A x) {
> > > x.equals(...)
> > > }
> This follows from the JLS 15.11.3:
>
> 15.11.3 Compile-Time Step 3: Is the Chosen Method Appropriate?
> ...
> The following compile-time information is then associated with the
> method invocation for use at run time:
> ...
> + Otherwise, if the compile-time declaration is in an interface,
> then the invocation mode is interface.
>
> Here, the compile-time declaration of x is A,
I believe you're misreading it. The "compile-time declaration" as
defined at the beginning of section 15.11.3 is "the most specific
method declaration for a method invocation". The "compile-time
declaration of x" is not relevant to the issue at all.
> which is an interface,
> hence the invocation mode is interface, which is expressed by choosing
> the invokeinterface bytecode instruction.
The "most specific method" is java.lang.Object.equals(Object).
That is the "compile-time declaration" for the method invocation.
The compile-time declaration is "in" java.lang.Object, which is a
class, not an interface. Thus the invocation mode is virtual,
not interface.
--
--Per Bothner
per@bothner.com http://www.bothner.com/~per/