MCPcopy Create free account
hub / github.com/NativeScript/android / FindClass

Method FindClass

test-app/runtime/src/main/cpp/JEnv.cpp:722–757  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

720}
721
722jclass JEnv::FindClass(const string &className) {
723 jclass global_class = CheckForClassInCache(className);
724
725 if (global_class == nullptr) {
726 auto classIsMissing = CheckForClassMissingCache(className);
727 // class is missing. Set the same JNI error we had when we tried to find it the first time
728 if (classIsMissing != nullptr) {
729 m_env->Throw(classIsMissing);
730 return nullptr;
731 }
732 jclass tmp = m_env->FindClass(className.c_str());
733
734 if (m_env->ExceptionCheck() == JNI_TRUE) {
735 m_env->ExceptionClear();
736 string cannonicalClassName = Util::ConvertFromJniToCanonicalName(className);
737 jstring s = m_env->NewStringUTF(cannonicalClassName.c_str());
738 tmp = static_cast<jclass>(m_env->CallStaticObjectMethod(RUNTIME_CLASS,
739 GET_CACHED_CLASS_METHOD_ID, s));
740
741 m_env->DeleteLocalRef(s);
742 // we failed our static class check
743 // if we continue, we will crash (C++ level)
744 // so just return null and let the runtime deal with the NativeScriptException
745 if (m_env->ExceptionCheck() == JNI_TRUE) {
746 auto tmpException = m_env->ExceptionOccurred();
747 m_env->ExceptionClear();
748 m_env->Throw(InsertClassIntoMissingCache(className, tmpException));
749 return nullptr;
750 }
751 }
752
753 global_class = InsertClassIntoCache(className, tmp);
754 }
755
756 return global_class;
757}
758
759jclass JEnv::CheckForClassInCache(const string &className) {
760 jclass global_class = nullptr;

Callers 15

RuntimeMethod · 0.45
InitializeSecurityConfigFunction · 0.45
InitMethod · 0.45
InitMethod · 0.45
ConvertArgMethod · 0.45
ToJavaArrayMethod · 0.45
InitMethod · 0.45
InitMethod · 0.45

Calls 7

ExceptionCheckMethod · 0.80
ExceptionClearMethod · 0.80
NewStringUTFMethod · 0.80
DeleteLocalRefMethod · 0.80
ExceptionOccurredMethod · 0.80
ThrowMethod · 0.45

Tested by 1

JsV8InspectorClientMethod · 0.36