Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between javaassist and cglib

I learning hibernate and I understood that hibernate has stopped using cglib and switched to javaassist.

I also understood that javaassist and cglib are used for proxy generation.

so I was wondering how these two works and which one is better? What is the difference between their working style?

like image 878
user3359405 Avatar asked Sep 05 '15 12:09

user3359405


1 Answers

Cglib is no longer actively maintained and the library's developers would not even apply provided patches: https://jaxenter.com/hibernate-to-deprecate-cglib-as-bytecode-provider-102106.html

Additionally, javassist offers an API for modifying classes and not only for subclassing them. These APIs allow also for byte code-level manipulation while cglib only allows for several hardcoded interceptions.

Finally, there is a minor performance difference. For an overview, see this table on a third byte code manipulation framework, Byte Buddy, that I created: http://bytebuddy.net/#/tutorial

like image 153
Rafael Winterhalter Avatar answered Sep 30 '22 17:09

Rafael Winterhalter