temurin-build icon indicating copy to clipboard operation
temurin-build copied to clipboard

Temurin 21 JDK does not link to major version of libfreetype or is not statically linked

Open nudgegoonies opened this issue 1 year ago • 6 comments

What are you trying to do? Do something that uses the font manager.

Expected behaviour: It should work like with Temurin 17 JDK.

Observed behaviour: Error in java when using Temurin 21 JDK:

[...]
java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager
[...]
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.UnsatisfiedLinkError: /usr/lib/jvm/temurin-21-jdk-amd64/lib/libfontmanager.so: libfreetype.so: cannot open shared object file: No such file or directory
[...]

Any other comments: Can be verified by using ldd libfontmanager.so | grep freetype: temurin 17: libfreetype.so.6 => /lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007fbccc335000) in comparison to temurin 21: libfreetype.so => not found

debian package is temurin-21-jdk in version 21.0.2.0.0+13 operating system is Debian 12

nudgegoonies avatar Jan 29 '24 15:01 nudgegoonies

Interesting. Thanks for the report! We did change the build platform for Linux/x64 for JDK21, but I've replicated this on Linux/aarch64 which hasn't changed so it's not related to that.

Noting that most other openjdk providers seem to ship their own freetype library. Temurin does not

https://github.com/adoptium/temurin-build/pull/3557 indicates we changed the behaviour for JDK21+ as a result of discussions in https://github.com/adoptium/temurin-build/issues/3504.

FYI @andrew-m-leonard - we should probably call this out in https://adoptium.net/blog/2024/01/eclipse-temurin-8u402-11022-1710-and-2102-available but it seems we may have a change in behaviour here which was not expected.

sxa avatar Jan 29 '24 16:01 sxa

Noting that installing libfreetype-dev alongside libfreetype6 should resolve this, as it includes the desired libfreetype.so symlink under /usr/lib/<arch_triple>

sxa avatar Jan 29 '24 16:01 sxa

not sure I understand the "scenario" ? libfontmanager.so and libfreetype.so are within the same directory

Is this an Installer issue maybe?

andrew-m-leonard avatar Jan 29 '24 17:01 andrew-m-leonard

not sure I understand the "scenario" ? libfontmanager.so and libfreetype.so are within the same directory

Is this an Installer issue maybe?

Quite likely - it looks like it's present in the tarball (which I hadn't checked earlier but not the installed .deb ...

sxa avatar Jan 29 '24 17:01 sxa

Probably due to this line ... https://github.com/adoptium/installer/blob/20411d5179aa81121755a729dac120f9b5dce0a2/linux/jdk/debian/src/main/packaging/temurin/21/debian/rules#L63

sxa avatar Jan 29 '24 17:01 sxa

Assigning George as he agreed to look at this in the PMC potentially as part of his investigations of https://github.com/adoptium/installer/issues/801 in case they can both be tested together

sxa avatar Feb 08 '24 12:02 sxa

I believe @steelhead31 has resolved this now, so I'll leave him to add some closing comments :-)

sxa avatar Feb 29 '24 11:02 sxa

The initial bug was fixed in adoptium/installer#812 , which then subsequently required republished of the JDK21.0.2+13 release packages, which was complete via PR adoptium/installer#824 , in addition s390x support was added adoptium/installer#827 and a bug identified and fixed in the JRE 21 RPM packages which was also fixed adoptium/installer#831. All the new installer packages have been published to the jfrog artifactory, and can be identified with the suffixed spec version of -2 ( and -3 for the ppc64le JRE fix ).

steelhead31 avatar Mar 04 '24 08:03 steelhead31

Thank you!

nudgegoonies avatar Mar 08 '24 14:03 nudgegoonies

Debian images (e.g. tag eclipse-temurin:21.0.2_13-jdk, https://hub.docker.com/layers/library/eclipse-temurin/21.0.2_13-jdk/images/sha256-723e15b2ddb23812fcb49eb688717f926545504e69a24b8f3b2135777de1c3b9?context=explore) appear to have been rebuilt 11days ago and we found some builds on our CI infra to fail with

java.lang.RuntimeException: Fontconfig head is null, check your fonts or fonts configuration at 
java.desktop/sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1263) at 
java.desktop/sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:221) at 
java.desktop/sun.awt.FontConfiguration.init(FontConfiguration.java:105) at 
java.desktop/sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:696) at 
java.desktop/sun.font.SunFontManager$2.run(SunFontManager.java:352) at 
java.desktop/sun.font.SunFontManager$2.run(SunFontManager.java:309) at 
java.base/java.security.AccessController.doPrivileged(AccessController.java:319) at 
java.desktop/sun.font.SunFontManager.<init>(SunFontManager.java:309) at 
java.desktop/sun.awt.FcFontManager.<init>(FcFontManager.java:35) at 
java.desktop/sun.awt.X11FontManager.<init>(X11FontManager.java:55) at 
java.desktop/sun.font.PlatformFontInfo.createFontManager(PlatformFontInfo.java:37) at 
java.desktop/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:51) at 
java.desktop/sun.font.SunFontManager.getInstance(SunFontManager.java:242) at 
java.desktop/sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:260) at 
java.desktop/sun.java2d.SunGraphics2D.getFontMetrics(SunGraphics2D.java:862) at 
org.jfree.chart.text.G2TextMeasurer.getStringWidth(G2TextMeasurer.java:63) at 
org.jfree.chart.text.TextUtils.nextLineBreak(TextUtils.java:227) at 
org.jfree.chart.text.TextUtils.createTextBlock(TextUtils.java:168) at 
org.jfree.chart.title.TextTitle.arrangeRR(TextTitle.java:628) at 
org.jfree.chart.title.TextTitle.arrange(TextTitle.java:496) at 
org.jfree.chart.JFreeChart.drawTitle(JFreeChart.java:1260) at 
org.jfree.chart.JFreeChart.draw(JFreeChart.java:1150) at 
org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1343) at 
org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1324) at 
org.jfree.chart.ChartUtils.writeChartAsPNG(ChartUtils.java:144) at 
org.jfree.chart.ChartUtils.writeChartAsPNG(ChartUtils.java:98) at 

Is this directly related? If so, shall I create a ticket in the containers project?

DRoppelt avatar Apr 08 '24 11:04 DRoppelt

I think that's different enough to warrant creation of another issue. What are you running when you get that error? It would be good to have a recreate since just running the image with jshell doesn't seem to show that exception. If you can determine if it is reproducible outside the container image that would also be useful to know.

sxa avatar Apr 08 '24 12:04 sxa

Debian images (e.g. tag eclipse-temurin:21.0.2_13-jdk, https://hub.docker.com/layers/library/eclipse-temurin/21.0.2_13-jdk/images/sha256-723e15b2ddb23812fcb49eb688717f926545504e69a24b8f3b2135777de1c3b9?context=explore) appear to have been rebuilt 11days ago and we found some builds on our CI infra to fail with

java.lang.RuntimeException: Fontconfig head is null, check your fonts or fonts configuration at 
java.desktop/sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1263) at 
java.desktop/sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:221) at 
java.desktop/sun.awt.FontConfiguration.init(FontConfiguration.java:105) at 
java.desktop/sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:696) at 
java.desktop/sun.font.SunFontManager$2.run(SunFontManager.java:352) at 
java.desktop/sun.font.SunFontManager$2.run(SunFontManager.java:309) at 
java.base/java.security.AccessController.doPrivileged(AccessController.java:319) at 
java.desktop/sun.font.SunFontManager.<init>(SunFontManager.java:309) at 
java.desktop/sun.awt.FcFontManager.<init>(FcFontManager.java:35) at 
java.desktop/sun.awt.X11FontManager.<init>(X11FontManager.java:55) at 
java.desktop/sun.font.PlatformFontInfo.createFontManager(PlatformFontInfo.java:37) at 
java.desktop/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:51) at 
java.desktop/sun.font.SunFontManager.getInstance(SunFontManager.java:242) at 
java.desktop/sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:260) at 
java.desktop/sun.java2d.SunGraphics2D.getFontMetrics(SunGraphics2D.java:862) at 
org.jfree.chart.text.G2TextMeasurer.getStringWidth(G2TextMeasurer.java:63) at 
org.jfree.chart.text.TextUtils.nextLineBreak(TextUtils.java:227) at 
org.jfree.chart.text.TextUtils.createTextBlock(TextUtils.java:168) at 
org.jfree.chart.title.TextTitle.arrangeRR(TextTitle.java:628) at 
org.jfree.chart.title.TextTitle.arrange(TextTitle.java:496) at 
org.jfree.chart.JFreeChart.drawTitle(JFreeChart.java:1260) at 
org.jfree.chart.JFreeChart.draw(JFreeChart.java:1150) at 
org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1343) at 
org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1324) at 
org.jfree.chart.ChartUtils.writeChartAsPNG(ChartUtils.java:144) at 
org.jfree.chart.ChartUtils.writeChartAsPNG(ChartUtils.java:98) at 

Is this directly related? If so, shall I create a ticket in the containers project?

I am wondering if the container image needs "fontconfig" installing ?

andrew-m-leonard avatar Apr 08 '24 14:04 andrew-m-leonard

@sxa ok will create an issue later and see if I can create a minimal demo to reproduce it

@andrew-m-leonard fontconfig should already be installed but I'll try to verify if that is a "should" or actually present

DRoppelt avatar Apr 08 '24 14:04 DRoppelt