Patch: PR java/20338 - Call _Jv_InitClass for private static methods in an inner class
Bryce McKinlay
mckinlay@redhat.com
Wed Mar 9 18:44:00 GMT 2005
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. This fix looks good as an interim solution, though.
Bryce
Ranjit Mathew wrote:
> This patch proposes to fix PR java/20338 by allowing a call to
>_Jv_InitClass to be emitted for a private static method if it is inside
>an inner class. Tested on i686-pc-linux-gnu with Jacks included
>and causes no regressions.
>
>When I tried to add a testcase for this however, I noted a
>queer thing: if the class file is generated by GCJ, gij throws
>an IllegalAccessError, while JDK 1.4.2_03 does not. If the
>class file is generated by JDK instead, gij seems to
>execute it just fine. I did not probe it further though.
>
>OK for mainline?
>
>Thanks,
>Ranjit.
>
>
>
>------------------------------------------------------------------------
>
>Index: ChangeLog
>from Ranjit Mathew <rmathew@hotmail.com>
>
> PR java/20338
> * decl.c (finish_method): Emit _Jv_InitClass for private static
> methods inside inner classes as well.
>
>Index: decl.c
>===================================================================
>--- decl.c 2005-03-09 17:16:36.000000000 +0530
>+++ decl.c 2005-03-09 19:05:39.000000000 +0530
>@@ -2039,5 +2039,7 @@ finish_method (tree fndecl)
> /* Prepend class initialization for static methods reachable from
> other classes. */
>- if (METHOD_STATIC (fndecl) && ! METHOD_PRIVATE (fndecl)
>+ if (METHOD_STATIC (fndecl)
>+ && (! METHOD_PRIVATE (fndecl)
>+ || INNER_CLASS_P (DECL_CONTEXT (fndecl)))
> && ! DECL_CLINIT_P (fndecl)
> && ! CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (fndecl))))
>
>
More information about the Java-patches
mailing list