Top Description Fields Constructors Methods
sun.rmi.server

public final Class Util

extends Object
Class Inheritance
Annotations
@SuppressWarnings:deprecation
Imports
java.io.ByteArrayOutputStream, .IOException, .DataOutputStream, java.lang.reflect.Constructor, .InvocationHandler, .InvocationTargetException, .Proxy, .Method, java.rmi.Remote, .RemoteException, .StubNotFoundException, java.rmi.registry.Registry, java.rmi.server.LogStream, .ObjID, .RMIClientSocketFactory, .RemoteObjectInvocationHandler, .RemoteRef, .RemoteStub, .Skeleton, .SkeletonNotFoundException, java.security.AccessController, .MessageDigest, .DigestOutputStream, .NoSuchAlgorithmException, .PrivilegedAction, java.util.ArrayList, .Collections, .Map, .WeakHashMap, sun.rmi.registry.RegistryImpl, sun.rmi.runtime.Log, sun.rmi.transport.LiveRef, sun.rmi.transport.tcp.TCPEndpoint

A utility class with static methods for creating stubs/proxies and skeletons for remote objects.

Field Summary

Modifier and TypeField and Description
private static final boolean
ignoreStubClasses

cached value of property java.rmi.server.ignoreStubClasses

pack-priv static final int
logLevel

"server" package log level

public static final Log
serverRefLog

server reference log

private static final Class<?>[]
stubConsParamTypes

parameter types for stub constructor

private static final Map<Class<?>, Void>
withoutStubs

cache of impl classes that have no corresponding stub class

Constructor Summary

AccessConstructor and Description
private
Util()

Method Summary

Modifier and TypeMethod and Description
private static void
checkMethod(Method m)

Verifies that the supplied method has at least one declared exception type that is RemoteException or one of its superclasses.

public static long
computeMethodHash(Method m)

Compute the "method hash" of a remote method.

public static Remote
createProxy(Class<?>
the class to obtain remote interfaces from
implClass
,
RemoteRef
the remote ref to use in the invocation handler
clientRef
,
boolean
if true, forces creation of a RemoteStub
forceStubUse
)

Returns a proxy for the specified implClass.

pack-priv static Skeleton
createSkeleton(Remote object)

Deprecated as a consequence of Skeleton being deprecated.
Locate and return the Skeleton for the specified remote object
private static RemoteStub
createStub(Class<?> remoteClass, RemoteRef ref)

Deprecated as a consequence of RemoteStub being deprecated.
Creates a RemoteStub instance for the specified class, constructed with the specified RemoteRef.
private static String
getMethodNameAndDescriptor(Method m)

Return a string consisting of the given method's name followed by its "method descriptor", as appropriate for use in the computation of the "method hash".

private static Class<?>
private static Class<?>[]
getRemoteInterfaces(Class<?>
the class to obtain remote interfaces from
remoteClass
)

Returns an array containing the remote interfaces implemented by the given class.

private static void
getRemoteInterfaces(ArrayList<Class<?>> list, Class<?> cl)

Fills the given array list with the remote interfaces implemented by the given class.

private static String
getTypeDescriptor(Class<?> type)

Get the descriptor of a particular type, as appropriate for either a parameter or return type in a method descriptor.

public static String
getUnqualifiedName(Class<?> c)

Returns the binary name of the given type without package qualification.

private static boolean
stubClassExists(Class<?>
the class to obtain remote interfaces from
remoteClass
)

Returns true if a stub class for the given impl class can be loaded, otherwise returns false.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ignoreStubClassesback to summary
private static final boolean ignoreStubClasses

cached value of property java.rmi.server.ignoreStubClasses

Annotations
@SuppressWarnings:removal
logLevelback to summary
pack-priv static final int logLevel

"server" package log level

Annotations
@SuppressWarnings:removal
serverRefLogback to summary
public static final Log serverRefLog

server reference log

stubConsParamTypesback to summary
private static final Class<?>[] stubConsParamTypes

parameter types for stub constructor

withoutStubsback to summary
private static final Map<Class<?>, Void> withoutStubs

cache of impl classes that have no corresponding stub class

Constructor Detail

Utilback to summary
private Util()

Method Detail

checkMethodback to summary
private static void checkMethod(Method m)

Verifies that the supplied method has at least one declared exception type that is RemoteException or one of its superclasses. If not, then this method throws IllegalArgumentException.

Exceptions
IllegalArgumentException:
if m is an illegal remote method
computeMethodHashback to summary
public static long computeMethodHash(Method m)

Compute the "method hash" of a remote method. The method hash is a long containing the first 64 bits of the SHA digest from the UTF encoded string of the method name and descriptor.

createProxyback to summary
public static Remote createProxy(Class<?> implClass, RemoteRef clientRef, boolean forceStubUse) throws StubNotFoundException

Returns a proxy for the specified implClass. If both of the following criteria is satisfied, a dynamic proxy for the specified implClass is returned (otherwise a RemoteStub instance for the specified implClass is returned): a) either the property java.rmi.server.ignoreStubClasses is true or a pregenerated stub class does not exist for the impl class, and b) forceStubUse is false. If the above criteria are satisfied, this method constructs a dynamic proxy instance (that implements the remote interfaces of implClass) constructed with a RemoteObjectInvocationHandler instance constructed with the clientRef. Otherwise, this method loads the pregenerated stub class (which extends RemoteStub and implements the remote interfaces of implClass) and constructs an instance of the pregenerated stub class with the clientRef.

Parameters
implClass:Class<?>

the class to obtain remote interfaces from

clientRef:RemoteRef

the remote ref to use in the invocation handler

forceStubUse:boolean

if true, forces creation of a RemoteStub

Annotations
@SuppressWarnings:removal
Exceptions
StubNotFoundException:
if problem locating/creating stub or creating the dynamic proxy instance
IllegalArgumentException:
if implClass implements illegal remote interfaces
createSkeletonback to summary
pack-priv static Skeleton createSkeleton(Remote object) throws SkeletonNotFoundException

Deprecated

as a consequence of Skeleton being deprecated. See corresponding docs for further information.

Locate and return the Skeleton for the specified remote object

createStubback to summary
private static RemoteStub createStub(Class<?> remoteClass, RemoteRef ref) throws StubNotFoundException

Deprecated

as a consequence of RemoteStub being deprecated. See corresponding docs for further information.

Creates a RemoteStub instance for the specified class, constructed with the specified RemoteRef. The supplied class must be the most derived class in the remote object's superclass chain that implements a remote interface. The stub class name is the name of the specified remoteClass with the suffix "_Stub". The loading of the stub class is initiated from class loader of the specified class (which may be the bootstrap class loader).

getMethodNameAndDescriptorback to summary
private static String getMethodNameAndDescriptor(Method m)

Return a string consisting of the given method's name followed by its "method descriptor", as appropriate for use in the computation of the "method hash". See section 4.3.3 of The Java Virtual Machine Specification for the definition of a "method descriptor".

getRemoteClassback to summary
private static Class<?> getRemoteClass(Class<?> cl) throws ClassNotFoundException
getRemoteInterfacesback to summary
private static Class<?>[] getRemoteInterfaces(Class<?> remoteClass)

Returns an array containing the remote interfaces implemented by the given class.

Parameters
remoteClass:Class<?>

the class to obtain remote interfaces from

Exceptions
IllegalArgumentException:
if remoteClass implements any illegal remote interfaces
NullPointerException:
if remoteClass is null
getRemoteInterfacesback to summary
private static void getRemoteInterfaces(ArrayList<Class<?>> list, Class<?> cl)

Fills the given array list with the remote interfaces implemented by the given class.

Exceptions
IllegalArgumentException:
if the specified class implements any illegal remote interfaces
NullPointerException:
if the specified class or list is null
getTypeDescriptorback to summary
private static String getTypeDescriptor(Class<?> type)

Get the descriptor of a particular type, as appropriate for either a parameter or return type in a method descriptor.

getUnqualifiedNameback to summary
public static String getUnqualifiedName(Class<?> c)

Returns the binary name of the given type without package qualification. Nested types are treated no differently from top-level types, so for a nested type, the returned name will still be qualified with the simple name of its enclosing top-level type (and perhaps other enclosing types), the separator will be '$', etc.

stubClassExistsback to summary
private static boolean stubClassExists(Class<?> remoteClass)

Returns true if a stub class for the given impl class can be loaded, otherwise returns false.

Parameters
remoteClass:Class<?>

the class to obtain remote interfaces from