RFR: 8239563 - Reduce public exports in dynamic libraries built from static JDK libraries
david.holmes at oracle.com
Wed Feb 26 07:41:22 UTC 2020
On 26/02/2020 6:37 am, Bob Vandette wrote:
> 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.
I have reservations about turning this into something we have to expose
and support, rather than being something totally handled within the
OpenJDK build system. I'm tempted to suggest the header files be
adjusted to have:
<JNIEXPORT basic definitions as they are now >
and then we define the modified JNIEXPORT via the build system when
doing a static build.
Is that feasible?
> 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