Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Re: aspects in annotations (java.lang.VerifyError)

Dear all,

I have solved part of my problem. Since I use LTW with annotation based aspects, I need to pass '-g' flag to the 'apt' tools while generating the classes.

When I rerun the samples, the following java.lang.VerifyError happens:

info register classloader sun.misc.Launcher$AppClassLoader@7494106
info using file:/home/eric/java/test/aop/J.jar!/META-INF/aop.xml
info register aspect A
info weaving 'A'
info weaver operating in reweavable mode. Need to verify any required types exist. weaveinfo Join point 'method-execution(void A.start())' in Type 'A' (A.java:12) advised by afterThrowing advice from 'A' (A.java) weaveinfo Join point 'method-execution(void A.stop())' in Type 'A' (A.java:23) advised by afterThrowing advice from 'A' (A.java) Exception in thread "main" java.lang.VerifyError: (class: A, method: stop signature: ()V) catch_type not a subclass of Throwable

And here is the source files:

A.java:
--------------------------------------------------------------------------
import org.aspectj.lang.annotation.*;
import org.aspectj.lang.JoinPoint;

@Aspect ("issingleton()")
public class A implements Ai
{
 private  int  i = 0;

 /** implements Ai.start()  */
 public void start() throws Exception
 {
   i++;

   if (i == 0)
   {
     throw new IllegalArgumentException();
   }
 }

 /** implements Ai.start()  */
 public void stop() throws Exception
 {
   if (i != 0)
   {
     throw new IllegalArgumentException();
   }
 }

 public static void main(String[] args)
 {
   A  a = new A();

   try
   {
     a.start();
     a.stop();
   }
   catch (Exception e)
   {
     e.printStackTrace();
   }
 }

@AfterThrowing (pointcut = "(execution(public void A.start() throws java.lang.Exception) || execution(public void A.stop() throws java.lang.Exception))", throwing = "ex")
 /**  handle the exception generated by Ai interface methods  */
 public void  handleException(JoinPoint jp, Exception  ex) throws Exception
 {
   if (ex instanceof IllegalArgumentException)
   {
     throw  new Exception(ex.getMessage());
   }
   else
   {
     throw  ex;
   }
 }
}
------------------------------------------------------------------------------
Ai.java
------------------------------------------------------------------------------
public interface Ai
{
 void start() throws Exception;
 void stop() throws Exception;
}
------------------------------------------------------------------------------
aop.xml
------------------------------------------------------------------------------
<?xml version="1.0"?>
<!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD 1.5.0//EN" "http://.../dtd/aspectj_1_5_0.dtd";>

<aspectj>
 <weaver options="-1.5 -Xreweavable -verbose -showWeaveInfo">
   <include within="*"/>
 </weaver>

 <aspects>
    <!-- declare existing aspects to the weaver -->
    <aspect name="A"/>
 </aspects>

</aspectj>
-------------------------------------------------------------------------------------


Thanks,
Eric



Back to the top