changeset 8241:c4bc1ce10662

8076397: Better MBean connections Reviewed-by: dfuchs, ahgross
author jbachorik
date Fri, 10 Apr 2015 16:08:13 +0200
parents a0feab3bb26e
children 2e939bf6c09b
files src/share/classes/javax/management/MBeanServerInvocationHandler.java
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/javax/management/MBeanServerInvocationHandler.java	Mon Jul 06 20:06:03 2015 +0100
+++ b/src/share/classes/javax/management/MBeanServerInvocationHandler.java	Fri Apr 10 16:08:13 2015 +0200
@@ -141,6 +141,12 @@
         if (connection == null) {
             throw new IllegalArgumentException("Null connection");
         }
+        if (Proxy.isProxyClass(connection.getClass())) {
+            if (MBeanServerInvocationHandler.class.isAssignableFrom(
+                    Proxy.getInvocationHandler(connection).getClass())) {
+                throw new IllegalArgumentException("Wrapping MBeanServerInvocationHandler");
+            }
+        }
         if (objectName == null) {
             throw new IllegalArgumentException("Null object name");
         }
@@ -418,6 +424,10 @@
                              new Class<?>[] {Object.class})
             && isLocal(proxy, method))
             return true;
+        if (methodName.equals("finalize")
+            && method.getParameterTypes().length == 0) {
+            return true;
+        }
         return false;
     }
 
@@ -453,6 +463,9 @@
                 connection + "[" + objectName + "])";
         } else if (methodName.equals("hashCode")) {
             return objectName.hashCode()+connection.hashCode();
+        } else if (methodName.equals("finalize")) {
+            // ignore the finalizer invocation via proxy
+            return null;
         }
 
         throw new RuntimeException("Unexpected method name: " + methodName);