I tried use --static -jar
with Ceylon's compiled fat jar:
native-image --static -jar default.jar
(default.jar
is a fat jar produced by ceylon fat-jar
.)
But I got an UnsupportedFeatureException
saying java.lang.Class.getConstantPool()
is not supported.
The ceylon program is just a simple hello world (print out a string).
Ceylon and GraalVM version:
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)
Full error log:
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$2.getConstantPool(System.java:1227)
Call path from entry point to java.lang.System$2.getConstantPool(Class):
at java.lang.System$2.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.access$1100(AbstractModelLoader.java:103)
at com.redhat.ceylon.model.loader.AbstractModelLoader$18.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
At least for a simple “hello world” program generated by ceylon new hello-world
, adding the --report-unsupported-elements-at-runtime
option (as suggested by the error message) is enough to make the program run:
$ ./com.example.helloworld-1.0.0
Hello, World!
I dimly remember using this a while ago with ceylon.formatter
, and I think it also worked at the time (i. e. it doesn’t just support very simplistic programs), though I don’t recall if it performed better or worse than running it normally.