JDK-8134709 : Cannot compile FXDnD with JDK 9: DropTargetContext::addNotify, removeNotify not found
  • Type: Bug
  • Component: javafx
  • Sub-Component: swing
  • Affected Version: 9
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2015-08-28
  • Updated: 2016-02-18
  • Resolved: 2016-02-18
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.
JDK 9
9Fixed
Related Reports
Blocks :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
As a result of the fix for JDK-8074763 we can no longer compile FX 9-dev using JDK 9 as the boot JDK. We currently use JDK 8u40 as our boot JDK, so our production builds are not affected. However, Swing / FX drag and drop will likely fail at runtime with a NoSuchMethodError as a result of this.

Here is the error:

$ java -version
java version "1.9.0-ea"
Java(TM) SE Runtime Environment (build 1.9.0-ea-b77)
Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b77, mixed mode)

$ gradle
...
:swing:compileJava/localhome/kcr/javafx/9-kcr/jfx/rt/modules/swing/src/main/java/javafx/embed/swing/FXDnD.java:480: error: cannot find symbol
                    if (ctx != null) ctx.removeNotify();
                                        ^
  symbol:   method removeNotify()
  location: variable ctx of type DropTargetContext
/localhome/kcr/javafx/9-kcr/jfx/rt/modules/swing/src/main/java/javafx/embed/swing/FXDnD.java:489: error: cannot find symbol
                        ctx.addNotify(FXDropTargetContextPeer.this);
                           ^
  symbol:   method addNotify(FXDnD.FXDropTargetContextPeer)
  location: variable ctx of type DropTargetContext
/localhome/kcr/javafx/9-kcr/jfx/rt/modules/swing/src/main/java/javafx/embed/swing/FXDnD.java:511: error: cannot find symbol
                    if (ctx != null) ctx.removeNotify();
                                        ^
  symbol:   method removeNotify()
  location: variable ctx of type DropTargetContext
/localhome/kcr/javafx/9-kcr/jfx/rt/modules/swing/src/main/java/javafx/embed/swing/FXDnD.java:520: error: cannot find symbol
                    if (ctx != null) ctx.removeNotify();
                                        ^
  symbol:   method removeNotify()
  location: variable ctx of type DropTargetContext
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 errors
 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':swing:compileJava'.
> Compilation failed with exit code 1; see the compiler error output for details
.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

BUILD FAILED

Comments
I filed JDK-8150175 to re-enable this code with JDK 9 API once we switch to using JDK 9 as the boot JDK.
18-02-2016

Changeset: 1b7a67a95553 Author: kcr Date: 2016-02-18 08:05 -0800 URL: http://hg.openjdk.java.net/openjfx/9-dev/rt/rev/1b7a67a95553 8134709: Cannot compile FXDnD with JDK 9: DropTargetContext::addNotify, removeNotify not found Reviewed-by: serb
18-02-2016

Looks fine.
18-02-2016

Webrev: http://cr.openjdk.java.net/~kcr/8134709/webrev.00/ This implements the above mentioned short-term fix, but without the print statement (I could add that if it was felt to be useful). I will file a follow-on JIRA to restore the code with the equivalent JDK-9 code after we switch to compiling with JDK 9 as the boot JDK.
18-02-2016

As a short-term solution (workaround) for the compilation error, we could comment out the offending code, and replace it with a print statement and a "FIXME" comment. If the fix using reflection isn't too hard, though, that would be another (better) short-term solution. Once we have upgraded to JDK 9, we can remove the reflection (or implement it if we end up commenting it out rather than using reflection).
16-02-2016

I filed JDK-8149967 to track the SurfaceData::getDefaultScale issue.
16-02-2016

I will file a separate JIRA for the getDefaultScale failure, since it is unrelated. This bug will track the failures due to the DropTargetContext::addNotify, removeNotify.
16-02-2016

The change to the getDefaultScale method is causing all JFXPanel apps to get a NoSuchMethodError at runtime. Rendering generally seems to work, but a constant stream of exceptions are printed on the console.
16-02-2016

We now have one more instance of this: /localhome/kcr/javafx/9-kcr/jfx/rt/modules/swing/src/main/java/javafx/embed/swing/JFXPanel.java:692: error: cannot find symbol newScaleFactor = ((SunGraphics2D)g).surfaceData.getDefaultScale(); ^ symbol: method getDefaultScale() location: variable surfaceData of type SurfaceData This one is a result of changes to the sun.java2d.SurfaceData class for Windows Hi-DPI support -- see JDK-8073320. This class used to have a getDefaultScale() method and now has separate getDefaultScaleX() and getDefaultScaleY() methods.
16-02-2016

Note: it would be best if a solution could be found that can go into FX 9-dev such that we can compile on either JDK 8u40 or on JDK 9. At least until we are ready to switch to using a build of JDK 9 as the boot JDK.
28-08-2015

Note that this issue was discussed at the time JDK-8074763 was reviewed: http://mail.openjdk.java.net/pipermail/awt-dev/2015-March/009158.html
28-08-2015