Java Platform Module System compatibility
Platform: java --version openjdk 15 2020-09-15 OpenJDK Runtime Environment Zulu15.27+17-CA (build 15+36) OpenJDK 64-Bit Server VM Zulu15.27+17-CA (build 15+36, mixed mode, sharing)
IDE:
- [ ] Netbeans IDE 12.1
Build system: Maven -> embedded
Platform installed with: Maven Central
The version of the SDK:
module-info.java of project module com.test { requires javafx.controls; requires java.net.http; requires org.controlsfx.controls; requires io.sentry; exports com.test; }
When I try to make self-contained installer by jpackage for my modular test project it ends with error: jdk.incubator.jpackage.internal.PackagerException: jlink failed with: Error: automatic module cannot be used with jlink: io.sentry from file:///C:/Users/....../sentry-1.7.30.jar Do you have any plans to make Sentry modular that includes module-info.class file?
apparently, we can do it using Gradle https://docs.gradle.org/current/samples/sample_java_modules_multi_project.html
with Gradle and badass-jlink-plugin I have maked self-contained installer, but for now it's impossible using Maven and jpackage tool
Would be nice to see this as part of any work to resurrect OSGi support (#983). Keeping the library JDK8 compatible for now should be of concern as well IMHO.
We are looking to migrate from JDK 11 to JDK 17, and this is a major blocker in our applications preventing the migration to java 9 modules. Can someone please look into this?
@tlf30 would you like to contribute with a PR?
https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_modular
maybe @maciejwalkowiak can guide you during the process, I'm not familiar with the Java platform module system yet
I have this issue on my todo list, but I will also need some time to dig into it as I haven't worked with JPMS yet. @tlf30 you're welcome to create a PR.
@maciejwalkowiak unfortunately the module system is fairly new to me as well. I have only been learning it these last couple weeks as my company pushes to move from jdk 11 to jdk 17. Our biggest motivator to use modular applications was jfx 16 requiring it, and we are heavily dependent on javafx.
I'm afraid that if I was to prepare a PR that i would overlook something important. I am already fighting that in my own applications.
The Java Platform Module System (JPMS) was released in 2017 as a core feature of Java 9.
It would be great if at least an Automatic-Module-Name could be added to the META-INF/MANIFEST.MF file of the Sentry's JAR files until the library is fully modularized.
Is this the reason why Sentry does not work if run from a build created with the org.beryx.jlink plugin?
Is this the reason why Sentry does not work if run from a build created with the
org.beryx.jlinkplugin?
Very likely, yes. From https://github.com/beryx/badass-jlink-plugin:
Using this Gradle plugin you can create a custom runtime image of your modular application with minimal effort, even if it depends on automatic modules.
Currently, Sentry does not support JPMS modules and does not even provide an automatic module name.
We'll bump prio on this but I can't give an ETA on when we'll get to it.
Luckily I found a way to avoid the JPMS.
Luckily I found a way to avoid the JPMS.
Thanks for letting us know! 😉
I am still very much interested in Java Module support. Here are the module-info.java values that worked for me:
For the sentry artifact:
module io.sentry
{
exports io.sentry;
exports io.sentry.exception;
exports io.sentry.protocol;
exports io.sentry.util;
}
For the sentry-jdbc artifact:
module io.sentry.jdbc
{
requires io.sentry;
requires p6spy;
provides com.p6spy.engine.event.JdbcEventListener with
io.sentry.jdbc.SentryJdbcEventListener;
exports io.sentry.jdbc;
}
For the sentry-logback artifact:
module io.sentry.logback
{
requires io.sentry;
requires ch.qos.logback.core;
requires ch.qos.logback.classic;
exports io.sentry.logback;
}
Can you please include these in your upcoming release?
Thanks @cowwoc, we'll take a look. We're planning to release v8 beta.2 soon. This would go into a follow-up release.
Hi @cowwoc,
were you able to compile the sdk with your proposed module-info.java files?
I did give that a try, unfortunately, as soon as we add those our build breaks as we need to support Java 8. Also, I haven't found a good solution to supply module-info.java while still supporting Java 8. This will need to be discussed in more detail internally to find a solution. So, unfortunately, we won't be able to provide full JPMS support with the upcoming Sentry 8 Java SDK release.
However, I will investigate if it is possible to at least add the Automatic-Module-Name to META-INF.
If the Automatic-Module-Name alone is not enough for your use case, you will have to manually patch the jar to add module-info.
@lbloder You can support both Java 8 and Java Modules quite easily. Just publish a multi-release JAR. Look for sample code involving the use of this property: https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#multiReleaseOutput