diff --git a/src/mod/languages/mod_v8/src/jsbase.cpp b/src/mod/languages/mod_v8/src/jsbase.cpp index 1cfa776837..12d65b8996 100644 --- a/src/mod/languages/mod_v8/src/jsbase.cpp +++ b/src/mod/languages/mod_v8/src/jsbase.cpp @@ -154,7 +154,11 @@ void JSBase::CreateInstance(const v8::FunctionCallbackInfo& args) } else { // Create a new C++ instance #if defined(V8_MAJOR_VERSION) && V8_MAJOR_VERSION >=5 - Handle ex = Handle::Cast(args.Callee()->GetPrivate(args.GetIsolate()->GetCurrentContext(), Private::New(args.GetIsolate(), String::NewFromUtf8(args.GetIsolate(), "constructor_method"))).ToLocalChecked()); + Isolate *isolate = args.GetIsolate(); + v8::Local context = isolate->GetCurrentContext(); + v8::Local key = String::NewFromUtf8(isolate, "constructor_method"); + v8::Local privateKey = v8::Private::ForApi(isolate, key); + Handle ex = Handle::Cast(args.Callee()->GetPrivate(context, privateKey).ToLocalChecked()); #else Handle ex = Handle::Cast(args.Callee()->GetHiddenValue(String::NewFromUtf8(args.GetIsolate(), "constructor_method"))); #endif @@ -209,7 +213,10 @@ void JSBase::Register(Isolate *isolate, const js_class_definition_t *desc) } #if defined(V8_MAJOR_VERSION) && V8_MAJOR_VERSION >=5 - function->GetFunction()->SetPrivate(isolate->GetCurrentContext(), Private::New(isolate, String::NewFromUtf8(isolate, "constructor_method")), External::New(isolate, (void *)desc->constructor)); + v8::Local context = isolate->GetCurrentContext(); + v8::Local key = String::NewFromUtf8(isolate, "constructor_method"); + v8::Local privateKey = v8::Private::ForApi(isolate, key); + function->GetFunction()->SetPrivate(context, privateKey, External::New(isolate, (void *)desc->constructor)); #else function->GetFunction()->SetHiddenValue(String::NewFromUtf8(isolate, "constructor_method"), External::New(isolate, (void *)desc->constructor)); #endif