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

Jan Lahoda jlahoda at openjdk.org
Mon Oct 3 07:27:21 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.

This pull request has now been integrated.

Changeset: 8e9cfeb1
Author:    Jan Lahoda <jlahoda at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/8e9cfeb17ccb6c37243d43f76d5eecb3f521141f
Stats:     9 lines in 2 files changed: 5 ins; 0 del; 4 mod

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

Reviewed-by: sundar

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

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


More information about the kulla-dev mailing list