From da88423f0264171ac0c9fb77fb8e23067b680cb1 Mon Sep 17 00:00:00 2001 From: "Keith W. Campbell" Date: Tue, 29 Aug 2023 17:51:52 -0400 Subject: [PATCH 1/2] Correct return type of JVM_LoadZipLibrary() Signed-off-by: Keith W. Campbell --- runtime/j9vm/javanextvmi.cpp | 3 ++- runtime/redirector/forwarders.m4 | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/runtime/j9vm/javanextvmi.cpp b/runtime/j9vm/javanextvmi.cpp index 1d501b1de3f..73434f85627 100644 --- a/runtime/j9vm/javanextvmi.cpp +++ b/runtime/j9vm/javanextvmi.cpp @@ -220,10 +220,11 @@ JVM_ReportFinalizationComplete(JNIEnv *env, jobject obj) #endif /* JAVA_SPEC_VERSION >= 18 */ #if JAVA_SPEC_VERSION >= 19 -JNIEXPORT void JNICALL +JNIEXPORT void * JNICALL JVM_LoadZipLibrary(void) { Assert_SC_true(!"JVM_LoadZipLibrary unimplemented"); + return NULL; } JNIEXPORT void JNICALL diff --git a/runtime/redirector/forwarders.m4 b/runtime/redirector/forwarders.m4 index 9c31e5852e4..230cf13dfd3 100644 --- a/runtime/redirector/forwarders.m4 +++ b/runtime/redirector/forwarders.m4 @@ -390,7 +390,7 @@ _IF([JAVA_SPEC_VERSION >= 18], _IF([JAVA_SPEC_VERSION >= 18], [_X(JVM_ReportFinalizationComplete, JNICALL, false, void, JNIEnv *env, jobject obj)]) _IF([JAVA_SPEC_VERSION >= 19], - [_X(JVM_LoadZipLibrary, JNICALL, false, void, void)]) + [_X(JVM_LoadZipLibrary, JNICALL, false, void *, void)]) _IF([JAVA_SPEC_VERSION >= 19], [_X(JVM_RegisterContinuationMethods, JNICALL, false, void, JNIEnv *env, jclass clz)]) _IF([JAVA_SPEC_VERSION >= 19], From 1578cc5b61fe7d19a0c0bb478f3be52c0a8d9b5a Mon Sep 17 00:00:00 2001 From: "Keith W. Campbell" Date: Tue, 29 Aug 2023 17:51:52 -0400 Subject: [PATCH 2/2] Correct return type of JVM_LoadZipLibrary() Signed-off-by: Keith W. Campbell wip Signed-off-by: Keith W. Campbell Implement JVM_LoadZipLibrary() Signed-off-by: Keith W. Campbell --- runtime/j9vm/javanextvmi.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/runtime/j9vm/javanextvmi.cpp b/runtime/j9vm/javanextvmi.cpp index 73434f85627..b06eb62f633 100644 --- a/runtime/j9vm/javanextvmi.cpp +++ b/runtime/j9vm/javanextvmi.cpp @@ -223,8 +223,26 @@ JVM_ReportFinalizationComplete(JNIEnv *env, jobject obj) JNIEXPORT void * JNICALL JVM_LoadZipLibrary(void) { - Assert_SC_true(!"JVM_LoadZipLibrary unimplemented"); - return NULL; + void *zipHandle = NULL; + J9JavaVM *vm = BFUjavaVM; + + if (NULL != vm) { + PORT_ACCESS_FROM_JAVAVM(vm); + uintptr_t handle = 0; + + if (J9PORT_SL_FOUND == j9sl_open_shared_library( + (char *)"zip", + &handle, + OMRPORT_SLOPEN_DECORATE | OMRPORT_SLOPEN_LAZY) + ) { + zipHandle = (void *)handle; + } + } + + /* We may as well assert here: we won't make much progress without the library. */ + Assert_SC_notNull(zipHandle); + + return zipHandle; } JNIEXPORT void JNICALL