AspectJ 1.81에서 빌드 된 AJDT 2.2.4를 사용하고 있습니다. 그것은이다 LogMe 주석 전에 텍스트 인쇄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");
}
}
:
이 간단한 측면을 고려public class DummyClass {
@LogMe
public void doSomething() {
SampleUtil sampleUtil = new SampleUtil();
//pass null for simplicity !
sampleUtil.sampleMethod(null);
System.out.println("Do Something");
}
}
: 이제
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface LogMe {}
를, 나는 같은 몇 가지 방법이 주석을 적용
SampleUtil은
입니다. 나는 오류가 갈 것Map<String, Object> aMap
같은 다른 무언가로
sampleMethod
매개 변수를 변경하는 경우
can not resolve this member:
void foo.SampleUtil.sampleMethod(java.util.Map[]) [Xlint:unresolvableMember]
:
public class SampleUtil {
public void sampleMethod(
Map<String, Object>[] mapArray){
}
}
나는이 경고를 얻을.
왜이 경고 메시지가 표시됩니까?
FYI : 'before'라는 조언 메서드의 이름을 지정할 수 없습니다. 이것은 AspectJ에서 예약 된 키워드입니다. Eclipse는 이상한 오류 메시지를 표시합니다. 질문을 편집하고 'beforeAdvice'로 이름을 바꿉니다. 또한 애스펙트 코드를 약간 단순화하여 문제를 재현 가능하게 유지할 것입니다. – kriegaex