Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Annotations and assertion failed

I still an AssertError with the following code (http://veleno.pastebin.com/312459 for highlight):

public aspect AnnotatorAspect {

declare @method: public * Pusher+.*(..): @ManagedResourceAnnotation;

}

/****************************************/
import java.lang.reflect.Method;

class AnnotatorTest {

   public static void main(String[] args){

       Pusher p = new PusherImpl();

       Class<Pusher> clazz = Pusher.class;
       try{
       Method method = clazz.getMethod("push", String.class);
assert method.getAnnotation(ManagedResourceAnnotation.class) != null; /*I GET NULL */ System.out.println(method.getAnnotation(ManagedResourceAnnotation.class));
       }catch (NoSuchMethodException e){
           e.printStackTrace();
       }
   }

}

/****************************************/
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;

/**
* Marker annotation to indicate that a resource has to be monitored
*/

/*meta-annotation target only methods */
@Target({ElementType.METHOD})

/*meta-annotation to change default retention policy to runtime*/
@Retention(RetentionPolicy.RUNTIME)

public @interface ManagedResourceAnnotation  {

}
/****************************************/
public class PusherImpl implements Pusher {
       public void push(String s) {

       }

}
/****************************************/
public interface Pusher {

       void push (String s);

}

ajc -version:
AspectJ Compiler 1.5.0M2 built on Thursday Apr 7, 2005 at 12:53:37 GMT

compiling without problems  with:
ajc -1.5 -argfile test.lst

launghing with:
java -ea AnnotatorTest

(to be sure that assertions are enabled)

i get :
Exception in thread "main" java.lang.AssertionError
       at AnnotatorTest.main(AnnotatorTest.java:13)


Anyone with suggestions or comments?

Thanks
Valerio





Back to the top