Calls a JavaScript method on the object.
@param method The name of the method.
@param returnType The return type.
@param args Method arguments.
@param <T> Java type for the return value.
@return A return value.
952
@Nullable
    protected final <T> T jsiiCall(final String method, final Class<T> returnType, @Nullable final Object... args) {
        return JsiiObjectMapper.treeToValue(JsiiObject.engine.getClient()
                                                                .callMethod(this.objRef,
                                                                            method,
                                                                            JsiiObjectMapper.valueToTree(args)),
                                            returnType);
    }
400500
public void call(String method, Object[] args)
        throws IOException
    {
        int length = args != null ? args.length : 0;

        startCall(method, length);

        for (int i = 0; i < length; i++)
            writeObject(args[i]);

        completeCall();
    }

    /**
     * Starts the method call:
     *
     * <code><pre>
     * C
     * </pre></code>
     *
     * @param method the method name to call.
     */
    abstract public void startCall()
        throws IOException;

    /**
     * Starts the method call:
     *
     * <code><pre>
     * C string int
     * </pre></code>
     *
     * @param method the method name to call.
     */
    abstract public void startCall(String method, int length)
        throws IOException;

    /**
     * For Hessian 2.0, use the Header envelope instead
     *
     * @deprecated
     */
    public void writeHeader(String name)
        throws IOException
    {
        throw new UnsupportedOperationException(getClass().getSimpleName());
    }

    /**
     * Writes the method tag.
     *
     * <code><pre>
     * string
     * </pre></code>
     *
     * @param method the method name to call.
     */
    abstract public void writeMethod(String method)
        throws IOException;

    /**
     * Completes the method call:
     *
     * <code><pre>
     * </pre></code>
     */
    abstract public void completeCall()
        throws IOException;

    /**
     * Writes a boolean value to the stream.  The boolean will be written
     * with the following syntax:
     *
     * <code><pre>
     * T
     * F
     * </pre></code>
     *
     * @param value the boolean value to write.
     */
    abstract public void writeBoolean(boolean value)
        throws IOException;

    /**
     * Writes an integer value to the stream.  The integer will be written
     * with the following syntax:
     *
     * <code><pre>
     * I b32 b24 b16 b8
     * </pre></code>
     *
     * @param value the integer value to write.
     */
    abstract public void writeInt(int value)
        throws IOException;

    /**
     * Writes a long value to the stream.  The long will be written
     * with the following syntax:
     *
     * <code><pre>
     * L b64 b56 b48 b40 b32 b24 b16 b8
     * </pre></code>
     *
     * @param value the long value to write.
     */
    abstract public void writeLong(long value)
        throws IOException;

    /**
     * Writes a double value to the stream.  The double will be written
     * with the following syntax:
     *
     * <code><pre>
     * D b64 b56 b48 b40 b32 b24 b16 b8
     * </pre></code>
     *
     * @param value the double value to write.
     */
    abstract public void writeDouble(double value)
        throws IOException;

    /**
     * Writes a date to the stream.
     *
     * <code><pre>
     * T  b64 b56 b48 b40 b32 b24 b16 b8
     * </pre></code>
     *
     * @param time the date in milliseconds from the epoch in UTC
     */
    abstract public void writeUTCDate(long time)
        throws IOException;

    /**
     * Writes a null value to the stream.
     * The null will be written with the following syntax
     *
     * <code><pre>
     * N
     * </pre></code>
     *
     * @param value the string value to write.
     */
    abstract public void writeNull()
        throws IOException;

    /**
     * Writes a string value to the stream using UTF-8 encoding.
     * The string will be written with the following syntax:
     *
     * <code><pre>
     * S b16 b8 string-value
     * </pre></code>
     *
     * If the value is null, it will be written as
     *
     * <code><pre>
     * N
     * </pre></code>
     *
     * @param value the string value to write.
     */
    abstract public void writeString(String value)
        throws IOException;

    /**
     * Writes a string value to the stream using UTF-8 encoding.
     * The string will be written with the following syntax:
     *
     * <code><pre>
     * S b16 b8 string-value
     * </pre></code>
     *
     * If the value is null, it will be written as
     *
     * <code><pre>
     * N
     * </pre></code>
     *
     * @param value the string value to write.
     */
    abstract public void writeString(char[] buffer, int offset, int length)
        throws IOException;

    /**
     * Writes a byte array to the stream.
     * The array will be written with the following syntax:
     *
     * <code><pre>
     * B b16 b18 bytes
     * </pre></code>
     *
     * If the value is null, it will be written as
     *
     * <code><pre>
     * N
     * </pre></code>
     *
     * @param value the string value to write.
     */
    abstract public void writeBytes(byte[] buffer)
        throws IOException;

    /**
     * Writes a byte array to the stream.
     * The array will be written with the following syntax:
     *
     * <code><pre>
     * B b16 b18 bytes
     * </pre></code>
     *
     * If the value is null, it will be written as
     *
     * <code><pre>
     * N
     * </pre></code>
     *
     * @param value the string value to write.
     */
    abstract public void writeBytes(byte[] buffer, int offset, int length)
        throws IOException;

    /**
     * Writes a byte buffer to the stream.
     */
    abstract public void writeByteBufferStart()
        throws IOException;

    /**
     * Writes a byte buffer to the stream.
     *
     * <code><pre>
     * b b16 b18 bytes
     * </pre></code>
     *
     * @param value the string value to write.
     */
    abstract public void writeByteBufferPart(byte[] buffer,
                                             int offset,
                                             int length)
        throws IOException;

    /**
     * Writes the last chunk of a byte buffer to the stream.
     *
     * <code><pre>
     * b b16 b18 bytes
     * </pre></code>
     *
     * @param value the string value to write.
     */
    abstract public void writeByteBufferEnd(byte[] buffer,
                                            int offset,
                                            int length)
        throws IOException;

    /**
     * Writes a full output stream.
     */
    public void writeByteStream(InputStream is)
        throws IOException
    {
        writeByteBufferStart();

        if (_byteBuffer == null)
            _byteBuffer = new byte[1024];

        byte[] buffer = _byteBuffer;

        int len;
        while ((len = is.read(buffer, 0, buffer.length)) > 0) {
            if (len < buffer.length) {
                int len2 = is.read(buffer, len, buffer.length - len);

                if (len2 < 0) {
                    writeByteBufferEnd(buffer, 0, len);
                    return;
                }

                len += len2;
            }

            writeByteBufferPart(buffer, 0, len);
        }

        writeByteBufferEnd(buffer, 0, 0);
    }

    /**
     * Writes a reference.
     *
     * <code><pre>
     * Q int
     * </pre></code>
     *
     * @param value the integer value to write.
     */
    abstract protected void writeRef(int value)
        throws IOException;

    /**
     * Removes a reference.
     */
    public boolean removeRef(Object obj)
        throws IOException
    {
        return false;
    }

    /**
     * Replaces a reference from one object to another.
     */
    abstract public boolean replaceRef(Object oldRef, Object newRef)
        throws IOException;

    /**
     * Adds an object to the reference list.  If the object already exists,
     * writes the reference, otherwise, the caller is responsible for
     * the serialization.
     *
     * <code><pre>
     * R b32 b24 b16 b8
     * </pre></code>
     *
     * @param object the object to add as a reference.
     *
     * @return true if the object has already been written.
     */
    abstract public boolean addRef(Object object)
        throws IOException;

    /**
     * @param obj
     * @return
     */
    abstract public int getRef(Object obj);

    /**
     * Resets the references for streaming.
     */
    public void resetReferences()
    {
    }

    /**
     * Writes a generic object to the output stream.
     */
    abstract public void writeObject(Object object)
        throws IOException;

    /**
     * Writes the list header to the stream.  List writers will call
     * <code>writeListBegin</code> followed by the list contents and then
     * call <code>writeListEnd</code>.
     *
     * <code><pre>
     * V
     *   x13 java.util.ArrayList   # type
     *   x93                       # length=3
     *   x91                       # 1
     *   x92                       # 2
     *   x93                       # 3
     * &lt;/list>
     * </pre></code>
     */
    abstract public boolean writeListBegin(int length, String type)
        throws IOException;

    /**
     * Writes the tail of the list to the stream.
     */
    abstract public void writeListEnd()
        throws IOException;

    /**
     * Writes the map header to the stream.  Map writers will call
     * <code>writeMapBegin</code> followed by the map contents and then
     * call <code>writeMapEnd</code>.
     *
     * <code><pre>
     * M type (<key> <value>)* Z
     * </pre></code>
     */
    abstract public void writeMapBegin(String type)
        throws IOException;

    /**
     * Writes the tail of the map to the stream.
     */
    abstract public void writeMapEnd()
        throws IOException;

    /**
     * Writes the object header to the stream (for Hessian 2.0), or a
     * Map for Hessian 1.0.  Object writers will call
     * <code>writeObjectBegin</code> followed by the map contents and then
     * call <code>writeObjectEnd</code>.
     *
     * <code><pre>
     * C type int <key>*
     * C int <value>*
     * </pre></code>
     *
     * @return true if the object has already been defined.
     */
    public int writeObjectBegin(String type)
        throws IOException
    {
        writeMapBegin(type);

        return -2;
    }

    /**
     * Writes the end of the class.
     */
    public void writeClassFieldLength(int len)
        throws IOException
    {
    }

    /**
     * Writes the tail of the object to the stream.
     */
    public void writeObjectEnd()
        throws IOException
    {
    }

    public void writeReply(Object o)
        throws IOException
    {
        startReply();
        writeObject(o);
        completeReply();
    }

    public void startReply()
        throws IOException
    {
    }

    public void completeReply()
        throws IOException
    {
    }

    public void writeFault(String code, String message, Object detail)
        throws IOException
    {
    }

    public void flush()
        throws IOException
    {
    }

    public void close()
        throws IOException
    {
    }
}
812712
public static Method getMethod(String clazzName, String methodName, String[] argsType) {
        Class clazz = ClassUtils.forName(clazzName);
        Class[] classes = ClassTypeUtils.getClasses(argsType);
        return getMethod(clazz, methodName, classes);
    }
715283
@SuppressWarnings({"ThrowableInstanceNeverThrown"})
    public static void validatePrimitiveArray(Method method, Class type, List<Throwable> errors)
    {
        Class returnType = method.getReturnType();
        if (!returnType.isArray() || !returnType.getComponentType().equals(type))
        {
            errors.add(new Exception("Method " + method.getName() + "() should return " + type.getName() + "[]"));
        }
    }
632340
protected <T> T invokeJavascriptReturnValue(String function, Class<T> returnType, Object... args) {
        Object returnObject = invokeJavascript(function, args);
        if (returnObject != null) {
            return (T) returnObject;
        } else {
            return null;
        }
    }
721650
public final String callMethod(String method) {
    parent.assertConnected();
    return debugger.callFunctionOnObject(method, objectId);
  }
219971
@Override
  public <V> MethodVault<V> newMethod(Class<?> type, 
                                      String methodName,
                                      Class<?> []paramTypes)
  {
    Objects.requireNonNull(type);
    
    MethodVault<V> method = newMethodRec(type, methodName, paramTypes);

    if (method != null) {
      return method;
    }
    
    throw new IllegalStateException(L.l("Unknown method {0}.{1} {2}",
                                        type.getSimpleName(),
                                        methodName,
                                        Arrays.asList(paramTypes)));
  }
1118523
private boolean methodIsAbstractGetter(TypeElement valueType, ExecutableElement method) {
    Set<Modifier> modifiers = method.getModifiers();
    if (!modifiers.contains(Modifier.ABSTRACT)) {
      return false;
    }
    boolean declaredOnValueType = method.getEnclosingElement().equals(valueType);
    TypeMirror returnType = getReturnType(valueType, method, types);
    if (returnType.getKind() == TypeKind.VOID || !method.getParameters().isEmpty()) {
      if (declaredOnValueType) {
        messager.printMessage(
            ERROR,
            "Only getter methods may be declared abstract on FreeBuilder types",
            method);
      } else {
        printNoImplementationMessage(valueType, method);
      }
      return false;
    }
    return true;
  }
862482
@SuppressWarnings({ "rawtypes", "unchecked" })
	public void callMethod(final MethodCallInfo info) {
		try {
			MethodsCaller.logger.info("loading class : ".concat(info.getClassName()));
			final Class clas = getClass().getClassLoader().loadClass(info.getClassName());
			MethodsCaller.logger.info("calling default constructor");
			final Object object = clas.newInstance();
			MethodsCaller.logger.info("calling method : " + info.getMethodName() + " , with params: ".concat(Arrays.toString(info.getParamters())));
			final Method method = clas.getMethod(info.getMethodName(), info.getParamtersTypes());
			final Object result = method.invoke(object, info.getParamters());
			if (!(result instanceof Serializable)) {
				throw new IllegalStateException("object " + result + " from type " + result.getClass().getName() + " is not serialzable");
			}
			info.setResult(result);
		} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | SecurityException
				| IllegalArgumentException | InvocationTargetException e) {
			MethodsCaller.logger.severe("calling to method failed : ".concat(info.toString()));
			throw new RemoteReflectionException(e);
		}
	}
1305785
public static Object callMethod(Scriptable obj, String methodName,
                                    Object[] args)
    {
        return callMethod(null, obj, methodName, args);
    }
297678
@Nullable
    protected final <T> T jsiiAsyncCall(final String method, final Class<T> returnType, @Nullable final Object... args) {
        JsiiClient client = engine.getClient();
        JsiiPromise promise = client.beginAsyncMethod(this.objRef, method, JsiiObjectMapper.valueToTree(args));

        engine.processAllPendingCallbacks();

        return JsiiObjectMapper.treeToValue(client.endAsyncMethod(promise), returnType);
    }
530620
function getType(type, method) {
    var generics = [];
    switch (type) {
      case 'Array':
        type = 'T[]';
        generics.push('T');
        break;
      case 'New Array':
        type = 'U[]';
        generics.push('T');
        generics.push('U');
        break;
      case 'ArrayElement':
        type = 'T';
        generics.push('T');
        break;
      case 'Mixed':
        type = 'T';
        generics.push('T');
        break;
      case 'Property':
        type = 'T';
        generics.push('T');
        break;
      case 'NewArrayElement':
        type = 'U';
        generics.push('T');
        generics.push('U');
        break;
      case 'NewProperty':
        type = 'U';
        generics.push('T');
        generics.push('U');
        break;
      case 'RangeElement':
        type = 'T';
        generics.push('T');
        break;
      case 'String':
      case 'Number':
      case 'Boolean':
        type = type.toLowerCase();
        break;
    }
    if (method && generics) {
      addMethodGenerics(method, generics);
    }
    return type;
  }
411525
public static TypeName extractReturnType(final SQLiteModelMethod method) {
		SQLiteEntity daoEntity = method.getParent().getEntity();
		// if true, field must be associate to ben attributes
		TypeName returnTypeName = method.getReturnClass();
		TypeName result = null;

		if (TypeUtility.isTypeIncludedIn(returnTypeName, Void.class, Void.TYPE)) {
			// return VOID (in the parameters must be a listener)

			// case OnReadBeanListener
			Pair<String, TypeName> foundElement = SqlBuilderHelper.searchInEachParameter(method,
					new SqlBuilderHelper.OnParameterListener() {

						@Override
						public boolean onParameter(Pair<String, TypeName> item) {
							return (item.value1 instanceof ParameterizedTypeName && TypeUtility.isEquals(
									((ParameterizedTypeName) item.value1).rawType, OnReadBeanListener.class.getName()));
						}
					});

			if (foundElement != null) {
				result = ((ParameterizedTypeName) foundElement.value1).typeArguments.get(0);
			}
		} else if (TypeUtility.isTypeIncludedIn(returnTypeName, Cursor.class)) {
			// return Cursor (no listener)
			result = null;
		} else if (returnTypeName instanceof ParameterizedTypeName) {
			ParameterizedTypeName returnParameterizedTypeName = (ParameterizedTypeName) returnTypeName;
			ClassName returnParameterizedClassName = returnParameterizedTypeName.rawType;

			// return List (no listener)
			AssertKripton.assertTrueOrInvalidMethodSignException(returnParameterizedTypeName.typeArguments.size() == 1,
					method, "return type %s is not supported", returnTypeName);
			TypeName elementName = returnParameterizedTypeName.typeArguments.get(0);

			Class<?> wrapperClazz = null;
			try {
				wrapperClazz = Class.forName(returnParameterizedClassName.toString());
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
				throw (new KriptonClassNotFoundException(e));
			}
			if (PagedResultImpl.class.isAssignableFrom(wrapperClazz)
					|| Collection.class.isAssignableFrom(wrapperClazz)) {
				if (SQLTransformer.isSupportedJDKType(elementName) || TypeUtility.isByteArray(elementName)) {
					// scalar list
					result = null;
				} else {
					result = elementName;
				}

			} else {
				result = null;
			}

		} else if (TypeUtility.isEquals(returnTypeName, daoEntity)) {
			// return one element (no listener)
			result = null;
		} else if (SQLTransformer.isSupportedJDKType(returnTypeName) || TypeUtility.isByteArray(returnTypeName)) {
			// return single value string, int, long, short, double, float,
			// String (no listener)
			result = null;
		} else {
			result = returnTypeName;
		}

		if (result == null || TypeUtility.isEquals(result, daoEntity)) {
			return null;
		} else {
			return result;
		}
	}
1321585
@Override
	public Object invokeMethod(Object... args) {
		Assert.state(this.parameterTypes.length == args.length,
				"Wrong number of arguments, expected no more than: ["
						+ this.parameterTypes.length + "]");

		try {
			// Extract the target from an Advised as late as possible
			// in case it contains a lazy initialization
			Object target = extractTarget(this.object, this.method);
			return method.invoke(target, args);
		}
		catch (Exception e) {
			throw new IllegalArgumentException("Unable to invoke method: [" + this.method
					+ "] on object: [" + this.object + "] with arguments: ["
					+ Arrays.toString(args) + "]", e);
		}
	}
363614
public final Invokable<T, Object> method(Method method) {
    checkArgument(of(method.getDeclaringClass()).isAssignableFrom(this),
        "%s not declared by %s", method, this);
    return new Invokable.MethodInvokable<T>(method) {
      @Override Type getGenericReturnType() {
        return resolveType(super.getGenericReturnType()).getType();
      }
      @Override Type[] getGenericParameterTypes() {
        return resolveInPlace(super.getGenericParameterTypes());
      }
      @Override Type[] getGenericExceptionTypes() {
        return resolveInPlace(super.getGenericExceptionTypes());
      }
      @Override public TypeToken<T> getOwnerType() {
        return TypeToken.this;
      }
      @Override public String toString() {
        return getOwnerType() + "." + super.toString();
      }
    };
  }
317792
public JSONArray call(String method, Object ... args) throws Exception {
        return super.callMethod(method, args);
    }
969995
function showInterfaceJavaMethod(intf, method, html) {
    var line = ""

    line += "\n    /**"
    line += "\n     * "
    line += "\n     */"
    line += "\n    <span class='methodName'>public void " + method.name + "</span>(" + getJavaParameterListSimple(method.parameters, method.returns) + ") throws IOException {"
    line += "\n        Main.warn(getClass().getName() + \"." + method.name + "() not implemented\");"
    line += "\n"
    line += "\n        channel.sendCallback(\"" + intf.name + "\", callbackId" + getJavaCallbackParameterListSimple(method.callbackParameters) + ");"
    line += "\n    }"
    line += "\n"
    html.push(line)
}