提交 4c37f228 编写于 作者: I igerasim

8076339: Better handling of remote object invocation

Reviewed-by: asmotrak, igerasim, skoivu
上级 8e3fba6f
...@@ -162,6 +162,14 @@ public class RemoteObjectInvocationHandler ...@@ -162,6 +162,14 @@ public class RemoteObjectInvocationHandler
public Object invoke(Object proxy, Method method, Object[] args) public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable throws Throwable
{ {
if (! Proxy.isProxyClass(proxy.getClass())) {
throw new IllegalArgumentException("not a proxy");
}
if (Proxy.getInvocationHandler(proxy) != this) {
throw new IllegalArgumentException("handler mismatch");
}
if (method.getDeclaringClass() == Object.class) { if (method.getDeclaringClass() == Object.class) {
return invokeObjectMethod(proxy, method, args); return invokeObjectMethod(proxy, method, args);
} else if ("finalize".equals(method.getName()) && method.getParameterCount() == 0 && } else if ("finalize".equals(method.getName()) && method.getParameterCount() == 0 &&
...@@ -186,11 +194,13 @@ public class RemoteObjectInvocationHandler ...@@ -186,11 +194,13 @@ public class RemoteObjectInvocationHandler
} else if (name.equals("equals")) { } else if (name.equals("equals")) {
Object obj = args[0]; Object obj = args[0];
InvocationHandler hdlr;
return return
proxy == obj || proxy == obj ||
(obj != null && (obj != null &&
Proxy.isProxyClass(obj.getClass()) && Proxy.isProxyClass(obj.getClass()) &&
equals(Proxy.getInvocationHandler(obj))); (hdlr = Proxy.getInvocationHandler(obj)) instanceof RemoteObjectInvocationHandler &&
this.equals(hdlr));
} else if (name.equals("toString")) { } else if (name.equals("toString")) {
return proxyToString(proxy); return proxyToString(proxy);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册