[External] : Re: RFR: 8193904: Uninitialized final field access and qualified this
Alex Buckley
alex.buckley at oracle.com
Wed Nov 2 21:19:21 UTC 2022
DU/DA analysis is about whether names have bindings. `x.foo` and `new
C().foo` and `m().foo` are expressions, not names, so we don't attempt
the analysis on them. As Jan points out [1], access via expressions is
hard to track. `this.foo` is an expression, but a very easy one, so we
treat it like the name `foo` and do the analysis. `A.B.C.this.foo` is an
expression with a qualified-this subexpression and now you need a bunch
of analysis to figure out whether it means the same as the name `foo`.
Alex
[1]
https://bugs.openjdk.org/browse/JDK-8289777?focusedCommentId=14516785&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-14516785
On 11/2/2022 1:18 PM, Archie Cobbs wrote:
> On Wed, Nov 2, 2022 at 2:47 PM Alex Buckley <alex.buckley at oracle.com
> <mailto:alex.buckley at oracle.com>> wrote:
>
> JLS ch.16 is specific that only `foo` and `this.foo` cause an error.
> See
> the definition of "access" in the opening paragraphs of the chapter.
>
>
> Thanks for pointing that out, which I forgot to do. The JLS language is:
>
> An access to its value consists of the simple name of the variable (or,
> for a field, the simple name of the field qualified by |this|) occurring
> anywhere in an expression except as the left-hand operand of the simple
> assignment operator |=| ||
>
> In theory one could argue that MyClass.this.foo is also an example of
> "the simple name of the field qualified by |this" - just look at the
> latter part, no?
> |
> |
> |
> Regardless, it looks like there needs to be a spec change... right? I'm
> assuming we'd rather do that than continue to allow the current behavior.
>
> Thanks,
> -Archie
>
> --
> Archie L. Cobbs
More information about the compiler-dev
mailing list