RFR: 8239563 - Reduce public exports in dynamic libraries built from static JDK libraries

Bob Vandette bob.vandette at oracle.com
Tue Feb 25 20:37:19 UTC 2020

Please review this RFE that alters the visibility of JNI entrypoints to hidden when a shared library
is created using static JDK libraries.







All JNI entrypoints that exist in JDK static libraries are declared as exported or visible. 
If a dynamic library is built from these static libraries, we end up with many exported
functions that we don't want to provide access to,

This RFE will change the definition of JNIEXPORT for libraries built when JNI_STATIC_BUILD
is defined.  When defined, functions declared with JNIEXPORT will not be exported when 
linked into shared or dynamic libraries.  This will still allow linking of these functions into
dynamic libraries but will not export the JDK symbols outside of the shared library.

A CSR has been filed (https://bugs.openjdk.java.net/browse/JDK-8239791) to add the JNI_STATIC_BUILD
define support in jni.h.


In JDK8 the JNI specification and JDK implementation was enhanced to support static JNI libraries
but we didn’t consider the issue of exportibility of JNI entrypoint symbols.


If developers use these static JDK libraries in order to produce a custom shared library, all of the
JNIEXPORTS will be exposed by this library even if the developer did not choose to export these.
This is a security issue and a potential problem if this library is mixed with other libraries containing
these symbols.


More information about the core-libs-dev mailing list