Skip to content

Commit fe55852

Browse files
committed
Append /lib to LIBPATH if it is not present on z/OS Java 21+
Currently Java 21 and up on z/OS build with system zlib under /lib. Append it to LIBPATH so that system zlib can be resolved. Signed-off-by: Hang Shao <[email protected]>
1 parent 941f56a commit fe55852

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

runtime/j9vm/jvm.c

Lines changed: 14 additions & 6 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
@@ -2059,13 +2059,21 @@ JNI_CreateJavaVM_impl(JavaVM **pvm, void **penv, void *vm_args, BOOLEAN isJITSer
20592059
* Example libpath:
20602060
* LIBPATH=/jre/lib/ppc64/j9vm:/jre/lib/ppc64:/jre/lib/ppc64/jli:/jre/../lib/ppc64:/usr/lib
20612061
*/
2062-
2062+
#if defined(AIXPPC)
2063+
const char *usrLib = "/usr/lib";
2064+
const UDATA usrLibLength = LITERAL_STRLEN("/usr/lib");
2065+
#else /* defined(AIXPPC) */
2066+
/**
2067+
* Currently Java 21 and up on z/OS build with system zlib: /lib/libzz64.so. If /lib isn't already present in LIBPATH, append it to the end,
2068+
* so that system zlib can be resolved.
2069+
*/
2070+
const char *usrLib = "/lib";
2071+
const UDATA usrLibLength = LITERAL_STRLEN("/lib");
2072+
#endif /* defined(AIXPPC) */
20632073
const char *currentLibPath = getenv("LIBPATH");
20642074
BOOLEAN appendToLibPath = TRUE;
20652075
if (NULL != currentLibPath) {
20662076
const size_t currentLibPathLength = strlen(currentLibPath);
2067-
const char *usrLib = "/usr/lib";
2068-
const UDATA usrLibLength = LITERAL_STRLEN("/usr/lib");
20692077
const char *needle = strstr(currentLibPath, usrLib);
20702078
while (NULL != needle) {
20712079
/* Note, inside the loop we're guaranteed to have
@@ -2085,7 +2093,7 @@ JNI_CreateJavaVM_impl(JavaVM **pvm, void **penv, void *vm_args, BOOLEAN isJITSer
20852093
}
20862094
}
20872095
if (appendToLibPath) {
2088-
addToLibpath("/usr/lib", FALSE);
2096+
addToLibpath(usrLib, FALSE);
20892097
}
20902098
}
20912099
/* CMVC 135358.
@@ -2095,7 +2103,7 @@ JNI_CreateJavaVM_impl(JavaVM **pvm, void **penv, void *vm_args, BOOLEAN isJITSer
20952103
* result from above.
20962104
*/
20972105
origLibpath = getenv("LIBPATH");
2098-
#endif
2106+
#endif /* defined(AIXPPC) || (defined(J9ZOS390) && (JAVA_SPEC_VERSION >= 21)) */
20992107

21002108
/* no tracing for this function, since it's unlikely to be used once the VM is running and the trace engine is initialized */
21012109
preloadLibraries();

0 commit comments

Comments
 (0)