RFR: javac should not place initializers of null restricted fields before the super invocation
Vicente Romero
vromero at openjdk.org
Thu Jan 29 02:23:40 UTC 2026
On Thu, 29 Jan 2026 01:34:35 GMT, Vicente Romero <vromero at openjdk.org> wrote:
> javac is automatically placing the initializers of null restricted fields before the super invocation. This is incorrect, null restricted fields are not strict and those initializers should be placed after the super. But javac will check that null restricted fields have been initialized before a super invocation. This implies that null restricted fields should not have initializers and users should manually initialize them in all the constructors and before explicit super invocations.
test/langtools/tools/javac/nullability/NullabilityCompilationTests.java line 597:
> 595: """
> 596: class Test {
> 597: Object! o = new Object();
this section was checking that non-nullable fields were strict
test/langtools/tools/javac/valhalla/value-objects/ValueObjectCompilationTests.java line 1066:
> 1064: assertFail("compiler.err.non.nullable.should.be.initialized",
> 1065: """
> 1066: import jdk.internal.vm.annotation.Strict;
the strict annotation is being eliminated in lworld, this part was failing so I removed it as it will be removed anyways after we merge with lworld
-------------
PR Review Comment: https://git.openjdk.org/valhalla/pull/1990#discussion_r2739458808
PR Review Comment: https://git.openjdk.org/valhalla/pull/1990#discussion_r2739462944
More information about the valhalla-dev
mailing list