graalvm/graalvm-demos

scala-examples: issue with building and running scala-native substitution demo

Opened this issue · 5 comments

On the back of the PR #93, building and running the scala-native substitution demo gives an issue after following the steps in the README were followed, see https://github.com/graalvm/graalvm-demos/tree/master/scala-examples/scalac-native#native-image-of-the-scala-compiler.

Running the step ./scalac-image.sh gives the below error:

root@b41b00dc8fec:/graalvm-demos/scala-examples/scalac-native# ./scalac-image.sh -H:+ReportExceptionStackTraces
[scalac:220]    classlist:  25,162.81 ms,  0.96 GB
Error: Main entry point class 'scala.tools.nsc.Main' not found.
com.oracle.svm.core.util.UserError$UserException: Main entry point class 'scala.tools.nsc.Main' not found.
	at com.oracle.svm.core.util.UserError.abort(UserError.java:68)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:323)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:543)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:119)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:573)
[scalac:220]      [total]:  25,444.44 ms,  0.96 GB
Error: Image build request failed with exit status 1

The original contributor to the example has been contacted and help has been sought to help fix this issue when running with the latest version of GraalVM CE.

A helped PR from @vjovanov #98, thanks

@vjovanov just merged your commit to the newly built image, and re-ran the above steps, I did take care of GRAALVM_HOME and JAVA_HOME to point to the right binaries (GraalVM 21.2.0 Java 11 and Java 8 respectively - this is correct?), but we are expecting this error, right?

./scalac-image.sh -H:+ReportExceptionStackTraces
[scalac:141]    classlist:  40,863.00 ms,  0.93 GB
Error: Main entry point class 'scala.tools.nsc.Main' not found.
com.oracle.svm.core.util.UserError$UserException: Main entry point class 'scala.tools.nsc.Main' not found.
	at com.oracle.svm.core.util.UserError.abort(UserError.java:68)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:323)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:543)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:119)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:573)
[scalac:141]      [total]:  41,248.44 ms,  0.93 GB
Error: Image build request failed with exit status 1

I'll debug further from here to see why this is still happening.

Does it need any specific build of Java 8 (OpenJDK 8 will do?)?

If you use GraalVM on Java 11 or 17, you would see this notice printed:
This demo works only with Java 8. Set your JAVA_HOME to a JDK 8 version.
I've merged the PR from
Vojin Jovanovic: #98:

I didn't see this notice This demo works only with Java 8. Set your JAVA_HOME to a JDK 8 version.

Also would be good to add this note to the README page of the demo :D

I'm reopening the issue. I’ve just tested on Java 8 GraalVM and it fails to compile scalac:

Error: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported method java.lang.invoke.MethodHandleNatives.setCallSiteTargetNormal(CallSite, MethodHandle) 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.