changeset 6303:edb71a37fcb7

8001048: JSR-160: Allow IIOP transport to be optional Reviewed-by: dsamersoff, dfuchs, mchung
author alanb
date Thu, 20 Dec 2012 20:29:59 +0000
parents c1a55ee9618e
children eeda18683ddc
files src/share/classes/com/sun/jmx/remote/internal/IIOPHelper.java src/share/classes/javax/management/remote/JMXConnectorFactory.java src/share/classes/javax/management/remote/JMXConnectorServerFactory.java src/share/classes/javax/management/remote/rmi/RMIConnector.java src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java src/share/classes/javax/management/remote/rmi/package.html test/javax/management/remote/mandatory/connection/AddressableTest.java test/javax/management/remote/mandatory/connection/CloseableTest.java test/javax/management/remote/mandatory/connection/ConnectionListenerNullTest.java test/javax/management/remote/mandatory/connection/IIOPURLTest.java test/javax/management/remote/mandatory/connection/IdleTimeoutTest.java test/javax/management/remote/mandatory/connection/MultiThreadDeadLockTest.java test/javax/management/remote/mandatory/connectorServer/SetMBeanServerForwarder.java test/javax/management/remote/mandatory/loading/MissingClassTest.java test/javax/management/remote/mandatory/provider/ProviderTest.java test/javax/management/remote/mandatory/serverError/JMXServerErrorTest.java
diffstat 16 files changed, 211 insertions(+), 187 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/jmx/remote/internal/IIOPHelper.java	Thu Dec 20 20:12:32 2012 +0400
+++ b/src/share/classes/com/sun/jmx/remote/internal/IIOPHelper.java	Thu Dec 20 20:29:59 2012 +0000
@@ -26,13 +26,8 @@
 package com.sun.jmx.remote.internal;
 
 import java.util.Properties;
+import java.io.IOException;
 import java.rmi.Remote;
-import java.rmi.RemoteException;
-import java.rmi.NoSuchObjectException;
-
-import java.util.Properties;
-import java.rmi.Remote;
-import java.rmi.RemoteException;
 import java.rmi.NoSuchObjectException;
 
 import java.security.AccessController;
@@ -115,9 +110,10 @@
      * Connects the Stub to the given ORB.
      */
     public static void connect(Object stub, Object orb)
-        throws RemoteException
+        throws IOException
     {
-        ensureAvailable();
+        if (proxy == null)
+            throw new IOException("Connection to ORB failed, RMI/IIOP not available");
         proxy.connect(stub, orb);
     }
 
@@ -125,15 +121,17 @@
      * Returns true if the given object is an ORB.
      */
     public static boolean isOrb(Object obj) {
-        ensureAvailable();
-        return proxy.isOrb(obj);
+        return (proxy == null) ? false : proxy.isOrb(obj);
     }
 
     /**
      * Creates, and returns, a new ORB instance.
      */
-    public static Object createOrb(String[] args, Properties props) {
-        ensureAvailable();
+    public static Object createOrb(String[] args, Properties props)
+        throws IOException
+    {
+        if (proxy == null)
+            throw new IOException("ORB initialization failed, RMI/IIOP not available");
         return proxy.createOrb(args, props);
     }
 
@@ -166,24 +164,27 @@
     /**
      * Makes a server object ready to receive remote calls
      */
-    public static void exportObject(Remote obj) throws RemoteException {
-        ensureAvailable();
+    public static void exportObject(Remote obj) throws IOException {
+        if (proxy == null)
+            throw new IOException("RMI object cannot be exported, RMI/IIOP not available");
         proxy.exportObject(obj);
     }
 
     /**
      * Deregisters a server object from the runtime.
      */
-    public static void unexportObject(Remote obj) throws NoSuchObjectException {
-        ensureAvailable();
+    public static void unexportObject(Remote obj) throws IOException {
+        if (proxy == null)
+            throw new NoSuchObjectException("Object not exported");
         proxy.unexportObject(obj);
     }
 
     /**
      * Returns a stub for the given server object.
      */
-    public static Remote toStub(Remote obj) throws NoSuchObjectException {
-        ensureAvailable();
+    public static Remote toStub(Remote obj) throws IOException {
+        if (proxy == null)
+            throw new NoSuchObjectException("Object not exported");
         return proxy.toStub(obj);
     }
 }
--- a/src/share/classes/javax/management/remote/JMXConnectorFactory.java	Thu Dec 20 20:12:32 2012 +0400
+++ b/src/share/classes/javax/management/remote/JMXConnectorFactory.java	Thu Dec 20 20:29:59 2012 +0000
@@ -137,8 +137,10 @@
  * JAR conventions for service providers</a>, where the service
  * interface is <code>JMXConnectorProvider</code>.</p>
  *
- * <p>Every implementation must support the RMI connector protocols,
- * specified with the string <code>rmi</code> or
+ * <p>Every implementation must support the RMI connector protocol with
+ * the default RMI transport, specified with string <code>rmi</code>.
+ * An implementation may optionally support the RMI connector protocol
+ * with the RMI/IIOP transport, specified with the string
  * <code>iiop</code>.</p>
  *
  * <p>Once a provider is found, the result of the
--- a/src/share/classes/javax/management/remote/JMXConnectorServerFactory.java	Thu Dec 20 20:12:32 2012 +0400
+++ b/src/share/classes/javax/management/remote/JMXConnectorServerFactory.java	Thu Dec 20 20:29:59 2012 +0000
@@ -129,8 +129,10 @@
  * JAR conventions for service providers</a>, where the service
  * interface is <code>JMXConnectorServerProvider</code>.</p>
  *
- * <p>Every implementation must support the RMI connector protocols,
- * specified with the string <code>rmi</code> or
+ * <p>Every implementation must support the RMI connector protocol with
+ * the default RMI transport, specified with string <code>rmi</code>.
+ * An implementation may optionally support the RMI connector protocol
+ * with the RMI/IIOP transport, specified with the string
  * <code>iiop</code>.</p>
  *
  * <p>Once a provider is found, the result of the
--- a/src/share/classes/javax/management/remote/rmi/RMIConnector.java	Thu Dec 20 20:12:32 2012 +0400
+++ b/src/share/classes/javax/management/remote/rmi/RMIConnector.java	Thu Dec 20 20:29:59 2012 +0000
@@ -238,10 +238,21 @@
     //--------------------------------------------------------------------
     // implements JMXConnector interface
     //--------------------------------------------------------------------
+
+    /**
+     * @throws IOException if the connection could not be made because of a
+     *   communication problem, or in the case of the {@code iiop} protocol,
+     *   that RMI/IIOP is not supported
+     */
     public void connect() throws IOException {
         connect(null);
     }
 
+    /**
+     * @throws IOException if the connection could not be made because of a
+     *   communication problem, or in the case of the {@code iiop} protocol,
+     *   that RMI/IIOP is not supported
+     */
     public synchronized void connect(Map<String,?> environment)
     throws IOException {
         final boolean tracing = logger.traceOn();
--- a/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java	Thu Dec 20 20:12:32 2012 +0400
+++ b/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java	Thu Dec 20 20:29:59 2012 +0000
@@ -337,7 +337,8 @@
      * @exception IllegalStateException if the connector server has
      * not been attached to an MBean server.
      * @exception IOException if the connector server cannot be
-     * started.
+     * started, or in the case of the {@code iiop} protocol, that
+     * RMI/IIOP is not supported.
      */
     public synchronized void start() throws IOException {
         final boolean tracing = logger.traceOn();
--- a/src/share/classes/javax/management/remote/rmi/package.html	Thu Dec 20 20:12:32 2012 +0400
+++ b/src/share/classes/javax/management/remote/rmi/package.html	Thu Dec 20 20:29:59 2012 +0000
@@ -36,8 +36,8 @@
       that different implementations of the RMI connector can
       interoperate.</p>
 
-    <p>The RMI connector supports both the JRMP and the IIOP transports
-      for RMI.</p>
+    <p>The RMI connector supports the JRMP transport for RMI, and
+      optionally the IIOP transport.</p>
 
     <p>Like most connectors in the JMX Remote API, an RMI connector
       usually has an address, which
--- a/test/javax/management/remote/mandatory/connection/AddressableTest.java	Thu Dec 20 20:12:32 2012 +0400
+++ b/test/javax/management/remote/mandatory/connection/AddressableTest.java	Thu Dec 20 20:29:59 2012 +0000
@@ -45,19 +45,36 @@
 
     private static final MBeanServer mbs = MBeanServerFactory.createMBeanServer();
 
+    private static boolean isProtocolSupported(String protocol) {
+        if (protocol.equals("rmi"))
+            return true;
+        if (protocol.equals("iiop")) {
+            try {
+                Class.forName("javax.management.remote.rmi._RMIConnectionImpl_Tie");
+                return true;
+            } catch (ClassNotFoundException x) { }
+        }
+        return false;
+    }
+
     public static void main(String[] args) throws Exception {
         System.out.println(">>> test the new interface Addressable.");
         boolean ok = true;
 
         for (int i = 0; i < protocols.length; i++) {
-            try {
-                test(protocols[i], prefixes[i]);
-
-                System.out.println(">>> Test successed for "+protocols[i]);
-            } catch (Exception e) {
-                System.out.println(">>> Test failed for "+protocols[i]);
-                e.printStackTrace(System.out);
-                ok = false;
+            String protocol = protocols[i];
+            if (isProtocolSupported(protocol)) {
+                try {
+                    test(protocol, prefixes[i]);
+                    System.out.println(">>> Test successed for "+protocols[i]);
+                } catch (Exception e) {
+                    System.out.println(">>> Test failed for "+protocols[i]);
+                    e.printStackTrace(System.out);
+                    ok = false;
+                }
+            } else {
+                System.out.format(">>> Test skipped for %s, protocol not supported%n",
+                    protocol);
             }
         }
 
@@ -65,7 +82,7 @@
             System.out.println(">>> All Test passed.");
         } else {
             System.out.println(">>> Some TESTs FAILED");
-            System.exit(1);
+            throw new RuntimeException("See log for details");
         }
     }
 
--- a/test/javax/management/remote/mandatory/connection/CloseableTest.java	Thu Dec 20 20:12:32 2012 +0400
+++ b/test/javax/management/remote/mandatory/connection/CloseableTest.java	Thu Dec 20 20:29:59 2012 +0000
@@ -42,7 +42,6 @@
 import javax.management.remote.rmi.RMIIIOPServerImpl;
 import javax.management.remote.rmi.RMIJRMPServerImpl;
 import javax.management.remote.rmi.RMIServerImpl;
-import org.omg.stub.javax.management.remote.rmi._RMIConnection_Stub;
 
 public class CloseableTest {
     private static final Class closeArray[] = {
@@ -51,26 +50,43 @@
         RMIConnection.class,
         RMIConnectionImpl.class,
         RMIConnectionImpl_Stub.class,
-        _RMIConnection_Stub.class,
         RMIServerImpl.class,
         RMIIIOPServerImpl.class,
         RMIJRMPServerImpl.class
     };
+
+    static int error;
+
+    static void test(Class<?> c) {
+        System.out.println("\nTest " + c);
+        if (Closeable.class.isAssignableFrom(c)) {
+            System.out.println("Test passed!");
+        } else {
+            error++;
+            System.out.println("Test failed!");
+        }
+    }
+
+    static void test(String cn) {
+        try {
+            test(Class.forName(cn));
+        } catch (ClassNotFoundException ignore) {
+            System.out.println("\n" + cn + " not tested.");
+        }
+    }
+
     public static void main(String[] args) throws Exception {
         System.out.println("Test that all the JMX Remote API classes that " +
                            "define\nthe method \"void close() throws " +
                            "IOException;\" extend\nor implement the " +
                            "java.io.Closeable interface.");
-        int error = 0;
-        for (Class c : closeArray) {
-            System.out.println("\nTest " + c);
-            if (Closeable.class.isAssignableFrom(c)) {
-                System.out.println("Test passed!");
-            } else {
-                error++;
-                System.out.println("Test failed!");
-            }
+        for (Class<?> c : closeArray) {
+            test(c);
         }
+
+        // Stub classes not present if RMI-IIOP not supported
+        test("org.omg.stub.javax.management.remote.rmi._RMIConnection_Stub");
+
         if (error > 0) {
             final String msg = "\nTest FAILED! Got " + error + " error(s)";
             System.out.println(msg);
--- a/test/javax/management/remote/mandatory/connection/ConnectionListenerNullTest.java	Thu Dec 20 20:12:32 2012 +0400
+++ b/test/javax/management/remote/mandatory/connection/ConnectionListenerNullTest.java	Thu Dec 20 20:29:59 2012 +0000
@@ -39,33 +39,22 @@
 import java.util.Map;
 public class ConnectionListenerNullTest {
 
-    static final boolean optionalFlag;
-    static {
-        Class genericClass = null;
+    static boolean isPresent(String cn) {
         try {
-            genericClass =
-            Class.forName("javax.management.remote.generic.GenericConnector");
+            Class.forName(cn);
+            return true;
         } catch (ClassNotFoundException x) {
-            // NO optional package
+            return false;
         }
-        optionalFlag = (genericClass != null);
     }
 
-    final static String[] mandatoryList = {
-        "service:jmx:rmi://", "service:jmx:iiop://"
-    };
-
-    final static String[] optionalList = {
-        "service:jmx:jmxmp://"
-    };
-
-    public static int test(String[] urls) {
+    public static int test(String... urls) {
         int errCount = 0;
         for (int i=0;i<urls.length;i++) {
             try {
                 final JMXServiceURL url = new JMXServiceURL(urls[i]);
                 final JMXConnector c =
-                    JMXConnectorFactory.newJMXConnector(url,(Map)null);
+                    JMXConnectorFactory.newJMXConnector(url,(Map<String,String>)null);
                 final NotificationListener nl = null;
                 final NotificationFilter   nf = null;
                 final Object               h  = null;
@@ -121,12 +110,19 @@
 
     public static void main(String args[]) {
         int errCount = 0;
-        errCount += test(mandatoryList);
-        if (optionalFlag) errCount += test(optionalList);
+
+        // mandatory
+        errCount += test("service:jmx:rmi://");
+
+        // optional
+        if (isPresent("javax.management.remote.rmi._RMIConnectionImpl_Tie"))
+            errCount += test("service:jmx:iiop://");
+        if (isPresent("javax.management.remote.generic.GenericConnector"))
+            errCount += test("service:jmx:jmxmp://");
+
         if (errCount > 0) {
-            System.err.println("ConnectionListenerNullTest failed: " +
-                               errCount + " error(s) reported.");
-            System.exit(1);
+            throw new RuntimeException("ConnectionListenerNullTest failed: " +
+                errCount + " error(s) reported.");
         }
         System.out.println("ConnectionListenerNullTest passed.");
     }
--- a/test/javax/management/remote/mandatory/connection/IIOPURLTest.java	Thu Dec 20 20:12:32 2012 +0400
+++ b/test/javax/management/remote/mandatory/connection/IIOPURLTest.java	Thu Dec 20 20:29:59 2012 +0000
@@ -49,17 +49,24 @@
     public static void main(String[] args) throws Exception {
         JMXServiceURL inputAddr =
             new JMXServiceURL("service:jmx:iiop://");
-        JMXConnectorServer s =
-            JMXConnectorServerFactory.newJMXConnectorServer(inputAddr, null,
-                                                            null);
+        JMXConnectorServer s;
+        try {
+            s = JMXConnectorServerFactory.newJMXConnectorServer(inputAddr, null, null);
+        } catch (java.net.MalformedURLException x) {
+            try {
+                Class.forName("javax.management.remote.rmi._RMIConnectionImpl_Tie");
+                throw new RuntimeException("MalformedURLException thrown but iiop appears to be supported");
+            } catch (ClassNotFoundException expected) { }
+            System.out.println("IIOP protocol not supported, test skipped");
+            return;
+        }
         MBeanServer mbs = MBeanServerFactory.createMBeanServer();
         mbs.registerMBean(s, new ObjectName("a:b=c"));
         s.start();
         JMXServiceURL outputAddr = s.getAddress();
         if (!outputAddr.getURLPath().startsWith("/ior/IOR:")) {
-            System.out.println("URL path should start with \"/ior/IOR:\": " +
-                               outputAddr);
-            System.exit(1);
+            throw new RuntimeException("URL path should start with \"/ior/IOR:\": " +
+                                       outputAddr);
         }
         System.out.println("IIOP URL path looks OK: " + outputAddr);
         JMXConnector c = JMXConnectorFactory.connect(outputAddr);
--- a/test/javax/management/remote/mandatory/connection/IdleTimeoutTest.java	Thu Dec 20 20:12:32 2012 +0400
+++ b/test/javax/management/remote/mandatory/connection/IdleTimeoutTest.java	Thu Dec 20 20:29:59 2012 +0000
@@ -52,21 +52,27 @@
 import com.sun.jmx.remote.util.EnvHelp;
 
 public class IdleTimeoutTest {
+
+    static boolean isPresent(String cn) {
+        try {
+            Class.forName(cn);
+            return true;
+        } catch (ClassNotFoundException x) {
+            return false;
+        }
+    }
+
     public static void main(String[] args) throws Exception {
         boolean ok = true;
         List protos;
         if (args.length > 0)
             protos = Arrays.asList(args);
         else {
-            protos =
-                new ArrayList(Arrays.asList(new String[] {"rmi", "iiop"}));
-            try {
-                Class.forName("javax.management.remote.jmxmp." +
-                              "JMXMPConnectorServer");
+            protos = new ArrayList(Arrays.asList(new String[] {"rmi"}));
+            if (isPresent("javax.management.remote.rmi._RMIConnectionImpl_Tie"))
+                protos.add("iiop");
+            if (isPresent("javax.management.remote.jmxmp.JMXMPConnectorServer"))
                 protos.add("jmxmp");
-            } catch (ClassNotFoundException e) {
-                // OK: Optional JMXMP support is not present
-            }
         }
         for (Iterator it = protos.iterator(); it.hasNext(); ) {
             String proto = (String) it.next();
@@ -81,13 +87,13 @@
             }
         }
         if (!ok) {
-            System.out.println("SOME TESTS FAILED");
-            System.exit(1);
+            throw new RuntimeException("Some tests failed - see log for details");
         }
     }
 
     private static long getIdleTimeout(MBeanServer mbs, JMXServiceURL url)
-        throws Exception {
+        throws Exception
+    {
         JMXConnectorServer server =
             JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
         server.start();
--- a/test/javax/management/remote/mandatory/connection/MultiThreadDeadLockTest.java	Thu Dec 20 20:12:32 2012 +0400
+++ b/test/javax/management/remote/mandatory/connection/MultiThreadDeadLockTest.java	Thu Dec 20 20:29:59 2012 +0000
@@ -253,4 +253,3 @@
         System.out.println("===Leave the method: " + m);
     }
 }
-
--- a/test/javax/management/remote/mandatory/connectorServer/SetMBeanServerForwarder.java	Thu Dec 20 20:12:32 2012 +0400
+++ b/test/javax/management/remote/mandatory/connectorServer/SetMBeanServerForwarder.java	Thu Dec 20 20:29:59 2012 +0000
@@ -40,27 +40,16 @@
 
 public class SetMBeanServerForwarder {
 
-    static final boolean optionalFlag;
-    static {
-        Class genericClass = null;
+    static boolean isPresent(String cn) {
         try {
-            genericClass =
-            Class.forName("javax.management.remote.generic.GenericConnector");
+            Class.forName(cn);
+            return true;
         } catch (ClassNotFoundException x) {
-            // NO optional package
+            return false;
         }
-        optionalFlag = (genericClass != null);
     }
 
-    final static String[] mandatoryList = {
-        "service:jmx:rmi://", "service:jmx:iiop://"
-    };
-
-    final static String[] optionalList = {
-        "service:jmx:jmxmp://"
-    };
-
-    public static int test(String[] urls) {
+    public static int test(String... urls) {
         int errorCount = 0;
         for (int i=0;i<urls.length;i++) {
             try {
@@ -241,12 +230,19 @@
 
     public static void main(String args[]) {
         int errCount = 0;
-        errCount += test(mandatoryList);
-        if (optionalFlag) errCount += test(optionalList);
+
+        // mandatory
+        errCount += test("service:jmx:rmi://");
+
+        // optional
+        if (isPresent("javax.management.remote.rmi._RMIConnectionImpl_Tie"))
+            errCount += test("service:jmx:iiop://");
+        if (isPresent("javax.management.remote.generic.GenericConnector"))
+            errCount += test("service:jmx:jmxmp://");
+
         if (errCount > 0) {
-            System.err.println("SetMBeanServerForwarder failed: " +
-                               errCount + " error(s) reported.");
-            System.exit(1);
+            throw new RuntimeException("SetMBeanServerForwarder failed: " +
+                                       errCount + " error(s) reported.");
         }
         System.out.println("SetMBeanServerForwarder passed.");
     }
--- a/test/javax/management/remote/mandatory/loading/MissingClassTest.java	Thu Dec 20 20:12:32 2012 +0400
+++ b/test/javax/management/remote/mandatory/loading/MissingClassTest.java	Thu Dec 20 20:29:59 2012 +0000
@@ -70,7 +70,6 @@
 import javax.management.remote.JMXConnectorServerFactory;
 import javax.management.remote.JMXServiceURL;
 import javax.management.remote.rmi.RMIConnectorServer;
-import org.omg.CORBA.MARSHAL;
 
 public class MissingClassTest {
     private static final int NNOTIFS = 50;
@@ -84,6 +83,15 @@
 
     private static final Object unserializableObject = Thread.currentThread();
 
+    private static boolean isInstance(Object o, String cn) {
+        try {
+            Class<?> c = Class.forName(cn);
+            return c.isInstance(o);
+        } catch (ClassNotFoundException x) {
+            return false;
+        }
+    }
+
     public static void main(String[] args) throws Exception {
         System.out.println("Test that the client or server end of a " +
                            "connection does not fail if sent an object " +
@@ -118,8 +126,7 @@
         if (ok)
             System.out.println("Test passed");
         else {
-            System.out.println("TEST FAILED");
-            System.exit(1);
+            throw new RuntimeException("TEST FAILED");
         }
     }
 
@@ -133,7 +140,7 @@
 
         JMXConnectorServer cs;
         JMXServiceURL url = new JMXServiceURL(proto, null, 0);
-        Map serverMap = new HashMap();
+        Map<String,Object> serverMap = new HashMap<>();
         serverMap.put(JMXConnectorServerFactory.DEFAULT_CLASS_LOADER,
                       serverLoader);
 
@@ -151,7 +158,7 @@
         }
         cs.start();
         JMXServiceURL addr = cs.getAddress();
-        Map clientMap = new HashMap();
+        Map<String,Object> clientMap = new HashMap<>();
         clientMap.put(JMXConnectorFactory.DEFAULT_CLASS_LOADER,
                       clientLoader);
 
@@ -174,7 +181,7 @@
             ok = false;
         } catch (IOException e) {
             Throwable cause = e.getCause();
-            if (cause instanceof MARSHAL)  // see CR 4935098
+            if (isInstance(cause, "org.omg.CORBA.MARSHAL"))  // see CR 4935098
                 cause = cause.getCause();
             if (cause instanceof ClassNotFoundException) {
                 System.out.println("Success: got an IOException wrapping " +
@@ -188,7 +195,7 @@
         }
 
         System.out.println("Doing queryNames to ensure connection alive");
-        Set names = mbsc.queryNames(null, null);
+        Set<ObjectName> names = mbsc.queryNames(null, null);
         System.out.println("queryNames returned " + names);
 
         System.out.println("Provoke exception of unknown class");
@@ -198,7 +205,7 @@
             ok = false;
         } catch (IOException e) {
             Throwable wrapped = e.getCause();
-            if (wrapped instanceof MARSHAL)  // see CR 4935098
+            if (isInstance(wrapped, "org.omg.CORBA.MARSHAL"))  // see CR 4935098
                 wrapped = wrapped.getCause();
             if (wrapped instanceof ClassNotFoundException) {
                 System.out.println("Success: got an IOException wrapping " +
@@ -251,7 +258,7 @@
                 ok = false;
             } catch (IOException e) {
                 Throwable cause = e.getCause();
-                if (cause instanceof MARSHAL)  // see CR 4935098
+                if (isInstance(cause, "org.omg.CORBA.MARSHAL"))  // see CR 4935098
                     cause = cause.getCause();
                 if (cause instanceof ClassNotFoundException) {
                     System.out.println("Success: got an IOException " +
@@ -584,15 +591,13 @@
             try {
                 new ObjectOutputStream(new ByteArrayOutputStream())
                     .writeObject(tricky);
-                System.out.println("TEST INCORRECT: tricky notif is " +
-                                   "serializable");
-                System.exit(1);
+                throw new RuntimeException("TEST INCORRECT: tricky notif is " +
+                                           "serializable");
             } catch (NotSerializableException e) {
                 // OK: tricky notif is not serializable
             } catch (IOException e) {
-                System.out.println("TEST INCORRECT: tricky notif " +
-                                   "serialization check failed");
-                System.exit(1);
+                throw new RuntimeException("TEST INCORRECT: tricky notif " +
+                                            "serialization check failed");
             }
 
             /* Now shuffle an imaginary deck of cards where K, U, T, and
@@ -629,12 +634,11 @@
             }
             if (knownCount != 0 || unknownCount != 0
                 || trickyCount != 0 || boringCount != 0) {
-                System.out.println("TEST INCORRECT: Shuffle failed: " +
+                throw new RuntimeException("TEST INCORRECT: Shuffle failed: " +
                                    "known=" + knownCount +" unknown=" +
                                    unknownCount + " tricky=" + trickyCount +
                                    " boring=" + boringCount +
                                    " deal=" + notifList);
-                System.exit(1);
             }
             String notifs = notifList.toString();
             System.out.println("Shuffle: " + notifs);
@@ -646,10 +650,8 @@
                 case 't': n = tricky; break;
                 case 'b': n = boring; break;
                 default:
-                    System.out.println("TEST INCORRECT: Bad shuffle char: " +
-                                       notifs.charAt(i));
-                    System.exit(1);
-                    throw new Error();
+                    throw new RuntimeException("TEST INCORRECT: Bad shuffle char: " +
+                                               notifs.charAt(i));
                 }
                 sendNotification(n);
             }
--- a/test/javax/management/remote/mandatory/provider/ProviderTest.java	Thu Dec 20 20:12:32 2012 +0400
+++ b/test/javax/management/remote/mandatory/provider/ProviderTest.java	Thu Dec 20 20:29:59 2012 +0000
@@ -49,13 +49,13 @@
 import provider.JMXConnectorProviderImpl;
 import provider.JMXConnectorServerProviderImpl;
 public class ProviderTest {
+
     public static void main(String[] args) throws Exception {
         System.out.println("Starting ProviderTest");
         MBeanServer mbs = MBeanServerFactory.newMBeanServer();
-        //First do the test with a protocol handled by Service providers
-        JMXServiceURL url =
-            new JMXServiceURL("service:jmx:rmi://");
 
+        // First do the test with a protocol handled by Service providers
+        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
         dotest(url, mbs);
 
         boolean clientCalled = provider.JMXConnectorProviderImpl.called();
@@ -66,16 +66,22 @@
                 System.out.println("Client provider not called");
             if (!serverCalled)
                 System.out.println("Server provider not called");
-            System.out.println("Test Failed");
-            System.exit(1);
+            throw new RuntimeException("Test failed - see log for details");
         }
 
-        //The Service Provider doesn't handle IIOP. Default providers MUST
-        //be called.
-        url =
-            new JMXServiceURL("service:jmx:iiop://");
-
-        dotest(url, mbs);
+        // The Service Provider doesn't handle IIOP. Default providers MUST
+        // be called, which may or may not support IIOP.
+        url = new JMXServiceURL("service:jmx:iiop://");
+        try {
+            dotest(url, mbs);
+        } catch (MalformedURLException e) {
+            try {
+                Class.forName("javax.management.remote.rmi._RMIConnectionImpl_Tie");
+                e.printStackTrace(System.out);
+                throw new RuntimeException("MalformedURLException throw but IIOP appears to be supported");
+            } catch (ClassNotFoundException expected) { }
+            System.out.println("MalformedURLException thrown, IIOP transport not supported");
+        }
 
         // Unsupported protocol.
         JMXConnectorServer server = null;
@@ -87,31 +93,19 @@
                 JMXConnectorServerFactory.newJMXConnectorServer(url,
                                                                 null,
                                                                 mbs);
-            System.out.println("Exception not thrown.");
-            System.exit(1);
-        }catch(MalformedURLException e) {
+            throw new RuntimeException("Exception not thrown.");
+        } catch (MalformedURLException e) {
             System.out.println("Expected MalformedURLException thrown.");
         }
-        catch(Exception e) {
-            e.printStackTrace();
-            System.out.println("Exception thrown : " + e);
-            System.exit(1);
-        }
 
         try {
             client =
                 JMXConnectorFactory.newJMXConnector(url,
                                                     null);
-            System.out.println("Exception not thrown.");
-            System.exit(1);
-        }catch(MalformedURLException e) {
+            throw new RuntimeException("Exception not thrown.");
+        } catch (MalformedURLException e) {
             System.out.println("Expected MalformedURLException thrown.");
         }
-        catch(Exception e) {
-            e.printStackTrace();
-            System.out.println("Exception thrown : " + e);
-            System.exit(1);
-        }
 
         //JMXConnectorProviderException
         url =
@@ -121,60 +115,34 @@
                 JMXConnectorServerFactory.newJMXConnectorServer(url,
                                                                 null,
                                                                 mbs);
-            System.out.println("Exception not thrown.");
-            System.exit(1);
-        }catch(JMXProviderException e) {
+            throw new RuntimeException("Exception not thrown.");
+        } catch(JMXProviderException e) {
             System.out.println("Expected JMXProviderException thrown.");
         }
-        catch(Exception e) {
-            e.printStackTrace();
-            System.out.println("Exception thrown : " + e);
-            System.exit(1);
-        }
 
         try {
             client =
                 JMXConnectorFactory.newJMXConnector(url,
                                                     null);
-            System.out.println("Exception not thrown.");
-            System.exit(1);
+            throw new RuntimeException("Exception not thrown.");
         }catch(JMXProviderException e) {
             System.out.println("Expected JMXProviderException thrown.");
         }
-        catch(Exception e) {
-            e.printStackTrace();
-            System.out.println("Exception thrown : " + e);
-            System.exit(1);
-        }
 
         System.out.println("Test OK");
-        return;
     }
 
     private static void dotest(JMXServiceURL url, MBeanServer mbs)
         throws Exception {
         JMXConnectorServer server = null;
         JMXConnector client = null;
-        try {
-            server =
-                JMXConnectorServerFactory.newJMXConnectorServer(url,
-                                                                null,
-                                                                mbs);
-        }catch(IllegalArgumentException e) {
-            e.printStackTrace();
-            System.exit(1);
-        }
+
+        server = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
         server.start();
         JMXServiceURL outputAddr = server.getAddress();
         System.out.println("Server started ["+ outputAddr+ "]");
 
-        try {
-            client =
-                JMXConnectorFactory.newJMXConnector(outputAddr, null);
-        }catch(IllegalArgumentException e) {
-            e.printStackTrace();
-            System.exit(1);
-        }
+        client = JMXConnectorFactory.newJMXConnector(outputAddr, null);
 
         client.connect();
         System.out.println("Client connected");
--- a/test/javax/management/remote/mandatory/serverError/JMXServerErrorTest.java	Thu Dec 20 20:12:32 2012 +0400
+++ b/test/javax/management/remote/mandatory/serverError/JMXServerErrorTest.java	Thu Dec 20 20:29:59 2012 +0000
@@ -120,7 +120,7 @@
         try {
             cs=JMXConnectorServerFactory.newJMXConnectorServer(jurl,null,kbs);
         } catch (MalformedURLException m) {
-            if ("jmxmp".equals(jurl.getProtocol())) {
+            if ("jmxmp".equals(jurl.getProtocol()) || "iiop".equals(jurl.getProtocol())) {
                 // OK, we may not have this in the classpath...
                 System.out.println("WARNING: Skipping protocol: " + jurl);
                 return;