Skip to content

Commit fed262a

Browse files
committed
8306949: Resolve miscellaneous multiple symbol definition issues when statically linking JDK/VM natives with standard launcher
Reviewed-by: alanb
1 parent 96cdf93 commit fed262a

File tree

11 files changed

+27
-28
lines changed

11 files changed

+27
-28
lines changed

src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -55,7 +55,7 @@ Boolean awt_ModLockIsShiftLock = False;
5555
static int32_t num_buttons = 0;
5656
int32_t getNumButtons();
5757

58-
extern JavaVM *jvm;
58+
extern JavaVM *jvm_xawt;
5959

6060
// Tracing level
6161
static int tracing = 0;
@@ -130,7 +130,7 @@ JNIEXPORT jlong JNICALL Java_sun_awt_X11_XToolkit_getDefaultXColormap
130130
JNIEXPORT jint JNICALL
131131
DEF_JNI_OnLoad(JavaVM *vm, void *reserved)
132132
{
133-
jvm = vm;
133+
jvm_xawt = vm;
134134

135135
//Set the gtk backend to x11 on all the systems
136136
putenv("GDK_BACKEND=x11");
@@ -698,7 +698,7 @@ performPoll(JNIEnv *env, jlong nextTaskTime) {
698698
*/
699699
void awt_output_flush() {
700700
if (awt_next_flush_time == 0) {
701-
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
701+
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm_xawt, JNI_VERSION_1_2);
702702

703703
jlong curTime = awtJNI_TimeMillis(); // current time
704704
jlong l_awt_last_flush_time = awt_last_flush_time; // last time we flushed queue

src/java.desktop/unix/native/libawt_xawt/xawt/XlibWrapper.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -1324,15 +1324,15 @@ JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XlibWrapper_IsKanaKeyboard
13241324
return result ? JNI_TRUE : JNI_FALSE;
13251325
}
13261326

1327-
JavaVM* jvm = NULL;
1327+
JavaVM* jvm_xawt = NULL;
13281328
static int ToolkitErrorHandler(Display * dpy, XErrorEvent * event) {
13291329
JNIEnv * env;
13301330
// First call the native synthetic error handler declared in "awt_util.h" file.
13311331
if (current_native_xerror_handler != NULL) {
13321332
current_native_xerror_handler(dpy, event);
13331333
}
1334-
if (jvm != NULL) {
1335-
env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
1334+
if (jvm_xawt != NULL) {
1335+
env = (JNIEnv *)JNU_GetEnv(jvm_xawt, JNI_VERSION_1_2);
13361336
if (env) {
13371337
return JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XErrorHandlerUtil",
13381338
"globalErrorHandler", "(JJ)I", ptr_to_jlong(dpy), ptr_to_jlong(event)).i;
@@ -1349,7 +1349,7 @@ static int ToolkitErrorHandler(Display * dpy, XErrorEvent * event) {
13491349
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XlibWrapper_SetToolkitErrorHandler
13501350
(JNIEnv *env, jclass clazz)
13511351
{
1352-
if ((*env)->GetJavaVM(env, &jvm) < 0) {
1352+
if ((*env)->GetJavaVM(env, &jvm_xawt) < 0) {
13531353
return 0;
13541354
}
13551355
AWT_CHECK_HAVE_LOCK_RETURN(0);

src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -35,8 +35,7 @@
3535
#include "jni_util.h"
3636
#include "awt_Taskbar.h"
3737

38-
39-
extern JavaVM *jvm;
38+
extern JavaVM *jvm_xawt;
4039

4140
#define NO_SYMBOL_EXCEPTION 1
4241

@@ -100,7 +99,7 @@ static gboolean unity_load() {
10099
}
101100

102101
void callback(DbusmenuMenuitem* mi, guint ts, jobject data) {
103-
JNIEnv* env = (JNIEnv*) JNU_GetEnv(jvm, JNI_VERSION_1_2);
102+
JNIEnv* env = (JNIEnv*) JNU_GetEnv(jvm_xawt, JNI_VERSION_1_2);
104103
(*env)->CallStaticVoidMethod(env, jTaskbarCls, jTaskbarCallback, data);
105104
}
106105

@@ -196,7 +195,7 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_updateProgress
196195
}
197196

198197
void deleteGlobalRef(gpointer data) {
199-
JNIEnv* env = (JNIEnv*) JNU_GetEnv(jvm, JNI_VERSION_1_2);
198+
JNIEnv* env = (JNIEnv*) JNU_GetEnv(jvm_xawt, JNI_VERSION_1_2);
200199
(*env)->DeleteGlobalRef(env, data);
201200
}
202201

src/java.smartcardio/unix/native/libj2pcsc/pcsc_md.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static void throwIOException(JNIEnv *env, const char *msg)
7575
throwByName(env, "java/io/IOException", msg);
7676
}
7777

78-
void *findFunction(JNIEnv *env, void *hModule, char *functionName) {
78+
static void *findFunction(JNIEnv *env, void *hModule, char *functionName) {
7979
void *fAddress = dlsym(hModule, functionName);
8080
if (fAddress == NULL) {
8181
char errorMessage[256];

src/jdk.crypto.cryptoki/share/native/libj2pkcs11/j2secmod.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,7 @@ JNIEXPORT jboolean JNICALL Java_sun_security_pkcs11_Secmod_nssVersionCheck
4040
FPTR_VersionCheck versionCheck;
4141
const char *requiredVersion;
4242

43-
versionCheck = (FPTR_VersionCheck)findFunction(env, jHandle,
43+
versionCheck = (FPTR_VersionCheck)p11FindFunction(env, jHandle,
4444
"NSS_VersionCheck");
4545
if (versionCheck == NULL) {
4646
return JNI_FALSE;
@@ -68,10 +68,10 @@ JNIEXPORT jboolean JNICALL Java_sun_security_pkcs11_Secmod_nssInitialize
6868
{
6969
int res = 0;
7070
FPTR_Initialize initialize =
71-
(FPTR_Initialize)findFunction(env, jHandle, "NSS_Initialize");
71+
(FPTR_Initialize)p11FindFunction(env, jHandle, "NSS_Initialize");
7272
#ifdef SECMOD_DEBUG
7373
FPTR_GetError getError =
74-
(FPTR_GetError)findFunction(env, jHandle, "PORT_GetError");
74+
(FPTR_GetError)p11FindFunction(env, jHandle, "PORT_GetError");
7575
#endif // SECMOD_DEBUG
7676
unsigned int flags = 0x00;
7777
const char *configDir = NULL;
@@ -162,7 +162,7 @@ JNIEXPORT jobject JNICALL Java_sun_security_pkcs11_Secmod_nssGetModuleList
162162
(JNIEnv *env, jclass thisClass, jlong jHandle, jstring jLibDir)
163163
{
164164
FPTR_GetDBModuleList getModuleList =
165-
(FPTR_GetDBModuleList)findFunction(env, jHandle, "SECMOD_GetDefaultModuleList");
165+
(FPTR_GetDBModuleList)p11FindFunction(env, jHandle, "SECMOD_GetDefaultModuleList");
166166

167167
SECMODModuleList *list;
168168
SECMODModule *module;

src/jdk.crypto.cryptoki/share/native/libj2pkcs11/j2secmod.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,7 @@
3434
#include "p11_md.h"
3535

3636

37-
void *findFunction(JNIEnv *env, jlong jHandle, const char *functionName);
37+
void *p11FindFunction(JNIEnv *env, jlong jHandle, const char *functionName);
3838

3939
#ifdef SECMOD_DEBUG
4040
#define dprintf(s) printf(s)

src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_general.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jclass jLongClass;
7575

7676
JavaVM* jvm_j2pkcs11 = NULL;
7777

78-
jboolean debug = 0;
78+
jboolean debug_j2pkcs11 = 0;
7979

8080
JNIEXPORT jint JNICALL DEF_JNI_OnLoad(JavaVM *vm, void *reserved) {
8181
jvm_j2pkcs11 = vm;
@@ -122,7 +122,7 @@ Java_sun_security_pkcs11_wrapper_PKCS11_initializeLibrary
122122
#endif
123123

124124
prefetchFields(env, thisClass);
125-
debug = enableDebug;
125+
debug_j2pkcs11 = enableDebug;
126126
}
127127

128128
jclass fetchClass(JNIEnv *env, const char *name) {

src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,7 @@ void p11free(void *p, char *file, int line) {
13341334

13351335
// prints a message to stdout if debug output is enabled
13361336
void printDebug(const char *format, ...) {
1337-
if (debug == JNI_TRUE) {
1337+
if (debug_j2pkcs11 == JNI_TRUE) {
13381338
va_list args;
13391339
fprintf(stdout, "sunpkcs11: ");
13401340
va_start(args, format);

src/jdk.crypto.cryptoki/share/native/libj2pkcs11/pkcs11wrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@
231231
#endif
232232

233233
/* debug output */
234-
extern jboolean debug;
234+
extern jboolean debug_j2pkcs11;
235235
void printDebug(const char *format, ...);
236236

237237
#define CK_ASSERT_OK 0L

src/jdk.crypto.cryptoki/unix/native/libj2pkcs11/j2secmod_md.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include "j2secmod.h"
3535
#include "pkcs11wrapper.h"
3636

37-
void *findFunction(JNIEnv *env, jlong jHandle, const char *functionName) {
37+
void *p11FindFunction(JNIEnv *env, jlong jHandle, const char *functionName) {
3838
void *hModule = (void*)jlong_to_ptr(jHandle);
3939
void *fAddress = dlsym(hModule, functionName);
4040
if (fAddress == NULL) {

src/jdk.crypto.cryptoki/windows/native/libj2pkcs11/j2secmod_md.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
extern void p11ThrowNullPointerException(JNIEnv *env, const char *message);
3535
extern void p11ThrowIOException(JNIEnv *env, const char *message);
3636

37-
void *findFunction(JNIEnv *env, jlong jHandle, const char *functionName) {
37+
void *p11FindFunction(JNIEnv *env, jlong jHandle, const char *functionName) {
3838
HINSTANCE hModule = (HINSTANCE)jHandle;
3939
void *fAddress = GetProcAddress(hModule, functionName);
4040
if (fAddress == NULL) {

0 commit comments

Comments
 (0)