RFR: 8346394: Bundled freetype library needs to have JNI_OnLoad for static builds [v2]
Magnus Ihse Bursie
ihse at openjdk.org
Tue Dec 17 15:53:34 UTC 2024
On Tue, 17 Dec 2024 15:21:53 GMT, Phil Race <prr at openjdk.org> wrote:
> If I understand correctly, this is a "new" requirement because of the need to support static builds ?
Yes.
> Seems odd if the library doesn't actually use JNI.
`DEF_STATIC_JNI_OnLoad` is kind of a misnomer. It really means "mark this library as a JDK library, which is included in the statically linked binary, so if a request comes to load a dynamic library by this name, just ignore it, since it is already loaded". (I am thinking about renaming the macro to be more clear on this, as part of the general cleanup on how static builds are being done..)
So what this means is that the code executing `System.loadLibrary("freetype")` will not actually try to load a `freetype.dll` and fail.
> And what if the JDK is trying to load a library that is not part of the JDK ?
Then it will not find the special marker method, and assume it will have to load it normally, as it then is a user-supplied or 3rd party dll.
> > freetype bundling is only enabled on Windows anyways.
>
> We bundle it on mac too ..
Oh, that's right. But the macOS bundling is done purely at link time, so we do not have this problem, as far as I can tell.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/22791#issuecomment-2548830757
More information about the build-dev
mailing list