1

As the title suggest, is there any way to validate pointcut syntax using for example annotatoion processor (APT) ?

It is quite easy to get value from @Pointcut(value) using APT ... But after that, there is a problem for me to validate if given String matches the valid syntax for AspectJ weaver ...

spili
  • 61
  • 7

1 Answers1

4

AspectJ includes a type org.aspectj.weaver.patterns.PatternParser. Call the constructor with the text of your pointcut then call getPointcut() to retrieve a pointcut object - it will throw exceptions if there is a problem parsing your input text as a pointcut. However this is purely a syntax check on your text, it does not verify/resolve type references (but you suggest you don't need to go that far). There are resolve methods on the pointcut object if you want to get into resolution.

Andy Clement
  • 2,510
  • 16
  • 11