adoptium / temurin-build

Eclipse Temurin™ build scripts - common across all releases/versions
Apache License 2.0
1.02k stars 249 forks source link

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

Closed nudgegoonies closed 8 months ago

nudgegoonies commented 9 months ago

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

sxa commented 9 months ago

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 commented 9 months ago

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

andrew-m-leonard commented 9 months ago

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

Is this an Installer issue maybe?

sxa commented 9 months ago

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 commented 9 months ago

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

sxa commented 8 months ago

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 commented 8 months ago

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

steelhead31 commented 8 months ago

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 ).

nudgegoonies commented 8 months ago

Thank you!

DRoppelt commented 6 months ago

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?

sxa commented 6 months ago

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.

andrew-m-leonard commented 6 months ago

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 ?

DRoppelt commented 6 months ago

@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