Bug 1244875 - Update JNI usages; r=snorp
authorJim Chen <nchen@mozilla.com>
Tue, 09 Feb 2016 17:27:28 -0500
changeset 307315 491e5d70946314c14aebcf67c045905c0f1de5f3
parent 307314 1294093ae14da4bd86a3443099a1a7dc84d83e49
child 307316 cb0087d80b92f1b7b2284f0c9a6e21f9fb204140
push idunknown
push userunknown
push dateunknown
reviewerssnorp
bugs1244875
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1244875 - Update JNI usages; r=snorp Update JNI usages to match the changes in JNI templates.
dom/mobilemessage/android/SmsManager.cpp
widget/android/AndroidBridge.cpp
widget/android/NativeJSContainer.cpp
widget/android/PrefsHelper.h
widget/android/nsAndroidProtocolHandler.cpp
widget/android/nsAppShell.cpp
widget/android/nsWindow.cpp
--- a/dom/mobilemessage/android/SmsManager.cpp
+++ b/dom/mobilemessage/android/SmsManager.cpp
@@ -33,19 +33,19 @@ SmsManager::NotifySmsReceived(int32_t aI
 {
     // TODO Need to correct the message `threadId` parameter value. Bug 859098
     SmsMessageData message;
     message.id() = aId;
     message.threadId() = 0;
     message.iccId() = EmptyString();
     message.delivery() = eDeliveryState_Received;
     message.deliveryStatus() = eDeliveryStatus_Success;
-    message.sender() = aSender ? nsString(aSender) : EmptyString();
+    message.sender() = aSender ? aSender->ToString() : EmptyString();
     message.receiver() = EmptyString();
-    message.body() = aBody ? nsString(aBody) : EmptyString();
+    message.body() = aBody ? aBody->ToString() : EmptyString();
     message.messageClass() = static_cast<MessageClass>(aMessageClass);
     message.timestamp() = aTimestamp;
     message.sentTimestamp() = aSentTimestamp;
     message.deliveryTimestamp() = aTimestamp;
     message.read() = false;
 
     nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction([=] () {
         nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
@@ -71,18 +71,18 @@ SmsManager::NotifySmsSent(int32_t aId,
     // TODO Need to correct the message `threadId` parameter value. Bug 859098
     SmsMessageData message;
     message.id() = aId;
     message.threadId() = 0;
     message.iccId() = EmptyString();
     message.delivery() = eDeliveryState_Sent;
     message.deliveryStatus() = eDeliveryStatus_Pending;
     message.sender() = EmptyString();
-    message.receiver() = aReceiver ? nsString(aReceiver) : EmptyString();
-    message.body() = aBody ? nsString(aBody) : EmptyString();
+    message.receiver() = aReceiver ? aReceiver->ToString() : EmptyString();
+    message.body() = aBody ? aBody->ToString() : EmptyString();
     message.messageClass() = eMessageClass_Normal;
     message.timestamp() = aTimestamp;
     message.sentTimestamp() = aTimestamp;
     message.deliveryTimestamp() = aTimestamp;
     message.read() = true;
 
     nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction([=]() {
         /*
@@ -120,18 +120,18 @@ SmsManager::NotifySmsDelivery(int32_t aI
     // TODO Need to correct the message `threadId` parameter value. Bug 859098
     SmsMessageData message;
     message.id() = aId;
     message.threadId() = 0;
     message.iccId() = EmptyString();
     message.delivery() = eDeliveryState_Sent;
     message.deliveryStatus() = static_cast<DeliveryStatus>(aDeliveryStatus);
     message.sender() = EmptyString();
-    message.receiver() = aReceiver ? nsString(aReceiver) : EmptyString();
-    message.body() = aBody ? nsString(aBody) : EmptyString();
+    message.receiver() = aReceiver ? aReceiver->ToString() : EmptyString();
+    message.body() = aBody ? aBody->ToString() : EmptyString();
     message.messageClass() = eMessageClass_Normal;
     message.timestamp() = aTimestamp;
     message.sentTimestamp() = aTimestamp;
     message.deliveryTimestamp() = aTimestamp;
     message.read() = true;
 
     nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction([=]() {
         nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
@@ -170,31 +170,31 @@ SmsManager::NotifyGetSms(int32_t aId,
                          int32_t aDeliveryStatus,
                          jni::String::Param aReceiver,
                          jni::String::Param aSender,
                          jni::String::Param aBody,
                          int64_t aTimestamp,
                          bool aRead,
                          int32_t aRequestId)
 {
-    nsString receiver(aReceiver);
+    nsString receiver(aReceiver->ToString());
     DeliveryState state = receiver.IsEmpty() ? eDeliveryState_Received
                                              : eDeliveryState_Sent;
 
     // TODO Need to add the message `messageClass` parameter value. Bug 804476
     // TODO Need to correct the message `threadId` parameter value. Bug 859098
     SmsMessageData message;
     message.id() = aId;
     message.threadId() = 0;
     message.iccId() = EmptyString();
     message.delivery() = state;
     message.deliveryStatus() = static_cast<DeliveryStatus>(aDeliveryStatus);
-    message.sender() = aSender ? nsString(aSender) : EmptyString();
+    message.sender() = aSender ? aSender->ToString() : EmptyString();
     message.receiver() = receiver;
-    message.body() = aBody ? nsString(aBody) : EmptyString();
+    message.body() = aBody ? aBody->ToString() : EmptyString();
     message.messageClass() = eMessageClass_Normal;
     message.timestamp() = aTimestamp;
     message.sentTimestamp() = aTimestamp;
     message.deliveryTimestamp() = aTimestamp;
     message.read() = aRead;
 
     nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction([=]() {
         nsCOMPtr<nsIMobileMessageCallback> request =
@@ -284,19 +284,19 @@ SmsManager::NotifyThreadCursorResult(int
                                      jni::ObjectArray::Param aParticipants,
                                      int64_t aTimestamp,
                                      jni::String::Param aLastMessageType,
                                      int32_t aRequestId)
 {
     ThreadData thread;
     thread.id() = aId;
     thread.lastMessageSubject() = aLastMessageSubject ?
-                                    nsString(aLastMessageSubject) :
+                                    aLastMessageSubject->ToString() :
                                     EmptyString();
-    thread.body() = aBody ? nsString(aBody) : EmptyString();
+    thread.body() = aBody ? aBody->ToString() : EmptyString();
     thread.unreadCount() = aUnreadCount;
     thread.timestamp() = aTimestamp;
     thread.lastMessageType() = eMessageType_SMS;
 
     JNIEnv* const env = jni::GetEnvForThread();
 
     jobjectArray participants = aParticipants.Get();
     jsize length = env->GetArrayLength(participants);
@@ -335,30 +335,30 @@ SmsManager::NotifyMessageCursorResult(in
                                       jni::String::Param aReceiver,
                                       jni::String::Param aSender,
                                       jni::String::Param aBody,
                                       int64_t aTimestamp,
                                       int64_t aThreadId,
                                       bool aRead,
                                       int32_t aRequestId)
 {
-    nsString receiver = nsString(aReceiver);
+    nsString receiver = aReceiver->ToString();
     DeliveryState state = receiver.IsEmpty() ? eDeliveryState_Received
                                              : eDeliveryState_Sent;
 
     // TODO Need to add the message `messageClass` parameter value. Bug 804476
     SmsMessageData message;
     message.id() = aMessageId;
     message.threadId() = aThreadId;
     message.iccId() = EmptyString();
     message.delivery() = state;
     message.deliveryStatus() = static_cast<DeliveryStatus>(aDeliveryStatus);
-    message.sender() = aSender ? nsString(aSender) : EmptyString();
+    message.sender() = aSender ? aSender->ToString() : EmptyString();
     message.receiver() = receiver;
-    message.body() = aBody ? nsString(aBody) : EmptyString();
+    message.body() = aBody ? aBody->ToString() : EmptyString();
     message.messageClass() = eMessageClass_Normal;
     message.timestamp() = aTimestamp;
     message.sentTimestamp() = aTimestamp;
     message.deliveryTimestamp() = aTimestamp;
     message.read() = aRead;
 
     nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction([=]() {
         nsCOMPtr<nsIMobileMessageCursorCallback> request =
--- a/widget/android/AndroidBridge.cpp
+++ b/widget/android/AndroidBridge.cpp
@@ -67,38 +67,38 @@ class AndroidRefable {
 };
 
 // This isn't in AndroidBridge.h because including StrongPointer.h there is gross
 static android::sp<AndroidRefable> (*android_SurfaceTexture_getNativeWindow)(JNIEnv* env, jobject surfaceTexture) = nullptr;
 
 jclass AndroidBridge::GetClassGlobalRef(JNIEnv* env, const char* className)
 {
     // First try the default class loader.
-    auto classRef = ClassObject::LocalRef::Adopt(
+    auto classRef = Class::LocalRef::Adopt(
             env, env->FindClass(className));
 
     if (!classRef && sBridge && sBridge->mClassLoader) {
         // If the default class loader failed but we have an app class loader, try that.
         // Clear the pending exception from failed FindClass call above.
         env->ExceptionClear();
-        classRef = ClassObject::LocalRef::Adopt(env,
+        classRef = Class::LocalRef::Adopt(env, jclass(
                 env->CallObjectMethod(sBridge->mClassLoader.Get(),
                                       sBridge->mClassLoaderLoadClass,
-                                      Param<String>(className, env).Get()));
+                                      StringParam(className, env).Get())));
     }
 
     if (!classRef) {
         ALOG(">>> FATAL JNI ERROR! FindClass(className=\"%s\") failed. "
              "Did ProGuard optimize away something it shouldn't have?",
              className);
         env->ExceptionDescribe();
         MOZ_CRASH();
     }
 
-    return ClassObject::GlobalRef(env, classRef).Forget();
+    return Class::GlobalRef(env, classRef).Forget();
 }
 
 jmethodID AndroidBridge::GetMethodID(JNIEnv* env, jclass jClass,
                               const char* methodName, const char* methodType)
 {
    jmethodID methodID = env->GetMethodID(jClass, methodName, methodType);
    if (!methodID) {
        ALOG(">>> FATAL JNI ERROR! GetMethodID(methodName=\"%s\", "
@@ -194,17 +194,17 @@ AndroidBridge::AndroidBridge()
     AutoLocalJNIFrame jniFrame(jEnv);
 
     mClassLoader = Object::GlobalRef(jEnv, widget::GeckoThread::ClsLoader());
     mClassLoaderLoadClass = GetMethodID(
             jEnv, jEnv->GetObjectClass(mClassLoader.Get()),
             "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;");
 
     mMessageQueue = widget::GeckoThread::MsgQueue();
-    auto msgQueueClass = ClassObject::LocalRef::Adopt(
+    auto msgQueueClass = Class::LocalRef::Adopt(
             jEnv, jEnv->GetObjectClass(mMessageQueue.Get()));
     // mMessageQueueNext must not be null
     mMessageQueueNext = GetMethodID(
             jEnv, msgQueueClass.Get(), "next", "()Landroid/os/Message;");
     // mMessageQueueMessages may be null (e.g. due to proguard optimization)
     mMessageQueueMessages = jEnv->GetFieldID(
             msgQueueClass.Get(), "mMessages", "Landroid/os/Message;");
 
@@ -469,41 +469,41 @@ AndroidBridge::GetHandlersForURL(const n
 void
 AndroidBridge::GetMimeTypeFromExtensions(const nsACString& aFileExt, nsCString& aMimeType)
 {
     ALOG_BRIDGE("AndroidBridge::GetMimeTypeFromExtensions");
 
     auto jstrType = GeckoAppShell::GetMimeTypeFromExtensionsWrapper(aFileExt);
 
     if (jstrType) {
-        aMimeType = jstrType;
+        aMimeType = jstrType->ToCString();
     }
 }
 
 void
 AndroidBridge::GetExtensionFromMimeType(const nsACString& aMimeType, nsACString& aFileExt)
 {
     ALOG_BRIDGE("AndroidBridge::GetExtensionFromMimeType");
 
     auto jstrExt = GeckoAppShell::GetExtensionFromMimeTypeWrapper(aMimeType);
 
     if (jstrExt) {
-        aFileExt = nsCString(jstrExt);
+        aFileExt = jstrExt->ToCString();
     }
 }
 
 bool
 AndroidBridge::GetClipboardText(nsAString& aText)
 {
     ALOG_BRIDGE("AndroidBridge::GetClipboardText");
 
     auto text = Clipboard::GetClipboardTextWrapper();
 
     if (text) {
-        aText = nsString(text);
+        aText = text->ToString();
     }
     return !!text;
 }
 
 void
 AndroidBridge::ShowAlertNotification(const nsAString& aImageUrl,
                                      const nsAString& aAlertTitle,
                                      const nsAString& aAlertText,
@@ -1668,17 +1668,17 @@ AndroidBridge::GetProxyForURI(const nsAC
         return NS_ERROR_FAILURE;
     }
 
     auto jstrRet = GeckoAppShell::GetProxyForURIWrapper(aSpec, aScheme, aHost, aPort);
 
     if (!jstrRet)
         return NS_ERROR_FAILURE;
 
-    aResult = nsCString(jstrRet);
+    aResult = jstrRet->ToCString();
     return NS_OK;
 }
 
 bool
 AndroidBridge::PumpMessageLoop()
 {
     JNIEnv* const env = jni::GetGeckoThreadEnv();
 
@@ -1739,31 +1739,31 @@ Java_org_mozilla_gecko_GeckoAppShell_all
 bool
 AndroidBridge::GetThreadNameJavaProfiling(uint32_t aThreadId, nsCString & aResult)
 {
     auto jstrThreadName = GeckoJavaSampler::GetThreadNameJavaProfilingWrapper(aThreadId);
 
     if (!jstrThreadName)
         return false;
 
-    aResult = nsCString(jstrThreadName);
+    aResult = jstrThreadName->ToCString();
     return true;
 }
 
 bool
 AndroidBridge::GetFrameNameJavaProfiling(uint32_t aThreadId, uint32_t aSampleId,
                                           uint32_t aFrameId, nsCString & aResult)
 {
     auto jstrSampleName = GeckoJavaSampler::GetFrameNameJavaProfilingWrapper
             (aThreadId, aSampleId, aFrameId);
 
     if (!jstrSampleName)
         return false;
 
-    aResult = nsCString(jstrSampleName);
+    aResult = jstrSampleName->ToCString();
     return true;
 }
 
 static float
 GetScaleFactor(nsPresContext* aPresContext) {
     nsIPresShell* presShell = aPresContext->PresShell();
     LayoutDeviceToLayerScale cumulativeResolution(presShell->GetCumulativeResolution());
     return cumulativeResolution.scale;
@@ -2207,11 +2207,11 @@ nsresult AndroidBridge::GetExternalPubli
               NS_ConvertUTF16toUTF8(aType).get());
         return NS_ERROR_NOT_AVAILABLE;
     }
 
     auto path = GeckoAppShell::GetExternalPublicDirectory(aType);
     if (!path) {
         return NS_ERROR_NOT_AVAILABLE;
     }
-    aPath = nsString(path);
+    aPath = path->ToString();
     return NS_OK;
 }
--- a/widget/android/NativeJSContainer.cpp
+++ b/widget/android/NativeJSContainer.cpp
@@ -44,18 +44,18 @@ CheckJSCall(bool result)
 {
     if (!result) {
         jni::ThrowException("java/lang/UnsupportedOperationException",
                             "JSAPI call failed");
     }
     return result;
 }
 
-template<class C> bool
-CheckJNIArgument(const jni::Ref<C>& arg)
+template<class C, typename T> bool
+CheckJNIArgument(const jni::Ref<C, T>& arg)
 {
     if (!arg) {
         jni::ThrowException("java/lang/IllegalArgumentException",
                             "Null argument");
     }
     return !!arg;
 }
 
@@ -241,18 +241,18 @@ class NativeJSContainerImpl final
 
     jni::String::LocalRef
     StringFromValue(const JS::HandleString str) const
     {
         nsAutoJSString autoStr;
         if (!CheckJSCall(autoStr.init(mJSContext, str))) {
             return nullptr;
         }
-        // Param<String> can automatically convert a nsString to jstring.
-        return jni::Param<jni::String>(autoStr, mEnv);
+        // StringParam can automatically convert a nsString to jstring.
+        return jni::StringParam(autoStr, mEnv);
     }
 
     jni::String::LocalRef
     StringFromValue(JS::HandleValue val)
     {
         const JS::RootedString str(mJSContext, val.toString());
         return StringFromValue(str);
     }
@@ -369,18 +369,17 @@ class NativeJSContainerImpl final
         JS::RootedObject object(mJSContext, &val.toObject());
         return CreateChild(object);
     }
 
     template<class Prop> typename Prop::NativeArray
     ObjectNewArray(JS::HandleObject array, size_t length)
     {
         auto jarray = Prop::NativeArray::Adopt(mEnv, mEnv->NewObjectArray(
-                length,
-                jni::Accessor::EnsureClassRef<typename Prop::ClassType>(mEnv),
+                length, typename Prop::ClassType::Context().ClassRef(),
                 nullptr));
         if (!jarray) {
             return nullptr;
         }
 
         // For object arrays, we have to set each element separately.
         for (size_t i = 0; i < length; i++) {
             JS::RootedValue elem(mJSContext);
@@ -810,17 +809,17 @@ public:
         }
 
         JS::RootedValue value(mJSContext, JS::ObjectValue(*mJSObject));
         nsAutoString json;
         if (!CheckJSCall(JS_Stringify(mJSContext, &value, nullptr,
                                       JS::NullHandleValue, AppendJSON, &json))) {
             return nullptr;
         }
-        return jni::Param<jni::String>(json, mEnv);
+        return jni::StringParam(json, mEnv);
     }
 };
 
 
 // Define the "static constexpr" members of our property types (e.g.
 // PrimitiveProperty<>::InValue). This is tricky because there are a lot of
 // template parameters, so we use macros to make it simpler.
 
--- a/widget/android/PrefsHelper.h
+++ b/widget/android/PrefsHelper.h
@@ -25,17 +25,17 @@ class PrefsHelper
     PrefsHelper() = delete;
 
     static bool GetVariantPref(nsIObserverService* aObsServ,
                                nsIWritableVariant* aVariant,
                                jni::Object::Param aPrefHandler,
                                jni::String::LocalRef& aPrefName)
     {
         if (NS_FAILED(aObsServ->NotifyObservers(aVariant, "android-get-pref",
-                                                nsString(aPrefName).get()))) {
+                                                aPrefName->ToString().get()))) {
             return false;
         }
 
         uint16_t varType = nsIDataType::VTYPE_EMPTY;
         if (NS_FAILED(aVariant->GetDataType(&varType))) {
             return false;
         }
 
@@ -63,18 +63,18 @@ class PrefsHelper
                     return false;
                 }
                 break;
             default:
                 return false;
         }
 
         const auto& jstrVal = type == widget::PrefsHelper::PREF_STRING ?
-                jni::Param<jni::String>(strVal, aPrefName.Env()) :
-                jni::Param<jni::String>(nullptr);
+                jni::StringParam(strVal, aPrefName.Env()) :
+                jni::StringParam(nullptr);
 
         widget::PrefsHelper::CallPrefHandler(
                 aPrefHandler, type, aPrefName, boolVal, intVal, jstrVal);
         return true;
     }
 
     static bool SetVariantPref(nsIObserverService* aObsServ,
                                nsIWritableVariant* aVariant,
@@ -90,23 +90,23 @@ class PrefsHelper
         switch (aType) {
             case widget::PrefsHelper::PREF_BOOL:
                 rv = aVariant->SetAsBool(aBoolVal);
                 break;
             case widget::PrefsHelper::PREF_INT:
                 rv = aVariant->SetAsInt32(aIntVal);
                 break;
             case widget::PrefsHelper::PREF_STRING:
-                rv = aVariant->SetAsAString(nsString(aStrVal));
+                rv = aVariant->SetAsAString(aStrVal->ToString());
                 break;
         }
 
         if (NS_SUCCEEDED(rv)) {
             rv = aObsServ->NotifyObservers(aVariant, "android-set-pref",
-                                           nsString(aPrefName).get());
+                                           aPrefName->ToString().get());
         }
 
         uint16_t varType = nsIDataType::VTYPE_EMPTY;
         if (NS_SUCCEEDED(rv)) {
             rv = aVariant->GetDataType(&varType);
         }
 
         // We use set-to-empty to signal the pref was handled.
@@ -116,34 +116,34 @@ class PrefsHelper
             rv = Preferences::GetService()->SavePrefFile(nullptr);
         }
 
         if (NS_SUCCEEDED(rv)) {
             return handled;
         }
 
         NS_WARNING(nsPrintfCString("Failed to set pref %s",
-                                   nsCString(aPrefName).get()).get());
+                                   aPrefName->ToCString().get()).get());
         // Pretend we handled the pref.
         return true;
     }
 
 public:
-    static void GetPrefs(const jni::ClassObject::LocalRef& aCls,
+    static void GetPrefs(const jni::Class::LocalRef& aCls,
                          jni::ObjectArray::Param aPrefNames,
                          jni::Object::Param aPrefHandler)
     {
-        nsTArray<jni::Object::LocalRef> nameRefArray(aPrefNames.GetElements());
+        nsTArray<jni::Object::LocalRef> nameRefArray(aPrefNames->GetElements());
         nsCOMPtr<nsIObserverService> obsServ;
         nsCOMPtr<nsIWritableVariant> value;
         nsAdoptingString strVal;
 
         for (jni::Object::LocalRef& nameRef : nameRefArray) {
             jni::String::LocalRef nameStr(mozilla::Move(nameRef));
-            const nsCString& name = nsCString(nameStr);
+            const nsCString& name = nameStr->ToCString();
 
             int32_t type = widget::PrefsHelper::PREF_INVALID;
             bool boolVal = false;
             int32_t intVal = 0;
 
             switch (Preferences::GetType(name.get())) {
                 case nsIPrefBranch::PREF_BOOL:
                     type = widget::PrefsHelper::PREF_BOOL;
@@ -180,18 +180,18 @@ public:
                                         aPrefHandler, nameStr)) {
                         NS_WARNING(nsPrintfCString("Failed to get pref %s",
                                                    name.get()).get());
                     }
                     continue;
             }
 
             const auto& jstrVal = type == widget::PrefsHelper::PREF_STRING ?
-                    jni::Param<jni::String>(strVal, aCls.Env()) :
-                    jni::Param<jni::String>(nullptr);
+                    jni::StringParam(strVal, aCls.Env()) :
+                    jni::StringParam(nullptr);
 
             widget::PrefsHelper::CallPrefHandler(
                     aPrefHandler, type, nameStr, boolVal, intVal, jstrVal);
         }
 
         widget::PrefsHelper::CallPrefHandler(
                 aPrefHandler, widget::PrefsHelper::PREF_FINISH,
                 nullptr, false, 0, nullptr);
@@ -199,17 +199,17 @@ public:
 
     static void SetPref(jni::String::Param aPrefName,
                         bool aFlush,
                         int32_t aType,
                         bool aBoolVal,
                         int32_t aIntVal,
                         jni::String::Param aStrVal)
     {
-        const nsCString& name = nsCString(aPrefName);
+        const nsCString& name = aPrefName->ToCString();
 
         if (Preferences::GetType(name.get()) == nsIPrefBranch::PREF_INVALID) {
             // No pref; try asking first.
             nsCOMPtr<nsIObserverService> obsServ =
                     services::GetObserverService();
             nsCOMPtr<nsIWritableVariant> value = new nsVariant();
             if (obsServ && SetVariantPref(obsServ, value, aPrefName, aFlush,
                                           aType, aBoolVal, aIntVal, aStrVal)) {
@@ -220,63 +220,63 @@ public:
         switch (aType) {
             case widget::PrefsHelper::PREF_BOOL:
                 Preferences::SetBool(name.get(), aBoolVal);
                 break;
             case widget::PrefsHelper::PREF_INT:
                 Preferences::SetInt(name.get(), aIntVal);
                 break;
             case widget::PrefsHelper::PREF_STRING:
-                Preferences::SetString(name.get(), nsString(aStrVal));
+                Preferences::SetString(name.get(), aStrVal->ToString());
                 break;
             default:
                 MOZ_ASSERT(false, "Invalid pref type");
         }
 
         if (aFlush) {
             Preferences::GetService()->SavePrefFile(nullptr);
         }
     }
 
-    static void AddObserver(const jni::ClassObject::LocalRef& aCls,
+    static void AddObserver(const jni::Class::LocalRef& aCls,
                             jni::ObjectArray::Param aPrefNames,
                             jni::Object::Param aPrefHandler,
                             jni::ObjectArray::Param aPrefsToObserve)
     {
         // Call observer immediately with existing pref values.
         GetPrefs(aCls, aPrefNames, aPrefHandler);
 
         if (!aPrefsToObserve) {
             return;
         }
 
         nsTArray<jni::Object::LocalRef> nameRefArray(
-                aPrefsToObserve.GetElements());
+                aPrefsToObserve->GetElements());
         nsAppShell* const appShell = nsAppShell::Get();
         MOZ_ASSERT(appShell);
 
         for (jni::Object::LocalRef& nameRef : nameRefArray) {
             jni::String::LocalRef nameStr(mozilla::Move(nameRef));
             MOZ_ALWAYS_TRUE(NS_SUCCEEDED(Preferences::AddStrongObserver(
-                    appShell, nsCString(nameStr).get())));
+                    appShell, nameStr->ToCString().get())));
         }
     }
 
-    static void RemoveObserver(const jni::ClassObject::LocalRef& aCls,
+    static void RemoveObserver(const jni::Class::LocalRef& aCls,
                                jni::ObjectArray::Param aPrefsToUnobserve)
     {
         nsTArray<jni::Object::LocalRef> nameRefArray(
-                aPrefsToUnobserve.GetElements());
+                aPrefsToUnobserve->GetElements());
         nsAppShell* const appShell = nsAppShell::Get();
         MOZ_ASSERT(appShell);
 
         for (jni::Object::LocalRef& nameRef : nameRefArray) {
             jni::String::LocalRef nameStr(mozilla::Move(nameRef));
             MOZ_ALWAYS_TRUE(NS_SUCCEEDED(Preferences::RemoveObserver(
-                    appShell, nsCString(nameStr).get())));
+                    appShell, nameStr->ToCString().get())));
         }
     }
 
     static void OnPrefChange(const char16_t* aData)
     {
         const nsCString& name = NS_LossyConvertUTF16toASCII(aData);
 
         int32_t type = -1;
@@ -302,18 +302,18 @@ public:
                 break;
             default:
                 NS_WARNING(nsPrintfCString("Invalid pref %s",
                                            name.get()).get());
                 return;
         }
 
         const auto& jstrVal = type == widget::PrefsHelper::PREF_STRING ?
-                jni::Param<jni::String>(strVal) :
-                jni::Param<jni::String>(nullptr);
+                jni::StringParam(strVal) :
+                jni::StringParam(nullptr);
 
         widget::PrefsHelper::OnPrefChange(name, type, boolVal, intVal, jstrVal);
     }
 };
 
 } // namespace
 
 #endif // PrefsHelper_h
--- a/widget/android/nsAndroidProtocolHandler.cpp
+++ b/widget/android/nsAndroidProtocolHandler.cpp
@@ -68,17 +68,17 @@ class AndroidChannel : public nsBaseChan
 {
 private:
     AndroidChannel(nsIURI *aURI, jni::Object::Param aConnection) {
         mConnection = aConnection;
         SetURI(aURI);
 
         auto type = widget::GeckoAppShell::ConnectionGetMimeType(mConnection);
         if (type) {
-            SetContentType(nsCString(type));
+            SetContentType(type->ToCString());
         }
     }
 
 public:
     static AndroidChannel* CreateChannel(nsIURI *aURI)  {
         nsCString spec;
         aURI->GetSpec(spec);
 
--- a/widget/android/nsAppShell.cpp
+++ b/widget/android/nsAppShell.cpp
@@ -171,17 +171,17 @@ public:
         }
 
         nsCOMPtr<nsIIOService> ioServ = do_GetIOService();
         nsCOMPtr<nsISpeculativeConnect> specConn = do_QueryInterface(ioServ);
         if (!specConn) {
             return;
         }
 
-        nsCOMPtr<nsIURI> uri = ResolveURI(nsCString(uriStr));
+        nsCOMPtr<nsIURI> uri = ResolveURI(uriStr->ToCString());
         if (!uri) {
             return;
         }
         specConn->SpeculativeConnect(uri, nullptr);
     }
 };
 
 nsAppShell::nsAppShell()
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -254,17 +254,17 @@ public:
     using Base::DisposeNative;
     using EditableBase::DisposeNative;
 
     /**
      * GeckoView methods
      */
 public:
     // Create and attach a window.
-    static void Open(const jni::ClassObject::LocalRef& aCls,
+    static void Open(const jni::Class::LocalRef& aCls,
                      GeckoView::Window::Param aWindow,
                      GeckoView::Param aView, jni::Object::Param aGLController,
                      int32_t aWidth, int32_t aHeight);
 
     // Close and destroy the nsWindow.
     void Close();
 
     // Reattach this nsWindow to a new GeckoView.
@@ -531,17 +531,17 @@ public:
             return false;
         }
 
         RefPtr<APZCTreeManager> controller = mWindow->mAPZC;
         if (!controller) {
             return false;
         }
 
-        nsTArray<int32_t> pointerId(aPointerId);
+        nsTArray<int32_t> pointerId(aPointerId->GetElements());
         MultiTouchInput::MultiTouchType type;
         size_t startIndex = 0;
         size_t endIndex = pointerId.Length();
 
         switch (aAction) {
             case sdk::MotionEvent::ACTION_DOWN:
             case sdk::MotionEvent::ACTION_POINTER_DOWN:
                 type = MultiTouchInput::MULTITOUCH_START;
@@ -564,22 +564,22 @@ public:
             default:
                 return false;
         }
 
         MultiTouchInput input(type, aTime, TimeStamp(), 0);
         input.modifiers = GetModifiers(aMetaState);
         input.mTouches.SetCapacity(endIndex - startIndex);
 
-        nsTArray<float> x(aX);
-        nsTArray<float> y(aY);
-        nsTArray<float> orientation(aOrientation);
-        nsTArray<float> pressure(aPressure);
-        nsTArray<float> toolMajor(aToolMajor);
-        nsTArray<float> toolMinor(aToolMinor);
+        nsTArray<float> x(aX->GetElements());
+        nsTArray<float> y(aY->GetElements());
+        nsTArray<float> orientation(aOrientation->GetElements());
+        nsTArray<float> pressure(aPressure->GetElements());
+        nsTArray<float> toolMajor(aToolMajor->GetElements());
+        nsTArray<float> toolMinor(aToolMinor->GetElements());
 
         MOZ_ASSERT(pointerId.Length() == x.Length());
         MOZ_ASSERT(pointerId.Length() == y.Length());
         MOZ_ASSERT(pointerId.Length() == orientation.Length());
         MOZ_ASSERT(pointerId.Length() == pressure.Length());
         MOZ_ASSERT(pointerId.Length() == toolMajor.Length());
         MOZ_ASSERT(pointerId.Length() == toolMinor.Length());
 
@@ -974,17 +974,17 @@ nsWindow::GeckoViewSupport::~GeckoViewSu
     // Disassociate our GeckoEditable instance with our native object.
     // OnDestroy will call disposeNative after any pending native calls have
     // been made.
     MOZ_ASSERT(mEditable);
     mEditable->OnViewChange(nullptr);
 }
 
 /* static */ void
-nsWindow::GeckoViewSupport::Open(const jni::ClassObject::LocalRef& aCls,
+nsWindow::GeckoViewSupport::Open(const jni::Class::LocalRef& aCls,
                                  GeckoView::Window::Param aWindow,
                                  GeckoView::Param aView,
                                  jni::Object::Param aGLController,
                                  int32_t aWidth, int32_t aHeight)
 {
     MOZ_ASSERT(NS_IsMainThread());
 
     PROFILER_LABEL("nsWindow", "GeckoViewSupport::Open",
@@ -2655,18 +2655,18 @@ nsWindow::GeckoViewSupport::FlushIMEChan
             return;
         }
 
         textTransaction.AppendElement(
                 TextRecord{event.mReply.mString, change.mStart,
                            change.mOldEnd, change.mNewEnd});
     }
 
-    int32_t selStart;
-    int32_t selEnd;
+    int32_t selStart = -1;
+    int32_t selEnd = -1;
 
     if (mIMESelectionChanged) {
         WidgetQueryContentEvent event(true, eQuerySelectedText, &window);
         window.InitEvent(event, nullptr);
         window.DispatchEvent(&event);
 
         NS_ENSURE_TRUE_VOID(event.mSucceeded);
         NS_ENSURE_TRUE_VOID(event.mReply.mContentsRoot == imeRoot.get());
@@ -2877,17 +2877,17 @@ nsWindow::GeckoViewSupport::OnImeReplace
         // Not focused; still reply to events, but don't do anything else.
         return OnImeSynchronize();
     }
 
     /*
         Replace text in Gecko thread from aStart to aEnd with the string text.
     */
     RefPtr<nsWindow> kungFuDeathGrip(&window);
-    nsString string(aText);
+    nsString string(aText->ToString());
 
     const auto composition(window.GetIMEComposition());
     MOZ_ASSERT(!composition || !composition->IsEditorHandlingEvent());
 
     if (!mIMEKeyEvents.IsEmpty() || !composition ||
         uint32_t(aStart) != composition->NativeOffsetOfStartComposition() ||
         uint32_t(aEnd) != composition->NativeOffsetOfStartComposition() +
                           composition->String().Length())