jdk/test/javax/management/remote/mandatory/loading/RMIDownloadTest.java
author lana
Thu, 26 Dec 2013 12:04:16 -0800
changeset 23010 6dadb192ad81
parent 5506 202f599c92aa
child 30376 2ccf2cf7ea48
permissions -rw-r--r--
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013 Summary: updated files with 2011, 2012 and 2013 years according to the file's last updated date Reviewed-by: tbell, lancea, chegar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * @bug 5021246
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * @summary Check that class downloading is supported by RMI connector
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * @author Eamonn McManus
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * @run main RMIDownloadTest receive without
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * @run main RMIDownloadTest send without
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * @run main RMIDownloadTest receive with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * @run main RMIDownloadTest send with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * This test checks that class downloading is supported by the RMI connector.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * We copy a precompiled class file into the temporary directory (which we
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * assume is not in the classpath).  We also create an instance of that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * class using a hardcoded ClassLoader.  Then we try to get a remote attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * that returns that instance, and we try to set the remote attribute to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * instance.  In both cases, this will only work if the class can be downloaded
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * based on the codebase that we have set to the temporary directory.  We also
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * test that it does *not* work when the codebase is not set, in case the test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * is succeeding for some other reason.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * We run the test four times, for each combination of (send, receive) x
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * (with-codebase, without-codebase).  Doing all four tests within the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * run doesn't work, probably because RMI remembers the codebase property
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * setting at some point.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
import java.io.File;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
import java.io.FileOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
import java.io.OutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
import java.lang.management.ManagementFactory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
import java.net.URL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
import java.security.Permission;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
import java.util.Arrays;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
import javax.management.Attribute;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
import javax.management.MBeanServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
import javax.management.MBeanServerConnection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
import javax.management.ObjectName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
import javax.management.remote.JMXConnector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
import javax.management.remote.JMXConnectorFactory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
import javax.management.remote.JMXConnectorServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
import javax.management.remote.JMXConnectorServerFactory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
import javax.management.remote.JMXServiceURL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
public class RMIDownloadTest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    /* Following byte array was produced from this class:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * public class Zooby implements java.io.Serializable {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * by this program:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * public class MakeZooby {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     *     public static void main(String[] args) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     *         int b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     *         for (int offset = 0; (b = System.in.read()) >= 0; offset++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     *             System.out.print((byte) b + "," +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     *                              ((offset % 16) == 15 ? '\n' : ' '));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     *         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     *         System.out.println();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     *     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    private static final byte[] zoobyClassBytes = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        -54, -2, -70, -66, 0, 0, 0, 49, 0, 12, 10, 0, 3, 0, 8, 7,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        0, 9, 7, 0, 10, 7, 0, 11, 1, 0, 6, 60, 105, 110, 105, 116,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        62, 1, 0, 3, 40, 41, 86, 1, 0, 4, 67, 111, 100, 101, 12, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        5, 0, 6, 1, 0, 5, 90, 111, 111, 98, 121, 1, 0, 16, 106, 97,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        118, 97, 47, 108, 97, 110, 103, 47, 79, 98, 106, 101, 99, 116, 1, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        20, 106, 97, 118, 97, 47, 105, 111, 47, 83, 101, 114, 105, 97, 108, 105,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        122, 97, 98, 108, 101, 0, 33, 0, 2, 0, 3, 0, 1, 0, 4, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        0, 0, 1, 0, 1, 0, 5, 0, 6, 0, 1, 0, 7, 0, 0, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        17, 0, 1, 0, 1, 0, 0, 0, 5, 42, -73, 0, 1, -79, 0, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        0, 0, 0, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    private static class ZoobyClassLoader extends ClassLoader {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        protected Class<?> findClass(String name) throws ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            if (name.equals("Zooby")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                return super.defineClass(name, zoobyClassBytes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                        0, zoobyClassBytes.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            } else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                throw new ClassNotFoundException(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    private static MBeanServer pmbs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    private static ObjectName getSetName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    private static GetSet getSetInstance;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    public static void main(String[] args) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        int sendIndex = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        int withIndex = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        if (args.length == 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            sendIndex =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                    Arrays.asList("send", "receive").indexOf(args[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            withIndex =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                    Arrays.asList("with", "without").indexOf(args[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        if (sendIndex < 0 || withIndex < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            throw new Exception("Usage: RMIDownloadTest (send|receive) (with|without)");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        final boolean send = (sendIndex == 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        final boolean with = (withIndex == 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        pmbs = ManagementFactory.getPlatformMBeanServer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        getSetName = new ObjectName(":type=GetSet");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        getSetInstance = new GetSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        pmbs.registerMBean(getSetInstance, getSetName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        System.setSecurityManager(new LaidBackSecurityManager());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
//        System.setProperty("sun.rmi.loader.logLevel", "VERBOSE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        String tmpdir = System.getProperty("java.io.tmpdir");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        String classfile = tmpdir + File.separator + "Zooby.class";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        File zoobyFile = new File(classfile);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        zoobyFile.deleteOnExit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        OutputStream os = new FileOutputStream(zoobyFile);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        for (byte b : zoobyClassBytes)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            os.write(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        os.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        // Check that we can't load the Zooby class from the classpath
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            Class.forName("Zooby");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            throw new Exception("Class \"Zooby\" is in the classpath!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        } catch (ClassNotFoundException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            // OK: expected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        if (send)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            System.out.println("Testing we can send an object from client to server");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            System.out.println("Testing we can receive an object from server to client");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        if (with) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            // Test with the codebase property.  Downloading should work.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            URL zoobyURL = zoobyFile.getParentFile().toURI().toURL();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            System.setProperty("java.rmi.server.codebase", zoobyURL.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
            System.out.println("Testing with codebase, should work");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            System.out.println("Codebase is " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                    System.getProperty("java.rmi.server.codebase"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            test(send, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            // Test without setting the codebase property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            // This should not work; if it does it probably means java.io.tmpdir
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            // is in the classpath.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            System.out.println("Testing without codebase, should fail");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            test(send, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    private static void test(boolean send, boolean shouldWork) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            testWithException(send);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            if (shouldWork)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            System.out.println("Got exception as expected: " + e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        if (!shouldWork)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            throw new Exception("Test passed without codebase but should not");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    private static void testWithException(boolean send)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        ClassLoader zoobyCL = new ZoobyClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        Class<?> zoobyClass = Class.forName("Zooby", false, zoobyCL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        Object zooby = zoobyClass.newInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        JMXConnectorServer cs =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                JMXConnectorServerFactory.newJMXConnectorServer(url, null, pmbs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        cs.start();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        JMXServiceURL addr = cs.getAddress();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        JMXConnector cc = JMXConnectorFactory.connect(addr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        MBeanServerConnection mbsc = cc.getMBeanServerConnection();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        Object rzooby;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        if (send) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            System.out.println("Sending object...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            mbsc.setAttribute(getSetName, new Attribute("It", zooby));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            rzooby = getSetInstance.getIt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            System.out.println("Receiving object...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            getSetInstance.setIt(zooby);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            rzooby = mbsc.getAttribute(getSetName, "It");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        if (!rzooby.getClass().getName().equals("Zooby")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            throw new Exception("FAILED: remote object is not a Zooby");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        if (rzooby.getClass().getClassLoader() ==
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                zooby.getClass().getClassLoader()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            throw new Exception("FAILED: same class loader: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                    zooby.getClass().getClassLoader());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        cc.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        cs.stop();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    public static interface GetSetMBean {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        public Object getIt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        public void setIt(Object x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    public static class GetSet implements GetSetMBean {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        public GetSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        public Object getIt() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            return what;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        public void setIt(Object x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            this.what = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        private Object what;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    public static class LaidBackSecurityManager extends SecurityManager {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        public void checkPermission(Permission perm) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            // OK, dude
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
}