Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] MethodPattern - matching an annotated return value type

Hi Jay,

You actually have an annotated method there, not an annotated return value.  So this will match:

@Around"execution(@ImmutableCollection * *(..))")

*UNLESS* you are on Java8 and are exploiting type annotations?? If you are then I should say AspectJ does not yet support type annotations.

cheers,
Andy



On 6 May 2013 10:32, Jay Roberts <pudakai@xxxxxxxxx> wrote:
I have a simple test case that isn't working, but it seems like it should, could use a bit of help.

I have:

public class TestReturnAnnotation{
public Object object=null;
public @ImmutableCollection Object getObject(){
return object;
}
}


And from the advice:

@Around( "execution( (@ImmutableCollection *) *(..))")

This compiles ok, but the advice does not get applied to TestReturnAnnotation.getObject().  Looking at the spec for MethodPattern, it seems like it should, but I'm obviously missing something.  FWIW, in the aspect, I have another advice

@Around( "set(@ImmutableCollection * *) && args(newVal) && target(t)")

That is working fine.  Can I have two @Around in the same @Aspect class?

Thanks!

Jay Roberts

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



Back to the top