我的应用程序的 Graalvm 本机映像在以下方法调用中运行时失败:
Unsafe.allocateInstance(org.lwjgl.PointerBuffer.class);
有这个特例:
java.lang.IllegalArgumentException: Class org.lwjgl.PointerBuffer is instantiated reflectively but was never registered. Register the class by using org.graalvm.nativeimage.hosted.RuntimeReflection
at com.oracle.svm.core.graal.snippets.SubstrateAllocationSnippets.hubErrorStub(SubstrateAllocationSnippets.java:246)
在生成本机图像之前,我启动了应用程序,native-image-agent
它生成了 graalvm 配置 jsons,但reflect-config.json
没有org.lwjgl.PointerBuffer
.
即使我手动添加到reflect-config.json
{
"name":"org.lwjgl.PointerBuffer",
"allDeclaredFields":true,
"allPublicConstructors" : true
"allPublicFields": true,
"allDeclaredMethods": true,
"allPublicMethods": true
}
由于上述异常,本机映像仍然失败。有没有办法Unsafe.allocateInstance
在原生图像中工作?