[lworld] RFR: 8367698: [lworld] New lint category for code that would not be allowed in the prologue [v2]
Maurizio Cimadamore
mcimadamore at openjdk.org
Tue Sep 23 12:28:42 UTC 2025
On Tue, 23 Sep 2025 11:12:14 GMT, Vicente Romero <vromero at openjdk.org> wrote:
>> This PR introduces a new Xlint category: `initialization`. When enabled it will indicate if some code in an identity class couldn't be placed in the prologue phase. This applies to field initializers and constructors with no explicit `super` invocation. So for example for code like:
>>
>>
>> class Test {
>> int i = 0;
>>
>> Test() {
>> this.i = 1;
>> }
>> }
>>
>>
>> a warning will be issued as if there were a super invocation at the end of the constructor, the compiler would issue an error.
>>
>> PS. The new lint warning had to be disabled during the build as in other case it wouldn't finish
>
> Vicente Romero has updated the pull request incrementally with one additional commit since the last revision:
>
> addressing review comments
test/langtools/tools/javac/SuperInit/EarlyAssignments.out line 22:
> 20: EarlyAssignments.java:170:18: compiler.err.cant.ref.before.ctor.called: EarlyAssignments.Inner8
> 21: EarlyAssignments.java:179:17: compiler.err.cant.ref.before.ctor.called: x
> 22: 21 errors
Why the difference here? The missing error seems to be this:
EarlyAssignments.java:157:13: compiler.err.cant.assign.val.to.var: final, x
-------------
PR Review Comment: https://git.openjdk.org/valhalla/pull/1595#discussion_r2372147786
More information about the valhalla-dev
mailing list