Skip to content

Commit 3f56f9c

Browse files
committed
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.
1 parent a121063 commit 3f56f9c

1 file changed

Lines changed: 0 additions & 7 deletions

File tree

‎test-app/runtime/src/main/cpp/Runtime.cpp‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -660,13 +660,6 @@ jobject Runtime::CallJSMethodNative(JNIEnv* _env, jobject obj,
660660
throw NativeScriptException(ss.str());
661661
}
662662

663-
if (isConstructor) {
664-
DEBUG_WRITE(
665-
"CallJSMethodNative: Updating linked instance with its real class");
666-
jclass instanceClass = env.GetObjectClass(obj);
667-
m_objectManager->SetJavaClass(jsObject, instanceClass);
668-
}
669-
670663
DEBUG_WRITE("CallJSMethodNative called jsObject=%d",
671664
jsObject->GetIdentityHash());
672665

0 commit comments

Comments
 (0)