Open apocalyptech opened 1 year ago
Thank you for the report.
The problem is that the src/java.desktop/share/classes/javax/swing/text/html/default.css
from jdk is not added as a resource when html is used by a Swing application.
default.css
contains some default values which updates component margins and insets.
For some reason native-image-agent
does not dump the default.css
resource:
java -agentlib:native-image-agent=config-output-dir=conf-dir test
cat conf-dir/resource-config.json
{
"resources":{
"includes":[]},
"bundles":[
{
"name":"com.sun.swing.internal.plaf.basic.resources.basic",
"classNames":["com.sun.swing.internal.plaf.basic.resources.basic"]
},
{
"name":"com.sun.swing.internal.plaf.metal.resources.metal",
"classNames":["com.sun.swing.internal.plaf.metal.resources.metal"]
},
{
"name":"sun.awt.resources.awt",
"classNames":["sun.awt.resources.awt"]
}
]
}
The workaround is to explicitly include default.css
into the native image building with -H:IncludeResources=.*/default.css$
option:
native-image.cmd -Djava.awt.headless=false -H:IncludeResources=.*/default.css$ test
Hello! Indeed, that workaround works great. Thanks a bunch! That's definitely good enough for me -- feel free to close this out if there's nothing else you wanted to look into about it.
Cheers!
I'm working w/ Liberica NIK 22 (Java 17), and I've noticed that Liberica NIK-compiled Swing applications don't have consistent handling of HTML rendering, compared to the non-compiled versions. The two I've noticed in particular is that
<ul>
elements don't get bullet points (or get indented), and that<nobr>
tags seem to be ignored. A simple testcase for the<ul>
element could be shown with:When run with the usual JVMs (including the JVM included with the Liberica NIK), it renders like so:
... but once compiled with
native-image
, it ends up looking like:I've verified that I'm running both with the same Liberica NIK environments:
Let me know if I can provide any more info!