I'm running DMelt (http://jwork.org/dmelt) and I've noticed that simple Java code fails when using JDK9. Here is a Jython example, and the error is posted below. I use Ubuntu to run DMelt.
from jhplot import *
c1 = HPlot("Canvas")
c1.visible(1)
f1=F1D("x^2")
c1.draw(f1)
c1.export("image.pdf")
Or, rewritten in Java:
import jhplot.*;
class MyFunction
{
public static void main(String[] args) {
HPlot c1 = new HPlot("Canvas");
c1.visible(true);
F1D f1 = new F1D("x^2");
c1.draw(f1);
c1.export("image.pdf");
}
}
Here is the error:
Traceback (most recent call last):
File "a.py", line 7, in <module>
c1.export("image.pdf")
at java.desktop/javax.imageio.spi.ServiceRegistry.checkClassAllowed(ServiceRegistry.java:745)
at java.desktop/javax.imageio.spi.ServiceRegistry.<init>(ServiceRegistry.java:140)
at org.freehep.graphicsbase.util.export.ExportFileTypeRegistry.<init>(ExportFileTypeRegistry.java:33)
at org.freehep.graphicsbase.util.export.ExportFileTypeRegistry.getDefaultInstance(ExportFileTypeRegistry.java:44)
at org.freehep.graphicsbase.util.export.ExportFileType.getExportFileTypes(ExportFileType.java:180)
at org.freehep.graphicsbase.util.export.ExportFileType.getExportFileTypes(ExportFileType.java:172)
at jhplot.io.images.ExportVGraphics.export(ExportVGraphics.java:101)
at jhplot.gui.GHPanel.export(GHPanel.java:501)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: org.freehep.graphicsbase.util.export.ExportFileType is not an ImageIO SPI class
The same code works fine on all Java versions 1.5-1.8. Note that this error has nothing to do with Jython. This is a new JDK9 problem, which is not related to JDK9: An illegal reflective access operation has occurred. org.python.core.PySystemState