Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any AspectJ code generation library (like Sun's codemodel for Java code generation)?

Is there any free library to generate AspectJ code at compile-time (at the annotation processing step for example)? I am looking for something similar to codemodel, but to generate AspectJ code.

like image 328
Jérôme Verstrynge Avatar asked Feb 16 '26 17:02

Jérôme Verstrynge


1 Answers

It does not seem like such a library is available.

After doing more reading and analyzing codemodel's source code:

  1. Generating pure AspectJ code with codemodel is not possible, since one cannot declare something like:

    public aspect TransactionManager { ... }

  2. It is not possible to twist the JDeclaredClass item properly to solve 1. You would have to rewrite almost everything from scratch

  3. AspectJ5 introduces annotations, meaning we can declare aspects in pure Java:

    @Aspect public class TransactionManager { ... }

  4. The only really tricky part of @AspectJ seems to be Inter-type Declarations, but a good/viable solution is provided here.

Conclusion: It does not seem like a specific library to generate AspectJ code is necessary, one can rely on codemodel only.

like image 153
Jérôme Verstrynge Avatar answered Feb 18 '26 07:02

Jérôme Verstrynge



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!