Code Generation Library (CGLIB)
  • is a byte instrumentation library used in many Java frameworks such as Hibernate or Spring which allows manipulating or creating classes after the compilation phase of a program
  • the JDK dynamic proxy approach requires the target objects to implement one or more interfaces. What if you want to proxy legacy classes that do not have interfaces? You can use the CGLIB library
  • uses ASM underneath

Dependencies

Package Structure

net.sf.cglib.core

Low-level bytecode manipulation classes; Most of them are related to ASM.

net.sf.cglib.transform

Classes for class file transformations at runtime or build time

net.sf.cglib.proxy

Classes for proxy creation and method interceptions

net.sf.cglib.reflect

Classes for a faster reflection and C#-style delegates

net.sf.cglib.util

Collection sorting utilities

net.sf.cglib.beans

JavaBean related utilities

Code Examples

Resources