如何为 Ceylon 生成 GraalVM 本机图像?
How to generate GraalVM native-image for Ceylon?
我尝试将 --static -jar
与 Ceylon 编译的 fat jar 一起使用:
native-image --static -jar default.jar
(default.jar
是ceylon fat-jar
生产的肥罐子。)
但是我得到一个 UnsupportedFeatureException
说 java.lang.Class.getConstantPool()
不受支持。
ceylon 程序只是一个简单的 hello world(打印出一个字符串)。
Ceylon 和 GraalVM 版本:
ceylon version 1.3.3 0d594b3 (Contents May Differ)
java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) GraalVM EE 1.0.0-rc13 (build 25.202-b08-jvmci-0.55, mixed mode)
完整错误日志:
Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Unsupported method java.lang.Class.getConstantPool() is reachable: The declaring class of this element has been substituted, but this element is not present in the substitution class
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.
Detailed message:
Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Unsupported method java.lang.Class.getConstantPool() is reachable: The declaring class of this element has been substituted, but this element is not present in the substitution class
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.
Trace:
at parsing java.lang.System.getConstantPool(System.java:1227)
Call path from entry point to java.lang.System.getConstantPool(Class):
at java.lang.System.getConstantPool(System.java:1227)
at java.lang.reflect.Method.getDefaultValue(Method.java:609)
at com.redhat.ceylon.model.loader.impl.reflect.mirror.ReflectionMethod.isDefault(ReflectionMethod.java:263)
at com.redhat.ceylon.model.loader.AbstractModelLoader.addMethod(AbstractModelLoader.java:3810)
at com.redhat.ceylon.model.loader.AbstractModelLoader.complete(AbstractModelLoader.java:3247)
at com.redhat.ceylon.model.loader.AbstractModelLoader.access00(AbstractModelLoader.java:103)
at com.redhat.ceylon.model.loader.AbstractModelLoader.run(AbstractModelLoader.java:2616)
at java.lang.Shutdown.runHooks(Shutdown.java:123)
at java.lang.Shutdown.sequence(Shutdown.java:167)
at java.lang.Shutdown.shutdown(Shutdown.java:234)
at com.oracle.svm.core.jdk.RuntimeSupport.shutdown(RuntimeSupport.java:181)
at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:177)
at com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(generated:0)
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Error: Processing image build request failed
至少对于 ceylon new hello-world
生成的简单“hello world”程序,添加 --report-unsupported-elements-at-runtime
选项(如错误消息所建议的)足以使程序 运行 :
$ ./com.example.helloworld-1.0.0
Hello, World!
我依稀记得不久前在 ceylon.formatter
上使用过它,我认为它当时也有效(即它不仅支持非常简单的程序),尽管我不回想一下它的表现是否比 运行 正常使用更好或更差。
我尝试将 --static -jar
与 Ceylon 编译的 fat jar 一起使用:
native-image --static -jar default.jar
(default.jar
是ceylon fat-jar
生产的肥罐子。)
但是我得到一个 UnsupportedFeatureException
说 java.lang.Class.getConstantPool()
不受支持。
ceylon 程序只是一个简单的 hello world(打印出一个字符串)。
Ceylon 和 GraalVM 版本:
ceylon version 1.3.3 0d594b3 (Contents May Differ)
java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) GraalVM EE 1.0.0-rc13 (build 25.202-b08-jvmci-0.55, mixed mode)
完整错误日志:
Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Unsupported method java.lang.Class.getConstantPool() is reachable: The declaring class of this element has been substituted, but this element is not present in the substitution class
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.
Detailed message:
Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Unsupported method java.lang.Class.getConstantPool() is reachable: The declaring class of this element has been substituted, but this element is not present in the substitution class
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.
Trace:
at parsing java.lang.System.getConstantPool(System.java:1227)
Call path from entry point to java.lang.System.getConstantPool(Class):
at java.lang.System.getConstantPool(System.java:1227)
at java.lang.reflect.Method.getDefaultValue(Method.java:609)
at com.redhat.ceylon.model.loader.impl.reflect.mirror.ReflectionMethod.isDefault(ReflectionMethod.java:263)
at com.redhat.ceylon.model.loader.AbstractModelLoader.addMethod(AbstractModelLoader.java:3810)
at com.redhat.ceylon.model.loader.AbstractModelLoader.complete(AbstractModelLoader.java:3247)
at com.redhat.ceylon.model.loader.AbstractModelLoader.access00(AbstractModelLoader.java:103)
at com.redhat.ceylon.model.loader.AbstractModelLoader.run(AbstractModelLoader.java:2616)
at java.lang.Shutdown.runHooks(Shutdown.java:123)
at java.lang.Shutdown.sequence(Shutdown.java:167)
at java.lang.Shutdown.shutdown(Shutdown.java:234)
at com.oracle.svm.core.jdk.RuntimeSupport.shutdown(RuntimeSupport.java:181)
at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:177)
at com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(generated:0)
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Error: Processing image build request failed
至少对于 ceylon new hello-world
生成的简单“hello world”程序,添加 --report-unsupported-elements-at-runtime
选项(如错误消息所建议的)足以使程序 运行 :
$ ./com.example.helloworld-1.0.0
Hello, World!
我依稀记得不久前在 ceylon.formatter
上使用过它,我认为它当时也有效(即它不仅支持非常简单的程序),尽管我不回想一下它的表现是否比 运行 正常使用更好或更差。