jdk7-b64 has new dependency on glibc-2.4

Alan Bateman Alan.Bateman at Sun.COM
Mon Jul 20 08:53:16 PDT 2009

Martin Buchholz wrote:
> Hi Alan,
> As of openjdk7-b64, one can no longer build or run on glibc 2.3 
> systems because of a new dependency
> on fdopendir (and perhaps other glibc 2.4 functions).
> ../../../src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c: In 
> function 'Java_sun_nio_fs_UnixNativeDispatcher_fdopendir':
> ../../../src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c:569: 
> warning: implicit declaration of function 'fdopendir'
> I have been advocating continued support of glibc 2.3 systems,
> but this does not seem to be a popular sentiment.
> Would the nio2 team (and Sun)
> - regard the new build failure as a bug to be fixed?
> - grudgingly accept patches to allow possibly reduced functionality on 
> older systems?
> - refuse such patches?
> Thanks,
> Martin
Sorry for the late reply, I've been on vacation.

I don't think I've seen any discussion about the oldest version of glibc 
that OpenJDK should build with. As you know, in Sun, we build on Fedora 
9 now (glibc 2.8) so it's possible that dependencies on more recent 
glibc releases might creep in, unintentionally, as in this case.

I don't have any objection to locating fdopendir at runtime. That's the 
way it used to work before b64 and an over-sight, on my part, that this 
was only a recent addition to glibc. It's only used in the optional 
SecureDirectoryStream support and so isn't required to be present. The 
attached should get you going for now (you've probably done this 
already). Before you push this or similar, I'd like to re-examine the 
capability check to see this one should be lumped in with the existing 
*at calls or be its own capability.


$ diff -r 007eb542aceb src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c
--- a/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c      Fri Jul 
03 17:24:53 2009 +0100
+++ b/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c      Mon Jul 
20 16:50:27 2009 +0100
@@ -92,12 +92,14 @@ typedef int unlinkat_func(int, const cha
 typedef int unlinkat_func(int, const char*, int);
 typedef int renameat_func(int, const char*, int, const char*);
 typedef int futimesat_func(int, const char *, const struct timeval *);
+typedef DIR* fdopendir_func(int);

 static openat64_func* my_openat64_func = NULL;
 static fstatat64_func* my_fstatat64_func = NULL;
 static unlinkat_func* my_unlinkat_func = NULL;
 static renameat_func* my_renameat_func = NULL;
 static futimesat_func* my_futimesat_func = NULL;
+static fdopendir_func* my_fdopendir_func = NULL;

  * fstatat missing from glibc on Linux. Temporary workaround
@@ -196,6 +198,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_ini
     my_unlinkat_func = (unlinkat_func*) dlsym(RTLD_DEFAULT, "unlinkat");
     my_renameat_func = (renameat_func*) dlsym(RTLD_DEFAULT, "renameat");
     my_futimesat_func = (futimesat_func*) dlsym(RTLD_DEFAULT, "futimesat");
+    my_fdopendir_func = (fdopendir_func*) dlsym(RTLD_DEFAULT, "fdopendir");

     /* fstatat64 missing from glibc */
@@ -565,8 +568,13 @@ Java_sun_nio_fs_UnixNativeDispatcher_fdo
 Java_sun_nio_fs_UnixNativeDispatcher_fdopendir(JNIEnv* env, jclass 
this, int dfd) {
     DIR* dir;

-    /* EINTR not listed as a possible error */
-    dir = fdopendir((int)dfd);
+    if (my_fdopendir_func == NULL) {
+        JNU_ThrowInternalError(env, "should not reach here");
+        return (jlong)-1;
+    }
+    /* EINTR not listed as a possible error */
+    dir = (*my_fdopendir_func)((int)dfd);
     if (dir == NULL) {
         throwUnixException(env, errno);

More information about the nio-dev mailing list