Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

数组类型推断有问题 #43

Closed
PaulingZhou opened this issue Dec 22, 2018 · 1 comment
Closed

数组类型推断有问题 #43

PaulingZhou opened this issue Dec 22, 2018 · 1 comment

Comments

@PaulingZhou
Copy link

@Test
public void testFunction2() throws Exception {
    ExpressRunner runner = new ExpressRunner();
    String exp = "System.out.println(args[0]);";
    String[] args = {"123","456"};
    IExpressContext<String, Object> context = new DefaultContext<String, Object>();
    ((DefaultContext<String, Object>) context).put("args", args);
    Object result = runner.execute(exp,context,null,false,false);
}

发现上面这段代码在实际运行时调用的方法是
public void java.io.PrintStream.println(java.lang.Object)
却不是
public void java.io.PrintStream.println(java.lang.String)
debug时发现findMethod的type是class [Ljava.lang.String;
请问这是一个bug还是开发时特意保留的特性?

附debug到com.ql.util.express.ExpressUtil#findMethod的debugger截图
image

@baoxingjie
Copy link
Contributor

确实是一个数组识别的bug,在数组的识别上有问题。
如果拆成两句是能够正确识别的
String exp = "arg0 = args[0]; System.out.println(arg0);";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants