what is the difference between working of cglib and javaassist
- Does cglib creates proxies runtime?
- How does javaassist creates proxies?
- What is bytecode instrumentation?
- How hibernate uses these libraries?
what is the difference between working of cglib and javaassist
The best bytecode manipulation library is ASM (http://asm.ow2.org/). It's really fast and simple to understand.
Byte Buddy is a code generation library for creating Java classes during the runtime of a Java application and without the help of a compiler. Other than the code generation utilities, it allows the creation of arbitrary classes and is not limited to implementing interfaces for the creation of runtime proxies.
Byte Buddy is good alternative to both cglib and javaassist. Have a look at Benchmarking various alternatives among Byte Buddy, cglib, javaassist and jdkproxy.
Have a look at SE question regarding the same.
Regarding your queries:
Bytecode instrumentation: ( from cs.helsinki)
Bytecode instrumentation is a process where new function- ality is added to a program by modifying the bytecode of a set of classes before they are loaded by the virtual machine :
Both cglib and javassist were created early and their APIs were built around the language features that Java had to offer back in these days.
Annotation is significant innovations introduced after the inception of these libraries.
Byte Buddy uses annotations and a domain specific language for achieving its ambitions.