HumbleUI / Skija

Java bindings for Skia
Apache License 2.0
514 stars 34 forks source link

sun.misc.Cleaner class not found #36

Closed lambdaschmied2 closed 1 year ago

lambdaschmied2 commented 1 year ago

Exception in thread "main" java.lang.NoClassDefFoundError: sun.misc.Cleaner

I've been trying to get a HumbleUI app running as a native executable (GraalVM). When executing the uberjar (with aot), the mentioned error is thrown. (I followed this approach btw.: https://github.com/tonsky/uberdeps)

https://stackoverflow.com/questions/62815536/why-am-i-getting-the-error-noclassdeffounderror-sun-misc-unsafe-when-trying-t As stated in this post, it is one of the packages removed from Java 9 and can be fixed by adding requires jdk.unsupported; to module-info.java. I tried to test it locally but I wasn't able to properly integrate the local Skija build into the Clojure project.

Building the uberjar with Java 8 wouldn't work because other packages are compiled with Java 11.

tonsky commented 1 year ago

This is probably because uberdeps doesn’t know how to build multi-release jar. I’ll look into it

tonsky commented 1 year ago

Try building uberjar with --multi-release flag?

[~/ws/humbleui] clj -M:uberjar --aliases dev --multi-release
[uberdeps] Packaging target/humbleui.jar...
+ dev/**
+ test/**
+ src/**
! Duplicate entry ".DS_Store" from "src/**" already seen in "dev/**"
+ resources/**
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
+ criterium/criterium #:mvn{:version "0.4.6"}
+ io.github.humbleui/jwm #:mvn{:version "0.4.12"}
+ io.github.humbleui/skija-linux #:mvn{:version "0.109.0"}
.   io.github.humbleui/skija-shared #:mvn{:version "0.109.0"}
+ io.github.humbleui/skija-macos-arm64 #:mvn{:version "0.109.0"}
-   skipping duplicate lib io.github.humbleui/skija-shared #:mvn{:version 0.109.0}
+ io.github.humbleui/skija-macos-x64 #:mvn{:version "0.109.0"}
-   skipping duplicate lib io.github.humbleui/skija-shared #:mvn{:version 0.109.0}
+ io.github.humbleui/skija-windows #:mvn{:version "0.109.0"}
-   skipping duplicate lib io.github.humbleui/skija-shared #:mvn{:version 0.109.0}
+ io.github.humbleui/types$clojure #:mvn{:version "0.2.0"}
! Duplicate entry "META-INF/versions/9/module-info.class" from "io.github.humbleui/types$clojure #:mvn{:version "0.2.0"}" already seen in "io.github.humbleui/skija-shared #:mvn{:version "0.109.0"}"
+ nrepl/nrepl #:mvn{:version "1.0.0"}
+ org.clojure/clojure #:mvn{:version "1.11.1"}
.   org.clojure/core.specs.alpha #:mvn{:version "0.2.62"}
.   org.clojure/spec.alpha #:mvn{:version "0.3.218"}
+ org.clojure/tools.namespace #:mvn{:version "1.3.0"}
.   org.clojure/java.classpath #:mvn{:version "1.0.0"}
.   org.clojure/tools.reader #:mvn{:version "1.3.6"}
[uberdeps] Packaged target/humbleui.jar in 4286 ms
[~/ws/humbleui] java -cp target/humbleui.jar clojure.main -m user
nREPL server started on port 49228 on host localhost - nrepl://localhost:49228
tonsky commented 1 year ago

Uberdeps 1.2.0 should now also auto-detect multi-release jars and set the flag automatically. It’ll also remove all module-info.class from uberjar. Let me know if that works for you (I haven’t checked with Graal, but works on normal Java 18)

lambdaschmied2 commented 1 year ago

Works for me now as well. Thanks! GraalVM produces a new error - although it is related to JWM now. So this issue is all cleared up 👌🏼