package org.ray.spi.model;

import java.lang.reflect.Method;
import org.ray.api.RayRemote;
import org.ray.api.UniqueID;
import org.ray.util.MethodId;

/**
 * method info.
 */
public class RayMethod {

  public final Method invokable;
  public final String fullName;
  public final RayRemote remoteAnnotation;
  private final UniqueID funcId;

  public void check() {
    for (Class<?> paramCls : invokable.getParameterTypes()) {
      if (paramCls.isPrimitive()) {
        throw new RuntimeException(
            "@RayRemote function " + fullName + " must have all non-primitive typed parameters");
      }
    }
  }

  private RayMethod(Method m, RayRemote remoteAnnotation, UniqueID funcId) {
    this.invokable = m;
    this.remoteAnnotation = remoteAnnotation;
    this.funcId = funcId;
    fullName = m.getDeclaringClass().getName() + "." + m.getName();
  }

  public static RayMethod from(Method m, RayRemote parentRemoteAnnotation) {
    Class<?> clazz = m.getDeclaringClass();
    RayRemote remoteAnnotation = m.getAnnotation(RayRemote.class);
    MethodId mid = MethodId.fromMethod(m);
    UniqueID funcId = new UniqueID(mid.getSha1Hash());
    RayMethod method = new RayMethod(m,
        remoteAnnotation != null ? remoteAnnotation : parentRemoteAnnotation,
        funcId);
    method.check();
    return method;
  }

  @Override
  public String toString() {
    return fullName;
  }

  public UniqueID getFuncId() {
    return funcId;
  }
}
@@ -340,283 +340,8 @@
 d;%0A%0A
-  public void check() %7B%0A    for (Class%3C?%3E paramCls : invokable.getParameterTypes()) %7B%0A      if (paramCls.isPrimitive()) %7B%0A        throw new RuntimeException(%0A            %22@RayRemote function %22 + fullName + %22 must have all non-primitive typed parameters%22);%0A      %7D%0A    %7D%0A  %7D%0A%0A
   pr
@@ -1007,28 +1007,8 @@
 d);%0A
-    method.check();%0A
     
@@ -1150,8 +1150,9 @@
 d;%0A  %7D%0A%7D
+%0A

Remove the check of java primitive types (#2495)