-
Notifications
You must be signed in to change notification settings - Fork 19
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
SLING-11610 - Sling XSS API 2.3.0 does not work on Java 17 #32
Conversation
Switch from reflective access to using sun.misc.Unsafe. Even though 'unsafe' looks scary, it's part of the jdk.unsupported module which both 'exports' and 'opens' its packages. Reference: https://blogs.oracle.com/javamagazine/post/a-peek-into-java-17-continuing-the-drive-to-encapsulate-the-java-runtime-internals
Ensure that the jdk.unsupported module is available when compiling.
Move to using Java 11
- update to the latest version of Mockito - drop Powermock
Exclude xml-apis transitive dependency, this causes conflicts since we are using the module path See https://stackoverflow.com/questions/55571046/eclipse-is-confused-by-imports-accessible-from-more-than-one-module
Run tests on more Java versions
Exclude Java 8, for now, since we have a baseline Java 11 version.
Restore Java 8 compatibility, but with Java 9+ builds broken.
I've tried to set this up in a way that works with Java 8 through 21. I think the code is working fine, the problem is the build. In 29c1733 I see Java 11, 17 and 21 builds passing. I've reconfigured the project for Java 8 in 674c7cb, but at that point Java 11+ builds start failing with
That error makes sense, since the JPMS has been introduced with Java 9. I think supporting Java 11, 17, and 21 is preferred to only supporting Java 8 and 11, but I don't have an idea about how to fix the build. @kwin - maybe you have an idea? I know you've worked on the parent POM plumbing for the compiler plugin. |
Not sure here TBH. |
Configure the maven-compiler-plugin to use source/target instead of release, even for newer JDK versions. This has the effect of running javac with fewer checks, and allows compilation on Java 8 to complete succesfully.
Kudos, SonarCloud Quality Gate passed! |
It seems that I figured out the right incantations to allow compilation and test runs on Java 8. The CI tests make me pretty confident that this change works. Also ran the Starter tests with this change on Java 11 and 17. |
Switch from reflective access to using sun.misc.Unsafe. Even though 'unsafe' looks scary, it's part of the jdk.unsupported module which both 'exports' and 'opens' its packages.
Reference: https://blogs.oracle.com/javamagazine/post/a-peek-into-java-17-continuing-the-drive-to-encapsulate-the-java-runtime-internals