我正在使用建立在AspectJ 1.81上的AJDT 2.2.4。AspectJ和Map <String,Object> Array
考慮這個簡單的方面:
@Aspect
public class SampleAspect {
@Before("@annotation(logMe)")
public void beforeAdvice(JoinPoint joinPoint, LogMe logMe) {
System.out.println("Before the method");
}
}
它打印LogMe註釋這是前一段文字:
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface LogMe {}
現在,我將此註釋一些方法:
public class DummyClass {
@LogMe
public void doSomething() {
SampleUtil sampleUtil = new SampleUtil();
//pass null for simplicity !
sampleUtil.sampleMethod(null);
System.out.println("Do Something");
}
}
SampleUtil爲
如果我改變sampleMethod
參數別的東西像
Map<String, Object> aMap
錯誤會
can not resolve this member:
void foo.SampleUtil.sampleMethod(java.util.Map[]) [Xlint:unresolvableMember]
:
public class SampleUtil {
public void sampleMethod(
Map<String, Object>[] mapArray){
}
}
我得到這樣的警告。
爲什麼我會收到此警告?
供參考:您不能在'之前'指定建議方法。這是AspectJ中的保留關鍵字,Eclipse將顯示一條奇怪的錯誤消息。我將編輯您的問題並將其重命名爲'beforeAdvice'。我也將簡化方面代碼,仍然保持問題的可重現性。 – kriegaex