RFR: 8057543: Replace javac's Filter with Predicate (and lambdas) [v2]

Maurizio Cimadamore mcimadamore at openjdk.java.net
Thu Apr 22 13:26:25 UTC 2021


On Wed, 21 Apr 2021 15:36:39 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> When building the JDK, I got the following error:
>> 
>> 
>> jdk/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java:950: error: variable names might not have been initialized
>>                     t.name != names.init &&
>>                               ^
>> 1 error
>> 
>> 
>> Therefore I revised the modifier of the `Names names`.
>
> I see - honestly this seems like a bug in definite assignment? E.g. surely the instance field initializer for `bridgeFilter` must run _after_ the `final` field `names` has been initialized? For now you might try using an anonymous inner class instead of a lambda instead, pretty sure that will take care of the issue. But this looks like a compiler bug.

Actually - doing more tests, I think javac is right. Fields with explicit initializers are initialized BEFORE other constructor statements. Which means that the error message is legitimate (e.g. the lambda is capturing a final value that is not initialized). I think reverting back to anon class would be better here.

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

PR: https://git.openjdk.java.net/jdk/pull/1898


More information about the compiler-dev mailing list