зеркало из https://github.com/mozilla/gecko-dev.git
Родитель
e4a52cb978
Коммит
cf700c7c6b
|
@ -0,0 +1,29 @@
|
|||
/* -*- Mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
package org.mozilla.xpcom;
|
||||
|
||||
public class XPCOMException extends RuntimeException {
|
||||
public XPCOMException(int xpcomCode) {
|
||||
super(" [nsresult=" + xpcomCode + "]");
|
||||
}
|
||||
}
|
|
@ -85,11 +85,17 @@ void bcJavaStub::Dispatch(bcICall *call) {
|
|||
bcIUnMarshaler * um = call->GetUnMarshaler();
|
||||
mt->UnMarshal(um);
|
||||
jobject jiid = bcIIDJava::GetObject(&iid);
|
||||
jobject retval = bcJavaGlobal::GetJNIEnv()->CallStaticObjectMethod(utilitiesClass, callMethodByIndexMID, object, jiid, (jint)mid, args);
|
||||
//nb return value; excepion handling
|
||||
jobject retval = env->CallStaticObjectMethod(utilitiesClass, callMethodByIndexMID, object, jiid, (jint)mid, args);
|
||||
nsresult result = NS_OK;
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
result = NS_ERROR_FAILURE;
|
||||
}
|
||||
bcIMarshaler * m = call->GetMarshaler();
|
||||
mt->Marshal(m, retval);
|
||||
//nb memory deallocation
|
||||
m->WriteSimple(&result, bc_T_U32);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
mt->Marshal(m, retval);
|
||||
}
|
||||
delete m; delete um; delete mt;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
#include "ctype.h"
|
||||
#include "bcJavaGlobal.h"
|
||||
|
||||
|
||||
static jclass XPCOMExceptionClass = NULL;
|
||||
static jmethodID XPCOMExceptionInitMID = NULL;
|
||||
/*
|
||||
* Class: org_mozilla_xpcom_Utilities
|
||||
* Method: callMethodByIndex
|
||||
|
@ -68,8 +71,29 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_xpcom_Utilities_callMethodByIndex
|
|||
mt->Marshal(m);
|
||||
orb->SendReceive(call);
|
||||
bcIUnMarshaler * um = call->GetUnMarshaler();
|
||||
nsresult result;
|
||||
jobject retval;
|
||||
mt->UnMarshal(um, &retval);
|
||||
um->ReadSimple(&result, bc_T_U32);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
mt->UnMarshal(um, &retval);
|
||||
} else {
|
||||
if (XPCOMExceptionClass == NULL) {
|
||||
XPCOMExceptionClass = (jclass) env->FindClass("org/mozilla/xpcom/XPCOMException");
|
||||
if (!env->ExceptionOccurred()) { // if there is an exception it will be catched in java
|
||||
XPCOMExceptionClass = (jclass)env->NewGlobalRef(XPCOMExceptionClass);
|
||||
if (!env->ExceptionOccurred()) {
|
||||
XPCOMExceptionInitMID = env->GetMethodID(XPCOMExceptionClass,"<init>","(I)V");
|
||||
if (env->ExceptionOccurred()) {
|
||||
XPCOMExceptionClass = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!env->ExceptionOccurred()) {
|
||||
jthrowable exception = (jthrowable) env->NewObject(XPCOMExceptionClass, XPCOMExceptionInitMID,(jint)result);
|
||||
env->Throw(exception);
|
||||
}
|
||||
}
|
||||
delete call; delete m; delete um; delete mt;
|
||||
|
||||
return retval;
|
||||
|
|
|
@ -116,10 +116,10 @@ public class bcJavaSample implements bcIJavaSample {
|
|||
nsISupportsString strObj;
|
||||
while (true) {
|
||||
obj = enumerator.currentItem();
|
||||
if (obj == null
|
||||
|| counter > 300) {
|
||||
break;
|
||||
}
|
||||
// if (obj == null
|
||||
// || counter > 300) {
|
||||
// break;
|
||||
//}
|
||||
strObj = (nsISupportsString) obj.queryInterface(nsISupportsString.IID);
|
||||
str = strObj.getData();
|
||||
System.out.println("--[java] bcJavaSample.Test5 string "+str);
|
||||
|
|
Загрузка…
Ссылка в новой задаче