This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: PR java/25429: can't see private static final int CREATE = 1
Andrew Haley writes:
> Tom Tromey writes:
> > >>>>> "Andrew" == Andrew Haley <aph@redhat.com> writes:
> >
> > I was just writing a comment in the RH PR ...
> >
> > Andrew> + if (nested_member_access_p (current_class, decl)
> > Andrew> + && ! (JDECL_P (decl) && CLASS_FINAL_VARIABLE_P (decl)
> > Andrew> + && DECL_INITIAL (decl) != NULL_TREE))
> >
> > I'm not sure about this patch. It seems to me that the test has to be
> > for whether the field's value is inlineable, i.e., the DECL_INITIAL is
> > a constant expression.
>
> Well, it's the exact same test that is used to do the same thing
> elsewhere in the compiler.
>
> > For instance, won't this skip the accessor if we see:
> >
> > private static final Object FIELD = new Object();
> >
> > ... but that would be wrong.
>
> No, because when we see more complex initialization we don't set the
> DECL_INITIAL. Instead, we generate a synthetic method that contains
> all the initializations. We only set DECL_INITIAL if the
> initialization requires no code to be executed at runtime.
Belay that. You're right...
Andrew.