Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java 9: Inaccessable internal APIs in ˋcom.sun.*ˋ #228

Open
hastebrot opened this issue Aug 7, 2015 · 14 comments
Open

Java 9: Inaccessable internal APIs in ˋcom.sun.*ˋ #228

hastebrot opened this issue Aug 7, 2015 · 14 comments

Comments

@hastebrot
Copy link
Member

Some TestFX functionality might become unavailable with Java 9. We depend on internal JavaFX API for Monocle headless tests, the Glass robot, ... Monocle is an external JAR for desktop system, so this might not cause problems, but on embedded system it might.

https://github.com/TestFX/TestFX/search?q=%22com.sun%22&type=Code

@hastebrot
Copy link
Member Author

Here is some code for Java 9 support in Travis:

Schedule and features for Java 9:

JEP 253: Prepare JavaFX UI Controls & CSS APIs for Modularization

@hastebrot
Copy link
Member Author

Results of review of private JavaFX API for consideration to make public in JDK 9:

JEP 253: UI control skins and input mapping discussion

@hastebrot hastebrot changed the title Internal ˋcom.sunˋ API in Java 9 Java 9: Inaccessable internal APIs in ˋcom.sun.*ˋ Aug 7, 2015
@hastebrot
Copy link
Member Author

The first early access builds with the Java Platform Module System were published in September 2015.

The initial version of The State of the Module System, together with JEP 261 and the first early-access builds containing the prototype module system, were published in September 2015.
http://openjdk.java.net/projects/jigsaw/

Early Access builds of JDK 9 with Project Jigsaw:

@hastebrot
Copy link
Member Author

Assuming your test program is in the unnamed module (meaning it is run from a jar file or directory of classes on the classpath), the following will work:

java -XaddExports:javafx.graphics/com.sun.glass.ui=ALL-UNNAMED

@hastebrot
Copy link
Member Author

The first Java 9 early access build with integrated Jigsaw+JavaFX is 9 Build 113 [1].

Important milestones in the current schedule:

  • 2016/05/26: Feature Complete
  • 2017/01/26: Final Release Candidate
  • 2017/03/23: General Availability

[1] https://jdk9.java.net/download/

@brcolow
Copy link
Collaborator

brcolow commented Jan 17, 2017

The jdeps tool shows the cases where we use internal APIs:

testfx-core-4.0.5-alpha.jar -> C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\jfxrt.jar
   org.testfx.service.adapter.impl.GlassRobotAdapter (testfx-core-4.0.5-alpha.jar)
      -> com.sun.glass.ui.Application                       JDK internal API (jfxrt.jar)
      -> com.sun.glass.ui.Pixels                            JDK internal API (jfxrt.jar)
      -> com.sun.glass.ui.Robot                             JDK internal API (jfxrt.jar)
   org.testfx.service.adapter.impl.JavafxRobotAdapter (testfx-core-4.0.5-alpha.jar)
      -> com.sun.javafx.robot.FXRobot                       JDK internal API (jfxrt.jar)
      -> com.sun.javafx.robot.FXRobotFactory                JDK internal API (jfxrt.jar)
      -> com.sun.javafx.robot.FXRobotImage                  JDK internal API (jfxrt.jar)
   org.testfx.toolkit.impl.ToolkitServiceImpl (testfx-core-4.0.5-alpha.jar)
      -> com.sun.javafx.application.ParametersImpl          JDK internal API (jfxrt.jar)

Warning: JDK internal APIs are unsupported and private to JDK implementation that are
subject to be removed or changed incompatibly and could break your application.
Please modify your code to eliminate dependency on any JDK internal APIs.
For the most recent update on JDK internal API replacements, please check:
https://wiki.openjdk.java.net/display/JDK8/Java+Dependency+Analysis+Tool

@hastebrot
Copy link
Member Author

hastebrot commented Jan 17, 2017

@brcolow Robot is needed for Monocle. Solution is to use command line parameters for this (we need to use them for Monocle anyway). Functionality of FxRobot can be extracted (approx. five lines of code) [1].

[1] Removal of com.sun.javafx.robot

Platform.runLater(() -> {
    Event.fireEvent(scene.getFocusOwner(), keyEvent);
});

@brcolow
Copy link
Collaborator

brcolow commented Jan 18, 2017

Do you mean something like #355 ?

I was able to pull most things directly out of com.sun.javafx.robot.impl.BaseFxRobot so I am not sure about copyright, etc. But as a proof of concept, is this what you meant? Interestingly only 2 failing tests with this approach.

@tbee
Copy link

tbee commented Apr 22, 2017

JFXtras uses TextFX to make sure things keep working. It would be great if I can do the Java 9 migration with running those tests. Is TestFX already running on Java 9?

@brcolow
Copy link
Collaborator

brcolow commented Apr 22, 2017

TestFX should be working on Java 9 as I removed all uses of the private API. I would speak with more confidence if I could run the test suite but gradle does not currently support jigsaw Java 9 builds. Once gradle support has landed, I will be able to progress on this issue. Brave people who want to try and build without gradle are free to hack about, but I don't have time for that at that moment. I added a Java 9 build to our Travis CI infrastructure which is currently stuck at the gradle step. Seems that full jigsaw support is being tracked in gradle/gradle#719 - which is milestoned for version 4.1 (quite a ways away I think).

@tbee
Copy link

tbee commented Apr 23, 2017

Thanks for the response. I'm using Gradle as well for JFXtras, but Maven is already fully Java 9 compatible. I'm considering switching back (maybe polyglot maven :-) ) or to Kobalt

@brcolow
Copy link
Collaborator

brcolow commented Apr 23, 2017

Indeed - it would honestly not take that much work to also add the equivalent pom.xml's for TestFX...I will look in to maybe doing this in the meanwhile for Java 9 testing.

@hastebrot
Copy link
Member Author

From the Gradle 4.1 release notes (https://docs.gradle.org/4.1/release-notes.html):

This release supports running Gradle on the most recent JDK 9 release (b170+). Read our guide to building Java 9 modules to learn how to produce and consume Java 9 modules with Gradle.

@JordanMartinez
Copy link
Contributor

The guide works, but it's still not as simple as an established plugin. One could use the experimental one, but it's experimental.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants