Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[ajdt-dev] documentation for @DeclareParents

Hello,

as mentioned here on the list the @DeclareParents syntax changed a
little bit but is implemented now (when I remember right). Today I
checked the documentation in CVS and found the following comment in
ataspectj.xml:

// here is the actual ITD syntax when using @AspectJ
// public static is mandatory
// the field type must be the introduced interface. It can't be a class.
@DeclareParents("org.xzy..*")
public static Moody introduced = new MoodyImpl();

But when I tried it with my example and the newest build
(1.5.0.200510241400) I get the error message
"No enclosing instance of type GefuehlsAspekt is accessible. Must
qualify the allocation with an enclosing instance of type GefuehlsAspekt
(e.g. x.new A() where x is an instance of GefuehlsAspekt)."
(you'll find the GefuehlsAspekt at the end of this mail)
I think the "static" is wrong here - without it, it seems to compile. So
here my questions, before I dig deeper into the problem:

1) is the documentation wrong here?

2) will @DeclareParents work without the "static"?

regards
Oliver



For completness here my example aspect, which is very similar to the
Mood example in the documentation:

public class GefuehlsAspekt {

    public interface Feeling {
        String getSense();
    }

    public class FeelingImpl implements Feeling {
        private String sense = "I feel good";

        public String getSense() {
            return sense;
        }
    }

    @DeclareParents("verwaltung.Person")
    public static Feeling introduced = new FeelingImpl();

    @After("execution(* *.*(..)) && this(f) && !within(GefuehlsAspekt)")
    public void howdoyoufeeltoday(Feeling f) {
        System.out.println(f.getSense());
    }

}
-- 
Oliver Böhm
http://www.javatux.de



Back to the top