【发布时间】:2020-02-17 18:28:41
【问题描述】:
我正在通过运行构建原生 GraalVM 原生镜像:
./mvnw package -Pnative
这会引发错误:
Error: Detected a started Thread in the image heap. Threads running in the image generator are no longer running at image run time. To see how this object got instantiated use -H:+TraceClassInitialization. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image run time by using the option --initialize-at-build-time=<class-name>.
我可以看到它尝试运行的native-image 命令:
/Library/Java/JavaVirtualMachines/graalvm-ce-java8-19.3.1/Contents/Home/bin/native-image -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory -J-Dvertx.disableDnsResolver=true -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=1 --initialize-at-build-time= -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime -jar get-started-1.0-SNAPSHOT-runner.jar -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -H:-AddAllCharsets -H:EnableURLProtocols=http -H:+JNI --no-server -H:-UseServiceLoaderFeature -H:+StackTrace get-started-1.0-SNAPSHOT-runner
所以我想我可以添加 -H:+TraceClassInitialization 错误,但是当我运行 native-image 时,无论是否使用跟踪选项,我都会得到一个不同的错误:
[get-started-1.0-SNAPSHOT-runner:52581] classlist: 7,548.63 ms
[get-started-1.0-SNAPSHOT-runner:52581] setup: 55.85 ms
Error: policy com.oracle.svm.core.genscavenge.CollectionPolicy cannot be instantiated.
com.oracle.svm.core.util.UserError$UserException: policy com.oracle.svm.core.genscavenge.CollectionPolicy cannot be instantiated.
我不确定是否相关。我猜想通过 maven 运行会设置一些上下文,并且想知道 pom.xml 文件上是否有一个属性,我可以设置它来询问 -H:+TraceClassInitialization
【问题讨论】:
标签: quarkus graalvm graalvm-native-image