static SelType callJavaMethod(Object javaObj, SelType[] args, MethodHandle m, String methodName) {
    try {
      if (args.length == 0) {
        return callJavaMethod0(javaObj, m);
      } else if (args.length == 1) {
        return callJavaMethod1(javaObj, args[0], m);
      } else if (args.length == 2) {
        return callJavaMethod2(javaObj, args[0], args[1], m);
      }
    } catch (IllegalStateException e) {
      throw e;
    } catch (Throwable t) {
      throw new IllegalArgumentException("Failed calling method " + methodName, t);
    }
    throw new UnsupportedOperationException(
        "DO NOT support calling method: " + methodName + " with args: " + Arrays.toString(args));
  }
@Test
  public void testCallJavaMethodWithTwoArgs() throws Throwable {
    m1 =
        MethodHandles.lookup()
            .findStatic(
                MockType.class,
                "staticTwoArgs",
                MethodType.methodType(double.class, double.class, boolean.class));
    m2 =
        MethodHandles.lookup()
            .findVirtual(
                MockType.class,
                "twoArgs",
                MethodType.methodType(String.class, String.class, DateTime.class));
    SelType res =
        SelTypeUtil.callJavaMethod(
            null, new SelType[] {SelDouble.of(1.2), SelBoolean.of(true)}, m1, "staticTwoArgs");
    assertEquals(SelTypes.DOUBLE, res.type());
    assertEquals(2.2, ((SelDouble) res).doubleVal(), 0.01);
    res =
        SelTypeUtil.callJavaMethod(
            new MockType(),
            new SelType[] {SelString.of("foo"), SelJodaDateTime.of(new DateTime(DateTimeZone.UTC))},
            m2,
            "twoArgs");
    assertEquals(SelTypes.STRING, res.type());
    assertEquals("foo1970-01-01T00:00:12.345Z", res.toString());
  }