jdk/src/share/classes/sun/rmi/server/Util.java
author xdono
Wed, 02 Jul 2008 12:55:45 -0700
changeset 715 f16baef3a20e
parent 51 6fe31bc95bbc
child 5506 202f599c92aa
permissions -rw-r--r--
6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 51
diff changeset
     2
 * Copyright 1996-2008 Sun Microsystems, Inc.  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.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package sun.rmi.server;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.io.ByteArrayOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.io.DataOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.lang.reflect.Constructor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.lang.reflect.InvocationHandler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.lang.reflect.InvocationTargetException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.lang.reflect.Proxy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.lang.reflect.Method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.rmi.Remote;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.rmi.RemoteException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.rmi.StubNotFoundException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.rmi.registry.Registry;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.rmi.server.LogStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.rmi.server.ObjID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.rmi.server.RMIClientSocketFactory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.rmi.server.RemoteObjectInvocationHandler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.rmi.server.RemoteRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import java.rmi.server.RemoteStub;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import java.rmi.server.Skeleton;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import java.rmi.server.SkeletonNotFoundException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import java.security.AccessController;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import java.security.MessageDigest;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
import java.security.DigestOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
import java.security.NoSuchAlgorithmException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import java.util.ArrayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
import java.util.Collections;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
import java.util.WeakHashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
import sun.rmi.registry.RegistryImpl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
import sun.rmi.runtime.Log;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
import sun.rmi.transport.LiveRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
import sun.rmi.transport.tcp.TCPEndpoint;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
import sun.security.action.GetBooleanAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
import sun.security.action.GetPropertyAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * A utility class with static methods for creating stubs/proxies and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * skeletons for remote objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
public final class Util {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /** "server" package log level */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    static final int logLevel = LogStream.parseLevel(
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
    70
        AccessController.doPrivileged(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
            new GetPropertyAction("sun.rmi.server.logLevel")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    /** server reference log */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    public static final Log serverRefLog =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        Log.getLog("sun.rmi.server.ref", "transport", Util.logLevel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /** cached value of property java.rmi.server.ignoreStubClasses */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    private static final boolean ignoreStubClasses =
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
    79
        AccessController.doPrivileged(
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
    80
            new GetBooleanAction("java.rmi.server.ignoreStubClasses")).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
            booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    /** cache of  impl classes that have no corresponding stub class */
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
    84
    private static final Map<Class<?>, Void> withoutStubs =
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
    85
        Collections.synchronizedMap(new WeakHashMap<Class<?>, Void>(11));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    /** parameter types for stub constructor */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    private static final Class[] stubConsParamTypes = { RemoteRef.class };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    private Util() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * Returns a proxy for the specified implClass.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * If both of the following criteria is satisfied, a dynamic proxy for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * the specified implClass is returned (otherwise a RemoteStub instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * for the specified implClass is returned):
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     *    a) either the property java.rmi.server.ignoreStubClasses is true or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     *       a pregenerated stub class does not exist for the impl class, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     *    b) forceStubUse is false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * If the above criteria are satisfied, this method constructs a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * dynamic proxy instance (that implements the remote interfaces of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * implClass) constructed with a RemoteObjectInvocationHandler instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * constructed with the clientRef.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * Otherwise, this method loads the pregenerated stub class (which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * extends RemoteStub and implements the remote interfaces of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * implClass) and constructs an instance of the pregenerated stub
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * class with the clientRef.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * @param implClass the class to obtain remote interfaces from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * @param clientRef the remote ref to use in the invocation handler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @param forceStubUse if true, forces creation of a RemoteStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * @throws IllegalArgumentException if implClass implements illegal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * remote interfaces
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * @throws StubNotFoundException if problem locating/creating stub or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * creating the dynamic proxy instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    public static Remote createProxy(Class implClass,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                                     RemoteRef clientRef,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                                     boolean forceStubUse)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        throws StubNotFoundException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        Class remoteClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            remoteClass = getRemoteClass(implClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        } catch (ClassNotFoundException ex ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            throw new StubNotFoundException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                "object does not implement a remote interface: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                implClass.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        if (forceStubUse ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            !(ignoreStubClasses || !stubClassExists(remoteClass)))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            return createStub(remoteClass, clientRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        ClassLoader loader = implClass.getClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        Class[] interfaces = getRemoteInterfaces(implClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        InvocationHandler handler =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            new RemoteObjectInvocationHandler(clientRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        /* REMIND: private remote interfaces? */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            return (Remote) Proxy.newProxyInstance(loader,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                                                   interfaces,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                                                   handler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        } catch (IllegalArgumentException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            throw new StubNotFoundException("unable to create proxy", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * Returns true if a stub class for the given impl class can be loaded,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * otherwise returns false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * @param remoteClass the class to obtain remote interfaces from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    private static boolean stubClassExists(Class remoteClass) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        if (!withoutStubs.containsKey(remoteClass)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                Class.forName(remoteClass.getName() + "_Stub",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                              false,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                              remoteClass.getClassLoader());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            } catch (ClassNotFoundException cnfe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                withoutStubs.put(remoteClass, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * Returns the class/superclass that implements the remote interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * @throws ClassNotFoundException if no class is found to have a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * remote interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    private static Class getRemoteClass(Class cl)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        throws ClassNotFoundException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        while (cl != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            Class[] interfaces = cl.getInterfaces();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            for (int i = interfaces.length -1; i >= 0; i--) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                if (Remote.class.isAssignableFrom(interfaces[i]))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                    return cl;          // this class implements remote object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            cl = cl.getSuperclass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        throw new ClassNotFoundException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                "class does not implement java.rmi.Remote");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * Returns an array containing the remote interfaces implemented
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * by the given class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * @param   remoteClass the class to obtain remote interfaces from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * @throws  IllegalArgumentException if remoteClass implements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     *          any illegal remote interfaces
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * @throws  NullPointerException if remoteClass is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    private static Class[] getRemoteInterfaces(Class remoteClass) {
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   210
        ArrayList<Class<?>> list = new ArrayList<Class<?>>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        getRemoteInterfaces(list, remoteClass);
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   212
        return list.toArray(new Class<?>[list.size()]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * Fills the given array list with the remote interfaces implemented
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * by the given class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * @throws  IllegalArgumentException if the specified class implements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     *          any illegal remote interfaces
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * @throws  NullPointerException if the specified class or list is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     */
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   223
    private static void getRemoteInterfaces(ArrayList<Class<?>> list, Class cl) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        Class superclass = cl.getSuperclass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        if (superclass != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            getRemoteInterfaces(list, superclass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        Class[] interfaces = cl.getInterfaces();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        for (int i = 0; i < interfaces.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            Class intf = interfaces[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
             * If it is a remote interface (if it extends from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
             * java.rmi.Remote) and is not already in the list,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
             * then add the interface to the list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            if (Remote.class.isAssignableFrom(intf)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                if (!(list.contains(intf))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                    Method[] methods = intf.getMethods();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                    for (int j = 0; j < methods.length; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                        checkMethod(methods[j]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                    list.add(intf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * Verifies that the supplied method has at least one declared exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * type that is RemoteException or one of its superclasses.  If not,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * then this method throws IllegalArgumentException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * @throws IllegalArgumentException if m is an illegal remote method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    private static void checkMethod(Method m) {
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   257
        Class<?>[] ex = m.getExceptionTypes();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        for (int i = 0; i < ex.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            if (ex[i].isAssignableFrom(RemoteException.class))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        throw new IllegalArgumentException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            "illegal remote method encountered: " + m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * Creates a RemoteStub instance for the specified class, constructed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * with the specified RemoteRef.  The supplied class must be the most
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * derived class in the remote object's superclass chain that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * implements a remote interface.  The stub class name is the name of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * the specified remoteClass with the suffix "_Stub".  The loading of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * the stub class is initiated from class loader of the specified class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * (which may be the bootstrap class loader).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    private static RemoteStub createStub(Class remoteClass, RemoteRef ref)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        throws StubNotFoundException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        String stubname = remoteClass.getName() + "_Stub";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        /* Make sure to use the local stub loader for the stub classes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
         * When loaded by the local loader the load path can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
         * propagated to remote clients, by the MarshalOutputStream/InStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
         * pickle methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        try {
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   286
            Class<?> stubcl =
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                Class.forName(stubname, false, remoteClass.getClassLoader());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            Constructor cons = stubcl.getConstructor(stubConsParamTypes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            return (RemoteStub) cons.newInstance(new Object[] { ref });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        } catch (ClassNotFoundException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            throw new StubNotFoundException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                "Stub class not found: " + stubname, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        } catch (NoSuchMethodException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            throw new StubNotFoundException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                "Stub class missing constructor: " + stubname, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        } catch (InstantiationException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
            throw new StubNotFoundException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                "Can't create instance of stub class: " + stubname, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        } catch (IllegalAccessException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
            throw new StubNotFoundException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                "Stub class constructor not public: " + stubname, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        } catch (InvocationTargetException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            throw new StubNotFoundException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                "Exception creating instance of stub class: " + stubname, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        } catch (ClassCastException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            throw new StubNotFoundException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                "Stub class not instance of RemoteStub: " + stubname, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * Locate and return the Skeleton for the specified remote object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    static Skeleton createSkeleton(Remote object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        throws SkeletonNotFoundException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        Class cl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
            cl = getRemoteClass(object.getClass());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        } catch (ClassNotFoundException ex ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
            throw new SkeletonNotFoundException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
                "object does not implement a remote interface: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                object.getClass().getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        // now try to load the skeleton based ont he name of the class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        String skelname = cl.getName() + "_Skel";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
            Class skelcl = Class.forName(skelname, false, cl.getClassLoader());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
            return (Skeleton)skelcl.newInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        } catch (ClassNotFoundException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
            throw new SkeletonNotFoundException("Skeleton class not found: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                                                skelname, ex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        } catch (InstantiationException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
            throw new SkeletonNotFoundException("Can't create skeleton: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                                                skelname, ex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        } catch (IllegalAccessException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
            throw new SkeletonNotFoundException("No public constructor: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                                                skelname, ex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        } catch (ClassCastException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
            throw new SkeletonNotFoundException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                "Skeleton not of correct class: " + skelname, ex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * Compute the "method hash" of a remote method.  The method hash
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * is a long containing the first 64 bits of the SHA digest from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * the UTF encoded string of the method name and descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    public static long computeMethodHash(Method m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        long hash = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        ByteArrayOutputStream sink = new ByteArrayOutputStream(127);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
            MessageDigest md = MessageDigest.getInstance("SHA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
            DataOutputStream out = new DataOutputStream(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
                new DigestOutputStream(sink, md));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
            String s = getMethodNameAndDescriptor(m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
            if (serverRefLog.isLoggable(Log.VERBOSE)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
                serverRefLog.log(Log.VERBOSE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                    "string used for method hash: \"" + s + "\"");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
            out.writeUTF(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
            // use only the first 64 bits of the digest for the hash
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
            out.flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            byte hasharray[] = md.digest();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
            for (int i = 0; i < Math.min(8, hasharray.length); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                hash += ((long) (hasharray[i] & 0xFF)) << (i * 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        } catch (IOException ignore) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
            /* can't happen, but be deterministic anyway. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
            hash = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        } catch (NoSuchAlgorithmException complain) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
            throw new SecurityException(complain.getMessage());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        return hash;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * Return a string consisting of the given method's name followed by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * its "method descriptor", as appropriate for use in the computation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * of the "method hash".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * See section 4.3.3 of The Java Virtual Machine Specification for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * the definition of a "method descriptor".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    private static String getMethodNameAndDescriptor(Method m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        StringBuffer desc = new StringBuffer(m.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        desc.append('(');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        Class[] paramTypes = m.getParameterTypes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        for (int i = 0; i < paramTypes.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
            desc.append(getTypeDescriptor(paramTypes[i]));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        desc.append(')');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        Class returnType = m.getReturnType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        if (returnType == void.class) { // optimization: handle void here
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
            desc.append('V');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
            desc.append(getTypeDescriptor(returnType));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        return desc.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * Get the descriptor of a particular type, as appropriate for either
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * a parameter or return type in a method descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    private static String getTypeDescriptor(Class type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        if (type.isPrimitive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
            if (type == int.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                return "I";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
            } else if (type == boolean.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
                return "Z";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
            } else if (type == byte.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                return "B";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
            } else if (type == char.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                return "C";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
            } else if (type == short.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                return "S";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
            } else if (type == long.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                return "J";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
            } else if (type == float.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                return "F";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
            } else if (type == double.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                return "D";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
            } else if (type == void.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                return "V";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                throw new Error("unrecognized primitive type: " + type);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        } else if (type.isArray()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
             * According to JLS 20.3.2, the getName() method on Class does
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
             * return the VM type descriptor format for array classes (only);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
             * using that should be quicker than the otherwise obvious code:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
             *     return "[" + getTypeDescriptor(type.getComponentType());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
            return type.getName().replace('.', '/');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            return "L" + type.getName().replace('.', '/') + ";";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * Returns the binary name of the given type without package
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * qualification.  Nested types are treated no differently from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * top-level types, so for a nested type, the returned name will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * still be qualified with the simple name of its enclosing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * top-level type (and perhaps other enclosing types), the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * separator will be '$', etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    public static String getUnqualifiedName(Class c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        String binaryName = c.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        return binaryName.substring(binaryName.lastIndexOf('.') + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
}