JDK-8295962 : Reference to State in Task.java is ambiguous when building with JDK 19
  • Type: Bug
  • Component: javafx
  • Sub-Component: other
  • Affected Version: openjfx20
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-10-26
  • Updated: 2022-11-18
  • Resolved: 2022-11-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
openjfx20Fixed
Related Reports
Relates :  
Description
When using JDK 19 to build JavaFX, we get the following error from the "javadoc" task:

modules/javafx.graphics/src/main/java/javafx/concurrent/Task.java:693: error: reference to State is ambiguous
    private ObjectProperty<State> state = new SimpleObjectProperty<>(this, "state", State.READY);
                           ^
  both enum java.util.concurrent.Future.State in Future and enum javafx.concurrent.Worker.State in Worker match
modules/javafx.graphics/src/main/java/javafx/concurrent/Task.java:694: error: reference to State is ambiguous
    final void setState(State value) { // package access for the Service
                        ^
  both enum java.util.concurrent.Future.State in Future and enum javafx.concurrent.Worker.State in Worker match
modules/javafx.graphics/src/main/java/javafx/concurrent/Task.java:732: error: reference to State is ambiguous
    @Override public final State getState() { checkThread(); return state.get(); }
                           ^
  both enum java.util.concurrent.Future.State in Future and enum javafx.concurrent.Worker.State in Worker match
modules/javafx.graphics/src/main/java/javafx/concurrent/Task.java:733: error: reference to State is ambiguous
    @Override public final ReadOnlyObjectProperty<State> stateProperty() { checkThread(); return state; }
                                                  ^
  both enum java.util.concurrent.Future.State in Future and enum javafx.concurrent.Worker.State in Worker match
4 errors


The only reason we don't get them from the javac task is that we run javac with "--release 17" for most modules, including the gaphics modules. If we instead use "-source 17 -target 17" then javac produces the same error.
Comments
Changeset: 4a2afb4c Author: Kevin Rushforth <kcr@openjdk.org> Date: 2022-11-02 17:14:10 +0000 URL: https://git.openjdk.org/jfx/commit/4a2afb4ce28b46ee463b1dc8d38d1c81962e3c88
02-11-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jfx/pull/933 Date: 2022-10-26 22:38:15 +0000
26-10-2022

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 enum "State", 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". The problem arises because java.util.concurrent.Future added an enum in JDK 19 also named "State" (as part of JDK-8277090), so the reference to "State" in the Task class is ambiguous. The solution is to replace all occurrences of "State" with "Worker.State" in Task.java.
26-10-2022