This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: gcj producing bad code
Eric Blake <ebb9@email.byu.edu> writes:
> Nic Ferrier wrote:
> >
> > GCJ is not compiling method calls quite right... it seems that all
> > super invocations are done through invokespecial. invokespecial
> > cannot be used when the target needs to be called through virtual
> > dispatch however.
>
> I'm not quite sure you said that right. Any call to super.method() is
> required to compile to invokespecial (unless method is static, in which
> case invokestatic is appropriate). By the way, in the case of
> EnclosingClass.super.method(), it may require the assistance of an
> accessor method to use invokespecial while still obeying access rules.
> Consider this example, from the point of view of class C:
The case I'm referring to is a metjod invocation on a property of the
super class, thus:
class A
X x;
public X getX() { return x; }
class B extends A
public Y getY() { return super.getX().getY(); }
The method B::getY() must compile to call getY() through a virtual
dispatch even though X is in super.
That's how Sun's compiler compiples such code anyway.
Nic