[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [aspectj-users] Exposing state held in method annotations
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hmmm, strange. I tried the following, but apparently AspectJ is
unable to resolve the annotation interface type ConstantArguments:
pointcut constantArgumentMethods() :
call(@ConstantArguments * *.*(..));
/*pointcut constantArgumentMethods(ConstantArguments annot)
: call(@ConstantArguments * *.*(..))
&& @annotation(annot);*/
Object around(): constantArgumentMethods() {
Signature sig =
thisJoinPointStaticPart.getSignature();
Class c = sig.getDeclaringType();
MethodSignature msig =
(MethodSignature)thisJoinPointStaticPart.getSignature();
Method m = c.getMethod(sig.getName(),
msig.getParameterTypes());
ConstantArguments = (ConstantArguments)
m.getAnnotation(ConstantArguments.class);
The last line here gives the error:
ConstantArguments cannot be resolved ConstantArgumentsAspect.aj
And that, though the annotation type is located in the very same
package! Yet another bug?
Eric
Pepe Iborra wrote:
> I've been using the following (ugly) code due to lack of binding
> support in M1:
>
> pointcut constantArgumentMethods(int[] value) :
> call(@ConstantArguments(value) * *.*(..));
>
> before(..) : constantArgumentMethods(..) {
> Signature sig =
> thisJoinPointStaticPart.getSignature();
> Class c = sig.getDeclaringType();
> MethodSignature msig =
> ((MethodSignature)thisJoinPointStaticPart).getSignature();
> Method m = c.getMethod(sig.getName(),
> sig.getParameterTypes());
>
> ConstantArguments = (ConstantArguments)
> m.getAnnotation(ConstantArguments.class);
>
> ---do something with the annotation---
>
> }
- --
Eric Bodden
Chair I2 for Programming Languages and Program Analysis
RWTH Aachen University
-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0.3
iQA/AwUBQfuZOMwiFCm7RlWCEQLRuACg24KjRryID3IGi57IhWhIaJoA94UAmwU2
2Y4Pbd0RE//tOUDFbeu5QO+m
=dXKC
-----END PGP SIGNATURE-----