* not part of tbox builds*

Fixed 57779, 58191


git-svn-id: svn://10.0.0.236/trunk@83932 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
idk%eng.sun.com
2000-12-21 01:34:53 +00:00
parent 6ae938a280
commit b83d28afac
30 changed files with 360 additions and 78 deletions

View File

@@ -197,7 +197,7 @@ public class InterfaceRegistry {
private static void printMethod(Method m) {
if (m == null) {
System.out.println("<null>");
Debug.log("<null>");
return;
}
Class retType = m.getReturnType();
@@ -210,12 +210,12 @@ public class InterfaceRegistry {
if (j > 0) System.out.print(", ");
System.out.print(paramTypes[j].getName());
}
System.out.println(");");
Debug.log(");");
}
private static void debug(String str) {
if (debug) {
System.out.println(str);
Debug.log(str);
}
}

View File

@@ -48,13 +48,13 @@ class ProxyKey {
public class ProxyFactory {
public static Class getInterface(IID iid) {
System.out.println("--[java] ProxyFactory.getInterface "+iid);
Debug.log("--[java] ProxyFactory.getInterface "+iid);
return InterfaceRegistry.getInterface(iid);
}
public static Object getProxy(long oid, IID iid, long orb) {
try {
System.out.println("--[java] ProxyFactory.getProxy "+iid);
Debug.log("--[java] ProxyFactory.getProxy "+iid);
ProxyKey key = new ProxyKey(oid, iid);
Object obj = null;
Object result = null;
@@ -70,17 +70,17 @@ public class ProxyFactory {
if (result == null) {
Class inter = getInterface(iid);
if (inter == null) {
System.out.println("--[java] ProxyFactory.getProxy we did not find interface for iid="+iid+"returing null");
Debug.log("--[java] ProxyFactory.getProxy we did not find interface for iid="+iid+"returing null");
return null;
}
InvocationHandler handler = new ProxyHandler(oid, iid, orb);
result = Proxy.newProxyInstance(inter.getClassLoader(), new Class[] {inter},handler);
proxies.put(new WeakReference(result), key);
}
System.out.println("--[java] ProxyFactory.getProxy we got proxy "+result);
Debug.log("--[java] ProxyFactory.getProxy we got proxy "+result);
return result;
} catch (Exception e) {
System.out.println("--[java] ProxyFactory.getProxy we got exception "+e);
Debug.log("--[java] ProxyFactory.getProxy we got exception "+e);
}
return null;
}

View File

@@ -32,7 +32,7 @@ class ProxyHandler implements InvocationHandler {
public Object invoke(Object proxy,
Method method,
Object[] args) throws Throwable {
System.out.println("--[java]ProxyHandler.invoke "+method);
Debug.log("--[java]ProxyHandler.invoke "+method);
String str = method.getName();
if (str.equals("toString")) {
return "ProxyObject@{oid = "+oid+" iid = "+iid+"}";

View File

@@ -24,35 +24,54 @@ package org.mozilla.xpcom;
import java.lang.reflect.*;
public class Utilities {
static Class objectArrayClass = (new Object[1]).getClass();
static Object callMethodByIndex(Object obj, IID iid, int mid, Object[] args) {
System.out.println("--[java]org.mozilla.xpcom.Utilities.callMethodByIndex "+args.length+" "+mid);
Debug.log("--[java]org.mozilla.xpcom.Utilities.callMethodByIndex "+args.length+" "+mid);
Object retObject = null;
for (int i = 0; i < args.length; i++) {
System.out.println("--[java]callMethodByIndex args["+i+"] = "+args[i]);
Debug.log("--[java]callMethodByIndex args["+i+"] = "+args[i]);
}
Method method = InterfaceRegistry.getMethodByIndex(mid,iid);
System.out.println("--[java] org.mozilla.xpcom.Utilities.callMethodByIndex method "+method);
Debug.log("--[java] org.mozilla.xpcom.Utilities.callMethodByIndex method "+method);
try {
if (method != null) {
for (int i = 0 ; i < args.length; i++) {
/* this is hack. at the time we are doing holders for [out] interfaces
we might do not know the expected type and we are producing Object[] insted of
nsISupports[] for example. Here we are taking care about it.
If args[i] is Object[] of size 1 we are checking with expected type from method.
In case it is not expeceted type we are creating object[] of expected type.
*/
if (objectArrayClass.equals(args[i].getClass())
&& ((Object[])args[i]).length == 1) {
Class[] parameterTypes = method.getParameterTypes();
if (!objectArrayClass.equals(parameterTypes[i])
&& parameterTypes[i].isArray()) {
Class componentType = parameterTypes[i].getComponentType();
args[i] = java.lang.reflect.Array.newInstance(componentType,1);
}
}
}
retObject = method.invoke(obj,args);
System.out.println("--[java] Utilities.callMethodByIndex: retObject = " + retObject);
Debug.log("--[java] Utilities.callMethodByIndex: retObject = " + retObject);
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("--[java] Utilities.callMethodByIndex method finished"+method);
Debug.log("--[java] Utilities.callMethodByIndex method finished"+method);
return retObject;
}
static Object callMethod(long oid, Method method, IID iid, long orb , Object[] args) {
System.out.println("--[java]Utilities.callMethod "+method);
Debug.log("--[java]Utilities.callMethod "+method);
int mid = InterfaceRegistry.getIndexByMethod(method, iid);
if (mid < 0) {
System.out.println("--[java]Utilities.callMethod we do not have implementation for "+method);
Debug.log("--[java]Utilities.callMethod we do not have implementation for "+method);
return null;
}
System.out.println("--[java]Utilities.callMethod "+mid);
Debug.log("--[java]Utilities.callMethod "+mid);
return callMethodByIndex(oid,mid,iid.getString(), orb, args);
}