这是一个非常简单的AspectJ的示例程序,我只想尝试给GetReply()方法在调用前后增加一个类似日志的功能。但是遇到的这样的异常提示:Exception in thread "main" java.lang.VerifyError: Expecting a stackmap frame at branch target 6 in method LoggingAspect.<clinit>()V at offset 0
at MainProc.main(MainProc.java:6)
---------------------------------------------------------------------
这是主程序:
public class MainProc
{
public static void main(String[] args)
{
Replyer r = new Replyer();
int retVal = r.GetReply();
System.out.println("Return in main: " + retVal);
}
}
这是Replyer类:
public class Replyer
{
public int GetReply()
{
int retVal = 5;
System.out.println("Return in GetReply:" + retVal);
return retVal;
}
}这是定义的Aspect类,在Cross Reference图中能看到before与after成功找到切入点
public aspect LoggingAspect
{
public pointcut CallGetReply(): call(int Replyer.*(..)); before(): CallGetReply()
{
System.out.println("Start logging...");
} after() returning: CallGetReply()
{
System.out.println("Ending logging...");
}
}