jdk/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java
changeset 4167 76f44f2d5d4d
parent 4156 acaa49a2768a
child 5506 202f599c92aa
--- a/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java	Sat Oct 24 20:36:01 2009 +0100
+++ b/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java	Tue Oct 27 08:55:35 2009 +0000
@@ -27,6 +27,7 @@
 
 
 import com.sun.jmx.remote.security.MBeanServerFileAccessController;
+import com.sun.jmx.remote.internal.IIOPHelper;
 import com.sun.jmx.remote.util.ClassLogger;
 import com.sun.jmx.remote.util.EnvHelp;
 
@@ -674,7 +675,7 @@
         final int port;
 
         if (address == null) {
-            if (rmiServer instanceof javax.rmi.CORBA.Stub)
+            if (IIOPHelper.isStub(rmiServer))
                 protocol = "iiop";
             else
                 protocol = "rmi";
@@ -712,7 +713,7 @@
      **/
     static String encodeStub(
             RMIServer rmiServer, Map<String, ?> env) throws IOException {
-        if (rmiServer instanceof javax.rmi.CORBA.Stub)
+        if (IIOPHelper.isStub(rmiServer))
             return "/ior/" + encodeIIOPStub(rmiServer, env);
         else
             return "/stub/" + encodeJRMPStub(rmiServer, env);
@@ -733,10 +734,9 @@
             RMIServer rmiServer, Map<String, ?> env)
             throws IOException {
         try {
-            javax.rmi.CORBA.Stub stub =
-                (javax.rmi.CORBA.Stub) rmiServer;
-            return stub._orb().object_to_string(stub);
-        } catch (org.omg.CORBA.BAD_OPERATION x) {
+            Object orb = IIOPHelper.getOrb(rmiServer);
+            return IIOPHelper.objectToString(orb, rmiServer);
+        } catch (RuntimeException x) {
             throw newIOException(x.getMessage(), x);
         }
     }