[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] A gap between compile-time Join point matching and runtime reflection
|
Hi, All
I have a question about this subject. Please check following code.
=================================================================
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface Marker {
// Marker annotation
}
-----------------------------------------------------------------
@Marker
public interface Service {
public void doService();
}
-----------------------------------------------------------------
public class ServiceImpl implements Service {
public void doService() {
}
}
-----------------------------------------------------------------
public class Client {
private Service service = new ServiceImpl();
private ServiceImpl serviceImpl = new ServiceImpl();
public void useService() {
service.doService(); // Match! -> "Match-A"
serviceImpl.doService(); // Match! -> "Match-B"
}
}
-----------------------------------------------------------------
@Aspect
public class AnAspect {
@Around("call(* (@Maker *).*(..))")
public Object doAdvice(ProceedingJoinPoint pjp) throws Throwable {
pjp.getSignature().getDeclaringType().getAnnotation(Maker.class);
// ...
}
}
When specified Joint point is "Match-A",
pjp.getSignature().getDeclaringType().getAnnotation(Maker.class) returns
Maker annotation, but specified Joint point is "Match-B",
it returns null...
Though this pointcut expression matches both of join point, I cannot get
the same annotation with runtime reflection.
Why this pointcut expression matches both of join point?
Is it the AspectJ 5 specification?
(I use AspectJ 1.5.1a with AJDT 1.4.0.20060413082832 on
Eclipse 3.2M6)
Thanx!
Eiichiro UCHIUMI (Tokyo/Japan)