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

Issues with JDK9 #452

Closed
mgarin opened this issue Mar 22, 2017 · 4 comments
Closed

Issues with JDK9 #452

mgarin opened this issue Mar 22, 2017 · 4 comments

Comments

@mgarin
Copy link
Owner

mgarin commented Mar 22, 2017

There are quite a few problems that appeared on JDK 9.

One of them was mentioned by @Abu-Abdullah on Gitter:

[AWT-EventQueue-0] ERROR com.alee.utils.ProprietaryUtils - java.lang.NoSuchFieldException: Field "AA_TEXT_PROPERTY_KEY" not found in class: sun.swing.SwingUtilities2
java.lang.NoSuchFieldException: Field "AA_TEXT_PROPERTY_KEY" not found in class: sun.swing.SwingUtilities2

It seems that there were major changes to the internal text rendering made in JDK 9 and the field requested above doesn't exist anymore. To be even more precise - AATextInfo class doesn't exist anymore and was replaced by common Graphics2D settings.

There are also some other issues which can be seen in runtime on the lists related to reflection API usage.

@mgarin
Copy link
Owner Author

mgarin commented Apr 28, 2017

Just a short update - I will be patching known JDK 9 -related issues somewhere around the middle of the next week. Fixes will only be going into the styling branch and all related builds.

Although I still do not recommend running WebLaF under JDK 9 ea builds as there might be more issues hidden from sight as I haven't properly tested it yet.

@mgarin
Copy link
Owner Author

mgarin commented Apr 2, 2018

I have fixed a few issues that have been appearing under JDK 9 and 10. I have also updated the mechanism that detects JDK version to be properly able to run version-related code and patched some of that version-related code to work under JDK 9+.

These changes have been added with 57ab5dd commit in styling branch and new snapshot builds will soon be available.

@mgarin mgarin closed this as completed Apr 2, 2018
@mokun
Copy link

mokun commented Jun 8, 2018

When I use the 1.2.9-snapshot version, The "AA_TEXT_PROPERTY_KEY" exception is gone. But I still have issues with xstream v1.4.9 used by weblaf.

See this issue

mokun added a commit to mars-sim/mars-sim that referenced this issue Jun 8, 2018
r4282
2018-06-08

Note 1: the following warning shows up when starting mars-sim :
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by
com.thoughtworks.xstream.core.util.Fields
(file:/C:/Users/mk/.m2/repository/com/thoughtworks/xstream/xstream/1.4.9/xstream-1.4.9.jar)
to field java.util.TreeMap.comparator

See issue x-stream/xstream#101

Note 2: weblaf has resolved a java 9 compatibility issue due to the
exception by "AA_TEXT_PROPERTY_KEY" in 1.2.9-SNAPSHOT. However,
the xtream library is still using reflection that's deemed "illegal"
in Java 9.

See issue mgarin/weblaf#452

# CHANGES
1. Revert back weblaf-ui and weblaf-core to 1.2.9-SNAPSHOT for Java 9
   compatibility.

2. Revise class relating to sponsors' mission objectives. Will code in
   the use of these objectives in future.
@mgarin
Copy link
Owner Author

mgarin commented Jun 9, 2018

There is, unfortunately, no good way to avoid those warnings anyhow right now. I've already investigated this problem when I was trying to fix all JDK9+ issues.

Basically you get those warnings because some part of your code (or any library you use) is doing some "illegal" Reflection operations. Like accessing a private field, changing a final field value, calling private methods or constructors etc. Those operations can now be allowed only if you have configured your module permissions in a specific way.

Obviously default JDK modules are NOT configured to allow anyone to access such stuff. Which basically means that, for instance, you can only use publicly opened APIs in Swing framework which is quite bad for many practical cases.

XStream does take a big part in WebLaF's Reflection usage, but it is also used within the library for other things. A lot actually. Its main use is still configuring components and UIs, but quite a few "illegal" things are also done to go around Swing limitations and some badly designed APIs. There are also quite a few Reflection usages that help supporting various features on different JDK versions without directly touching proprietary APIs.

There is only one approach that would allow you to avoid these warnings on JDK9+ but it is rather inconvenient. You can use --add-opens and --add-exports command line options for JVM to allow accessing modules that do not provide the rights you need by default.

There are quite a few articles around the internet explaining how those options work, for example:
https://blog.codefx.org/java/five-command-line-options-to-hack-the-java-9-module-system/

I have tried opening all required modules some time ago and it did work for me with earlier JDK9 version, but I ended up never using those options.

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

2 participants