[lworld] RFR: 8367698: [lworld] New lint category for code that would not be allowed in the prologue

Vicente Romero vromero at openjdk.org
Wed Sep 17 15:52:06 UTC 2025


On Wed, 17 Sep 2025 13:41:21 GMT, Maurizio Cimadamore <mcimadamore 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
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 1601:
> 
>> 1599:                             v.type = chk.checkLocalVarType(tree, tree.init.type, tree.name);
>> 1600:                         }
>> 1601:                         if (allowValueClasses && v.owner.kind == TYP && !v.isStatic()) {
> 
> checking again whether value classes are enabled here seems redundant?

not sure, we don't want to issue the warning if preview mode is not enabled, we can probably check explicitly for preview

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

PR Review Comment: https://git.openjdk.org/valhalla/pull/1595#discussion_r2355984391


More information about the valhalla-dev mailing list