Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Matching on parameter annotations

Hi Eric -

I'm not sure what kind of static checking happens or is possible using @args(..), 
but you can staticly pick them out using the method-execution join point signature:

  execution(* *(@Annotation *)) // for any method with one parameter so annotated
    
In the test below, only the annotation-laden shadow x(..) is flagged as an error.  
Would that help?

Wes

--------------------- annot/AnnotationBinding.java
package annot;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

public class AnnotationBinding {
    @Retention(RetentionPolicy.RUNTIME)
    public @interface TestAnnotation {
    }
    @TestAnnotation
    public static class Foo {}
    public static class Bar {}
    public void x(Foo foo) {}   // error here
    public void x(Bar bar) {}   // no error here
    static aspect A {
        declare error: execution(void AnnotationBinding.x(@TestAnnotation *)) 
          : "parameter annotated with @TestAnnotation";
    }    
}


------------Original Message------------
From: Eric Crahen <eric_crahen@xxxxxxxxx>
To: aspectj-users@xxxxxxxxxxx
Date: Sun, Aug-6-2006 3:33 PM
Subject: [aspectj-users] Matching on parameter annotations
Is there any upcoming work being done to allow for parameter annotations to be matched more efficently? 

So far I've found that using @args() inserts bytecodes that check the annotations of the object passed in to see if an annotation is present and its not quite what I wanted. And using the static parts of a join point also inserts bytecode into each method. This works, but if you weave 100 methods and only 1 contains a parameter annotation, thats alot of extra code inserted into 99 methods that wouldn't behave any differently.


- Eric


Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail Beta._______________________________________________ 
aspectj-users mailing list 
aspectj-users@xxxxxxxxxxx 
https://dev.eclipse.org/mailman/listinfo/aspectj-users 



Back to the top