@Throws(Exception::class) operator fun invoke( obj: java.rmi.Remote?, method: Method?, params: Array<Any?>?, opnum: Long ): Any? { var force = false var localRef: java.rmi.server.RemoteRef var exception: Exception? = null synchronized(this) { if (sun.jvm.hotspot.oops.CellTypeState.ref == null) { localRef = activate(force) force = true } else { localRef = sun.jvm.hotspot.oops.CellTypeState.ref } } for (retries in MAX_RETRIES downTo 1) { try { return localRef.invoke(obj, method, params, opnum) } catch (e: java.rmi.NoSuchObjectException) { exception = e } catch (e: ConnectException) { exception = e } catch (e: UnknownHostException) { exception = e } catch (e: java.rmi.ConnectIOException) { exception = e } catch (e: MarshalException) { throw e } catch (e: java.rmi.ServerError) { throw e } catch (e: java.rmi.ServerException) { throw e } catch (e: RemoteException) { synchronized(this) { if (localRef === sun.jvm.hotspot.oops.CellTypeState.ref) { sun.jvm.hotspot.oops.CellTypeState.ref = null } } throw e } if (retries > 1) { synchronized(this) { if (localRef.remoteEquals(sun.jvm.hotspot.oops.CellTypeState.ref) || sun.jvm.hotspot.oops.CellTypeState.ref == null) { var newRef: java.rmi.server.RemoteRef = activate(force) if (newRef.remoteEquals(localRef) && exception is java.rmi.NoSuchObjectException && force == false) { newRef = activate(true) } localRef = newRef force = true } else { localRef = sun.jvm.hotspot.oops.CellTypeState.ref force = false } } } } throw exception!! }
Invoke method on remote object . This method delegates remote method invocation to the underlying ref type . If the underlying reference is not known ( is null ) , then the object must be activated first . If an attempt at method invocation fails , the object should force reactivation . Method invocation must preserve `` at most once '' call semantics . In RMI , `` at most once '' applies to parameter deserialization at the remote site and the remote object 's method execution . `` At most once '' does not apply to parameter serialization at the client so the parameters of a call do n't need to be buffered in anticipation of call retry . Thus , a method call is only be retried if the initial method invocation does not execute at all at the server ( including parameter deserialization ) .