Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] DirtinessAspect

Ricardo Giacomin wrote:
> I wrote the aspect below to keep track of modification of entities' state
> (assuming all entity attributes have corresponding getter and setter
> method)
<snip>
>   String m = "g" + thisJoinPoint.getSignature().getName().substring(1);
>   Object value = entity.getClass().getMethod(m, argTypes).invoke(entity, args);
<snip>
> Just wondering if it is possible to accomplish the same without using
> reflection (without invoking the getter to get the current value).

Your code is the best implementation that I'm aware of in the current version of AspectJ.

We spent a lot of time on this issue when designing field-set joinpoints.  We knew that it would be useful to provide a simple non-reflective way for people to get the current value of the field but couldn't come up with an elegant way to do so.  In the end we decided that this wouldn't be used often enough to justify a special-case language hack.

I'm glad you shared this code with the list as it shows this is a more general problem than just field-set joinpoints.  These kinds of examples will be valuable when future improvements to AspectJ are discussed.

-Jim


Back to the top