Open
Description
This was reported originally as sbt/sbt#5756
reproduction steps
using Scala 2.12.12:
val s = "foo"
val xs = s.getBytes("UTF-8") ++ System.lineSeparator.getBytes("UTF-8")
(actual code looks like https://github.com/sbt/sbt/blob/8ce423b088b85bb3016cfb994791c3536f7b627e/internal/util-logging/src/main/scala/sbt/internal/util/Terminal.scala#L384-L391)
Then build GraalVM native image.
problem
See https://ci.appveyor.com/project/sbt/sbt/builds/34671063/job/qveplsfqy7wyby3m
Error: Unsupported features in 2 methods
Detailed message:
Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Invoke with MethodHandle argument could not be reduced to at most a single call or single field access. The method handle must be a compile time constant, e.g., be loaded from a `static final` field. Method that contains the method handle invocation: java.lang.invoke.MethodHandle.invokeBasic()
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The error is then reported at run time when the invoke is executed.
Trace:
at parsing java.lang.invoke.LambdaForm$MH/1971838936.invoke_MT(LambdaForm$MH)
Call path from entry point to java.lang.invoke.LambdaForm$MH/1971838936.invoke_MT(Object, Object):
at java.lang.invoke.LambdaForm$MH/1971838936.invoke_MT(LambdaForm$MH)
at scala.collection.immutable.VM.releaseFence(VM.java:25)
at scala.collection.immutable.HashSet$HashSetBuilder.result(HashSet.scala:1283)
at scala.collection.immutable.HashSet$HashSetBuilder.result(HashSet.scala:1192)
at scala.collection.TraversableLike.defaultPlusPlus$1(TraversableLike.scala:153)
at scala.collection.TraversableLike.$plus$plus(TraversableLike.scala:160)
at scala.collection.TraversableLike.$plus$plus$(TraversableLike.scala:147)
at scala.collection.mutable.ArrayOps$ofByte.$plus$plus(ArrayOps.scala:210)
at sbt.internal.util.Terminal$LinePrintStream.println(Terminal.scala:388)
at com.oracle.svm.jni.functions.JNIFunctions.ExceptionDescribe(JNIFunctions.java:759)
at com.oracle.svm.core.code.IsolateEnterStub.JNIFunctions_ExceptionDescribe_b5412f7570bccae90b000bc37855f00408b2ad73(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
com.oracle.svm.core.util.UserError$UserException: Unsupported features in 2 methods
Detailed message:
Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Invoke with MethodHandle argument could not be reduced to at most a single call or single field access. The method handle must be a compile time constant, e.g., be loaded from a `static final` field. Method that contains the method handle invocation: java.lang.invoke.MethodHandle.invokeBasic()
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The error is then reported at run time when the invoke is executed.
Trace:
at parsing java.lang.invoke.LambdaForm$MH/1971838936.invoke_MT(LambdaForm$MH)
Call path from entry point to java.lang.invoke.LambdaForm$MH/1971838936.invoke_MT(Object, Object):
at java.lang.invoke.LambdaForm$MH/1971838936.invoke_MT(LambdaForm$MH)
at scala.collection.immutable.VM.releaseFence(VM.java:25)
at scala.collection.immutable.HashSet$HashSetBuilder.result(HashSet.scala:1283)
at scala.collection.immutable.HashSet$HashSetBuilder.result(HashSet.scala:1192)
at scala.collection.TraversableLike.defaultPlusPlus$1(TraversableLike.scala:153)
at scala.collection.TraversableLike.$plus$plus(TraversableLike.scala:160)
at scala.collection.TraversableLike.$plus$plus$(TraversableLike.scala:147)
at scala.collection.mutable.ArrayOps$ofByte.$plus$plus(ArrayOps.scala:210)
at sbt.internal.util.Terminal$LinePrintStream.println(Terminal.scala:388)
at com.oracle.svm.jni.functions.JNIFunctions.ExceptionDescribe(JNIFunctions.java:759)
at com.oracle.svm.core.code.IsolateEnterStub.JNIFunctions_ExceptionDescribe_b5412f7570bccae90b000bc37855f00408b2ad73(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
at com.oracle.svm.core.util.UserError.abort(UserError.java:79)
at com.oracle.svm.hosted.FallbackFeature.reportAsFallback(FallbackFeature.java:217)
at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:753)
at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:538)
at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:451)
at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
expectation
I can continue to build GraalVM native image?
note
The last call on the stack is scala.collection.immutable.HashSet.HashSetBuilder.result
: https://github.com/scala/scala/blob/v2.12.12/src/library/scala/collection/immutable/HashSet.scala#L1281-L1285
override def result(): HashSet[A] = {
rootNode = nullToEmpty(makeImmutable(rootNode))
VM.releaseFence()
rootNode
}
VM.releaseFence()
was added in scala/scala#8722.