native-image usage with NativePRNG secure random algorithm
Leonardo Loch Zanivan
pangalz at gmail.com
Tue Dec 5 15:32:53 UTC 2017
Native image compilation doesn't work when using NativePRNG secure random
algorithm (enabled by default on Linux/MacOS), causing a simple
UUID.randomUUID fail.
Note: Disabling NativePRNG in java.security file from GraalVM folder works.
HelloWorld class:
import java.util.UUID;
public class HelloWorld {
public static void main(String[] args) {
System.out.println(*UUID.randomUUID().toString()*);
}
}
*$ native-image -verbose HelloWorld*
Executing [
/Downloads/graalvm-0.30/Contents/Home/jre/bin/java \
-server \
-XX:+UnlockExperimentalVMOptions \
-XX:+EnableJVMCI \
-XX:-UseJVMCIClassLoader \
-XX:+UseJVMCICompiler \
-Dgraal.CompileGraalWithC1Only=false \
-d64 \
-noverify \
-Xbootclasspath/a:/Downloads/graalvm-0.30/Contents/Home/jre/lib/boot/graaljs-scriptengine.jar:/Downloads/graalvm-0.30/Contents/Home/jre/lib/boot/graal-sdk.jar
\
-cp \
/Downloads/graalvm-0.30/Contents/Home/jre/lib/svm/svm.jar:/Downloads/graalvm-0.30/Contents/Home/jre/lib/svm/objectfile.jar:/Downloads/graalvm-0.30/Contents/Home/jre/lib/svm/pointsto.jar:/Downloads/graalvm-0.30/Contents/Home/jre/lib/svm/svm-enterprise.jar:/Downloads/graalvm-0.30/Contents/Home/jre/lib/jvmci/graal.jar:/Downloads/graalvm-0.30/Contents/Home/jre/lib/jvmci/enterprise-graal.jar:/Downloads/graalvm-0.30/Contents/Home/jre/lib/jvmci/jvmci-api.jar:/Downloads/graalvm-0.30/Contents/Home/jre/lib/jvmci/jvmci-hotspot.jar
\
-Duser.country=US \
-Duser.language=en \
-Dgraal.EagerSnippets=true \
-Dsubstratevm.version=4e7e677ee680676a3285352862d011c324200b57 \
-Dgraalvm.version=0.30 \
-Dorg.graalvm.version=0.30 \
-Xms1G \
-Xss10m \
-Dcom.oracle.graalvm.isaot=true \
com.oracle.svm.hosted.NativeImageGeneratorRunner \
-imagecp \
/Downloads/graalvm-0.30/Contents/Home/jre/lib/svm/svm.jar:/Downloads/graalvm-0.30/Contents/Home/jre/lib/svm/objectfile.jar:/Downloads/graalvm-0.30/Contents/Home/jre/lib/svm/pointsto.jar:/Downloads/graalvm-0.30/Contents/Home/jre/lib/svm/svm-enterprise.jar:/Downloads/graalvm-0.30/Contents/Home/jre/lib/jvmci/graal.jar:/Downloads/graalvm-0.30/Contents/Home/jre/lib/jvmci/enterprise-graal.jar:/Downloads/graalvm-0.30/Contents/Home/jre/lib/jvmci/jvmci-api.jar:/Downloads/graalvm-0.30/Contents/Home/jre/lib/jvmci/jvmci-hotspot.jar:/Downloads/graalvm-0.30/Contents/Home/jre/lib/svm/library-support.jar:/Downloads/graalvm-0.30/Contents/Home/examples/native-image
\
-H:Path=. \
-H:InspectServerContentPath=/Downloads/graalvm-0.30/Contents/Home/jre/lib/svm/inspect
\
-H:CLibraryPath=/Downloads/graalvm-0.30/Contents/Home/jre/lib/svm/clibraries/darwin-amd64
\
-H:Class=HelloWorld \
-H:Name=helloworld
]
classlist: 919.94 ms
(cap): 1,034.18 ms
setup: 1,766.95 ms
analysis: 3,921.37 ms
error: Must not have a FileDescriptor in the image heap.
Detailed message:
Error: Must not have a FileDescriptor in the image heap.
Trace: object java.io.FileInputStream
object sun.security.provider.NativePRNG$RandomIO
method sun.security.provider.NativePRNG.engineNextBytes(byte[])
Call path from entry point to
sun.security.provider.NativePRNG.engineNextBytes(byte[]):
at sun.security.provider.NativePRNG.engineNextBytes(NativePRNG.java:220)
at java.security.SecureRandom.nextBytes(SecureRandom.java:468)
at java.util.UUID.randomUUID(UUID.java:145)
at HelloWorld.main(HelloWorld.java:6)
at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:137)
at
Lcom/oracle/svm/core/code/CEntryPointCallStubs;.com_002eoracle_002esvm_002ecore_002eJavaMainWrapper_002erun_0028int_002corg_002egraalvm_002enativeimage_002ec_002etype_002eCCharPointerPointer_0029(generated:0)
Error: Image building with exit status 1
More information about the graal-dev
mailing list