From 7257c23e208189e95f42338d435ea4b3516368d0 Mon Sep 17 00:00:00 2001 From: plamen5kov Date: Fri, 20 Feb 2015 11:43:58 +0200 Subject: [PATCH] resolved issue #20 - Hidden JSinstance info ... raised --- src/jni/MetadataNode.cpp | 10 ++++++---- src/jni/NativeScriptRuntime.cpp | 10 ++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/jni/MetadataNode.cpp b/src/jni/MetadataNode.cpp index fc4ce80c0..c0a0178e2 100644 --- a/src/jni/MetadataNode.cpp +++ b/src/jni/MetadataNode.cpp @@ -1344,11 +1344,13 @@ void MetadataNode::SetterCallback(Local property, Local value, co { if(first.isFinal) { - Isolate *isolate(Isolate::GetCurrent()); - Handle exceptionMessage = ConvertToV8String("You are trying to SET a final field! Final fields can only be read."); - Local IllegalAccessException(exceptionMessage); + stringstream ss; + ss << "You are trying to SET \"" << first.name << "\" which is a final field! Final fields can only be read."; + string exceptionMessage = ss.str(); - isolate->ThrowException(IllegalAccessException); + Isolate *isolate(Isolate::GetCurrent()); + isolate->ThrowException(v8::Exception::Error((ConvertToV8String(exceptionMessage)))); + return; } s_setJavaField(thiz, value, node->m_name, first.name, first.sig, first.declaringType, first.isStatic); diff --git a/src/jni/NativeScriptRuntime.cpp b/src/jni/NativeScriptRuntime.cpp index 10ac5a290..2ed80a3cf 100644 --- a/src/jni/NativeScriptRuntime.cpp +++ b/src/jni/NativeScriptRuntime.cpp @@ -186,6 +186,16 @@ void NativeScriptRuntime::CallJavaMethod(const Handle& caller, const str if (!isStatic) { callerJavaObject = objectManager->GetJavaObjectByJsObject(caller); + if(callerJavaObject == nullptr) + { + Isolate *isolate = Isolate::GetCurrent(); + stringstream ss; + ss << "No java object found on which to call \"" << methodName << "\" method. It is possible your Javascript object is not linked with the corresponding Java class. Try passing context(this) to the constructor function."; + string exceptionMessage = ss.str(); + isolate->ThrowException(v8::Exception::ReferenceError(ConvertToV8String(exceptionMessage))); + return; + } + if (isSuper) { clazz = env.FindClass(className);