Hi does anybody has some experiences with an embedded apache fop transformation (xml to pdf) with Graal's native-image?
I made some really simple xml to pdf transformation like the one in the examples: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop/examples/embedding/java/embedding/ExampleXML2PDF.java?view=markup I can compile it to a native-image but I get some runtime error: java.lang.UnsupportedOperationException: Don't know how to handle "application/pdf" as an output format. Neither an FOEventHandler, nor a Renderer could be found for this output format. at org.apache.fop.render.RendererFactory.createFOEventHandler(RendererFactory.java:365) at org.apache.fop.fo.FOTreeBuilder.<init>(FOTreeBuilder.java:107) at org.apache.fop.apps.Fop.createDefaultHandler(Fop.java:104) at org.apache.fop.apps.Fop.<init>(Fop.java:78) at org.apache.fop.apps.FOUserAgent.newFop(FOUserAgent.java:182) at org.apache.fop.apps.FopFactory.newFop(FopFactory.java:239) at apache.fop.graalvm.Converter.runXml2Pdf(Converter.java:51) at apache.fop.graalvm.App.main(App.java:42) I guess apache fop tries to figure out which java classes it needs on runtime which will not work with graal's native image. I then tried to define the output format on compile time with this code: IFDocumentHandler handler = new PDFDocumentHandler(new IFContext(foUserAgent)); StreamResult streamResult = new StreamResult(); streamResult.setSystemId(pdffile.getAbsolutePath()); handler.setResult(streamResult); foUserAgent.setDocumentHandlerOverride(handler); Fop fop = fopFactory.newFop(foUserAgent); This works again with Java but the I cannot compile to a native image with graal: Error: Detected a started Thread in the image heap. Threads running in the image generator are no longer running at image run time. The object was probably created by a class initializer and is reachable from a static field. By default, all class initialization is done during native image building.You can manually delay class initialization to image run time by using the option --delay-class-initialization-to-runtime=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point. Detailed message: Error: Detected a started Thread in the image heap. Threads running in the image generator are no longer running at image run time. The object was probably created by a class initializer and is reachable from a static field. By default, all class initialization is done during native image building.You can manually delay class initialization to image run time by using the option --delay-class-initialization-to-runtime=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point. Trace: object sun.java2d.opengl.OGLRenderQueue field sun.java2d.opengl.OGLRenderQueue.theInstance At the moment I have no idea if there's chance to make this work or if they are (perhaps known) constraints on the apache fop side. Graal's limitations are documented here: https://github.com/oracle/graal/blob/master/substratevm/LIMITATIONS.md My sample project: https://github.com/edigonzales/apache-fop-graalvm Any help is appreciated. Thanks regards Stefan
