周りのアドバイスで、ジョインポイント Sourcelocation から行番号にアクセスしようとしています (ログの目的で)。しかし、それは与えています
Exception in thread "main" java.lang.UnsupportedOperationException
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint$SourceLocationImpl.getLine(MethodInvocationProceedingJoinPoint.java:282)
loc.getLine()
デバッグ時に null を取得しています。
@Around("execution (* com.logger.rms.*.*(..))")
public void logAround(ProceedingJoinPoint procJoinpoint) throws Throwable {
StaticPart part = (procJoinpoint.getStaticPart());
org.aspectj.lang.reflect.SourceLocation loc = part.getSourceLocation();
int line = loc.getLine();
System.out.println(line);
try {
procJoinpoint.proceed();
} catch (Throwable e) {
System.out.println("checking " + procJoinpoint.getSourceLocation().getWithinType().getCanonicalName());
String str = "Aspect ConcreteTester :" + procJoinpoint.getStaticPart().getSourceLocation().getLine();
throw new BusinessLogicException("Throwing Custom business exception from around");
} finally {
}
}