From 79bbda59f8dee4544facdcbec10fc0df025bab97 Mon Sep 17 00:00:00 2001 From: blagoev Date: Mon, 6 Jul 2015 21:36:38 +0300 Subject: [PATCH 1/5] copy the correct android.jar. Correct is the jar pointed by the target property from project.properties file Do not copy over the file if it is already there and the same --- build/project-template/custom_rules.xml | 61 +++++++++++-------------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/build/project-template/custom_rules.xml b/build/project-template/custom_rules.xml index 999b13a63..05cea3c7a 100644 --- a/build/project-template/custom_rules.xml +++ b/build/project-template/custom_rules.xml @@ -24,43 +24,36 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + Resolving Android.jar and Build Target for ${ant.project.name}... + + + + + + + + Using android.jar from ${project.target.android.jar} + + + + + - - - - - - - - - - From f0162fdd4e682e2bf952dc9c4e490709ca45187e Mon Sep 17 00:00:00 2001 From: blagoev Date: Wed, 8 Jul 2015 13:42:48 +0300 Subject: [PATCH 2/5] fix project template build --- build/project-template/custom_rules.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/project-template/custom_rules.xml b/build/project-template/custom_rules.xml index 05cea3c7a..882c089d9 100644 --- a/build/project-template/custom_rules.xml +++ b/build/project-template/custom_rules.xml @@ -79,7 +79,7 @@ - + - + From c7bbabb2ea8df93d7d449050f83d6d3b8297fff1 Mon Sep 17 00:00:00 2001 From: blagoev Date: Wed, 15 Jul 2015 15:51:18 +0300 Subject: [PATCH 3/5] use the class of the existing child when calling base classes that are not present in the current version of the android framework. --- src/jni/NativeScriptRuntime.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/jni/NativeScriptRuntime.cpp b/src/jni/NativeScriptRuntime.cpp index 9b39ef75d..663be100f 100644 --- a/src/jni/NativeScriptRuntime.cpp +++ b/src/jni/NativeScriptRuntime.cpp @@ -203,7 +203,16 @@ void NativeScriptRuntime::CallJavaMethod(const Handle& caller, const str entry->clazz = env.FindClass(className); if (entry->clazz == nullptr) { - DEBUG_WRITE("Cannot resolve class=%s while calling method %s", className.c_str(), methodName.c_str()); + MetadataNode* callerNode = MetadataNode::GetNodeFromHandle(caller); + const string callerClassName = callerNode->GetName(); + + DEBUG_WRITE("Cannot resolve class: %s while calling method: %s callerNode: %s", className.c_str(), methodName.c_str(), callerNode->GetName().c_str()); + entry->clazz = env.FindClass(callerClassName); + if (entry->clazz == nullptr) + { + ASSERT_FAIL("Cannot resolve caller's class name: %s", callerClassName.c_str()); + APP_FAIL("Cannot resolve caller's class name"); + } } entry->memberId = isStatic From 75737918325f05e543a5a6a572ac734feb5960e8 Mon Sep 17 00:00:00 2001 From: blagoev Date: Thu, 16 Jul 2015 11:57:34 +0300 Subject: [PATCH 4/5] fix for method resolving when class hierarchy is not the same as in the MetadataNode do not set the memberId when the class of the MetadataEntry is not found --- src/jni/NativeScriptRuntime.cpp | 87 +++++++++++++++++++++++++++++---- 1 file changed, 77 insertions(+), 10 deletions(-) diff --git a/src/jni/NativeScriptRuntime.cpp b/src/jni/NativeScriptRuntime.cpp index 663be100f..8f20effda 100644 --- a/src/jni/NativeScriptRuntime.cpp +++ b/src/jni/NativeScriptRuntime.cpp @@ -198,6 +198,7 @@ void NativeScriptRuntime::CallJavaMethod(const Handle& caller, const str if ((entry != nullptr) && entry->isResolved) { isStatic = entry->isStatic; + if (entry->memberId == nullptr) { entry->clazz = env.FindClass(className); @@ -206,31 +207,97 @@ void NativeScriptRuntime::CallJavaMethod(const Handle& caller, const str MetadataNode* callerNode = MetadataNode::GetNodeFromHandle(caller); const string callerClassName = callerNode->GetName(); - DEBUG_WRITE("Cannot resolve class: %s while calling method: %s callerNode: %s", className.c_str(), methodName.c_str(), callerNode->GetName().c_str()); - entry->clazz = env.FindClass(callerClassName); - if (entry->clazz == nullptr) + DEBUG_WRITE("Cannot resolve class: %s while calling method: %s callerClassName: %s", className.c_str(), methodName.c_str(), callerClassName.c_str()); + clazz = env.FindClass(callerClassName); + if (clazz == nullptr) { ASSERT_FAIL("Cannot resolve caller's class name: %s", callerClassName.c_str()); APP_FAIL("Cannot resolve caller's class name"); + return; } + + mid = isStatic ? + env.GetStaticMethodID(clazz, methodName, entry->sig) : + env.GetMethodID(clazz, methodName, entry->sig); + } + else + { + entry->memberId = isStatic ? + env.GetStaticMethodID(entry->clazz, methodName, entry->sig) : + env.GetMethodID(entry->clazz, methodName, entry->sig); } - entry->memberId = isStatic - ? env.GetStaticMethodID(entry->clazz, methodName, entry->sig) - : env.GetMethodID(entry->clazz, methodName, entry->sig); + + } + + if (entry->clazz != nullptr) + { + clazz = entry->clazz; + mid = reinterpret_cast(entry->memberId); } - clazz = entry->clazz; - mid = reinterpret_cast(entry->memberId); + sig = entry->sig; + + +// if (entry->memberId == nullptr) +// { +// entry->clazz = env.FindClass(className); +// if (entry->clazz == nullptr) +// { +// MetadataNode* callerNode = MetadataNode::GetNodeFromHandle(caller); +// const string callerClassName = callerNode->GetName(); +// +// DEBUG_WRITE("Cannot resolve class: %s while calling method: %s callerClassName: %s", className.c_str(), methodName.c_str(), callerClassName.c_str()); +// clazz = env.FindClass(callerClassName); +// if (clazz == nullptr) +// { +// ASSERT_FAIL("Cannot resolve caller's class name: %s", callerClassName.c_str()); +// APP_FAIL("Cannot resolve caller's class name"); +// return; +// } +// } +// else +// { +// clazz = entry->clazz; +// } +// +// entry->memberId = isStatic ? +// env.GetStaticMethodID(clazz, methodName, entry->sig) : +// env.GetMethodID(clazz, methodName, entry->sig); +// } +// +// if (entry->clazz != nullptr) +// { +// clazz = entry->clazz; +// } +// +// mid = reinterpret_cast(entry->memberId); +// sig = entry->sig; } else { + //nameri pravilnia klass koito e definiral tova ime za tekustata platforma + //spesti resolvemethod call ako clasa s ime className go niama i tarsi napravo ot object na dolu koi e definiral tozi method i + //vikai resolve na nego + //sled tova zapazi v entrito na metoda koi e iskinskia className. to realno parametara classname idva nai veroiatno ot entrito + //prosto mu smeni imeto + + DEBUG_WRITE("Resolving method: %s.%s on className %s", className.c_str(), methodName.c_str(), className.c_str()); auto mi = MethodCache::ResolveMethodSignature(className, methodName, args, isStatic); if (mi.mid == nullptr) { - DEBUG_WRITE("Cannot resolve class=%s, method=%s, isStatic=%d, isSuper=%d", className.c_str(), methodName.c_str(), isStatic, isSuper); - return; + MetadataNode* callerNode = MetadataNode::GetNodeFromHandle(caller); + const string callerClassName = callerNode->GetName(); + DEBUG_WRITE("Resolving method on callers class: %s.%s on className %s", callerClassName.c_str(), methodName.c_str(), className.c_str()); + mi = MethodCache::ResolveMethodSignature(callerClassName, methodName, args, isStatic); + if (mi.mid == nullptr) + { + ASSERT_FAIL("Cannot resolve class=%s, method=%s, isStatic=%d, isSuper=%d, callerClass=%s", className.c_str(), methodName.c_str(), isStatic, isSuper, callerClassName.c_str()); + APP_FAIL("Cannot resolve class"); + return; + } } + clazz = mi.clazz; mid = mi.mid; sig = mi.signature; From e507d7574a549c81cdd620fa888dc9fe6e473a61 Mon Sep 17 00:00:00 2001 From: blagoev Date: Thu, 16 Jul 2015 13:51:30 +0300 Subject: [PATCH 5/5] check for method found before trying to invoke it removed commented code --- src/jni/NativeScriptRuntime.cpp | 51 ++++----------------------------- 1 file changed, 6 insertions(+), 45 deletions(-) diff --git a/src/jni/NativeScriptRuntime.cpp b/src/jni/NativeScriptRuntime.cpp index 8f20effda..f9cba2689 100644 --- a/src/jni/NativeScriptRuntime.cpp +++ b/src/jni/NativeScriptRuntime.cpp @@ -212,7 +212,6 @@ void NativeScriptRuntime::CallJavaMethod(const Handle& caller, const str if (clazz == nullptr) { ASSERT_FAIL("Cannot resolve caller's class name: %s", callerClassName.c_str()); - APP_FAIL("Cannot resolve caller's class name"); return; } @@ -225,9 +224,13 @@ void NativeScriptRuntime::CallJavaMethod(const Handle& caller, const str entry->memberId = isStatic ? env.GetStaticMethodID(entry->clazz, methodName, entry->sig) : env.GetMethodID(entry->clazz, methodName, entry->sig); - } - + if (entry->memberId == nullptr) + { + ASSERT_FAIL("Cannot resolve a method %s on class: %s", methodName.c_str(), className.c_str()); + return; + } + } } if (entry->clazz != nullptr) @@ -237,51 +240,9 @@ void NativeScriptRuntime::CallJavaMethod(const Handle& caller, const str } sig = entry->sig; - - -// if (entry->memberId == nullptr) -// { -// entry->clazz = env.FindClass(className); -// if (entry->clazz == nullptr) -// { -// MetadataNode* callerNode = MetadataNode::GetNodeFromHandle(caller); -// const string callerClassName = callerNode->GetName(); -// -// DEBUG_WRITE("Cannot resolve class: %s while calling method: %s callerClassName: %s", className.c_str(), methodName.c_str(), callerClassName.c_str()); -// clazz = env.FindClass(callerClassName); -// if (clazz == nullptr) -// { -// ASSERT_FAIL("Cannot resolve caller's class name: %s", callerClassName.c_str()); -// APP_FAIL("Cannot resolve caller's class name"); -// return; -// } -// } -// else -// { -// clazz = entry->clazz; -// } -// -// entry->memberId = isStatic ? -// env.GetStaticMethodID(clazz, methodName, entry->sig) : -// env.GetMethodID(clazz, methodName, entry->sig); -// } -// -// if (entry->clazz != nullptr) -// { -// clazz = entry->clazz; -// } -// -// mid = reinterpret_cast(entry->memberId); -// sig = entry->sig; } else { - //nameri pravilnia klass koito e definiral tova ime za tekustata platforma - //spesti resolvemethod call ako clasa s ime className go niama i tarsi napravo ot object na dolu koi e definiral tozi method i - //vikai resolve na nego - //sled tova zapazi v entrito na metoda koi e iskinskia className. to realno parametara classname idva nai veroiatno ot entrito - //prosto mu smeni imeto - DEBUG_WRITE("Resolving method: %s.%s on className %s", className.c_str(), methodName.c_str(), className.c_str()); auto mi = MethodCache::ResolveMethodSignature(className, methodName, args, isStatic); if (mi.mid == nullptr)