PR 13948 and Miranda Methods

Ranjit Mathew rmathew@gmail.com
Tue May 4 13:30:00 GMT 2004


Tom Tromey wrote:
> Ranjit> 1. In line 2057 of class.c (add_miranda_methods), why do
> Ranjit> we start searching from index 1 and not 0?
>> My recollection is that index 0 is always the super class, and for
> interfaces this slot is either NULL or Object (I forget which).

With a debugger I see java.lang.Object here at all the
times that I have checked.
> Ranjit> 2. Miranda methods are needed to work with older buggy VMs
> Ranjit> that need an implicit method declaration in an abstract
> Ranjit> class for a method from an implemented interface (right?).
>> An abstract class isn't required to declare methods inherited from
> interfaces. However, when we build vtables these methods have to
> come from somewhere. So, we introduce these fake Miranda methods to
> make vtable construction work out right. We do this in the compiler
> when generating .o files and in the runtime for other classes. So,
> it isn't a compatibility thing -- it is really needed.

I'm not totally sure, but can't this be treated in the way that
multiple inheritance is in the C++ ABI? (Of which I know zilch,
so never mind...)
> Ranjit> However, layout_class_methods() calls add_miranda_methods()
> Ranjit> anyways - so isn't the call on line 2097 made redundant by his
> Ranjit> patch?
>> I don't know, but it would appear so.

Hmmm... Bryce/Andrew - what're your thoughts on this?
I removed that line (i.e. 2097 in class.c) and recompiled
libjava and ran the testsuite (including Jacks), without
any regressions. Would anyone have any objections to
removing it?
> Ranjit> 4. Line 2076 says:
> Ranjit> /* An interface can have <clinit>. */
> Ranjit> How? A naive attempt to write one fails as I had thought.
> Ranjit> So what gives?
>> public interface X
> {
> public static final Object val = new Object ();
> }
>> In other words, you'll get a <clinit> method for an interface if it
> contains any field that isn't a compile-time constant.

Aah! Thanks for explaining that - I learn something new
every day!
Thanks,
Ranjit.
-- 
Ranjit Mathew Email: rmathew AT gmail DOT com
Bangalore, INDIA. Web: http://ranjitmathew.tripod.com/


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /