이클립스 + AJDT에서 다음과 같이 권한을 확인하는 메소드 주석을 구현했다.이클립스는 예외 발생 측면을 오해한다
주석 :
@Retention(RetentionPolicy.RUNTIME)
public @interface Secured {}
측면 :
public aspect SecurityCheck {
pointcut checkSecurity(Secured annotation) : execution(@Secured * *.*(..)) && @annotation(annotation);
Object around(Secured annotation) throws PermissionException:
checkSecurity(annotation) {
...
if (...) throw new PermissionException();
...
return proceed(annotation);
}
}
용도 :
@Secured
public void someMethod() {}
애노테이션 표시 화면이 적용되어야하는 모든 방법. Aspect는 승인을 확인하고 실패시 PermissionException
을 던집니다. 이 체크 예외로
그러나, someMethod()
선언 할 필요가 :
@Secured
public void someMethod() throws PermissionException {}
이클립스는이를 좋아하지 않는다 : PermissionException
을 던져 someMethod()
안에 아무것도 없다, 그것은 불평 있도록. 해결 방법을 수행해야합니다.
이렇게하면 Eclipse가 행복해지며 잘 작동합니다. 그러나 매번 warn()
번으로 전화를 걸어서 Eclipse를 닥치게 만드는 것은 꽤 추한 것입니다.
더 좋은 방법은 없을까요? 이것은 간단한 Eclipse 버그입니까?
확인해야 할 필요가 있습니다. 당신이 언급 한 버그는 내 문제와 관련이없는 것처럼 보입니다 ... – vektor
이클립스의 측면이 그대로 컴파일되고 있습니까? 확인 된 예외를 throw 할 수 없습니다 ...라는 오류가 표시되지 않습니까? – ramsinb
네, 제 양상은 이클립스에서 잘 컴파일되고 있습니다. – vektor