--- old/make/autoconf/flags-cflags.m4 2020-02-26 15:56:14.000000000 -0500 +++ new/make/autoconf/flags-cflags.m4 2020-02-26 15:56:13.000000000 -0500 @@ -709,7 +709,10 @@ # JDK libraries. STATIC_LIBS_CFLAGS="-DSTATIC_BUILD=1" if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then - STATIC_LIBS_CFLAGS="$STATIC_LIBS_CFLAGS -ffunction-sections -fdata-sections" + STATIC_LIBS_CFLAGS="$STATIC_LIBS_CFLAGS -ffunction-sections -fdata-sections \ + -DJNIEXPORT='__attribute__((visibility(\"hidden\")))'" + else + STATIC_LIBS_CFLAGS="$STATIC_LIBS_CFLAGS -DJNIEXPORT=" fi if test "x$TOOLCHAIN_TYPE" = xgcc; then # Disable relax-relocation to enable compatibility with older linkers --- old/src/java.base/unix/native/include/jni_md.h 2020-02-26 15:56:15.000000000 -0500 +++ new/src/java.base/unix/native/include/jni_md.h 2020-02-26 15:56:15.000000000 -0500 @@ -29,16 +29,26 @@ #ifndef __has_attribute #define __has_attribute(x) 0 #endif + +#ifndef JNIEXPORT + #if (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ > 2))) || __has_attribute(visibility) + #ifdef ARM + #define JNIEXPORT __attribute__((externally_visible,visibility("default"))) + #else + #define JNIEXPORT __attribute__((visibility("default"))) + #endif + #else + #define JNIEXPORT + #endif +#endif + #if (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ > 2))) || __has_attribute(visibility) #ifdef ARM - #define JNIEXPORT __attribute__((externally_visible,visibility("default"))) #define JNIIMPORT __attribute__((externally_visible,visibility("default"))) #else - #define JNIEXPORT __attribute__((visibility("default"))) #define JNIIMPORT __attribute__((visibility("default"))) #endif #else - #define JNIEXPORT #define JNIIMPORT #endif --- old/src/java.base/windows/native/include/jni_md.h 2020-02-26 15:56:17.000000000 -0500 +++ new/src/java.base/windows/native/include/jni_md.h 2020-02-26 15:56:16.000000000 -0500 @@ -26,7 +26,9 @@ #ifndef _JAVASOFT_JNI_MD_H_ #define _JAVASOFT_JNI_MD_H_ -#define JNIEXPORT __declspec(dllexport) +#ifndef JNIEXPORT + #define JNIEXPORT __declspec(dllexport) +#endif #define JNIIMPORT __declspec(dllimport) #define JNICALL __stdcall