1

我有下一个 JInvocation:

JInvocation jInvoke = JExpr.invoke(anotherPageInstance, method);

哪里anotherPageInstanceJVar和方法是JMethod

我对此做了一些操作JInvocation,然后我想将它添加到test.body().invoketest 所在的位置JMethod

主要问题是我不能,因为test.body().invoke没有选择JInvocation作为参数。

我可以做下一个: test.body().invoke(anotherPageInstance, method),但这对我没有帮助,因为我想保存JInvocation,并且当某些情况发生时,将其添加Jinvocation到正文中(正如我之前提到的,同时我对此做了一些操作JInvocation)。

有什么帮助吗?

4

2 回答 2

2

JBlock您可以使用以下方法在正文 ( ) 中添加调用add()

test.body().add(jInvoke);
于 2013-12-05T17:26:18.120 回答
0

不要使用 JExpr.invoke() 实例化 JInvocation,而是使用 JExpr 工厂方法:

public static JInvocation invoke(JExpression lhs,
                                 JMethod method)
public static JInvocation invoke(JExpression lhs,
                                 String method)

请参阅JExpr

于 2017-02-27T21:33:56.780 回答