Closed
Description
An example which successfully compiles to native binaries from Scala 2.11 & 2.12 uber-jars cannot be compiled from Scala 2.13 uber-jar due some internal changes in Scala collection implementation.
Error output from the native-image tool is:
Error: Unsupported features in 5 methods
Detailed message:
Error: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved method during parsing: java.lang.Object[].clone(). To diagnose the issue you can use the --allow-incomplete-classpath option. The missing method is then reported at run time when it is accessed the first time.
Trace:
at parsing scala.collection.immutable.VectorPointer.gotoPosWritable1(Vector.scala:1243)
Call path from entry point to scala.collection.immutable.VectorPointer.gotoPosWritable1(int, int, int, Object[]):
at scala.collection.immutable.VectorPointer.gotoPosWritable1(Vector.scala:1242)
at scala.collection.immutable.VectorPointer.gotoPosWritable1$(Vector.scala:1241)
at scala.collection.immutable.VectorBuilder.addAll(Vector.scala:840)
at scala.collection.immutable.Vector$.from(Vector.scala:840)
at scala.collection.immutable.Vector$.from(Vector.scala:27)
at scala.collection.IterableFactory.apply(Factory.scala:104)
at scala.collection.IterableFactory.apply$(Factory.scala:104)
at scala.collection.immutable.List$.apply(List.scala:618)
at scala.collection.SeqFactory$Delegate.apply(Factory.scala:305)
at com.github.plokhotnyuk.jsoniter_scala.examples.Example01$.main(Example01.scala:18)
at com.github.plokhotnyuk.jsoniter_scala.examples.Example01.main(Example01.scala)
at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:147)
at com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(generated:0)
Error: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved method during parsing: java.lang.Object[][].clone(). To diagnose the issue you can use the --allow-incomplete-classpath option. The missing method is then reported at run time when it is accessed the first time.
Trace:
at parsing scala.collection.immutable.VectorPointer.stabilize(Vector.scala:1197)
Call path from entry point to scala.collection.immutable.VectorPointer.stabilize(int):
at scala.collection.immutable.VectorPointer.stabilize(Vector.scala:1163)
at scala.collection.immutable.VectorPointer.stabilize$(Vector.scala:1163)
at scala.collection.immutable.VectorBuilder.addAll(Vector.scala:840)
at scala.collection.immutable.Vector$.from(Vector.scala:840)
at scala.collection.immutable.Vector$.from(Vector.scala:27)
at scala.collection.IterableFactory.apply(Factory.scala:104)
at scala.collection.IterableFactory.apply$(Factory.scala:104)
at scala.collection.immutable.List$.apply(List.scala:618)
at scala.collection.SeqFactory$Delegate.apply(Factory.scala:305)
at com.github.plokhotnyuk.jsoniter_scala.examples.Example01$.main(Example01.scala:18)
at com.github.plokhotnyuk.jsoniter_scala.examples.Example01.main(Example01.scala)
at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:147)
at com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(generated:0)
Error: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported type java.lang.invoke.MemberName is reachable: All methods from java.lang.invoke should have been replaced during image building.
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.invoke.MethodHandles$Lookup.findVirtual(MethodHandles.java:861)
Call path from entry point to java.lang.invoke.MethodHandles$Lookup.findVirtual(Class, String, MethodType):
no path found from entry point to target method
Error: type is not available in this platform: com.oracle.svm.hosted.ClassValueFeature
Trace: object java.lang.Class[]
object java.lang.invoke.MethodType
object java.lang.invoke.MethodType$ConcurrentWeakInternSet$WeakEntry
object java.util.concurrent.ConcurrentHashMap$Node
object java.util.concurrent.ConcurrentHashMap$Node[]
object java.util.concurrent.ConcurrentHashMap
object java.lang.invoke.MethodType$ConcurrentWeakInternSet
method java.lang.invoke.MethodType.makeImpl(Class, Class[], boolean)
Call path from entry point to java.lang.invoke.MethodType.makeImpl(Class, Class[], boolean):
no path found from entry point to target method
Error: type is not available in this platform: com.oracle.svm.hosted.substitute.ComputedValueField
Trace: object java.lang.invoke.MethodType
object java.lang.invoke.MethodType$ConcurrentWeakInternSet$WeakEntry
object java.util.concurrent.ConcurrentHashMap$Node
object java.util.concurrent.ConcurrentHashMap$Node[]
object java.util.concurrent.ConcurrentHashMap
object java.lang.invoke.MethodType$ConcurrentWeakInternSet
method java.lang.invoke.MethodType.makeImpl(Class, Class[], boolean)
Call path from entry point to java.lang.invoke.MethodType.makeImpl(Class, Class[], boolean):
no path found from entry point to target method
Steps to reproduce:
- Install or make sure all those things are installed: Sbt, GraalVM CE/EE and its native-image tool
- Clone the following repo: https://github.com/plokhotnyuk/jsoniter-scala
- Checkout the
switch-examples-to-scala-2.13
branch - Run the following commands:
cd jsoniter-scala-examples
sbt clean +assembly
/usr/lib/jvm/graalvm-ce-19/bin/native-image --no-server --no-fallback -H:UnsafeAutomaticSubstitutionsLogLevel=3 -jar target/scala-2.13/jsoniter-scala-examples-assembly-0.1.0-SNAPSHOT.jar