#dynamic_proxy
Explore tagged Tumblr posts
devsnews ยท 3 years ago
Link
JDK Java dynamic proxy and CGLIB are both Java-based frameworks for creating proxies for objects. The main difference between them is that JDK Java dynamic proxy requires that the target class implements an interface. It then creates a proxy instance by wrapping the target instance in its proxy class. This proxy class implements the same methods as the target class, but delegates call to the target instance. CGLIB, on the other hand, does not require that the target class implements an interface. Instead, it uses bytecode manipulation to create a subclass of the target class and then modifies the bytecode of the subclass to create proxies. This allows CGLIB to create proxies for classes that do not implement interfaces. This article, with practical examples, gives you a good understanding of these two approaches to implementing dynamic proxy in Java.
0 notes