Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Using Annotation style to introduce members

Hi there,

Making code style ITDs like that affects the type system during
compilation.  Because ajc is doing the compilation it fully
understands what you are saying with the ITDs.  With annotation style
you are not limited to using ajc, you can use javac.  We cannot change
the behaviour of javacs type system to understand ITDs.  This means
doing that kind of thing in annotation style is rather different.  You
need to use @DeclareMixin - it is discussed here (towards the end of
the page):
http://www.eclipse.org/aspectj/doc/released/adk15notebook/ataspectj-itds.html

Andy

On 31 May 2010 04:05, Michael Kober <michael.kober@xxxxxxxxxx> wrote:
> Hi,
>
> I'm new to Aspectj - so I hope this is not a silly question.
>
> I've got an aspect which introduces some members in a class and works
> perfectly fine:
>
> public aspect MyAspect {
>
>   private long MyClass._timestamp;
>
>   public void MyClass.initTimestamp() {
>     _timestamp = System.currentTimeMillis();
>   }
>
>   after(MyClass example) : execution(mypackage.MyClass.new(..)) &&
> this(example) {
>     example.initTimestamp();
>   }
> }
>
> I would like to rewrite the aspect using annotation style (as my other
> aspects use annotation style) - but couldn't find any examples in the
> documentation. Any help on where I can find examples or how to achieve this
> appreciated.
>
> Thanks
> /Mike
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>


Back to the top