Java_sun_nio_fs_LinuxNativeDispatcher_getlinelen in jdk/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c calls the free function, but the source file does not include <stdlib.h>. This leads to a build failure with a C compiler which does not support implicit function declarations by default. The fix is simple: diff -up java-1.8.0-openjdk-1.8.0.352.b08-1.fc38.x86_64/openjdk/jdk/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c.c99 java-1.8.0-openjdk-1.8.0.352.b08-1.fc38.x86_64/openjdk/jdk/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c --- java-1.8.0-openjdk-1.8.0.352.b08-1.fc38.x86_64/openjdk/jdk/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c.c99 2022-12-11 22:23:17.729952935 +0100 +++ java-1.8.0-openjdk-1.8.0.352.b08-1.fc38.x86_64/openjdk/jdk/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c 2022-12-11 22:23:44.801668107 +0100 @@ -29,6 +29,7 @@ #include "jlong.h" #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <dlfcn.h> #include <errno.h> But I can't find the appropriate upstream commit for this. The code has been moved around a bit. The present sources with the getlinelen function no longer has this issue (and later OpenJDK releases were not flagged by the Fedora C99 tester, either).
I can try and dig out the upstream commit and backport it, or failing that just do this as a local 8u bug. But, in general, we know there may be issues like this with legacy JDKs and don't intend to do significant and potentially risky backport work just to silence compilers. The newer JDKs (java-17-openjdk, java-latest-openjdk) tend to fare better with warnings and newer compilers. Note that, on the C++ side, HotSpot is explicitly built with -std=gnu++98 to avoid newer features in that codebase.
I think switching to building with -std=gnu89 is the riskier change here. Adding <stdlib.h> should really be harmless. And maybe then also build with -std=gnu17, so that the language default will not change with further compiler upgrades (we are currently at C17 in GCC 12). Implicit function declaration were removed from the language in 1999, and we really need to reject them by default for programmer convenience. But to do that, we need to fix Fedora (and some upstreams) first.