Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java bytecode manipulation without external library

Libraries such as ASM, BCEL, Javaassist and AspectJ are all capable of runtime bytecode manipulation but how do they achieve this?

I have done some basic bytecode manipulation using ASM before but I don't understand how it works. Is the Java agent executed in the JVM before the remainder of the program, allowing for ASM to load the compiled classes and edit them before they are executed by the JVM?

If so, is it possible to perform Java bytecode manipulation without using an external library like ASM and loading the compiled class files with an BufferedReader and writing a custom parser etc. for example?

like image 626
Will D Avatar asked Nov 04 '25 14:11

Will D


1 Answers

Recently java development group at Oracle announced a new JEP( Java enhancement proposal) for class file manipulation. Now we will not need any additional libraries.

https://openjdk.org/jeps/8280389

JEP 484: Class-File API finalized the API in Java 24. See java.lang.classfile and related packages.

like image 98
Vipin Avatar answered Nov 07 '25 13:11

Vipin