From 3f56f9cf164eda27fed683131f6fc0a9e0290812 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Fri, 20 Nov 2026 16:46:05 -0300 Subject: [PATCH] fix(runtime): keep a constructed instance's recorded class CallJSMethodNative replaced the class recorded for a JS-extended instance, on the Java constructor's call into JS, with env.GetObjectClass(obj): a JNI local ref, freed when the call returned, to com.tns.Runtime's class (obj is the receiver of the native method, not the instance). The error a failed Java object lookup reports names that class, so it named com.tns.Runtime or read a dead reference. Registration already records the instance's class as a global ref. --- test-app/runtime/src/main/cpp/Runtime.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test-app/runtime/src/main/cpp/Runtime.cpp b/test-app/runtime/src/main/cpp/Runtime.cpp index 5aa20ac59..d576841cb 100644 --- a/test-app/runtime/src/main/cpp/Runtime.cpp +++ b/test-app/runtime/src/main/cpp/Runtime.cpp @@ -660,13 +660,6 @@ jobject Runtime::CallJSMethodNative(JNIEnv* _env, jobject obj, throw NativeScriptException(ss.str()); } - if (isConstructor) { - DEBUG_WRITE( - "CallJSMethodNative: Updating linked instance with its real class"); - jclass instanceClass = env.GetObjectClass(obj); - m_objectManager->SetJavaClass(jsObject, instanceClass); - } - DEBUG_WRITE("CallJSMethodNative called jsObject=%d", jsObject->GetIdentityHash());