2

what is the difference between working of cglib and javaassist

  1. Does cglib creates proxies runtime?
  2. How does javaassist creates proxies?
  3. What is bytecode instrumentation?
  4. How hibernate uses these libraries?
Rafael Winterhalter
  • 42,759
  • 13
  • 108
  • 192
eatSleepCode
  • 4,427
  • 7
  • 44
  • 93
  • What have you found up yourself so far? – Adam Michalik Sep 08 '15 at 09:08
  • @AdamMichalik I don't have much idea about these but hibernate has deprecated using cglib, these two are used for bytecode instrumentation and proxy generation. don't know much. – eatSleepCode Sep 08 '15 at 09:43
  • Based in this [answer][1] I would say java assist [1]: http://stackoverflow.com/a/32417181/657745 – Sudarshan Sep 08 '15 at 10:50
  • Tag wiki : "*cglib is a run time code generation library for the Java platform licensed under the Apache 2.0 license. **Cglib is no longer under active development.***" – Tiny Sep 14 '15 at 05:41

2 Answers2

1

The best bytecode manipulation library is ASM (http://asm.ow2.org/). It's really fast and simple to understand.

Nikita Koval
  • 107
  • 5
1

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.

Community
  • 1
  • 1
Ravindra babu
  • 37,698
  • 11
  • 250
  • 211