Is it possible to intercept the execution of a method that is annotated with a custom annotation without using any AOP framework such as AspectJ, Spring AOP, Guice, etc… I’m curious to find out if any of the default java apis can be used for this purpose (such as Reflection).
Thanks.
You can use reflection to invoke methods, but you can’t use it to intercept method invocations. Likewise, you can create Proxies with dynamic invocation handlers with the
Proxyclass, but you can’t intercept existing code that doesn’t target a proxy.So the answer is no.