AspectJ:VerifyError [英] AspectJ: VerifyError
问题描述
创建的方面之间的所有连接都可以工作,但是当我尝试运行该项目,我收到以下异常:
线程main中的HelloException java.lang.VerifyError:期望堆栈框架在分支目标6在方法helloworld.World。< clinit>()V在偏移0
在helloworld.Hello.sayHello(Hello.java:11)
在helloworld.Hello.main(你好.java:6)
当我清空World.aj 类时,运行项目,一切正常,我在控制台中收到预期的Hello。
这是我在本教程中创建的类: p>
Hello.java
package helloworld;
public class Hello {
public static void main(String [] args){
sayHello();
}
public static void sayHello(){
System.out.print(Hello);
}
}
World.aj / p>
package helloworld;
public aspect World {
切入点():执行(* Hello.sayHello(..));
after()returns():greeting(){
System.out.println(World!);
}
}
我也按照教程,遇到同样的错误。这是我如何解决它。
我发现,默认情况下,我的eclipse(JavaSE-1.7)选择的执行环境JRE与AspectJ有问题。所以你需要做的是改变执行环境JRE,选择例如JavaSE-1.6。
之后,你可以按照教程,并获得所需的输出! :)
希望这有帮助!
I'm experimenting with Aspect-Oriented Programming. I've installed the AspectJ-Plugin in Eclipse and followed all the steps mentioned in this tutorial.
All connections between the created aspects work, but when I try to run the project, I receive the following exception:
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)
When I empty the class World.aj and run the project, everything works and I receive the expected "Hello" in the console.
Here are the classes I created during the tutorial:
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!");
}
}
I also followed the tutorial, and encountered the same error. And here is how I solved it.
I found out that that the execution environment JRE selected by default with my eclipse, JavaSE-1.7, had an issue with AspectJ. So what you have to do, is change the execution environment JRE, choose for example JavaSE-1.6.
After, you can follow the tutorial, and obtain the desired output! :)
Hope this helps!
这篇关于AspectJ:VerifyError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!