[ 
https://issues.apache.org/jira/browse/FOP-2967?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17192838#comment-17192838
 ] 

Jiri Ondrusek commented on FOP-2967:
------------------------------------

Hi [~ssteiner] ,

thanks for your previous comment, it showed my an obvious issue in my test 
configuration.

Although I'm able to use custom fonts in JVM execution, I've got still a 
problem in native.

I'm getting error:


Error: Classes that should be initialized at run time got initialized during 
image building:
 *sun.awt.X11FontManager* the class was requested to be initialized at *run 
time* (from feature io.quarkus.runner.AutoFeature.beforeAnalysis). 
sun.awt.X11FontManager has been initialized without the native-image 
initialization instrumentation and the stack trace can't be tracked. Try 
avoiding to initialize the class that caused initialization of 
sun.awt.X11FontManagere (from feature 
io.quarkus.runner.AutoFeature.beforeAnalysis). sun.font.TrueTypeFont has been 
initialized without the native-image initialization instrumentation and the 
stack trace can't be tracked. Try avoiding to initialize the class that caused 
initialization of sun.font.TrueTypeFont

My view of the problem is that a class 'X11FontManager' is selected for runtime 
execution. But there is some class(es) in FOP which tries to use it in 
buildtime. This typically mean that there is a static block (somewhere) which 
references (through some dependencies) `sun.awt.X11FontManager`. 


 * I've tried (for validating of my hypothesis) to remove default fonts 
([https://github.com/apache/xmlgraphics-fop/blob/trunk/fop-core/src/main/java/org/apache/fop/render/PrintRendererConfigurator.java#L126)]
 and custom fonts 
([https://github.com/apache/xmlgraphics-fop/blob/trunk/fop-core/src/main/java/org/apache/fop/render/PrintRendererConfigurator.java#L127])
 from being instantiated - no change in error.
 * Because I'm not able to catch in debug mode any access to X11FontManager 
during conversion to pdf. I've tried also another formats (e.g. png). I've 
found 
[https://github.com/apache/xmlgraphics-fop/blob/trunk/fop-core/src/main/java/org/apache/fop/render/java2d/Base14FontCollection.java#L110]
 I've removed this initialization from my quarkus extension (it shouldn't 
affect my pdf conversion scenario) - but no change.

I see several ways of my investigation:
- Try to find some static initialization of some classes, which are using 
X11FontManager 
- Try to make sure, that my fop jar supports only pdf type. (to eliminate 
possible impact from other types/renderers)

I think that correct compatibility with Graal VM is also in interest of FOP as 
well. So it would be nice to solve this problem correctly -
 * by finding static initializers, which are responsible for the issue

 

What do you think? 
 * Do you see any other option here?
 * Can you help me with finding static initializators of fonts (and 
X11FontManager)?
 * Is it possible to build fop libraries with support of only e.g. pdf 
conversio?

> Quarkus support of FOP
> ----------------------
>
>                 Key: FOP-2967
>                 URL: https://issues.apache.org/jira/browse/FOP-2967
>             Project: FOP
>          Issue Type: Improvement
>            Reporter: Jiri Ondrusek
>            Priority: Major
>
> I tried to create camel-quarkus extension for fop (see 
> [https://github.com/apache/camel-quarkus/issues/1642])
> I was not able to finish it successfully as I was facing issues with fonts:
> {quote}Error: No instances of sun.nio.ch.FileChannelImpl are allowed in the 
> image heap as this class should be initialized at image runtime. Object has 
> been initialized without the native-image initialization instrumentation and 
> the stack trace can't be tracked.
>  Trace: Object was reached by 
>  reading field sun.font.TrueTypeFont$TTDisposerRecord.channel of
>  constant sun.font.TrueTypeFont$TTDisposerRecord@2c7b7d19 reached by 
>  reading field java.util.Hashtable$Entry.value of
>  constant java.util.Hashtable$Entry@66aeea4 reached by 
>  indexing into array
>  constant java.util.Hashtable$Entry[]@7be2410f reached by 
>  reading field java.util.Hashtable.table of
>  constant java.util.Hashtable@33cc3b6c reached by 
>  scanning method sun.java2d.Disposer.addObjectRecord(Disposer.java:250)
> {quote}
> I spent some time with debugging of the fop and I discovered that fonts are 
> inseparable part of some rendering. Which makes it impossible to "avoid".
> I'm not sure how this could be solved. But it would be nice to have support 
> for quarkus.
> (I can imagine that for example only some features could be supported in 
> quarkus)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to