'Is Javax.ImageIO supported by graalVM native-image?
I am testing graalVM native image limitations with multiple different java features. I wrote a little program that performs canny edge detection and it loads in images using javax.ImageIO class. the code compiles to a native image just fine but I get the following runtime error when running code as a native image:
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)
which is caused by the following line of code:
File file = new File(args[0]);
BufferedImage image = ImageIO.read(file);
I tried to specify JpegImageReader in my jni-config.json file:
[
{
"name" : "com.sun.imageio.plugins.jpeg.JPEGImageReader",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
}
]
However i still get the same error as before. Does anyone know if ImageIO can be supported in graalvm native image and if it's not supporter why not?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|