Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] type pattern not matching when annotation values are enum instances (or psf Strings)

Supporting all the possible annotation value types is a lot of work
(for each piece of syntax where they might appear).  Typically the
most common are added first, and others later.  So usually string
first, then others on request and I can imagine enum being down the
list.  However, normally AspectJ throws an error if you use one that
isn't yet supported (and the exception tells you to go and ask for
it!), so maybe that isn't what is happening in this case.. (I haven't
investigated). Please open a bug, but it sounds like your inconsistent
class file thing is more pressing.

cheers,
Andy

On 13 September 2012 14:35, Matthew Adams <matthew@xxxxxxxxxxxxxxx> wrote:
> Consider the following annotation:
>
> @Target(TYPE)
> @Retention(RUNTIME)
> public @interface Persistable {
>
>         StoreType in() default StoreType.MONGO;
>
>         IdType id() default IdType.STRING;
> }
>
> I'm attempting to match a type pattern in a declare parents based on
> the id() property of the annotation:
>
>         declare parents :
>         (@Persistable(id=IdType.LONG) *)
>         implements L;
>
>         declare parents :
>         (@Persistable(id=IdType.STRING) *)
>         implements S;
>
> These aren't matching successfully.  However, if I change the
> annotation to use Strings instead (like the following), the matching
> starts working.
>
> @Target(TYPE)
> @Retention(RUNTIME)
> public @interface Persistable {
>
>         String in() default "MONGO";
>
>         String id() default "STRING";
> }
> =====
>         declare parents :
>         (@Persistable(id="LONG") *)
>         implements L;
>
>         declare parents :
>         (@Persistable(id="STRING") *)
>         implements S;
>
> Interestingly, if I create psf Strings for the values in the
> annotation type and try to use those, like I show below, it fails to
> match again.
>
> @Target(TYPE)
> @Retention(RUNTIME)
> @Trait
> public @interface Persistable {
>
>         public static final String MONGO = "MONGO";
>         public static final String JPA = "JPA";
>         public static final String JDO = "JDO";
>
>         public static final String STRING = "STRING";
>         public static final String LONG = "LONG";
>
>         String in() default "MONGO";
>
>         String id() default "STRING";
> }
> =====
>         declare parents :
>         (@Persistable(id=Persistable.LONG) *)
>         implements L;
>
>         declare parents :
>         (@Persistable(id=Persistable.STRING) *)
>         implements S;
>
> The same is true if I move the psf Strings to an interface as well.
>
> Am I doing something wrong?
>
> -matthew
> --
> mailto:matthew@xxxxxxxxxxxxxxx
> skype:matthewadams12
> googletalk: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