Tuesday 21 April 2020

Introduction to Javassist

In this tutorial series, you are going to learn about javasist library. This library is used to manipulate the byte code.

Maven Dependency used
<!-- https://mvnrepository.com/artifact/org.javassist/javassist -->
<dependency>
    <groupId>org.javassist</groupId>
    <artifactId>javassist</artifactId>
    <version>3.26.0-GA</version>
</dependency>

Prerequisite
Install java decompiler to see the updated byte code result. You can go to below post and setup java decompiler.

What is byte code?
When a java class is compiled by compiler it generates byte code, which is loaded by jre (java runtime environment) at run time. Once the byte code is loaded by jre, jvm (Java Virtual Machine) translates the byte code to machine level assembly instructions.

Use of Javassist
Many frameworks like Hibernate, Spring and EJB use byte code manipulation libraries to create proxy classes to the main class. These proxy classes are used to intercept method invocations.

Other Byte code manipulation libraries
a.   ASM
b.   BCEL
c.    cglib
d.   ByteBuddy
e.   jCLA
Previous                                                    Next                                                    Home

No comments:

Post a Comment