Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Type patterns & values of annotation properties?

Hi Matthew,

> Can type patterns match on values of properties of annotations?

Yes, *but* there is a bug (uncovered in the other thread in the
mailing list today) where '.class' is tripping up the pattern parser
in AspectJ.  So this is fine:

@interface Foo {
   int x();
}

declare @field: @Foo(x=3) * *: @Bar;

But you can't use 'Class x()' and then '@Foo(x=String.class)' in your
type pattern.  I'm just debugging it now, think I see what it is - I
guess no-one has ever
tried it for class type values.

> declare parents:
>  (@Foo(clazz=Number+) *)
>  implements Fooable<Integer>;

Don't think this is going to work, even after I fix the above.

So:
> Can I write a type pattern that matches for Thingy but not Stringy
> based only on the value of the "@Foo" annotation's "clazz" property?

Yes,

declare @type: @Foo(clazz=Long.class) *: @Bar;

We could support, I imagine:

declare @type: @Foo(clazz!=Long.class) *: @Bar;

but we don't right now.

cheers
Andy

On 6 September 2011 12:47, Matthew Adams <matthew@xxxxxxxxxxxxxxx> wrote:
>
> For example, given this ITD & classes:
>
> declare parents:
>  (@Foo(clazz=Number+) *)
>  implements Fooable<Integer>;
>
> @Foo(clazz=Long.class)
> public class Thingy {}
>
> @Foo(clazz=String.class)
> public class Stringy {}
>
> Can I write a type pattern that matches for Thingy but not Stringy
> based only on the value of the "@Foo" annotation's "clazz" property?
>
> -matthew
>
> --
> @matthewadams12
> mailto:matthew@xxxxxxxxxxxxxxx
> skype:matthewadams12
> yahoo:matthewadams
> aol:matthewadams12
> google-talk:matthewadams12@xxxxxxxxx
> msn:matthew@xxxxxxxxxxxxxxx
> http://matthewadams.me
> http://www.linkedin.com/in/matthewadams
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


Back to the top