我正在测试具有多个不同Java功能的graalVM本机映像限制。我写了一个小程序来执行canny边缘检测,并使用javax.ImageIO类将其加载到图像中。代码可以编译为本地映像,但是在将代码作为本地映像运行时出现以下运行时错误:
Exception in thread "main" java.lang.UnsatisfiedLinkError: com.sun.imageio.plugins.jpeg.JPEGImageReader.initJPEGImageReader()J [symbol: Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_initJPEGImageReader or Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_initJPEGImageReader__]
at com.oracle.svm.jni.access.JNINativeLinkage.getOrFindEntryPoint(JNINativeLinkage.java:145)
at com.oracle.svm.jni.JNIGeneratedMethodSupport.nativeCallAddress(JNIGeneratedMethodSupport.java:57)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.initJPEGImageReader(JPEGImageReader.java)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.<init>(JPEGImageReader.java:232)
at com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi.createReaderInstance(JPEGImageReaderSpi.java:85)
at javax.imageio.spi.ImageReaderSpi.createReaderInstance(ImageReaderSpi.java:320)
at javax.imageio.ImageIO$ImageReaderIterator.next(ImageIO.java:532)
at javax.imageio.ImageIO$ImageReaderIterator.next(ImageIO.java:516)
at javax.imageio.ImageIO.read(ImageIO.java:1463)
at javax.imageio.ImageIO.read(ImageIO.java:1315)
at Main.main(Main.java:32)
由以下代码行引起:
File file = new File(args[0]);
BufferedImage image = ImageIO.read(file);
我尝试在jni-config.json文件中指定JpegImageReader:
[
{
"name" : "com.sun.imageio.plugins.jpeg.JPEGImageReader",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
}
]
但是,我仍然收到与以前相同的错误。有谁知道graalvm本机映像是否可以支持ImageIO,为什么不支持ImageIO?