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

Rémi Forax github.com+828220+forax at openjdk.java.net
Thu Apr 22 13:43:22 UTC 2021


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

>> 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.

It's not a bug, it's a dubious feature, the lambda EG discussed that at length, you can ask Brian about it.

Usually replacing

t.name != names.init

by

  t.name != this.names.init

is enough.

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

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


More information about the compiler-dev mailing list