On Wed, 17 Sep 2025 13:43:37 GMT, Maurizio Cimadamore <[email protected]>
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
>
> test/langtools/tools/javac/SuperInit/InitializationWarningTest.java line 9:
>
>> 7: */
>> 8:
>> 9: class InitializationWarningTest implements Iterable<Object> {
>
> Since the code base is shared -- perhaps a better testing methodology would
> be to run _all_ the existing early init negative tests in this new mode, to
> make sure they generate a warning when there was an error before?
the problem with reusing existing tests is that most of them have a explicit
`super` invocation, but we are interested in constructor bodies without a
explicit super invocation, gonna think if there is a way out here
-------------
PR Review Comment:
https://git.openjdk.org/valhalla/pull/1595#discussion_r2356015636