Я изучаю Java и как-то попадал в AspectJ. Я попытался выполнить этот код из учебника:advexecution() не работает в AspectJ
pointcut adviceExecutionPointcut() : adviceexecution();
// Advice declaration
before() : adviceExecutionPointcut()
&& !within(AdviceExecutionRecipe +)
{
System.out.println(
"------------------- Aspect Advice Logic --------------------");
System.out.println("In the advice picked by ExecutionRecipe");
System.out.println(
"Signature: "
+ thisJoinPoint.getStaticPart().getSignature());
System.out.println(
"Source Line: "
+ thisJoinPoint.getStaticPart().getSourceLocation());
System.out.println(
"------------------------------------------------------------");
}
}
И это как-то дало мне ошибку.
Exception in thread "main" java.lang.StackOverflowError
at helloWorld.ajc$before$helloWorld$2$5e65e204(helloWorld.aj)
at helloWorld.ajc$before$helloWorld$2$5e65e204(helloWorld.aj)
at helloWorld.ajc$before$helloWorld$2$5e65e204(helloWorld.aj)
at helloWorld.ajc$before$helloWorld$2$5e65e204(helloWorld.aj)
at helloWorld.ajc$before$helloWorld$2$5e65e204(helloWorld.aj)
Для справки приведен пример кода и кода рекомендации.
public class myClass {
public void foo(int number, String name){
System.out.println("Inside foo(int, String)");
}
public static void main(String[] args) {
// TODO Auto-generated method stub
myClass myObject = new myClass();
myObject.foo(1, "ican");
}
public aspect helloWorld {
public int a;
long startTime;
pointcut callPointcut(int value, String name) :
call(* myClass.foo(int, String)) && args(value,name);
before(int value, String name) : callPointcut(value,name)
{
startTime = System.nanoTime();
System.out.println("Start Time in ns :" + startTime);
}
Любая помощь будет принята с благодарностью. Спасибо
Какая ошибка? он даже компилируется? вставьте в свой стек трассировку, возможно, – r4ccoon
Не компилируется. Он помещен в сообщение –