Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Why annotations are not exposed through JoinPoint.StaticPart?

Hi,

On 14 December 2011 11:27, Mark <mark.kharitonov@xxxxxxxxx> wrote:
> If so, then it should be available in JoinPoint.StaticPart, but it is
> neither there nor is it in JoinPoint. Why?

It isn't directly on either of those, but they are accessible if you
of course.  I presume you are doing something like this: for a Field
joinpoint:

((FieldSignature)thisJoinPoint.getSignature()).getField().getAnnotations()

similar thing for methods.  It could be exposed directly on JoinPoint
I suppose but it'd just be a cache of the call I showed above - there
isn't any magic in how AspectJ could do it in a more optimal way.
Annotations can't be 'new'd up directly, they tend to have to be
fetched from somewhere.

> Does it mean that accessing
> annotations through the reflection is so cheap that it is OK to do so in
> aspect advices?

No, reflection isn't cheap.  So you should cache the results if you
are going to keep asking the question.  I could cache them in the
joinpoint object, please raise an enhancement request if you want this
but without a few votes it won't be top of the list I'm afraid.

cheers
Andy


Back to the top