我正在尝试使用面向方面的编程。我已在Eclipse中安装AspectJ-Plugin,并遵循此tutorial中提及的所有步骤。
创建方面之间的所有连接工作,但是当我尝试运行该项目,我收到以下异常:AspectJ:验证错误
HelloException in thread "main" java.lang.VerifyError: Expecting a stackmap frame at branch target 6 in method helloworld.World.<clinit>()V at offset 0
at helloworld.Hello.sayHello(Hello.java:11)
at helloworld.Hello.main(Hello.java:6)
当我清空类World.aj并运行该项目,一切工作和我在控制台中收到预期的“Hello”。
下面是我在本教程中创建的类:
Hello.java
package helloworld;
public class Hello {
public static void main(String[] args) {
sayHello();
}
public static void sayHello() {
System.out.print("Hello");
}
}
World.aj
package helloworld;
public aspect World {
pointcut greeting() : execution(* Hello.sayHello(..));
after() returning() : greeting() {
System.out.println(" World!");
}
}