Skip to content

ClassMethodFunction类 addInstanceFunctions方法的使用问题分析 #691

Description

@pzLove

aviatorInstance.addInstanceFunctions("fnc",Xxxx.class);
对于非静态方法:
pTypes: [Class<?> clazz, 原参数类型...] (长度 = n+1)
jArgs: 直接从所有 args 构建 (长度 = n)
结果: 参数数量不匹配,导致类型转换错误Cannot cast java.lang.String to xxxx.aviator.impl.Xxxx
我目前的处理方式是使用静态方法包了一层,
后面看你的测试类,发现在方法的使用上,要先把方法类对象作为第一个参数传入,这个有优化方案吗
TestUtils t = new TestUtils();
Map<String, Object> env = new HashMap<>();
env.put("t", t);
assertTrue((boolean) this.instance.execute("test.is_empty(t, '')", env));
assertFalse((boolean) this.instance.execute("test.is_empty(t, t)", env));

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions