Hi,
I have created an aspect that can be used to track calls to deprecated methods in your product. It is currently implemented in "our product" but I want to make a library out of it so we can use it for other products.
The aspect currently looks something like:
aspect DeprecatedMethodLogger {
pointcut includeDeprecated():execution(public * *.*(..)) && @annotation(Deprecated);
pointcut excludeBeta():execution(public * *.*(..)) && !@annotation(com.google.common.annotations.Beta);
pointcut deprecatedMethods(): includeDeprecated() && excludeBeta();
before() :deprecatedMethods() {
if (thisJoinPoint.getTarget() != null) {
String targetClass = thisJoinPoint.getTarget().getClass().getName();
List<StackTraceElement> stackTraceElements = Arrays.asList(Thread.currentThread().getStackTrace());
StackTraceHelper stackTraceHelper = new StackTraceHelper(stackTraceElements);
DeprecatedMethodData deprecatedMethodData = stackTraceHelper.extractData(targetClass);
//There is also some additional connections to db and other tools here.