jdk/src/java.rmi/share/classes/sun/rmi/server/UnicastServerRef.java
author rriggs
Thu, 16 Mar 2017 16:16:31 -0400
changeset 45984 75fef64e21fa
parent 41231 3f8807f6fec3
child 45989 e4f526fd8e09
permissions -rw-r--r--
8163958: Improved garbage collection Reviewed-by: smarks, chegar, skoivu, rhalade
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
45984
75fef64e21fa 8163958: Improved garbage collection
rriggs
parents: 41231
diff changeset
     2
 * Copyright (c) 1996, 2017, 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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.rmi.server;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.io.ObjectInput;
41231
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
    30
import java.io.ObjectInputFilter;
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
    31
import java.io.ObjectInputStream;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.io.ObjectOutput;
37584
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
    33
import java.io.ObjectStreamClass;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.lang.reflect.InvocationTargetException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.lang.reflect.Method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.rmi.MarshalException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.rmi.Remote;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.rmi.RemoteException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.rmi.ServerError;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.rmi.ServerException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.rmi.UnmarshalException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.rmi.server.ExportException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.rmi.server.RemoteCall;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import java.rmi.server.RemoteRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import java.rmi.server.RemoteStub;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import java.rmi.server.ServerNotActiveException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import java.rmi.server.ServerRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import java.rmi.server.Skeleton;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
import java.rmi.server.SkeletonNotFoundException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
import java.security.AccessController;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import java.security.PrivilegedAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
import java.util.Collections;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
import java.util.Date;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
import java.util.HashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
import java.util.WeakHashMap;
37584
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
    57
import java.util.concurrent.atomic.AtomicInteger;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
import sun.rmi.runtime.Log;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
import sun.rmi.transport.LiveRef;
45984
75fef64e21fa 8163958: Improved garbage collection
rriggs
parents: 41231
diff changeset
    60
import sun.rmi.transport.StreamRemoteCall;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
import sun.rmi.transport.Target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
import sun.rmi.transport.tcp.TCPTransport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * UnicastServerRef implements the remote reference layer server-side
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * behavior for remote objects exported with the "UnicastRef" reference
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * type.
41231
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
    68
 * If an {@link ObjectInputFilter ObjectInputFilter} is supplied it is
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
    69
 * invoked during deserialization to filter the arguments,
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
    70
 * otherwise the default filter of {@link ObjectInputStream ObjectInputStream}
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
    71
 * applies.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * @author  Ann Wollrath
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * @author  Roger Riggs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * @author  Peter Jones
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 */
19211
32a04c562026 8022440: suppress deprecation warnings in sun.rmi
smarks
parents: 14342
diff changeset
    77
@SuppressWarnings("deprecation")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
public class UnicastServerRef extends UnicastRef
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    implements ServerRef, Dispatcher
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    /** value of server call log property */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    public static final boolean logCalls = AccessController.doPrivileged(
23333
b0af2c7c8c91 8035808: Eliminate dependency to GetPropertyAction and other sun.security.action convenient classes
mchung
parents: 21655
diff changeset
    83
        (PrivilegedAction<Boolean>) () -> Boolean.getBoolean("java.rmi.server.logCalls"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    /** server call log */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    public static final Log callLog =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        Log.getLog("sun.rmi.server.call", "RMI", logCalls);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    // use serialVersionUID from JDK 1.2.2 for interoperability
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    private static final long serialVersionUID = -7384275867073752268L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    /** flag to enable writing exceptions to System.err */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    private static final boolean wantExceptionLog =
23333
b0af2c7c8c91 8035808: Eliminate dependency to GetPropertyAction and other sun.security.action convenient classes
mchung
parents: 21655
diff changeset
    94
        AccessController.doPrivileged((PrivilegedAction<Boolean>) () ->
b0af2c7c8c91 8035808: Eliminate dependency to GetPropertyAction and other sun.security.action convenient classes
mchung
parents: 21655
diff changeset
    95
            Boolean.getBoolean("sun.rmi.server.exceptionTrace"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    private boolean forceStubUse = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * flag to remove server-side stack traces before marshalling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * exceptions thrown by remote invocations to this VM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    private static final boolean suppressStackTraces =
23333
b0af2c7c8c91 8035808: Eliminate dependency to GetPropertyAction and other sun.security.action convenient classes
mchung
parents: 21655
diff changeset
   104
        AccessController.doPrivileged((PrivilegedAction<Boolean>) () ->
b0af2c7c8c91 8035808: Eliminate dependency to GetPropertyAction and other sun.security.action convenient classes
mchung
parents: 21655
diff changeset
   105
            Boolean.getBoolean("sun.rmi.server.suppressStackTraces"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * skeleton to dispatch remote calls through, for 1.1 stub protocol
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * (may be null if stub class only uses 1.2 stub protocol)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    private transient Skeleton skel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
41231
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   113
    // The ObjectInputFilter for checking the invocation arguments
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   114
    private final transient ObjectInputFilter filter;
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   115
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    /** maps method hash to Method object for each remote method */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    private transient Map<Long,Method> hashToMethod_Map = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * A weak hash map, mapping classes to hash maps that map method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * hashes to method objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    private static final WeakClassHashMap<Map<Long,Method>> hashToMethod_Maps =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        new HashToMethod_Maps();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /** cache of impl classes that have no corresponding skeleton class */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    private static final Map<Class<?>,?> withoutSkeletons =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        Collections.synchronizedMap(new WeakHashMap<Class<?>,Void>());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
37584
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   130
    private final AtomicInteger methodCallIDCount = new AtomicInteger(0);
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   131
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * Create a new (empty) Unicast server remote reference.
41231
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   134
     * The filter is null to defer to the  default ObjectInputStream filter, if any.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    public UnicastServerRef() {
41231
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   137
        this.filter = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * Construct a Unicast server remote reference for a specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * liveRef.
41231
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   143
     * The filter is null to defer to the  default ObjectInputStream filter, if any.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    public UnicastServerRef(LiveRef ref) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        super(ref);
41231
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   147
        this.filter = null;
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   148
    }
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   149
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   150
    /**
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   151
     * Construct a Unicast server remote reference for a specified
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   152
     * liveRef and filter.
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   153
     */
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   154
    public UnicastServerRef(LiveRef ref, ObjectInputFilter filter) {
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   155
        super(ref);
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   156
        this.filter = filter;
2
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
     * Construct a Unicast server remote reference to be exported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * on the specified port.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    public UnicastServerRef(int port) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        super(new LiveRef(port));
41231
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   165
        this.filter = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * Constructs a UnicastServerRef to be exported on an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * anonymous port (i.e., 0) and that uses a pregenerated stub class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * (NOT a dynamic proxy instance) if 'forceStubUse' is 'true'.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * This constructor is only called by the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * UnicastRemoteObject.exportObject(Remote) passing 'true' for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * 'forceStubUse'.  The UnicastRemoteObject.exportObject(Remote) method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * returns RemoteStub, so it must ensure that the stub for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * exported object is an instance of a pregenerated stub class that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * extends RemoteStub (instead of an instance of a dynamic proxy class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * which is not an instance of RemoteStub).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    public UnicastServerRef(boolean forceStubUse) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        this(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        this.forceStubUse = forceStubUse;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * With the addition of support for dynamic proxies as stubs, this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * method is obsolete because it returns RemoteStub instead of the more
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * general Remote.  It should not be called.  It sets the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * 'forceStubUse' flag to true so that the stub for the exported object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * is forced to be an instance of the pregenerated stub class, which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * extends RemoteStub.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * Export this object, create the skeleton and stubs for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * dispatcher.  Create a stub based on the type of the impl,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * initialize it with the appropriate remote reference. Create the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * target defined by the impl, dispatcher (this) and stub.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * Export that target via the Ref.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    public RemoteStub exportObject(Remote impl, Object data)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        throws RemoteException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        forceStubUse = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        return (RemoteStub) exportObject(impl, data, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * Export this object, create the skeleton and stubs for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * dispatcher.  Create a stub based on the type of the impl,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * initialize it with the appropriate remote reference. Create the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * target defined by the impl, dispatcher (this) and stub.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * Export that target via the Ref.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    public Remote exportObject(Remote impl, Object data,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                               boolean permanent)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        throws RemoteException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    {
12040
558b0e0d5910 7146763: Warnings cleanup in the sun.rmi and related packages
khazra
parents: 10912
diff changeset
   218
        Class<?> implClass = impl.getClass();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        Remote stub;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            stub = Util.createProxy(implClass, getClientRef(), forceStubUse);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        } catch (IllegalArgumentException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            throw new ExportException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                "remote object implements illegal remote interface", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        if (stub instanceof RemoteStub) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            setSkeleton(impl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        Target target =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            new Target(impl, this, stub, ref.getObjID(), permanent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        ref.exportObject(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        hashToMethod_Map = hashToMethod_Maps.get(implClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        return stub;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * Return the hostname of the current client.  When called from a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * thread actively handling a remote method invocation the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * hostname of the client is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * @exception ServerNotActiveException If called outside of servicing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * a remote method invocation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    public String getClientHost() throws ServerNotActiveException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        return TCPTransport.getClientHost();
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
     * Discovers and sets the appropriate skeleton for the impl.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    public void setSkeleton(Remote impl) throws RemoteException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        if (!withoutSkeletons.containsKey(impl.getClass())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                skel = Util.createSkeleton(impl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            } catch (SkeletonNotFoundException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                 * Ignore exception for skeleton class not found, because a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                 * skeleton class is not necessary with the 1.2 stub protocol.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                 * Remember that this impl's class does not have a skeleton
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                 * class so we don't waste time searching for it again.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                withoutSkeletons.put(impl.getClass(), null);
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * Call to dispatch to the remote object (on the server side).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * The up-call to the server and the marshalling of return result
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * (or exception) should be handled before returning from this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * @param obj the target remote object for the call
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * @param call the "remote call" from which operation and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * method arguments can be obtained.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * @exception IOException If unable to marshal return result or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * release input or output streams
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    public void dispatch(Remote obj, RemoteCall call) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        // positive operation number in 1.1 stubs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        // negative version number in 1.2 stubs and beyond...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        int num;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        long op;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            // read remote call header
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            ObjectInput in;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
                in = call.getInputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                num = in.readInt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                if (num >= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                    if (skel != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                        oldDispatch(obj, call, num);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                        throw new UnmarshalException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                            "skeleton class not found but required " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                            "for client version");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                op = in.readLong();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
            } catch (Exception readEx) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
                throw new UnmarshalException("error unmarshalling call header",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                                             readEx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
             * Since only system classes (with null class loaders) will be on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
             * the execution stack during parameter unmarshalling for the 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
             * stub protocol, tell the MarshalInputStream not to bother trying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
             * to resolve classes using its superclasses's default method of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
             * consulting the first non-null class loader on the stack.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            MarshalInputStream marshalStream = (MarshalInputStream) in;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            marshalStream.skipDefaultResolveClass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
            Method method = hashToMethod_Map.get(op);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
            if (method == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                throw new UnmarshalException("unrecognized method hash: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                    "method not supported by remote object");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            // if calls are being logged, write out object id and operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
            logCall(obj, method);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
            // unmarshal parameters
37584
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   327
            Object[] params = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                unmarshalCustomCallData(in);
37584
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   331
                params = unmarshalParameters(obj, method, marshalStream);
45984
75fef64e21fa 8163958: Improved garbage collection
rriggs
parents: 41231
diff changeset
   332
            } catch (java.io.IOException | ClassNotFoundException e) {
75fef64e21fa 8163958: Improved garbage collection
rriggs
parents: 41231
diff changeset
   333
                // disable saving any refs in the inputStream for GC
75fef64e21fa 8163958: Improved garbage collection
rriggs
parents: 41231
diff changeset
   334
                ((StreamRemoteCall) call).discardPendingRefs();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                throw new UnmarshalException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                    "error unmarshalling arguments", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                call.releaseInputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
            // make upcall on remote object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
            Object result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                result = method.invoke(obj, params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            } catch (InvocationTargetException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                throw e.getTargetException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
            // marshal return value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                ObjectOutput out = call.getResultStream(true);
12040
558b0e0d5910 7146763: Warnings cleanup in the sun.rmi and related packages
khazra
parents: 10912
diff changeset
   352
                Class<?> rtype = method.getReturnType();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                if (rtype != void.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                    marshalValue(rtype, result, out);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            } catch (IOException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                throw new MarshalException("error marshalling return", ex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
                 * This throw is problematic because when it is caught below,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
                 * we attempt to marshal it back to the client, but at this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
                 * point, a "normal return" has already been indicated,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
                 * so marshalling an exception will corrupt the stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
                 * This was the case with skeletons as well; there is no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                 * immediately obvious solution without a protocol change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        } catch (Throwable e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
            logCallException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            ObjectOutput out = call.getResultStream(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
            if (e instanceof Error) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                e = new ServerError(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                    "Error occurred in server thread", (Error) e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
            } else if (e instanceof RemoteException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                e = new ServerException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                    "RemoteException occurred in server thread",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                    (Exception) e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
            if (suppressStackTraces) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                clearStackTraces(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
            out.writeObject(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
            call.releaseInputStream(); // in case skeleton doesn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            call.releaseOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
41231
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   389
    /**
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   390
     * Sets a filter for invocation arguments, if a filter has been set.
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   391
     * Called by dispatch before the arguments are read.
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   392
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    protected void unmarshalCustomCallData(ObjectInput in)
41231
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   394
            throws IOException, ClassNotFoundException {
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   395
        if (filter != null &&
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   396
                in instanceof ObjectInputStream) {
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   397
            // Set the filter on the stream
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   398
            ObjectInputStream ois = (ObjectInputStream) in;
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   399
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   400
            AccessController.doPrivileged((PrivilegedAction<Void>)() -> {
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   401
                ois.setObjectInputFilter(filter);
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   402
                return null;
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   403
            });
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   404
        }
3f8807f6fec3 8165806: UnicastServerRef support to export an object with a filter
rriggs
parents: 37584
diff changeset
   405
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * Handle server-side dispatch using the RMI 1.1 stub/skeleton
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * protocol, given a non-negative operation number that has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * already been read from the call stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * @param obj the target remote object for the call
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * @param call the "remote call" from which operation and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * method arguments can be obtained.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * @param op the operation number
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * @exception IOException if unable to marshal return result or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * release input or output streams
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    public void oldDispatch(Remote obj, RemoteCall call, int op)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        long hash;              // hash for matching stub with skeleton
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
            // read remote call header
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
            ObjectInput in;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                in = call.getInputStream();
10912
4f21298dca19 7077466: fix for RMI DGC
smarks
parents: 5506
diff changeset
   429
                try {
4f21298dca19 7077466: fix for RMI DGC
smarks
parents: 5506
diff changeset
   430
                    Class<?> clazz = Class.forName("sun.rmi.transport.DGCImpl_Skel");
4f21298dca19 7077466: fix for RMI DGC
smarks
parents: 5506
diff changeset
   431
                    if (clazz.isAssignableFrom(skel.getClass())) {
4f21298dca19 7077466: fix for RMI DGC
smarks
parents: 5506
diff changeset
   432
                        ((MarshalInputStream)in).useCodebaseOnly();
4f21298dca19 7077466: fix for RMI DGC
smarks
parents: 5506
diff changeset
   433
                    }
4f21298dca19 7077466: fix for RMI DGC
smarks
parents: 5506
diff changeset
   434
                } catch (ClassNotFoundException ignore) { }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                hash = in.readLong();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
            } catch (Exception readEx) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                throw new UnmarshalException("error unmarshalling call header",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                                             readEx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
            // if calls are being logged, write out object id and operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
            logCall(obj, skel.getOperations()[op]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
            unmarshalCustomCallData(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            // dispatch to skeleton for remote object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            skel.dispatch(obj, call, op, hash);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        } catch (Throwable e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
            logCallException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
            ObjectOutput out = call.getResultStream(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
            if (e instanceof Error) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                e = new ServerError(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                    "Error occurred in server thread", (Error) e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
            } else if (e instanceof RemoteException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                e = new ServerException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
                    "RemoteException occurred in server thread",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                    (Exception) e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
            if (suppressStackTraces) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
                clearStackTraces(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
            out.writeObject(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            call.releaseInputStream(); // in case skeleton doesn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
            call.releaseOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * Clear the stack trace of the given Throwable by replacing it with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * an empty StackTraceElement array, and do the same for all of its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * chained causative exceptions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    public static void clearStackTraces(Throwable t) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        StackTraceElement[] empty = new StackTraceElement[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        while (t != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
            t.setStackTrace(empty);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
            t = t.getCause();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * Log the details of an incoming call.  The method parameter is either of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * type java.lang.reflect.Method or java.rmi.server.Operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    private void logCall(Remote obj, Object method) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        if (callLog.isLoggable(Log.VERBOSE)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
            String clientHost;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
                clientHost = getClientHost();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
            } catch (ServerNotActiveException snae) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                clientHost = "(local)"; // shouldn't happen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
            callLog.log(Log.VERBOSE, "[" + clientHost + ": " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
                              obj.getClass().getName() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
                              ref.getObjID().toString() + ": " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
                              method + "]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * Log the exception detail of an incoming call.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    private void logCallException(Throwable e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        // if calls are being logged, log them
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        if (callLog.isLoggable(Log.BRIEF)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
            String clientHost = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
                clientHost = "[" + getClientHost() + "] ";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
            } catch (ServerNotActiveException snae) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
            callLog.log(Log.BRIEF, clientHost + "exception: ", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        // write exceptions (only) to System.err if desired
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        if (wantExceptionLog) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
            java.io.PrintStream log = System.err;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
            synchronized (log) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
                log.println();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
                log.println("Exception dispatching call to " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
                            ref.getObjID() + " in thread \"" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
                            Thread.currentThread().getName() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                            "\" at " + (new Date()) + ":");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
                e.printStackTrace(log);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * Returns the class of the ref type to be serialized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    public String getRefClass(ObjectOutput out) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
        return "UnicastServerRef";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     * Return the client remote reference for this remoteRef.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * In the case of a client RemoteRef "this" is the answer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * For a server remote reference, a client side one will have to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     * found or created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    protected RemoteRef getClientRef() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        return new UnicastRef(ref);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * Write out external representation for remote ref.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
    public void writeExternal(ObjectOutput out) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * Read in external representation for remote ref.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * @exception ClassNotFoundException If the class for an object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * being restored cannot be found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    public void readExternal(ObjectInput in)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        throws IOException, ClassNotFoundException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        // object is re-exported elsewhere (e.g., by UnicastRemoteObject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        ref = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        skel = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     * A weak hash map, mapping classes to hash maps that map method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     * hashes to method objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
    private static class HashToMethod_Maps
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        extends WeakClassHashMap<Map<Long,Method>>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
        HashToMethod_Maps() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        protected Map<Long,Method> computeValue(Class<?> remoteClass) {
12040
558b0e0d5910 7146763: Warnings cleanup in the sun.rmi and related packages
khazra
parents: 10912
diff changeset
   576
            Map<Long,Method> map = new HashMap<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
            for (Class<?> cl = remoteClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
                 cl != null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                 cl = cl.getSuperclass())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                for (Class<?> intf : cl.getInterfaces()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
                    if (Remote.class.isAssignableFrom(intf)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
                        for (Method method : intf.getMethods()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
                            final Method m = method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
                             * Set this Method object to override language
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
                             * access checks so that the dispatcher can invoke
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                             * methods from non-public remote interfaces.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                            AccessController.doPrivileged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                                new PrivilegedAction<Void>() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                                public Void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                                    m.setAccessible(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                            });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                            map.put(Util.computeMethodHash(m), m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
            return map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    }
37584
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   605
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   606
    /**
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   607
     * Unmarshal parameters for the given method of the given instance over
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   608
     * the given marshalinputstream. Perform any necessary checks.
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   609
     */
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   610
    private Object[] unmarshalParameters(Object obj, Method method, MarshalInputStream in)
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   611
    throws IOException, ClassNotFoundException {
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   612
        return (obj instanceof DeserializationChecker) ?
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   613
            unmarshalParametersChecked((DeserializationChecker)obj, method, in) :
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   614
            unmarshalParametersUnchecked(method, in);
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   615
    }
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   616
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   617
    /**
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   618
     * Unmarshal parameters for the given method of the given instance over
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   619
     * the given marshalinputstream. Do not perform any additional checks.
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   620
     */
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   621
    private Object[] unmarshalParametersUnchecked(Method method, ObjectInput in)
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   622
    throws IOException, ClassNotFoundException {
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   623
        Class<?>[] types = method.getParameterTypes();
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   624
        Object[] params = new Object[types.length];
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   625
        for (int i = 0; i < types.length; i++) {
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   626
            params[i] = unmarshalValue(types[i], in);
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   627
        }
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   628
        return params;
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   629
    }
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   630
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   631
    /**
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   632
     * Unmarshal parameters for the given method of the given instance over
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   633
     * the given marshalinputstream. Do perform all additional checks.
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   634
     */
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   635
    private Object[] unmarshalParametersChecked(
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   636
        DeserializationChecker checker,
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   637
        Method method, MarshalInputStream in)
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   638
    throws IOException, ClassNotFoundException {
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   639
        int callID = methodCallIDCount.getAndIncrement();
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   640
        MyChecker myChecker = new MyChecker(checker, method, callID);
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   641
        in.setStreamChecker(myChecker);
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   642
        try {
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   643
            Class<?>[] types = method.getParameterTypes();
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   644
            Object[] values = new Object[types.length];
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   645
            for (int i = 0; i < types.length; i++) {
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   646
                myChecker.setIndex(i);
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   647
                values[i] = unmarshalValue(types[i], in);
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   648
            }
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   649
            myChecker.end(callID);
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   650
            return values;
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   651
        } finally {
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   652
            in.setStreamChecker(null);
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   653
        }
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   654
    }
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   655
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   656
    private static class MyChecker implements MarshalInputStream.StreamChecker {
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   657
        private final DeserializationChecker descriptorCheck;
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   658
        private final Method method;
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   659
        private final int callID;
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   660
        private int parameterIndex;
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   661
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   662
        MyChecker(DeserializationChecker descriptorCheck, Method method, int callID) {
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   663
            this.descriptorCheck = descriptorCheck;
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   664
            this.method = method;
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   665
            this.callID = callID;
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   666
        }
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   667
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   668
        @Override
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   669
        public void validateDescriptor(ObjectStreamClass descriptor) {
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   670
            descriptorCheck.check(method, descriptor, parameterIndex, callID);
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   671
        }
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   672
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   673
        @Override
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   674
        public void checkProxyInterfaceNames(String[] ifaces) {
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   675
            descriptorCheck.checkProxyClass(method, ifaces, parameterIndex, callID);
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   676
        }
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   677
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   678
        void setIndex(int parameterIndex) {
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   679
            this.parameterIndex = parameterIndex;
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   680
        }
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   681
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   682
        void end(int callId) {
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   683
            descriptorCheck.end(callId);
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   684
        }
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 25859
diff changeset
   685
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
}