2016-09-28 5 views
0

주석 스타일을 사용하여 AndroidStudio에서 AspectJ 프로젝트를 빌드하는 중 "이 기호 변수를 찾을 수 없습니다."라는 문제를 해결하는 방법은 무엇입니까?기호 변수 thisJoinPoint를 찾을 수 없습니다.

플랫폼 세부 정보 : AspectJ를 1.8.1, 안드로이드 스튜디오 2.1.3

코드 예제 : 난 그냥 주석 스타일, 우리가 thisJoinPoint를 선언 할 필요가 발견 된 일부 테스트 및 연구 후

import org.aspectj.lang.JoinPoint.*;   // Not used! 
import org.aspectj.lang.ProceedingJoinPoint; // Not used! 
import org.aspectj.lang.annotation.After; 
import org.aspectj.lang.annotation.Pointcut; 

@Aspect 
public class MyAspect { 
    @Pointcut("execution(* *(..))") 
    public void methodExecution() {} 

    @After("methodExecution()") 
    public void accessThisJoinPointData() { 
     if (thisJointPoint != null) { // HERE the variable isn’t recognized! 
      // Do something with thisJoinPoint... 
     } 
    } 
} 

답변

0

조언을위한 매개 변수로. 그래서이 문제는 다음과 같이 해결된다 :

@After("methodExecution()") 
    public void accessThisJoinPointData(JoinPoint thisJoinPoint) { 
     if (thisJointPoint != null) { // Now the variable can be recognized! 
      // Do something with thisJoinPoint... 
     } 
} 

참조 :

"조언 몸이 thisJoinPoint, thisJoinPointStaticPart에 대한 액세스를 필요로하는 경우 주석 스타일을 사용하는 경우, thisEnclosingJoinPointStaticPart 다음이 추가 메서드 매개 변수로 선언해야합니다. "

https://eclipse.org/aspectj/doc/released/adk15notebook/ataspectj-pcadvice.html

관련 문제