/** * Invokes a remote method. * * @param oneWay if the target should send the response back. * @param methodId the target method id * @param params parameters for the method, must all be serializable. * @param <R> generic parameter to make the compiler happy. * @return a task that will contain the returned value, or if one-way a task indicating if the message could be send. */ @SuppressWarnings("unchecked") protected <R> Task<R> invoke(final Method method, final boolean oneWay, final int methodId, final Object[] params) { return (Task<R>) (runtime != null ? runtime : BasicRuntime.getRuntime()).invoke(this, method, oneWay, methodId, params); }