Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Annotated method parameters and wildcards

Hi Srdan.

The only think you can do in this case is to match on *any* method
that has an @NonNull annotation and then use thisJoinPoint.getArgs()
in the advice body to expose the arguments from there.

Also you should look at Contract4J, as it does exactly this (and more)
using AspectJ: http://www.contract4j.org/contract4j

Eric

2008/5/23 srdan bejakovic <s.bejakovic@xxxxxxxxx>:
> Maybe I'm going about it the wrong way. Is there a way to match a method
> that has a parameter of a given type (or annotation), regardless of the
> position? In particular, I'm trying to write an aspect that will perform a
> null pointer check for parameters with a @NotNull annotation.
> Thanks,
>
> Srdan
>
> On Thu, May 15, 2008 at 5:12 PM, Andy Clement <andrew.clement@xxxxxxxxx>
> wrote:
>>
>> 4th and 5th are actually not allowed I'm afraid.  You can't use '..'
>> in two places - really you should get an error for (4) and the fact
>> you don't is a regression.
>>
>> Andy.
>>
>> 2008/5/15 srdan bejakovic <s.bejakovic@xxxxxxxxx>:
>> > I haven't been able to match an annotated method parameter if it's
>> > surrounded on both sides by the .. wildcard. In the code below, the
>> > first 4
>> > advice declarations match foo, but the fifth doesn't. Am I doing
>> > something
>> > wrong or is this not allowed or is it a bug? Thanks for your help.
>> >
>> >      @interface A {};
>> >      public void foo(@A String s) {}
>> > 1    before(): execution(* *(@A (*))) {}
>> > 2    before(): execution(* *(.., @A (*))) {}
>> > 3   before(): execution(* *(@A (*), ..)) {}
>> > 4    before(): execution(* *(.., String, ..)) {}
>> > 5    before(): execution(* *(.., @A (*), ..)) {}
>> >
>> > _______________________________________________
>> > aspectj-users mailing list
>> > aspectj-users@xxxxxxxxxxx
>> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
>> >
>> >
>> _______________________________________________
>> aspectj-users mailing list
>> aspectj-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>



-- 
Eric Bodden
Sable Research Group
McGill University, Montréal, Canada


Back to the top