Java Core & JVM (50 Qs)•Part 3: JVM Internals, Low-Latency Systems & Production Tuning (25 - 35)
Java Dynamic Proxies vs Bytecode Manipulation (ByteBuddy / CGLIB).
senior LeveljavaJVM Internals
In Simple Words: Dynamic proxies create proxy classes at runtime:
- JDK Dynamic Proxy (
Proxy.newProxyInstance): Built into the JDK. Requires target classes to implement an interface. Intercepts calls viaInvocationHandler. - CGLIB / ByteBuddy: Subclasses concrete classes directly at runtime by generating raw JVM bytecode. Used by Spring Boot for
@Transactionaland AOP aspect interception on non-interface service classes.