[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] AJ 5 @AJ and aspectOf

Alexandre,

I used APT to generate AJ code in Contract4J (http://www.contract4j.org). Contract4J provides annotations for Design by Contract. For example,

@Pre ("i > 0")
@Post ("$return != null")
String foo (int i) {
   ...
}

Where a precondition on the method is that argument "i" must be > 0 and a postcondition on the method is that the return value (special keyword "$return") is not null. APT allows me to generate expressions from the strings. They are generated as part of the aspects that implement the tests. Hence, the performance is good - no reflection and no run-time parsing of the strings.

APT has a few drawbacks: (i) it can only parse Java code, not AJ code (hence Contract4J contracts can't be used in AJ code itself!), (ii) the user has to be willing to invoke APT in his/her build process, (iii) APT can't be configured to invoke AJ on the back end (there are workarounds for this limitation), and (iv) there is no ant task for APT (although the codebase for the forthcoming ant v1.7 already has one). I'm trying to develop alternative formulations of Contract4J that don't require APT, without compromising too much on performance or usability.

So, I think this approach has potential. It might be worth considering an APT-like extension to aspectj itself. (I'm sure Andy and crew have nothing better to do... ;^) Note that the next release of Java 6 ("Mustang") plans to make the APT API part of the standard for Java. (It is currently a sun-specific package...).

dean

Alexandre Vasseur wrote:

Since Wes seems to be suprised by my first post let me explain some

- APT = Annotation Processor Tool = see Java 5 doc, I am expect
aspectj-dev are familiar with most of the concepts around Java 5 (be
it semantics or tools around, like APT)

- @AJ aspect = I assume ones has read the AspectJ 5 developper
notebook. The @AJ aspect is the code name for the annotation style
syntax

- I usually use "*" (star) to emphasys on something like *that*, since
I don't write html emails and uses Bold style.

- we may do code gen if we need to do it. That s why I am discussing
that on the aspectj-dev. Raise your hand / ask question if you think
that s odd.
APT can actually be used for much more f.e. pointcut syntax checking
for @AJ aspect f.e.
It s is good to think about what we can do with it, especially as
regards @AJ aspects.

- the user benefit is as I describe: be able to use the aspectOf() API
with its @AJ aspect without requiring him to compile them with ajc and
further use them as a binary form (in which there is the aspectOf()
method)

Wes, I had no previous private discussion on that, and precisely wants
to start the discussion. Let me know if there is a better place for
this kind of discussion.

Alex


On Tue, 22 Mar 2005 08:07:48 -0800, Wes Isberg <wes@xxxxxxxxxxxxxx> wrote:


E.g., what is "APT"? "@AJ aspect"?  Why '*' in "Aspect*s*."?
Since when do we do "source gen"?  And what's the user benefit?


Wes



------------Original Message------------
From: Alexandre Vasseur <avasseur@xxxxxxxxx>
To: aspectj-dev@xxxxxxxxxxx
Date: Tue, Mar-22-2005 7:31 AM
Subject: [aspectj-dev] AJ 5 @AJ and aspectOf

I have started to have a look at APT.
This one could easily be used to handle aspectOf() for @AJ aspect.

Right now aspectOf is introduced to the @AJ aspect (compile time with
ajc or LTW), and the user can use an API like
Aspect*s*.aspectOf(MyAspect.class)
Aspect*s*.aspectOf(MyAspect.class, Object perX instance)
etc that behaves reflectively

APT could be used to generated (source gen) for each @AJ aspect
MyAspect a class
MyAspectFactory that contains the static aspectOf method and binding /
unbinding methods.
The user could then easily invoke MyAspect MyAspectFactory.aspectOf()
in his code, without any performance drawback, without beeing required
to expose its aspect to LTW or ajc compilation and use them as binary
form.

thoughts ?
Alex
_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-dev





_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-dev