HanSolo / jdktools

JDKTools is a library that contains tools related to system info and versioning
7 stars 0 forks source link

Custom Java Runtime with Jlink fails #2

Open aalmiray opened 2 years ago

aalmiray commented 2 years ago

If this library (currently 17.0.4) is added as a dependency, a custom JR generated with Jlink is created, results in a JNI error such as

discocli-standalone-17.0.4-SNAPSHOT-osx-x86_64/bin/discocli 
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.InternalError: Module eu.hansolo.discocli not in boot Layer
    at java.base/sun.launcher.LauncherHelper.loadModuleMainClass(Unknown Source)
    at java.base/sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

The JR contains all modules as far as I can see

discocli-standalone-17.0.4-SNAPSHOT-osx-x86_64/bin/java --list-modules
com.google.gson@2.9.0
eu.hansolo.discocli
eu.hansolo.jdktools
info.picocli
java.base@17.0.1
java.logging@17.0.1
java.naming@17.0.1
java.net.http@17.0.1
java.security.jgss@17.0.1
java.security.sasl@17.0.1
jdk.crypto.cryptoki@17.0.1
jdk.crypto.ec@17.0.1
jdk.security.jgss@17.0.1

The JR was created with

zulu17.30.15-ca-jdk17.0.1-macosx_x64/zulu-17.jdk/Contents/Home/bin/jlink \
--no-header-files --no-man-pages --compress=2 --strip-debug \
--module-path inputs/jars/universal \
--add-modules com.google.gson,eu.hansolo.discocli,eu.hansolo.jdktools,info.picocli,java.base,java.net.http,java.security.jgss,java.security.sasl,jdk.crypto.cryptoki,jdk.crypto.ec,jdk.security.jgss \
--launcher discocli=eu.hansolo.discocli/eu.hansolo.discocli.DiscoCLI --output discocli-standalone-17.0.4-SNAPSHOT-osx-x86_64
/inputs/jars/universal
├── discocli-17.0.4-SNAPSHOT.jar
├── gson-2.9.0.jar
├── jdktools-17.0.4.jar
└── picocli-4.6.3.jar