RFR: 8294431: jshell reports error on initialisation of static final field of anonymous class

Athijegannathan Sundararajan sundar at openjdk.org
Thu Sep 29 14:41:36 UTC 2022


On Thu, 29 Sep 2022 13:51:16 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> When variable with an inferred type (i.e. `var`) is initialized with an anonymous class, the inferred type of the variable is the actual anonymous type. To implement this in JShell, JShell will unroll the anonymous class into a normal class, and to do this, it needs to initialize fields inside a constructor.
> 
> But, as we can have static fields in the anonymous class now, it is necessary to not try to initialize static fields in the constructor, as we would initialize them too often.

LGTM

-------------

Marked as reviewed by sundar (Reviewer).

PR: https://git.openjdk.org/jdk/pull/10489


More information about the kulla-dev mailing list