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

Method CallJavaMethod

test-app/runtime/src/main/cpp/CallbackHandlers.cpp:199–549  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199void CallbackHandlers::CallJavaMethod(const Local<Object> &caller, const string &className,
200 const string &methodName, MetadataEntry *entry,
201 bool isFromInterface, bool isStatic,
202 bool isSuper,
203 const v8::FunctionCallbackInfo<v8::Value> &args) {
204 SET_PROFILER_FRAME();
205
206 JEnv env;
207
208 jclass clazz;
209 jmethodID mid;
210 string *sig = nullptr;
211 string *returnType = nullptr;
212 auto retType = MethodReturnType::Unknown;
213 MethodCache::CacheMethodInfo mi;
214
215 auto isolate = args.GetIsolate();
216
217 if ((entry != nullptr) && entry->getIsResolved()) {
218 auto &entrySignature = entry->getSig();
219 isStatic = entry->isStatic;
220
221 if (entry->memberId == nullptr) {
222 clazz = env.FindClass(className);
223
224 if (clazz == nullptr) {
225 MetadataNode *callerNode = MetadataNode::GetNodeFromHandle(caller);
226 const string callerClassName = callerNode->GetName();
227
228 DEBUG_WRITE("Cannot resolve class: %s while calling method: %s callerClassName: %s",
229 className.c_str(), methodName.c_str(), callerClassName.c_str());
230 clazz = env.FindClass(callerClassName);
231 if (clazz == nullptr) {
232 //todo: plamen5kov: throw exception here
233 DEBUG_WRITE("Cannot resolve caller's class name: %s", callerClassName.c_str());
234 return;
235 }
236
237 if (isStatic) {
238 if (isFromInterface) {
239 auto methodAndClassPair = env.GetInterfaceStaticMethodIDAndJClass(className,
240 methodName,
241 entrySignature);
242 entry->memberId = methodAndClassPair.first;
243 clazz = methodAndClassPair.second;
244 } else {
245 entry->memberId = env.GetStaticMethodID(clazz, methodName, entrySignature);
246 }
247 } else {
248 entry->memberId = env.GetMethodID(clazz, methodName, entrySignature);
249 }
250
251 if (entry->memberId == nullptr) {
252 //todo: plamen5kov: throw exception here
253 DEBUG_WRITE("Cannot resolve a method %s on caller class: %s",
254 methodName.c_str(), callerClassName.c_str());
255 return;
256 }

Callers

nothing calls this directly

Calls 15

JsArgConverterClass · 0.85
getIsResolvedMethod · 0.80
GetStaticMethodIDMethod · 0.80
GetMethodIDMethod · 0.80
getRetTypeMethod · 0.80
GetObjectManagerMethod · 0.80
IsConstructCallMethod · 0.80
CallStaticVoidMethodAMethod · 0.80
CallVoidMethodAMethod · 0.80

Tested by

no test coverage detected