RFR: 8295962: Reference to State in Task.java is ambiguous when building with JDK 19

Kevin Rushforth kcr at openjdk.org
Fri Oct 28 18:03:39 UTC 2022


On Wed, 26 Oct 2022 22:38:15 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:

> This PR replaces all occurrences of `State` with `Worker.State` in `javafx.concurrent.Task`.
> 
> The `javafx.concurrent.Task` class implements `javafx.concurrent.Worker` and extends `java.util.concurrent.FutureTask`, which in turn implements `java.util.concurrent.Future`.
> 
> `Worker` has a nested `State` enum, which is used in the implementing `Task` class without being qualified -- since `Task` is a `Worker`, we can just say `State` instead of `Worker.State`.
> 
> [JDK-8277090](https://bugs.openjdk.org/browse/JDK-8277090) added a nested `State` enum to the `java.util.concurrent.Future` interface in JDK 19, so an unqualified reference to `State` from the `Task` class is now ambiguous when using JDK 19 to build. The javadoc task fails with an error (and the only reason the javac task doesn't is that we use `--release 17`).
> 
> With this fix, a local build and test using JDK 19 passes.

The reason I didn't catch these is that `gradle test` passes when using JDK 19, for the same reason that "gradle sdk" does: we compile classes for all modules except `javafx.swing` and the system tests with `--release 17`. When building the javadocs and when building `javafx.swing` and the system tests, we (necessarily) use `-source 17 -target 17` instead of `--release 17`. I'll bet your Eclipse test run does the same (or maybe doesn't specificy anything relating the target release).

If I temporarily modify my build to use `-source 17 -target 17` for all modules, I also get errors. Conversely, if you add `--release 17` to your Eclipse options, you won't see the error.

I'll still fix those tests to make it more future proof.

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

PR: https://git.openjdk.org/jfx/pull/933


More information about the openjfx-dev mailing list