Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.UnsatisfiedLinkError: no awt in java.library.path #3575

Closed
twolf2919 opened this issue Jul 12, 2021 · 7 comments
Closed

java.lang.UnsatisfiedLinkError: no awt in java.library.path #3575

twolf2919 opened this issue Jul 12, 2021 · 7 comments
Assignees

Comments

@twolf2919
Copy link

graalBug.jar.gz
graalBug.jar.gz
src.tar.gz
I created a native image of my Java swing application. But when I try to run the native image, I immediately get the error mentioned in the title. A previous issue, 2842 (#2842), described the same problem and was closed (as fixed?), but I tried both the currently released version 21.1.0 as well as the latest dev snapshot 21.3.0-dev and still get this error.

To reproduce the problem, simply try to create a native image from the attached jar file (see below for exact commands I used). I'm also including the source code (just 3 java files and an icon) in case you need that.

Specific versions of graal I tried:
graalvm-ce-java16-21.3.0-dev
graalvm-ce-java16-21.1.0
And compiled the source using the JDK (16) that came with these graal installs. This was done on macOS Monterey.

Below is the verbose output from running native_image and the exception that occur when I try to run the native image:

twolf@MacBook-Pro dist % native-image -H:+ReportExceptionStackTraces --no-fallback --allow-incomplete-classpath --native-image-info --verbose -jar graalBug.jar
Executing [
/Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/bin/java
-XX:+UseParallelGC
-XX:+UnlockExperimentalVMOptions
-XX:+EnableJVMCI
-Dtruffle.TrustAllTruffleRuntimeProviders=true
-Dtruffle.TruffleRuntime=com.oracle.truffle.api.impl.DefaultTruffleRuntime
-Dgraalvm.ForcePolyglotInvalid=true
-Dgraalvm.locatorDisabled=true
-Dsubstratevm.IgnoreGraalVersionCheck=true
--add-exports=java.base/jdk.internal.module=ALL-UNNAMED
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.aarch64=ALL-UNNAMED
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.amd64=ALL-UNNAMED
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.site=ALL-UNNAMED
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.stack=ALL-UNNAMED
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code=ALL-UNNAMED
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.common=ALL-UNNAMED
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.aarch64=ALL-UNNAMED
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.amd64=ALL-UNNAMED
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot=ALL-UNNAMED
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.meta=ALL-UNNAMED
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.runtime=ALL-UNNAMED
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.services=ALL-UNNAMED
--add-opens=jdk.internal.vm.compiler/org.graalvm.compiler.debug=ALL-UNNAMED
--add-opens=jdk.internal.vm.compiler/org.graalvm.compiler.nodes=ALL-UNNAMED
--add-opens=jdk.unsupported/sun.reflect=ALL-UNNAMED
--add-opens=java.base/jdk.internal.module=ALL-UNNAMED
--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED
--add-opens=java.base/jdk.internal.reflect=ALL-UNNAMED
--add-opens=java.base/java.io=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED
--add-opens=java.base/java.lang.ref=ALL-UNNAMED
--add-opens=java.base/java.net=ALL-UNNAMED
--add-opens=java.base/java.nio=ALL-UNNAMED
--add-opens=java.base/java.nio.file=ALL-UNNAMED
--add-opens=java.base/java.security=ALL-UNNAMED
--add-opens=java.base/javax.crypto=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED
--add-opens=java.base/sun.security.x509=ALL-UNNAMED
--add-opens=java.base/jdk.internal.logger=ALL-UNNAMED
--add-opens=org.graalvm.sdk/org.graalvm.nativeimage.impl=ALL-UNNAMED
--add-opens=org.graalvm.sdk/org.graalvm.polyglot=ALL-UNNAMED
--add-opens=org.graalvm.truffle/com.oracle.truffle.polyglot=ALL-UNNAMED
--add-opens=org.graalvm.truffle/com.oracle.truffle.api.impl=ALL-UNNAMED
--add-opens=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED
--add-opens=java.base/sun.util.locale.provider=ALL-UNNAMED
--add-opens=java.base/sun.util.resources=ALL-UNNAMED
--add-opens=java.base/sun.security.util=ALL-UNNAMED
--add-opens=java.base/sun.util.calendar=ALL-UNNAMED
--add-opens=java.base/sun.security.provider=ALL-UNNAMED
--add-opens=java.base/sun.security.jca=ALL-UNNAMED
--add-opens=java.base/sun.reflect.generics.repository=ALL-UNNAMED
--add-opens=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED
--add-opens=java.base/sun.reflect.generics.tree=ALL-UNNAMED
--add-opens=java.base/sun.reflect.annotation=ALL-UNNAMED
--add-opens=java.base/sun.invoke.util=ALL-UNNAMED
--add-opens=java.xml.crypto/org.jcp.xml.dsig.internal.dom=ALL-UNNAMED
-XX:+UseJVMCINativeLibrary
-Xss10m
-Xms1g
-Xmx14g
-Duser.country=US
-Duser.language=en
-Djava.awt.headless=true
-Dorg.graalvm.version=21.1.0
-Dorg.graalvm.config=CE
-Dcom.oracle.graalvm.isaot=true
-Djava.system.class.loader=com.oracle.svm.hosted.NativeImageSystemClassLoader
-Xshare:off
--module-path
/Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/truffle/truffle-api.jar
-Djdk.internal.lambda.disableEagerInitialization=true
-Djdk.internal.lambda.eagerlyInitialize=false
-Djava.lang.invoke.InnerClassLambdaMetafactory.initializeLambdas=false
-javaagent:/Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/builder/svm.jar
-cp
/Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/builder/llvm-wrapper-shadowed.jar:/Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/builder/svm.jar:/Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/builder/objectfile.jar:/Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/builder/llvm-platform-specific-shadowed.jar:/Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/builder/javacpp-shadowed.jar:/Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/builder/svm-llvm.jar:/Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/builder/pointsto.jar
'com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus'
-imagecp
/Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/library-support.jar:/Users/twolf/NetBeansProjects/graalBug/dist:/Users/twolf/NetBeansProjects/graalBug/dist/graalBug.jar
-H:Path=/Users/twolf/NetBeansProjects/graalBug/dist
-H:+ReportExceptionStackTraces
-H:FallbackThreshold=0
-H:+AllowIncompleteClasspath
-H:+DumpTargetInfo
'-H:Class@manifest from file:///Users/twolf/NetBeansProjects/graalBug/dist/graalBug.jar=com.spectare.gui.Startup'
'-H:Name@manifest from file:///Users/twolf/NetBeansProjects/graalBug/dist/graalBug.jar=graalBug'
-H:CLibraryPath=/Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/clibraries/darwin-amd64
]
[graalBug:24051] classlist: 554.74 ms, 0.96 GB
[graalBug:24051] (cap): 1,622.55 ms, 0.96 GB
[graalBug:24051] setup: 2,707.38 ms, 0.96 GB

Building image for target platform: org.graalvm.nativeimage.Platform$DARWIN_AMD64

Using native toolchain:

Name: LLVM (clang)

Vendor: apple

Version: 13.0.0

Target architecture: x86_64

Path: /usr/bin/cc

Using CLibrary: com.oracle.svm.core.c.libc.NoLibC

[graalBug:24051] (clinit): 379.60 ms, 1.73 GB

Static libraries:

../../../../../Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/clibraries/darwin-amd64/liblibchelper.a

../../../../../Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/static/darwin-amd64/libprefs.a

../../../../../Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/static/darwin-amd64/libnet.a

../../../../../Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/clibraries/darwin-amd64/libdarwin.a

../../../../../Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/static/darwin-amd64/libnio.a

../../../../../Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/static/darwin-amd64/libjava.a

../../../../../Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/static/darwin-amd64/libfdlibm.a

../../../../../Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/static/darwin-amd64/libzip.a

../../../../../Library/Java/JavaVirtualMachines/graalvm-ce-java16-21.1.0/Contents/Home/lib/svm/clibraries/darwin-amd64/libjvm.a

Other libraries: -framework Foundation,pthread,dl,z

[graalBug:24051] (typeflow): 5,489.06 ms, 1.73 GB
[graalBug:24051] (objects): 4,294.06 ms, 1.73 GB
[graalBug:24051] (features): 369.10 ms, 1.73 GB
[graalBug:24051] analysis: 10,810.42 ms, 1.73 GB
[graalBug:24051] universe: 559.96 ms, 1.73 GB
[graalBug:24051] (parse): 1,069.37 ms, 1.77 GB
[graalBug:24051] (inline): 1,367.76 ms, 2.43 GB
[graalBug:24051] (compile): 8,293.06 ms, 3.65 GB
[graalBug:24051] compile: 11,516.41 ms, 3.65 GB
[graalBug:24051] image: 1,655.90 ms, 3.65 GB
[graalBug:24051] write: 446.83 ms, 3.65 GB

Printing build artifacts to: graalBug.build_artifacts.txt

[graalBug:24051] [total]: 28,380.95 ms, 3.65 GB
twolf@MacBook-Pro dist % ./graalBug
Exception in thread "main" java.lang.UnsatisfiedLinkError: no awt in java.library.path
at com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryRelative(NativeLibrarySupport.java:132)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:47)
at java.lang.Runtime.loadLibrary0(Runtime.java:808)
at java.lang.System.loadLibrary(System.java:1893)
at java.awt.Toolkit$2.run(Toolkit.java:1385)
at java.awt.Toolkit$2.run(Toolkit.java:1383)
at java.security.AccessController.doPrivileged(AccessController.java:82)
at java.awt.Toolkit.loadLibraries(Toolkit.java:1382)
at java.awt.Toolkit.(Toolkit.java:1415)
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:375)
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:295)
at java.awt.EventQueue.invokeLater(EventQueue.java:1313)
at javax.swing.SwingUtilities.invokeLater(SwingUtilities.java:1420)
at com.spectare.gui.Startup.main(Startup.java:7)

@twolf2919
Copy link
Author

I don't know if this is useful - or even helpful, but I took the above jar file to my Ubuntu Virtual machine, installed graalvm 21.1.0 there and tried to create a native image in Linux. But in Linux it doesn't even get through the native_image creation:
$ native-image -H:+ReportExceptionStackTraces --no-fallback --allow-incomplete-classpath -jar graalBug.jar
[graalBug:49515] classlist: 1,700.56 ms, 0.96 GB
[graalBug:49515] (cap): 537.64 ms, 0.96 GB
[graalBug:49515] setup: 2,005.90 ms, 0.96 GB
[graalBug:49515] analysis: 24,362.15 ms, 2.21 GB
Fatal error:com.oracle.graal.pointsto.util.AnalysisError$ParsingError: Error encountered while parsing sun.awt.X11.XSelection.getTargets(long)
Parsing context:
parsing sun.awt.X11.XClipboard.getClipboardFormats(XClipboard.java:118)
parsing sun.awt.datatransfer.ClipboardTransferable.(ClipboardTransferable.java:80)
parsing sun.awt.X11.XClipboard.getContents(XClipboard.java:108)
parsing javax.swing.TransferHandler$TransferAction.actionPerformedImpl(TransferHandler.java:1752)
parsing javax.swing.TransferHandler$TransferAction$1.run(TransferHandler.java:1712)
parsing javax.swing.TransferHandler$TransferAction$1.run(TransferHandler.java:1710)
parsing com.oracle.svm.core.jdk.Target_java_security_AccessController.doPrivileged(SecuritySubstitutions.java:82)
parsing sun.awt.AppContext.getAppContext(AppContext.java:294)
parsing sun.awt.SunToolkit.getSystemEventQueueImplPP(SunToolkit.java:1055)
parsing sun.awt.HeadlessToolkit.getSystemEventQueueImpl(HeadlessToolkit.java:263)
parsing java.awt.Toolkit.getEventQueue(Toolkit.java:1484)
parsing java.awt.EventQueue.invokeLater(EventQueue.java:1313)
parsing javax.swing.SwingUtilities.invokeLater(SwingUtilities.java:1420)
parsing com.spectare.gui.Startup.main(Startup.java:7)
parsing com.oracle.svm.core.JavaMainWrapper.runCore(JavaMainWrapper.java:146)
parsing com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:182)
parsing com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(generated:0)

at com.oracle.graal.pointsto.util.AnalysisError.parsingError(AnalysisError.java:138)
at com.oracle.graal.pointsto.flow.MethodTypeFlow.createTypeFlow(MethodTypeFlow.java:327)
at com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureTypeFlowCreated(MethodTypeFlow.java:302)
at com.oracle.graal.pointsto.flow.MethodTypeFlow.addContext(MethodTypeFlow.java:103)
at com.oracle.graal.pointsto.DefaultAnalysisPolicy$DefaultSpecialInvokeTypeFlow.onObservedUpdate(DefaultAnalysisPolicy.java:368)
at com.oracle.graal.pointsto.flow.TypeFlow.notifyObservers(TypeFlow.java:470)
at com.oracle.graal.pointsto.flow.TypeFlow.update(TypeFlow.java:542)
at com.oracle.graal.pointsto.BigBang$2.run(BigBang.java:547)
at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:173)
at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1434)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:295)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)

Caused by: org.graalvm.compiler.java.BytecodeParser$BytecodeParserError: com.oracle.graal.pointsto.util.AnalysisError: parsing had failed in another thread
at parsing sun.awt.X11.XSelection.getTargets(XSelection.java:198)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.throwParserError(BytecodeParser.java:2601)
at com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.throwParserError(SharedGraphBuilderPhase.java:106)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3456)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3258)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:1125)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:1019)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:84)
at com.oracle.svm.hosted.phases.SharedGraphBuilderPhase.run(SharedGraphBuilderPhase.java:76)
at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.run(Phase.java:49)
at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:212)
at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:42)
at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:38)
at com.oracle.graal.pointsto.flow.AnalysisParsedGraph.parseBytecode(AnalysisParsedGraph.java:113)
at com.oracle.svm.hosted.SVMHost.parseBytecode(SVMHost.java:647)
at com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsed(AnalysisMethod.java:592)
at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:163)
at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:304)
at com.oracle.graal.pointsto.flow.MethodTypeFlow.createTypeFlow(MethodTypeFlow.java:313)
... 13 more
Caused by: com.oracle.graal.pointsto.util.AnalysisError: parsing had failed in another thread
at com.oracle.graal.pointsto.util.AnalysisError.shouldNotReachHere(AnalysisError.java:158)
at com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsed(AnalysisMethod.java:640)
at com.oracle.svm.hosted.fieldfolding.StaticFinalFieldFoldingNodePlugin.handleLoadStaticField(StaticFinalFieldFoldingFeature.java:349)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genGetStatic(BytecodeParser.java:4972)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genGetStatic(BytecodeParser.java:4939)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5442)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3451)
... 28 more
Caused by: org.graalvm.compiler.java.BytecodeParser$BytecodeParserError: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported type sun.awt.X11.XBaseWindow is reachable
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
at parsing sun.awt.X11.XSelection.(XSelection.java:107)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.throwParserError(BytecodeParser.java:2601)
at com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.throwParserError(SharedGraphBuilderPhase.java:106)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3456)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3258)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:1125)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:1019)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:84)
at com.oracle.svm.hosted.phases.SharedGraphBuilderPhase.run(SharedGraphBuilderPhase.java:76)
at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.run(Phase.java:49)
at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:212)
at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:42)
at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:38)
at com.oracle.graal.pointsto.flow.AnalysisParsedGraph.parseBytecode(AnalysisParsedGraph.java:113)
at com.oracle.svm.hosted.SVMHost.parseBytecode(SVMHost.java:647)
at com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsed(AnalysisMethod.java:592)
at com.oracle.svm.hosted.fieldfolding.StaticFinalFieldFoldingNodePlugin.handleLoadStaticField(StaticFinalFieldFoldingFeature.java:349)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genGetStatic(BytecodeParser.java:4972)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genGetStatic(BytecodeParser.java:4939)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5442)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3451)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3258)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:1125)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:1019)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:84)
at com.oracle.svm.hosted.phases.SharedGraphBuilderPhase.run(SharedGraphBuilderPhase.java:76)
at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.run(Phase.java:49)
at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:212)
at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:42)
at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:38)
at com.oracle.graal.pointsto.flow.AnalysisParsedGraph.parseBytecode(AnalysisParsedGraph.java:113)
at com.oracle.svm.hosted.SVMHost.parseBytecode(SVMHost.java:647)
at com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsed(AnalysisMethod.java:592)
at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:163)
at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:304)
at com.oracle.graal.pointsto.flow.MethodTypeFlow.createTypeFlow(MethodTypeFlow.java:313)
at com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureTypeFlowCreated(MethodTypeFlow.java:302)
at com.oracle.graal.pointsto.flow.MethodTypeFlow.addContext(MethodTypeFlow.java:103)
at com.oracle.graal.pointsto.DefaultAnalysisPolicy$DefaultSpecialInvokeTypeFlow.onObservedUpdate(DefaultAnalysisPolicy.java:368)
at com.oracle.graal.pointsto.flow.TypeFlow.notifyObservers(TypeFlow.java:470)
at com.oracle.graal.pointsto.flow.TypeFlow.update(TypeFlow.java:542)
at com.oracle.graal.pointsto.flow.SourceTypeFlowBase.update(SourceTypeFlowBase.java:144)
... 8 more
Caused by: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported type sun.awt.X11.XBaseWindow is reachable
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.lookup(AnnotationSubstitutionProcessor.java:120)
at com.oracle.graal.pointsto.infrastructure.SubstitutionProcessor$ChainedSubstitutionProcessor.lookup(SubstitutionProcessor.java:125)
at com.oracle.graal.pointsto.infrastructure.SubstitutionProcessor$ChainedSubstitutionProcessor.lookup(SubstitutionProcessor.java:125)
at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookupAllowUnresolved(AnalysisUniverse.java:207)
at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookup(AnalysisUniverse.java:187)
at com.oracle.graal.pointsto.meta.AnalysisMethod.(AnalysisMethod.java:111)
at com.oracle.graal.pointsto.meta.AnalysisUniverse.createMethod(AnalysisUniverse.java:424)
at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookupAllowUnresolved(AnalysisUniverse.java:412)
at com.oracle.graal.pointsto.infrastructure.WrappedConstantPool.lookupMethod(WrappedConstantPool.java:125)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.lookupMethodInPool(BytecodeParser.java:4369)
at com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.lookupMethodInPool(SharedGraphBuilderPhase.java:119)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.lookupMethod(BytecodeParser.java:4363)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genInvokeStatic(BytecodeParser.java:1648)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5448)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3451)
... 46 more
Error: Image build request failed with exit status 1
$ cd
$

@pquiring
Copy link

pquiring commented Jul 13, 2021

I would try JDK11 and latest dev build, I've had better success with that.
Also make sure to copy $JAVA_HOME/lib/*font* to the apps folder.

@fernando-valdez fernando-valdez self-assigned this Jul 14, 2021
@fernando-valdez
Copy link
Member

Hi @twolf2919, I am taking care of this issue.
If I have a question I will let you know.

@chirontt
Copy link

chirontt commented Jul 18, 2021

@twolf2919,
Like @pquiring said, I've tried GraalVM 21.1 for JDK11 with the above src.tar.gz, in both Windows and Ubuntu, and I have no problem producing a native executable in either platforms, and they both work fine too. I have no access to a Mac to help you with, but here are some crucial points to make it work in Windows and Ubuntu:

  • you must run your Swing app first with the native-image-agent, to produce some native-image configuration files to help with the native-image command later. These resultant config files should be packaged in your graalBug.jar, in the META-INF/native-image folder. Most of the above errors were due to these missing config files.
  • for building in Linux platform, such as Ubuntu, the native-image command must be invoked with the following system property: -Djava.awt.headless=false for a successful build, i.e.

$ native-image -Djava.awt.headless=false -jar graalBug.jar

The above property will force the native-image command to link with proper system library (libawt_xawt.a, instead of libawt_headless.a) to make a successful native executable for any Swing app.

Hope the above can be applied to your Mac platform.

FYI, I have compiled the SwingSet3 sample app to native image successfully in both Windows and Ubuntu, in my repo here.

@twolf2919
Copy link
Author

@chirontt - i’m sorry, but I must’ve missed the instructions about running native-image-agent when I followed the instructions. I have no idea about that command. Can you point me to instructions on how to accomplish that first bullet?

@fernando-valdez
Copy link
Member

Thanks for your notes @chirontt!

@twolf2919, you can find more information on the native-image agent on the documentation page:
https://docs.oracle.com/en/graalvm/enterprise/21/docs/reference-manual/native-image/BuildConfiguration/

I was able to build and run the native image. Please follow the instructions on the page, and if you have any problems, please reopen this ticket.

@ShanGor
Copy link

ShanGor commented Nov 24, 2022

You can manually copied some small files of the JAVA_HOME\lib to solve the problem in windows. And run with -Djava.home=.
Ref to https://jianshu.com/p/a53ae350f845?v=1669292961020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants