Search code examples
javareflectionaspectjcompile-time-weaving

How to distinguish generated methods (AspectJ)


I am currently using aspectJ @Around in order to inspect my code. I am using aspectJ compiler in order to weave the aspects. BUT, in runtime, I am analyzing also the structure of classes using reflection type.getDeclaredMethods(). BUt i need to distinguish, which methods were originally present and which were added by the aspectJ compiler. Is it possible? Or is there some workaround?

Thanks in advance.


Solution

  • You can check if the members generated by AspectJ are synthetic. If that is not the case, you could generate an annotation for the methods that are target of a pointcut. During reflection you can filter members having such an annotation.