AspectJ:验证错误 [英] AspectJ: VerifyError

查看:24
本文介绍了AspectJ:验证错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在试验面向方面的编程.我已经在 Eclipse 中安装了 AspectJ-Plugin 并遵循了这个 教程.
创建的方面之间的所有连接都有效,但是当我尝试运行该项目时,我收到以下异常:

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)

当我清空 World.aj 类并运行该项目时,一切正常,我在控制台中收到预期的Hello".


以下是我在本教程中创建的类:

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.

我发现我的eclipse默认选择的执行环境JRE,JavaSE-1.7,AspectJ有问题.所以你要做的就是改变执行环境JRE,选择例如JavaSE-1.6.

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! :)

希望这会有所帮助!

这篇关于AspectJ:验证错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆