Din*_*lae 1 java aspectj aspect
我正在尝试更改 System.currentTimeMillis() 方法的行为以进行测试。我找到了下面的方法,但我不能在代码中使用 aspect 关键字。我真的不明白如何使用这种方法。有什么建议?
public aspect CurrentTimeInMillisMethodCallChanger {
long around():
call(public static native long java.lang.System.currentTimeMillis())
&& within(user.code.base.pckg.*) {
return 0; // provide your own implementation returning a long
}
}
Run Code Online (Sandbox Code Playgroud)
有关更多详细信息,请参阅包含上述代码来源的相关答案