sentry-java icon indicating copy to clipboard operation
sentry-java copied to clipboard

Java Platform Module System compatibility

Open 5force opened this issue 5 years ago • 13 comments

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: <groupId>io.sentry</groupId> <artifactId>sentry</artifactId> 1.7.30

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?

5force avatar Sep 28 '20 12:09 5force

apparently, we can do it using Gradle https://docs.gradle.org/current/samples/sample_java_modules_multi_project.html

marandaneto avatar Sep 28 '20 13:09 marandaneto

with Gradle and badass-jlink-plugin I have maked self-contained installer, but for now it's impossible using Maven and jpackage tool

5force avatar Sep 30 '20 23:09 5force

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.

talios avatar Nov 03 '20 20:11 talios

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 avatar Sep 30 '21 16:09 tlf30

@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

marandaneto avatar Oct 01 '21 06:10 marandaneto

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 avatar Oct 01 '21 07:10 maciejwalkowiak

@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.

tlf30 avatar Oct 01 '21 14:10 tlf30

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.

osiegmar avatar Jul 13 '24 07:07 osiegmar

Is this the reason why Sentry does not work if run from a build created with the org.beryx.jlink plugin?

StefanOltmann avatar Aug 08 '24 16:08 StefanOltmann

Is this the reason why Sentry does not work if run from a build created with the org.beryx.jlink plugin?

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.

osiegmar avatar Aug 08 '24 17:08 osiegmar

We'll bump prio on this but I can't give an ETA on when we'll get to it.

adinauer avatar Aug 23 '24 09:08 adinauer

Luckily I found a way to avoid the JPMS.

StefanOltmann avatar Aug 23 '24 10:08 StefanOltmann

Luckily I found a way to avoid the JPMS.

Thanks for letting us know! 😉

osiegmar avatar Aug 23 '24 15:08 osiegmar

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?

cowwoc avatar Nov 11 '24 18:11 cowwoc

Thanks @cowwoc, we'll take a look. We're planning to release v8 beta.2 soon. This would go into a follow-up release.

adinauer avatar Nov 12 '24 13:11 adinauer

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 avatar Nov 22 '24 10:11 lbloder

@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

cowwoc avatar Nov 22 '24 11:11 cowwoc