OpenJDK fails to build with GCC when the #include<time.h> inside zip.cpp comes from a non-sysroot path

Patrick Zhang patrick at
Wed Nov 28 09:45:39 UTC 2018

When I build on the latest jdk/jdk code base with GCC 8.2 (configured sysroot as a customized path instead of default root directory of the linux system), it failed with error: "jdk.pack/share/native/common-unpack/zip.cpp:420:23: error: declaration of 'tm* gmtime_r(const time_t*, tm*)' has a different exception specifier".

The root cause is the /usr/include/time.h included in src/jdk.pack/share/native/common-unpack/zip.cpp is treated as a non-system header file, so the originally suppressed error concerning "mismatched exception specifiers" gets exposed now. As the macro __THROW is defined in sys/cdefs.h we could reuse it on the condition of (defined(__GNUC__) && defined(__THROW)). Could you please help review this simple patch and comment, thanks!

diff -r 19b15ff2576b src/jdk.pack/share/native/common-unpack/zip.cpp

--- a/src/jdk.pack/share/native/common-unpack/zip.cpp    Tue Nov 27 21:20:16 2018 -0500

+++ b/src/jdk.pack/share/native/common-unpack/zip.cpp    Wed Nov 28 04:21:07 2018 -0500

@@ -417,7 +417,10 @@


#ifdef _REENTRANT // solaris

-extern "C" struct tm *gmtime_r(const time_t *, struct tm *);

+#if !(defined(__GNUC__) && defined(__THROW))

+#define __THROW


+extern "C" struct tm *gmtime_r(const time_t *, struct tm *) __THROW;


#define gmtime_r(t, s) gmtime(t)



More information about the jdk-dev mailing list