Open flben233 opened 2 months ago
Hi flben233, thanks for reaching out to us.
Could you please specify the exact versions of GraalVM that you are using? You can check by running the java --version
command.
Also could you please provide a reproducer to your issue alongside the steps needed to reproduce it?
Thank you.
Java Version GraalVM 21:
java 21.0.1 2023-10-17
Java(TM) SE Runtime Environment Oracle GraalVM 21.0.1+12.1 (build 21.0.1+12-jvmci-23.1-b19)
Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 21.0.1+12.1 (build 21.0.1+12-jvmci-23.1-b19, mixed mode, sharing)
GraalVM 24:
openjdk 24 2025-03-18
OpenJDK Runtime Environment GraalVM CE 24-dev+4.1 (build 24+4-jvmci-b01)
OpenJDK 64-Bit Server VM GraalVM CE 24-dev+4.1 (build 24+4-jvmci-b01, mixed mode, sharing)
Steps to reproduce
Commands (I ran them in x64 Native Tools Command Prompt for VS 2022
in the project root):
.\gradlew -Pagent run
.\gradlew metadataCopy --task run --dir src\main\resources\META-INF\native-image
.\gradlew nativeBuild
.\build\native\TyuShare.exe # run output exe
@flben233 Thank you for sharing the reproducer, I'm afraid I cannot reproduce the issue with the provided steps.
Please create a native image bundle of your application and share it with us, you can find details on how to generate bundles in here: https://www.graalvm.org/latest/reference-manual/native-image/overview/Bundles/
@oubidar-Abderrahim When I tried to create bundle, it told me:
Error: Failed to read bundle launcher resources '\com\oracle\svm\driver\launcher'
Caused by: java.lang.NullPointerException"
I also tried graalvm-community-openjdk-22.0.2+9.1
and I got the same output.
My graal configuration in build.gradle.kts is:
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}
graalvmNative {
toolchainDetection.set(false)
binaries{
named("main"){
mainClass.set("MainKt")
imageName.set("TyuShare")
buildArgs("-O4", "--bundle-create")
}
}
agent{
metadataCopy {
mergeWithExisting.set(true)
}
}
}
Full output:
D:\IdeaProjects\TyuShare>.\gradlew nativeCompile
> Task :nativeCompile FAILED
[native-image-plugin] GraalVM Toolchain detection is disabled
[native-image-plugin] GraalVM location read from environment variable: JAVA_HOME
[native-image-plugin] Native Image executable path: D:\Env\graalvm-jdk-21.0.1+12.1\bin\native-image.cmd
Error: Failed to read bundle launcher resources '\com\oracle\svm\driver\launcher'
Caused by: java.lang.NullPointerException
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':nativeCompile'.
> Process 'command 'D:\Env\graalvm-jdk-21.0.1+12.1\bin\native-image.cmd'' finished with non-zero exit value 20
* 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.
BUILD FAILED in 4s
9 actionable tasks: 1 executed, 8 up-to-date
Thank you for providing this information.
Do you manage to build your project when using the latest GraalVM ce build? You can find it using this link: https://github.com/graalvm/graalvm-ce-builds/releases
If not, could you please share the error you encounter? Otherwise you can share with us the error you see when trying to run the executable using the latest GraalVM ce build from the provided link.
Thank you.
I got the same error with the latest GraalVM CE: Version:
D:\IdeaProjects\TyuShare>java --version
openjdk 22.0.2 2024-07-16
OpenJDK Runtime Environment GraalVM CE 22.0.2+9.1 (build 22.0.2+9-jvmci-b01)
OpenJDK 64-Bit Server VM GraalVM CE 22.0.2+9.1 (build 22.0.2+9-jvmci-b01, mixed mode, sharing)
Output:
D:\IdeaProjects\TyuShare>.\build\native\nativeCompile\TyuShare.exe
java.lang.Error: no ComponentUI class for: javax.swing.JRootPane[,0,0,0x0,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=1,maximumSize=,minimumSize=,preferredSize=]
at java.desktop@22.0.2/javax.swing.UIDefaults.getUIError(UIDefaults.java:763)
at java.desktop@22.0.2/javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:144)
at java.desktop@22.0.2/javax.swing.UIDefaults.getUI(UIDefaults.java:793)
at java.desktop@22.0.2/javax.swing.UIManager.getUI(UIManager.java:1070)
at java.desktop@22.0.2/javax.swing.JRootPane.updateUI(JRootPane.java:447)
at java.desktop@22.0.2/javax.swing.JRootPane.<init>(JRootPane.java:341)
at java.desktop@22.0.2/javax.swing.JFrame.createRootPane(JFrame.java:279)
at java.desktop@22.0.2/javax.swing.JFrame.frameInit(JFrame.java:258)
at java.desktop@22.0.2/javax.swing.JFrame.<init>(JFrame.java:205)
at androidx.compose.ui.awt.ComposeWindow.<init>(ComposeWindow.desktop.kt:53)
at androidx.compose.ui.awt.ComposeWindow.<init>(ComposeWindow.desktop.kt:63)
at androidx.compose.ui.window.Window_desktopKt$Window$3.invoke(Window.desktop.kt:182)
at androidx.compose.ui.window.Window_desktopKt$Window$3.invoke(Window.desktop.kt:176)
at androidx.compose.ui.window.Window_desktopKt$Window$10.invoke(Window.desktop.kt:409)
at androidx.compose.ui.window.Window_desktopKt$Window$10.invoke(Window.desktop.kt:406)
at androidx.compose.ui.window.AwtWindow_desktopKt$AwtWindow$2.invoke(AwtWindow.desktop.kt:70)
at androidx.compose.ui.window.AwtWindow_desktopKt$AwtWindow$2.invoke(AwtWindow.desktop.kt:69)
at androidx.compose.runtime.DisposableEffectImpl.onRemembered(Effects.kt:82)
at androidx.compose.runtime.CompositionImpl$RememberEventDispatcher.dispatchRememberObservers(Composition.kt:1295)
at androidx.compose.runtime.CompositionImpl.applyChangesInLocked(Composition.kt:984)
at androidx.compose.runtime.CompositionImpl.applyChanges(Composition.kt:1005)
at androidx.compose.runtime.Recomposer.composeInitial$runtime(Recomposer.kt:1099)
at androidx.compose.runtime.CompositionImpl.composeInitial(Composition.kt:633)
at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:619)
at androidx.compose.ui.window.Application_desktopKt$awaitApplication$2$1$2.invokeSuspend(Application.desktop.kt:221)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
at java.desktop@22.0.2/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
at java.desktop@22.0.2/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
at java.desktop@22.0.2/java.awt.EventQueue$4.run(EventQueue.java:720)
at java.desktop@22.0.2/java.awt.EventQueue$4.run(EventQueue.java:714)
at java.base@22.0.2/java.security.AccessController.executePrivileged(AccessController.java:128)
at java.base@22.0.2/java.security.AccessController.doPrivileged(AccessController.java:400)
at java.base@22.0.2/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.desktop@22.0.2/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop@22.0.2/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:853)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:829)
Cannot open (null)\bin\jawt.dll
In fact, I searched for Cannot open (null)\bin\jawt.dll
and find a solution, which is specifying -Djava.home=$JAVA_HOME
so that program can find the jawt.dll
(Refer to #3084). It ran properly but java.lang.Error: no ComponentUI class for: javax.swing.JRootPane
still existed.
The output is:
D:\IdeaProjects\TyuShare>.\build\native\nativeCompile\TyuShare.exe -Djava.home=D:\Env\graalvm-community-openjdk-22.0.2+9.1
java.lang.Error: no ComponentUI class for: javax.swing.JRootPane[,0,0,0x0,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=1,maximumSize=,minimumSize=,preferredSize=]
at java.desktop@22.0.2/javax.swing.UIDefaults.getUIError(UIDefaults.java:763)
at java.desktop@22.0.2/javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:144)
at java.desktop@22.0.2/javax.swing.UIDefaults.getUI(UIDefaults.java:793)
at java.desktop@22.0.2/javax.swing.UIManager.getUI(UIManager.java:1070)
at java.desktop@22.0.2/javax.swing.JRootPane.updateUI(JRootPane.java:447)
at java.desktop@22.0.2/javax.swing.JRootPane.<init>(JRootPane.java:341)
at java.desktop@22.0.2/javax.swing.JFrame.createRootPane(JFrame.java:279)
at java.desktop@22.0.2/javax.swing.JFrame.frameInit(JFrame.java:258)
at java.desktop@22.0.2/javax.swing.JFrame.<init>(JFrame.java:205)
at androidx.compose.ui.awt.ComposeWindow.<init>(ComposeWindow.desktop.kt:53)
at androidx.compose.ui.awt.ComposeWindow.<init>(ComposeWindow.desktop.kt:63)
at androidx.compose.ui.window.Window_desktopKt$Window$3.invoke(Window.desktop.kt:182)
at androidx.compose.ui.window.Window_desktopKt$Window$3.invoke(Window.desktop.kt:176)
at androidx.compose.ui.window.Window_desktopKt$Window$10.invoke(Window.desktop.kt:409)
at androidx.compose.ui.window.Window_desktopKt$Window$10.invoke(Window.desktop.kt:406)
at androidx.compose.ui.window.AwtWindow_desktopKt$AwtWindow$2.invoke(AwtWindow.desktop.kt:70)
at androidx.compose.ui.window.AwtWindow_desktopKt$AwtWindow$2.invoke(AwtWindow.desktop.kt:69)
at androidx.compose.runtime.DisposableEffectImpl.onRemembered(Effects.kt:82)
at androidx.compose.runtime.CompositionImpl$RememberEventDispatcher.dispatchRememberObservers(Composition.kt:1295)
at androidx.compose.runtime.CompositionImpl.applyChangesInLocked(Composition.kt:984)
at androidx.compose.runtime.CompositionImpl.applyChanges(Composition.kt:1005)
at androidx.compose.runtime.Recomposer.composeInitial$runtime(Recomposer.kt:1099)
at androidx.compose.runtime.CompositionImpl.composeInitial(Composition.kt:633)
at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:619)
at androidx.compose.ui.window.Application_desktopKt$awaitApplication$2$1$2.invokeSuspend(Application.desktop.kt:221)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
at java.desktop@22.0.2/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
at java.desktop@22.0.2/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
at java.desktop@22.0.2/java.awt.EventQueue$4.run(EventQueue.java:720)
at java.desktop@22.0.2/java.awt.EventQueue$4.run(EventQueue.java:714)
at java.base@22.0.2/java.security.AccessController.executePrivileged(AccessController.java:128)
at java.base@22.0.2/java.security.AccessController.doPrivileged(AccessController.java:400)
at java.base@22.0.2/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.desktop@22.0.2/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop@22.0.2/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:853)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:829)
SLF4J(W): No SLF4J providers were found.
SLF4J(W): Defaulting to no-operation (NOP) logger implementation
SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details.
Aug 13, 2024 8:00:08 PM com.sun.jna.Native <clinit>
WARNING: Failed to get charset for native.encoding value : 'GBK'
java.nio.charset.UnsupportedCharsetException: GBK
at java.base@22.0.2/java.nio.charset.Charset.forName(Charset.java:559)
at com.sun.jna.Native.<clinit>(Native.java:133)
at com.sun.jna.Structure.setAlignType(Structure.java:291)
at com.sun.jna.Structure.<init>(Structure.java:208)
at com.sun.jna.Structure.<init>(Structure.java:204)
at com.sun.jna.Structure.<init>(Structure.java:191)
at com.sun.jna.Structure.<init>(Structure.java:183)
at com.sun.jna.platform.win32.WinNT$OSVERSIONINFOEX.<init>(WinNT.java:1980)
at com.sun.jna.platform.win32.VersionHelpers.IsWindowsVersionOrGreater(VersionHelpers.java:59)
at com.sun.jna.platform.win32.VersionHelpers.IsWindows8OrGreater(VersionHelpers.java:170)
at oshi.hardware.platform.windows.WindowsCentralProcessor.<clinit>(WindowsCentralProcessor.java:73)
at oshi.hardware.platform.windows.WindowsHardwareAbstractionLayer.createProcessor(WindowsHardwareAbstractionLayer.java:42)
at oshi.util.Memoizer$1.get(Memoizer.java:61)
at oshi.hardware.common.AbstractHardwareAbstractionLayer.getProcessor(AbstractHardwareAbstractionLayer.java:48)
at util.HardwareUtil.<init>(HardwareUtil.kt:8)
at util.HardwareUtil.<init>(HardwareUtil.kt)
at util.HardwareUtil$Default.<init>(HardwareUtil.kt:6)
at util.HardwareUtil$Default.<init>(HardwareUtil.kt)
at util.HardwareUtil.<clinit>(HardwareUtil.kt)
at view.ConnectViewKt$ConnectView$1$1.invokeSuspend(ConnectView.kt:61)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
at androidx.compose.ui.platform.FlushCoroutineDispatcher$flush$1.invoke(FlushCoroutineDispatcher.skiko.kt:90)
at androidx.compose.ui.platform.FlushCoroutineDispatcher$flush$1.invoke(FlushCoroutineDispatcher.skiko.kt:78)
at androidx.compose.ui.platform.FlushCoroutineDispatcher.performRun(FlushCoroutineDispatcher.skiko.kt:99)
at androidx.compose.ui.platform.FlushCoroutineDispatcher.flush(FlushCoroutineDispatcher.skiko.kt:78)
at androidx.compose.ui.scene.ComposeSceneRecomposer.performScheduledEffects(ComposeSceneRecomposer.skiko.kt:91)
at androidx.compose.ui.scene.BaseComposeScene.render(BaseComposeScene.skiko.kt:157)
at androidx.compose.ui.scene.ComposeSceneMediator.onRender(ComposeSceneMediator.desktop.kt:537)
at org.jetbrains.skiko.SkiaLayer.update$skiko(SkiaLayer.awt.kt:485)
at org.jetbrains.skiko.redrawer.AWTRedrawer.update(AWTRedrawer.kt:54)
at org.jetbrains.skiko.redrawer.Direct3DRedrawer.redrawImmediately(Direct3DRedrawer.kt:74)
at org.jetbrains.skiko.SkiaLayer.paint(SkiaLayer.awt.kt:325)
at androidx.compose.ui.scene.skia.WindowSkiaLayerComponent$contentComponent$1.paint(WindowSkiaLayerComponent.desktop.kt:54)
at java.desktop@22.0.2/javax.swing.JComponent.paintChildren(JComponent.java:961)
at java.desktop@22.0.2/javax.swing.JComponent.paint(JComponent.java:1137)
at java.desktop@22.0.2/javax.swing.JLayeredPane.paint(JLayeredPane.java:586)
at java.desktop@22.0.2/javax.swing.JComponent.paintChildren(JComponent.java:961)
at java.desktop@22.0.2/javax.swing.JComponent.paint(JComponent.java:1137)
at androidx.compose.ui.window.Window_desktopKt$Window$12$1.invoke(Window.desktop.kt:434)
at androidx.compose.ui.window.Window_desktopKt$Window$12$1.invoke(Window.desktop.kt:419)
at androidx.compose.ui.window.AwtWindow_desktopKt$AwtWindow$3.invoke(AwtWindow.desktop.kt:78)
at androidx.compose.ui.window.AwtWindow_desktopKt$AwtWindow$3.invoke(AwtWindow.desktop.kt:76)
at androidx.compose.ui.util.UpdateEffect_desktopKt$UpdateEffect$2$performUpdate$1.invoke(UpdateEffect.desktop.kt:59)
at androidx.compose.ui.util.UpdateEffect_desktopKt$UpdateEffect$2$performUpdate$1.invoke(UpdateEffect.desktop.kt:55)
at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2304)
at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:504)
at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:260)
at androidx.compose.ui.util.UpdateEffect_desktopKt$UpdateEffect$2.invoke$performUpdate(UpdateEffect.desktop.kt:55)
at androidx.compose.ui.util.UpdateEffect_desktopKt$UpdateEffect$2.invoke(UpdateEffect.desktop.kt:64)
at androidx.compose.ui.util.UpdateEffect_desktopKt$UpdateEffect$2.invoke(UpdateEffect.desktop.kt:47)
at androidx.compose.runtime.DisposableEffectImpl.onRemembered(Effects.kt:82)
at androidx.compose.runtime.CompositionImpl$RememberEventDispatcher.dispatchRememberObservers(Composition.kt:1295)
at androidx.compose.runtime.CompositionImpl.applyChangesInLocked(Composition.kt:984)
at androidx.compose.runtime.CompositionImpl.applyChanges(Composition.kt:1005)
at androidx.compose.runtime.Recomposer.composeInitial$runtime(Recomposer.kt:1099)
at androidx.compose.runtime.CompositionImpl.composeInitial(Composition.kt:633)
at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:619)
at androidx.compose.ui.window.Application_desktopKt$awaitApplication$2$1$2.invokeSuspend(Application.desktop.kt:221)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
at java.desktop@22.0.2/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
at java.desktop@22.0.2/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
at java.desktop@22.0.2/java.awt.EventQueue$4.run(EventQueue.java:720)
at java.desktop@22.0.2/java.awt.EventQueue$4.run(EventQueue.java:714)
at java.base@22.0.2/java.security.AccessController.executePrivileged(AccessController.java:128)
at java.base@22.0.2/java.security.AccessController.doPrivileged(AccessController.java:400)
at java.base@22.0.2/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.desktop@22.0.2/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop@22.0.2/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:853)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:829)
Hi @flben233,
Thank you for providing that information. Unfortunately I am unable to reproduce the issue either. Could you perhaps share a simpler reproducer that we can use please?
Thank you.
@selhagani Minimized code:
fun main() {
// I place jawt.dll in <Program Root>/bin to avoid the error caused by AWT
if (System.getProperty("java.home") == null) {
System.setProperty("java.home", ".")
}
application {
val state = rememberWindowState(placement = WindowPlacement.Floating)
Window(
undecorated = true,
onCloseRequest = {},
state = state,
transparent = true
) {
Surface(
modifier = Modifier.padding(10.dp).size(400.dp, 600.dp),
color = MaterialTheme.colorScheme.background,
) {}
}
}
}
Compose Multiplatform Version: 1.6.11
Unfortunately, I’m still unable to reproduce the issue on my end. Could you kindly provide the exact steps you take with the simpler reproducer so I can better understand how the problem occurs?
Describe the issue My project is a desktop application and it uses compose multiplatform library. As it was built to native image and I ran it, it showed me the error below and the application exited. I think it might cause by AWT and graal.
PS: GraalVM Community 24+4-jvmci-b01 cannot finish native compile.
Environment
More details
GraalVM 21 (While running the native image):
GraalVM 24: