Spring / Spring interview questions
The main difference between JDK dynamic proxy and CGLib.
JDK Dynamic proxy can only proxy by interface while CGLIB (and javassist) can create a proxy by subclassing.
In JDK dynamic proxy, your target class need to implement an interface, which is then implemented by the proxy class. In CGLIB the proxy becomes a subclass of the target class so there is no need for interfaces.
JDK Dynamic proxy uses JDK reflection API. CGLib (Code Generation Library) is built on top of ASM, generates proxy extending the spring bean and adds bean behavior in the proxy methods.
More Related questions...