Skip to content

Commit eec0c3d

Browse files
committed
Append /lib to LIBPATH if it is not present
Signed-off-by: Hang Shao <[email protected]>
1 parent 941f56a commit eec0c3d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

runtime/j9vm/jvm.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2045,7 +2045,7 @@ JNI_CreateJavaVM_impl(JavaVM **pvm, void **penv, void *vm_args, BOOLEAN isJITSer
20452045
}
20462046
#endif
20472047

2048-
#if defined(AIXPPC)
2048+
#if defined(AIXPPC) || (defined(J9ZOS390) && (JAVA_SPEC_VERSION >= 21))
20492049
/* CMVC 137180:
20502050
* in some cases the LIBPATH does not contain /usr/lib, when
20512051
* trying to load application native libraries that are linked against
@@ -2060,12 +2060,19 @@ JNI_CreateJavaVM_impl(JavaVM **pvm, void **penv, void *vm_args, BOOLEAN isJITSer
20602060
* LIBPATH=/jre/lib/ppc64/j9vm:/jre/lib/ppc64:/jre/lib/ppc64/jli:/jre/../lib/ppc64:/usr/lib
20612061
*/
20622062

2063+
/* On z/OS Java 21 and up, if /lib isn't already present in LIBPATH, append it to the end. */
20632064
const char *currentLibPath = getenv("LIBPATH");
20642065
BOOLEAN appendToLibPath = TRUE;
20652066
if (NULL != currentLibPath) {
20662067
const size_t currentLibPathLength = strlen(currentLibPath);
2068+
#if defined(AIXPPC)
20672069
const char *usrLib = "/usr/lib";
20682070
const UDATA usrLibLength = LITERAL_STRLEN("/usr/lib");
2071+
#else /* defined(AIXPPC) */
2072+
/* on z/OS Java 21+ */
2073+
const char *usrLib = "/lib";
2074+
const UDATA usrLibLength = LITERAL_STRLEN("/lib");
2075+
#endif /* defined(AIXPPC) */
20692076
const char *needle = strstr(currentLibPath, usrLib);
20702077
while (NULL != needle) {
20712078
/* Note, inside the loop we're guaranteed to have
@@ -2085,7 +2092,7 @@ JNI_CreateJavaVM_impl(JavaVM **pvm, void **penv, void *vm_args, BOOLEAN isJITSer
20852092
}
20862093
}
20872094
if (appendToLibPath) {
2088-
addToLibpath("/usr/lib", FALSE);
2095+
addToLibpath(usrLib, FALSE);
20892096
}
20902097
}
20912098
/* CMVC 135358.

0 commit comments

Comments
 (0)