| 391 | } |
| 392 | |
| 393 | void Runtime::CreateJSInstanceNative(JNIEnv* _env, jobject obj, |
| 394 | jobject javaObject, jint javaObjectID, |
| 395 | jstring className) { |
| 396 | SET_PROFILER_FRAME(); |
| 397 | |
| 398 | DEBUG_WRITE("createJSInstanceNative called"); |
| 399 | |
| 400 | auto isolate = m_isolate; |
| 401 | |
| 402 | JEnv env(_env); |
| 403 | |
| 404 | string existingClassName = ArgConverter::jstringToString(className); |
| 405 | string jniName = Util::ConvertFromCanonicalToJniName(existingClassName); |
| 406 | Local<Object> jsInstance; |
| 407 | Local<Object> implementationObject; |
| 408 | |
| 409 | auto proxyClassName = m_objectManager->GetClassName(javaObject); |
| 410 | DEBUG_WRITE("createJSInstanceNative class %s", proxyClassName.c_str()); |
| 411 | jsInstance = MetadataNode::CreateExtendedJSWrapper(isolate, m_objectManager, |
| 412 | proxyClassName); |
| 413 | |
| 414 | if (jsInstance.IsEmpty()) { |
| 415 | throw NativeScriptException( |
| 416 | string("Failed to create JavaScript extend wrapper for class '" + |
| 417 | proxyClassName + "'")); |
| 418 | } |
| 419 | |
| 420 | implementationObject = |
| 421 | MetadataNode::GetImplementationObject(isolate, jsInstance); |
| 422 | if (implementationObject.IsEmpty()) { |
| 423 | string msg("createJSInstanceNative: implementationObject is empty"); |
| 424 | throw NativeScriptException(msg); |
| 425 | } |
| 426 | DEBUG_WRITE("createJSInstanceNative: implementationObject :%d", |
| 427 | implementationObject->GetIdentityHash()); |
| 428 | |
| 429 | jclass clazz = env.FindClass(jniName); |
| 430 | m_objectManager->Link(jsInstance, javaObjectID, clazz); |
| 431 | } |
| 432 | |
| 433 | jint Runtime::GenerateNewObjectId(JNIEnv* env, jobject obj) { |
| 434 | int objectId = m_objectManager->GenerateNewObjectID(); |
no test coverage detected