RFR: 8346394: Bundled freetype library needs to have JNI_OnLoad for static builds [v2]

Phil Race prr at openjdk.org
Tue Dec 17 15:24:38 UTC 2024


On Tue, 17 Dec 2024 13:22:19 GMT, Magnus Ihse Bursie <ihse at openjdk.org> wrote:

>> All JDK native libraries needs to have a proper `JNI_OnLoad`, set either by `DEF_STATIC_JNI_OnLoad` or `DEF_JNI_OnLoad`. This is so that in a static build, the JVM can recognize that the library is already loaded, and does not try to load a (non-existent) external library.
>> 
>> Our bundled version of freetype is missing such a marker.
>> 
>> This turns out to be a problem just on Windows, since the `System.loadLibrary("freetype")` code in `FontManagerNativeLibrary` is only executed on Windows. However, the cost of including this in the bundled versions on all platforms is very small, and it is a safeguard for any future changes. In practice, freetype bundling is only enabled on Windows anyways.
>
> Magnus Ihse Bursie has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Move the file out of "src" as it is not part of upstream lib

If I understand correctly, this is a "new" requirement because of the need to support static builds ?

Seems odd if the library doesn't actually use JNI. And what if the JDK is trying to load  a library that is not part of the JDK ?

>  freetype bundling is only enabled on Windows anyways.

We bundle it on mac too ..

-------------

PR Comment: https://git.openjdk.org/jdk/pull/22791#issuecomment-2548742753


More information about the build-dev mailing list