提交 a3110f4c 编写于 作者: C coffeys

8076409: Reinforce RMI framework

Reviewed-by: smarks
上级 54a7784c
/* /*
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -31,6 +31,7 @@ import java.lang.reflect.Proxy; ...@@ -31,6 +31,7 @@ import java.lang.reflect.Proxy;
import java.rmi.Remote; import java.rmi.Remote;
import java.rmi.UnexpectedException; import java.rmi.UnexpectedException;
import java.rmi.activation.Activatable; import java.rmi.activation.Activatable;
import java.security.PrivilegedAction;
import java.util.Map; import java.util.Map;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import sun.rmi.server.Util; import sun.rmi.server.Util;
...@@ -56,6 +57,25 @@ public class RemoteObjectInvocationHandler ...@@ -56,6 +57,25 @@ public class RemoteObjectInvocationHandler
{ {
private static final long serialVersionUID = 2L; private static final long serialVersionUID = 2L;
// set to true if invocation handler allows finalize method (legacy behavior)
private static final boolean allowFinalizeInvocation;
static {
String propName = "sun.rmi.server.invocationhandler.allowFinalizeInvocation";
String allowProp = java.security.AccessController.doPrivileged(
new PrivilegedAction<String>() {
@Override
public String run() {
return System.getProperty(propName);
}
});
if ("".equals(allowProp)) {
allowFinalizeInvocation = true;
} else {
allowFinalizeInvocation = Boolean.parseBoolean(allowProp);
}
}
/** /**
* A weak hash map, mapping classes to weak hash maps that map * A weak hash map, mapping classes to weak hash maps that map
* method objects to method hashes. * method objects to method hashes.
...@@ -144,6 +164,9 @@ public class RemoteObjectInvocationHandler ...@@ -144,6 +164,9 @@ public class RemoteObjectInvocationHandler
{ {
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 &&
!allowFinalizeInvocation) {
return null; // ignore
} else { } else {
return invokeRemoteMethod(proxy, method, args); return invokeRemoteMethod(proxy, method, args);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册