Patch: PR java/20338 - Call _Jv_InitClass for private static methods in an inner class

Bryce McKinlay mckinlay@redhat.com
Wed Mar 9 19:25:00 GMT 2005


Ranjit Mathew wrote:

>On Wed, 09 Mar 2005 10:24:09 -0500, Bryce McKinlay <mckinlay@redhat.com> wrote:
>  
>
>>Other Java compilers generate "accessor" methods for calls to private
>>methods in a nested class, the real bug here is that GCJ doesn't do this
>>- thats why the javac bytecode works fine on gij but gcj-produced
>>bytecode does not.
>>    
>>
>
>Thanks for the explanation. It's strange then that
>"java" works with GCJ-generated bytecode. :-/
>  
>

Yeah, "java" is a bit more lenient. It has an option (-Xfuture iirc) to 
enable stricter checking. Probably we should have this for gij too.

>AFAIU, accessor methods were introduced to
>make inner classes work with JVMs without
>altering them - while generating native code,
>it should not really be necessary, no?
>  
>
Right.

>BTW -findirect_dispatch seems to set
>always_initialize_class_p, but that isn't 
>honoured here. Is this another bug or have
>I misunderstood things?
>  
>

I'm not sure what always_initialize_class_p is for, or why it is set for 
-findirect-dispatch. Maybe Andrew knows. In theory the conditions to 
initialize a class should be the same regardless of the ABI. With the 
BC-ABI its just more obvious if a class isn't getting initialized at the 
right time, because it might not even be linked and you'll see a crash.

There should be no reason to initialize the class when calling a private 
method, because private methods can (usually) only be called within the 
same class, thus the class must already be initialized.

Bryce



More information about the Java-patches mailing list