我正在嘗試使用面向方面的編程。我已在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!");
}
}