Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] How to identify the return value's annotation in compile time


declare error
   : execution((@OhNo *) *(..))
   : "Oh no!";

To dissect the execution pcd a little... the type pattern (@OhNo *) matches any type with the @OhNo annotation, so I used this type pattern for the return type pattern in the execution pcd, and then just wildcarded the rest (any method name, and declaring type, any arguments).

-- Adrian.

On 01/03/06, Michael Kantarovich <michaelk@xxxxxxxxxxx> wrote:

Hi

I want to define a compile-time pointcut (to use in "declare error") which identifies whether a method's return value has a certain annotation defined on it.

Here is an example. I want my aspect to create a compilation error on the method g().

class ReturnValue1 { }

@Ohno class ReturnValue2 { }

class MyClass {

        ReturnValue1 f() { … }    // this is OK

        ReturnValue2 g() { … }   // this is invalid

}

Anyone has an idea how to do this?

Thanks


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





--
-- Adrian
adrian.colyer@xxxxxxxxx

Back to the top