Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/jni/MetadataNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1344,11 +1344,13 @@ void MetadataNode::SetterCallback(Local<String> property, Local<Value> value, co
{
if(first.isFinal)
{
Isolate *isolate(Isolate::GetCurrent());
Handle<String> exceptionMessage = ConvertToV8String("You are trying to SET a final field! Final fields can only be read.");
Local<Value> 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);

Expand Down
10 changes: 10 additions & 0 deletions src/jni/NativeScriptRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@ void NativeScriptRuntime::CallJavaMethod(const Handle<Object>& 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);
Expand Down