This is an automated email from the ASF dual-hosted git repository.

hongze pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git


The following commit(s) were added to refs/heads/main by this push:
     new 7c069da5d6 [GLUTEN-11513][CORE] Add null checks and improve JNI 
listener initialization in JniCommon.h (#11664)
7c069da5d6 is described below

commit 7c069da5d6ca5ff8ce9749aced2952c55205ab2a
Author: Reema Alzaid <[email protected]>
AuthorDate: Fri Feb 27 13:34:43 2026 +0300

    [GLUTEN-11513][CORE] Add null checks and improve JNI listener 
initialization in JniCommon.h (#11664)
---
 cpp/core/jni/JniCommon.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/cpp/core/jni/JniCommon.h b/cpp/core/jni/JniCommon.h
index 1044edb6d7..783f8edfcc 100644
--- a/cpp/core/jni/JniCommon.h
+++ b/cpp/core/jni/JniCommon.h
@@ -99,6 +99,9 @@ static inline jmethodID getMethodId(JNIEnv* env, jclass 
thisClass, const char* n
 }
 
 static inline jmethodID getMethodIdOrError(JNIEnv* env, jclass thisClass, 
const char* name, const char* sig) {
+  if (thisClass == nullptr) {
+    throw gluten::GlutenException("Unable to find class while looking up 
method " + std::string(name));
+  }
   jmethodID ret = getMethodId(env, thisClass, name, sig);
   if (ret == nullptr) {
     std::string errorMessage = "Unable to find method " + std::string(name) + 
" within signature" + std::string(sig);
@@ -376,6 +379,10 @@ class SparkAllocationListener final : public 
gluten::AllocationListener {
     JNIEnv* env;
     attachCurrentThreadAsDaemonOrThrow(vm_, &env);
     jListenerGlobalRef_ = env->NewGlobalRef(jListenerLocalRef);
+    GLUTEN_CHECK(jListenerGlobalRef_ != nullptr, "Failed to create global 
reference for reservation listener.");
+    // Resolve JNI symbols on the creator thread to avoid first-touch 
initialization from IO threads.
+    (void)reserveMemoryMethod(env);
+    (void)unreserveMemoryMethod(env);
   }
 
   SparkAllocationListener(const SparkAllocationListener&) = delete;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to