This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Patch: PR java/20338 - Call _Jv_InitClass for private static methods in an inner class
- From: Ranjit Mathew <rmathew at gmail dot com>
- To: Bryce McKinlay <mckinlay at redhat dot com>
- Cc: GCJ Patches <java-patches at gcc dot gnu dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 10 Mar 2005 00:34:11 +0530
- Subject: Re: Patch: PR java/20338 - Call _Jv_InitClass for private static methods in an inner class
- References: <39399b9d05030906496bc93756@mail.gmail.com> <422F1519.1090908@redhat.com>
- Reply-to: Ranjit Mathew <rmathew at gmail dot com>
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. :-/
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?
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?
Thanks,
Ranjit.
> 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))))
> >
> >
>
>
--
Ranjit Mathew Email: rmathew AT gmail DOT com
Bangalore, INDIA. Web: http://ranjitmathew.hostingzero.com/