Skip to content

Allow RichtTextFX to access Java9 hidden methods#593

Closed
imario42 wants to merge 1 commit into
FXMisc:masterfrom
imario42:master
Closed

Allow RichtTextFX to access Java9 hidden methods#593
imario42 wants to merge 1 commit into
FXMisc:masterfrom
imario42:master

Conversation

@imario42

Copy link
Copy Markdown
Contributor

This pull request let you compile and use RichtTextFX with Java 9.
Methods, where possible, are changed to their public Java 9 counterparts.
Methods still private (only in TextFlowExt) are still used using reflection but in a way which does not even require the hidden classes to be visible.
Thus, you can use RichtTextFx without runtime switches.

@JordanMartinez

Copy link
Copy Markdown
Contributor

Thanks for the PR!

We'll need to update the build-related files to generate a separate build for Java 9 on Linux and Mac.

However, since everyone is not yet using Java 9, we want to allow RTFX to build on Java 9 and 8 machines alike. This code seems like it will only work on Java 9 if merged.

TestFX encountered the same problem: how can one build the project on both Java versions while maintaining the same code base as much as possible in cases where the API does not change across the Java versions?

When I wrote TestFX/TestFX#429, I created two packages with the same exact name and type signature. However, their implementations were specific to the Java version. Thus, Gradle would configure the core project in TestFX to use the correct internal package as a dependency based on which Java version was being used in Gradle. Using this API-adapter approach, any future changes to the core project will work in both versions of Java.

I don't know if we can take a similar approach here. It depends on what we need to access and how the type signatures change between the two Java versions. However, if we can, then let's do it that way because everyone is not yet using Java 9.

@imario42

imario42 commented Sep 26, 2017 via email

Copy link
Copy Markdown
Contributor Author

@JFormDesigner

Copy link
Copy Markdown
Contributor

@imario42 I've rebased your PR to master and made it compatible to Java 8 in PR #614

This works good so far, but I've a question regarding class GenericIceBreaker:
What's the reason for checking delegateMethod.canAccess(delegate) before invoking delegateMethod.setAccessible(true)?

Are there any downsides if I remove this check and always invoke setAccessible(true)?

canAccess() is not available in Java 8 and I'd like to avoid using reflection for Java 9 if this check is not necessary.

@imario42

imario42 commented Oct 16, 2017 via email

Copy link
Copy Markdown
Contributor Author

@JordanMartinez

Copy link
Copy Markdown
Contributor

Closing since this has been implemented in #614

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants