RFR: 8202794: Native Unix code should use readdir rather than readdir_r

Pengfei Li Pengfei.Li at arm.com
Thu Jun 28 10:01:08 UTC 2018


Hi

Last month, Bernard proposed a patch to fix the OpenJDK build issue with recent versions of glibc.
See http://mail.openjdk.java.net/pipermail/core-libs-dev/2018-May/052991.html
But this fix requires to be tested on all POSIX systems before getting integrated.

As recently, more and more guys are complaining about the OpenJDK build failure issue, shall we just add the following workaround to upstream before Bernard's real fix eventually merged?


diff --git a/src/java.base/unix/native/libjava/TimeZone_md.c b/src/java.base/unix/native/libjava/TimeZone_md.c
index f0bb362afc..e156381acd 100644
--- a/src/java.base/unix/native/libjava/TimeZone_md.c
+++ b/src/java.base/unix/native/libjava/TimeZone_md.c
@@ -146,7 +146,7 @@ findZoneinfoFile(char *buf, size_t size, const char *dir)
         (void) closedir(dirp);
         return NULL;
     }
-
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
     while (readdir64_r(dirp, entry, &dp) == 0 && dp != NULL) {
         /*
          * Skip '.' and '..' (and possibly other .* files)
diff --git a/src/java.base/unix/native/libjava/UnixFileSystem_md.c b/src/java.base/unix/native/libjava/UnixFileSystem_md.c
index 315aa92b64..5b9554dd47 100644
--- a/src/java.base/unix/native/libjava/UnixFileSystem_md.c
+++ b/src/java.base/unix/native/libjava/UnixFileSystem_md.c
@@ -339,6 +339,7 @@ Java_java_io_UnixFileSystem_list(JNIEnv *env, jobject this,
     if (rv == NULL) goto error;

     /* Scan the directory */
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
     while ((readdir64_r(dir, ptr, &result) == 0)  && (result != NULL)) {
         jstring name;
         if (!strcmp(ptr->d_name, ".") || !strcmp(ptr->d_name, ".."))
diff --git a/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c b/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c
index 53bb1c1009..72c38eb9a6 100644
--- a/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c
+++ b/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c
@@ -731,6 +731,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_readdir(JNIEnv* env, jclass this, jlong val

     /* EINTR not listed as a possible error */
     /* TDB: reentrant version probably not required here */
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
     res = readdir64_r(dirp, ptr, &result);

#ifdef _AIX
diff --git a/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c b/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c
index 1adeaf7bb5..080cf2a89b 100644
--- a/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c
+++ b/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c
@@ -80,6 +80,7 @@ static struct dirent* read_dir(DIR* dirp, struct dirent* entry) {
     return dbuf;
#else /* __linux__ || _ALLBSD_SOURCE */
     struct dirent* p;
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
     if (readdir_r(dirp, entry, &p) == 0) {
         return p;
     } else {


--
Thanks,
Pengfei


More information about the core-libs-dev mailing list