Skip to content

Commit 332d87c

Browse files
committed
8349859: Support static JDK in libfontmanager/freetypeScaler.c
Reviewed-by: prr
1 parent 73e1780 commit 332d87c

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

make/modules/java.desktop/lib/ClientLibraries.gmk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBFONTMANAGER, \
407407
LDFLAGS_aix := -Wl$(COMMA)-berok, \
408408
JDK_LIBS := libawt java.base:libjava $(LIBFONTMANAGER_JDK_LIBS), \
409409
JDK_LIBS_macosx := libawt_lwawt, \
410+
JDK_LIBS_unix := java.base:libjvm, \
410411
LIBS := $(LIBFONTMANAGER_LIBS), \
411412
LIBS_unix := $(LIBM), \
412413
LIBS_macosx := \

src/java.desktop/share/native/libfontmanager/freetypeScaler.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <stdlib.h>
3333
#if !defined(_WIN32) && !defined(__APPLE_)
3434
#include <dlfcn.h>
35+
#include "jvm.h"
3536
#endif
3637
#include <math.h>
3738
#include "ft2build.h"
@@ -298,6 +299,19 @@ static void setInterpreterVersion(FT_Library library) {
298299
#if defined(_WIN32) || defined(__APPLE__)
299300
FT_Property_Set(library, module, property, (void*)(&version));
300301
#else
302+
303+
if (JVM_IsStaticallyLinked()) {
304+
// The bundled libfreetype may be statically linked with
305+
// the launcher.
306+
if (dlsym(RTLD_DEFAULT, "FT_Property_Set") != NULL) {
307+
FT_Property_Set(library, module, property, (void*)(&version));
308+
return;
309+
}
310+
311+
// libfreetype is not statically linked with the executable,
312+
// fall through to find the system provided library dynamically.
313+
}
314+
301315
void *lib = dlopen("libfreetype.so", RTLD_LOCAL|RTLD_LAZY);
302316
if (lib == NULL) {
303317
lib = dlopen("libfreetype.so.6", RTLD_LOCAL|RTLD_LAZY);

0 commit comments

Comments
 (0)