Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Adding getter/setter using AspectJ

On 08/07/2011 11:00, Andy Clement wrote:
It wouldn't be all that difficult to extend AspectJ and define an
annotation that then triggered AspectJ to create accessors
(getters/setters) for any field that has that annotation, I just
haven't had that many users express an interest in AspectJ supporting
it.


I would be very interested in such a feature. Currently I use Lombok to generate getters and setters (toString, hashCode, constructors etc) at the source tree parsing level. It works quite well and is more addictive than good smack. Unfortunately its eclipse integration is not compatible with the AspectJ plugin - it just stops working if you add the aspect nature to a project.

BTW, how does one go about "extending AspectJ" to create accessors? I would love to start using AspectJ but giving up Lombok in return has so far stopped me getting any further than a quick experiment.

Also, a related question; I would like to generate fast accessors that bypass the security manager (like CGLIB FastMethod). So far I can only think of doing this at the source level by generating something like setField(String name, Object value). Is there any way AspectJ could be "extended" to help here? I want to avoid bytecode generating a new class at runtime to avoid serialization problems.

Thanks,

John


Back to the top