This is the mail archive of the java-discuss@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: interface dispatch


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/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]