initialization of final fields

Jerry Kramskoy Jerry.Kramskoy@insignia.com
Thu Nov 4 05:34:00 GMT 1999


Sun's stated semantics for writes to final fields are weaker than your
proposal ...
the current class (to which the executing method belongs)
must be the same as the declaring class for the final field.

cheers,
Jerry

----- Original Message -----
From: Martyn Pearce <m.pearce@inpharmatica.co.uk>
To: Per Bothner <per@bothner.com>
Cc: Godmar Back <gback@cs.utah.edu>; <java-discuss@sourceware.cygnus.com>;
<vgp@dms.at>
Sent: Thursday, November 04, 1999 9:01 AM
Subject: Re: initialization of final fields


>
> Per Bothner writes:
> | Godmar Back <gback@cs.utah.edu> writes:
> |
> | > My suggestion: until GCJ can prove that an assignment to a final
> | > variable is indeed illegal, could you make the error in
> | > expr.c:expand_java_field_op suppressable?
> |
> | I think we can say that a method may assign to a final field
> | iff the method is private and is only called (directly or indirectly)
> | by the initializer.
> |
> | You can verify this with two extra bits per method
> | ...
>
> Pathological example I know, but... I don't think we've covered the
> possibility that a given initializer calls such a method more than
> once.
>
> Actually, I don't think it's so patholgical --- the method call might be
> embedded in a loop without thinking.
>
> Mx.
>



More information about the Java mailing list