FasterXML / jackson-module-kotlin

Module that adds support for serialization/deserialization of Kotlin (http://kotlinlang.org) classes and data classes.
Apache License 2.0
1.11k stars 173 forks source link

Compatibility with JPMS #228

Open Burtan opened 5 years ago

Burtan commented 5 years ago

Hey, it seems that this module uses internal functions of kotlin.reflect and thus is incompatible with the JPMS:

Caused by: java.util.ServiceConfigurationError: kotlin.reflect.jvm.internal.impl.builtins.BuiltInsLoader: module merged.module does not declare `uses`
SR-Lut3t1um commented 2 years ago

This problem just cost me around 20 hours while trying to debug a JavaFX/GraalVM application. Hopefully someone reads this and doesn't have to waste the same amount of time :/

dinomite commented 2 years ago

@SR-Lut3t1um What version of Jackson are you using? I believe this was fixed in #393, released with Jackson 2.12.0. I'm able to build & run jackson-module-kotlin's tests using Azul Zulu 16.

Oddly, Maven actually tells me that the kotlin.reflect declaration in the module-info.java is unused:

[WARNING] Bundle com.fasterxml.jackson.module:jackson-module-kotlin:bundle:2.13.0-rc3-SNAPSHOT : Unused Import-Package instructions: [kotlin.reflect.*]

Despite the fact that we use kotlin.reflect.jvm.internal.KotlinReflectionInternalError in https://github.com/FasterXML/jackson-module-kotlin/blob/2.13/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinNamesAnnotationIntrospector.kt#L25

SR-Lut3t1um commented 2 years ago

@dinomite I'm using the 2.12.4 version. Also made a simple reproducer

dinomite commented 2 years ago

I'm unable to make the reproduction run. I've never used GraalVM, but here it is failing in the same way under Azul Zulu & GraalVM. This is on a Linux host.

Running under Azul Zulu 11.0.12:

13:50:36 code:~/tmp/jackson-bug-reproducer$ java -version
openjdk version "11.0.12" 2021-07-20 LTS
OpenJDK Runtime Environment Zulu11.50+19-CA (build 11.0.12+7-LTS)
OpenJDK 64-Bit Server VM Zulu11.50+19-CA (build 11.0.12+7-LTS, mixed mode)
13:50:39 code:~/tmp/jackson-bug-reproducer$ ./gradlew run
Starting a Gradle Daemon (subsequent builds will be faster)

> Configure project :
Project : => no module-info.java found

> Task :compileKotlin FROM-CACHE
> Task :compileJava FROM-CACHE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :configJavafxRun

> Task :run FAILED
Loading library prism_es2 from resource failed: java.lang.UnsatisfiedLinkError: /home/dinomite/.openjfx/cache/16/libprism_es2.so: libGL.so.1: cannot open shared object file: No such file or directory
java.lang.UnsatisfiedLinkError: /home/dinomite/.openjfx/cache/16/libprism_es2.so: libGL.so.1: cannot open shared object file: No such file or directory
        at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
        at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2442)
        at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2498)
        at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2694)
        at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2627)
        at java.base/java.lang.Runtime.load0(Runtime.java:768)
        at java.base/java.lang.System.load(System.java:1837)
        at javafx.graphics/com.sun.glass.utils.NativeLibLoader.installLibraryFromResource(NativeLibLoader.java:214)
        at javafx.graphics/com.sun.glass.utils.NativeLibLoader.loadLibraryFromResource(NativeLibLoader.java:194)
        at javafx.graphics/com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:135)
        at javafx.graphics/com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:53)
        at javafx.graphics/com.sun.prism.es2.ES2Pipeline.lambda$static$0(ES2Pipeline.java:69)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at javafx.graphics/com.sun.prism.es2.ES2Pipeline.<clinit>(ES2Pipeline.java:51)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:315)
        at javafx.graphics/com.sun.prism.GraphicsPipeline.createPipeline(GraphicsPipeline.java:218)
        at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:91)
        at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:124)
        at java.base/java.lang.Thread.run(Thread.java:829)
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.UnsupportedOperationException: Unable to open DISPLAY
        at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$new$6(GtkApplication.java:173)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.<init>(GtkApplication.java:171)
        at javafx.graphics/com.sun.glass.ui.gtk.GtkPlatformFactory.createApplication(GtkPlatformFactory.java:41)
        at javafx.graphics/com.sun.glass.ui.Application.run(Application.java:144)
        at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:280)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:288)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:160)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:409)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
        ... 5 more

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command '/home/dinomite/.sdkman/candidates/java/11.0.12-zulu/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 13s
5 actionable tasks: 2 executed, 2 from cache, 1 up-to-date

under GraalVM CE 21.2.0:

13:54:44 code:~/tmp/jackson-bug-reproducer$ java -version
openjdk version "16.0.2" 2021-07-20
OpenJDK Runtime Environment GraalVM CE 21.2.0 (build 16.0.2+7-jvmci-21.2-b08)
OpenJDK 64-Bit Server VM GraalVM CE 21.2.0 (build 16.0.2+7-jvmci-21.2-b08, mixed mode, sharing)
13:54:50 code:~/tmp/jackson-bug-reproducer$ ./gradlew run

> Configure project :
Project : => no module-info.java found

> Task :compileKotlin FROM-CACHE
> Task :compileJava FROM-CACHE
> Task :processResources
> Task :classes
> Task :configJavafxRun

> Task :run FAILED
Loading library prism_es2 from resource failed: java.lang.UnsatisfiedLinkError: /home/dinomite/.openjfx/cache/16/libprism_es2.so: libGL.so.1: cannot open shared object file: No such file or directory
java.lang.UnsatisfiedLinkError: /home/dinomite/.openjfx/cache/16/libprism_es2.so: libGL.so.1: cannot open shared object file: No such file or directory
        at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
        at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:383)
        at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:227)
        at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:169)
        at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2383)
        at java.base/java.lang.Runtime.load0(Runtime.java:746)
        at java.base/java.lang.System.load(System.java:1857)
        at javafx.graphics/com.sun.glass.utils.NativeLibLoader.installLibraryFromResource(NativeLibLoader.java:214)
        at javafx.graphics/com.sun.glass.utils.NativeLibLoader.loadLibraryFromResource(NativeLibLoader.java:194)
        at javafx.graphics/com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:135)
        at javafx.graphics/com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:53)
        at javafx.graphics/com.sun.prism.es2.ES2Pipeline.lambda$static$0(ES2Pipeline.java:69)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
        at javafx.graphics/com.sun.prism.es2.ES2Pipeline.<clinit>(ES2Pipeline.java:51)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:375)
        at javafx.graphics/com.sun.prism.GraphicsPipeline.createPipeline(GraphicsPipeline.java:218)
        at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:91)
        at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:124)
        at java.base/java.lang.Thread.run(Thread.java:831)
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:567)
        at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1071)
Caused by: java.lang.UnsupportedOperationException: Unable to open DISPLAY
        at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$new$6(GtkApplication.java:173)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
        at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.<init>(GtkApplication.java:171)
        at javafx.graphics/com.sun.glass.ui.gtk.GtkPlatformFactory.createApplication(GtkPlatformFactory.java:41)
        at javafx.graphics/com.sun.glass.ui.Application.run(Application.java:144)
        at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:280)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:288)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:160)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:409)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
        ... 5 more

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command '/home/dinomite/.sdkman/candidates/java/21.2.0.r16-grl/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 3s
5 actionable tasks: 3 executed, 2 from cache
SR-Lut3t1um commented 2 years ago

Did you try to run the example in a Environment without a Window Manager?

dinomite commented 2 years ago

@SR-Lut3t1um Oh yes, and there error does seem to imply that's a problem. I can give this a try in a VM, or if you can make a reproduction that doesn't require graphics I'll get to it much more quickly.