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 <[email protected]> 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:[email protected]
> skype:matthewadams12
> yahoo:matthewadams
> aol:matthewadams12
> google-talk:[email protected]
> msn:[email protected]
> http://matthewadams.me
> http://www.linkedin.com/in/matthewadams
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to