If you get my bitbucket repo at HEAD and try changing the 'declare parents'
lines in PersistableJpaAspect and/or PersistableMongoAspect to use the
enums instead of the annotations, you should see that the annotations don't
match.  AJDT markers don't show outgoing "Declared On" markers and intended
ITDs aren't reflected in target classes
(JpaLongPerson/JpaStringPerson/MongoLongPerson/MongoStringPerson in
src/test/java).

I'll enter bug now & include as much as I can.

-matthew

On Mon, Sep 17, 2012 at 11:30 AM, Andy Clement <[email protected]>wrote:

> I just tried this sample:
>
> ==== C.java ===
> package com.foo.bar;
>
> import java.lang.annotation.*;
>
> @Target(ElementType.TYPE)
> @Retention(RetentionPolicy.RUNTIME)
> @interface Persistable {
>         IdType id() default IdType.STRING;
> }
>
> enum IdType {
>         STRING, LONG;
> }
>
> interface I {}
>
> @Persistable()
> public class C {}
>
> @Persistable(id=IdType.LONG)
> class D {}
>
> aspect X {
>         declare parents: (@Persistable(id=IdType.STRING) *) implements I;
> }
> ===
>
> and it does work as expected (C gets the interface). My hunch is that
> it is a compilation ordering thing so I might need a real failing
> project to show the issue.
>
> Andy
>
> On 17 September 2012 09:06, Andy Clement <[email protected]> wrote:
> > 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 <[email protected]>
> 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:[email protected]
> >> skype:matthewadams12
> >> googletalk:[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
>



-- 
mailto:[email protected] <[email protected]>
skype:matthewadams12
googletalk:[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

Reply via email to