Categories
Byte Code Engineering Java

An open invitation to write an ebook on byte code engineering.

Three years ago I wrote a small dependency injection container (link), the first version I wrote was using Java Reflection APIs to read information about the classes which should be managed by my container. Later while discussing with Praseed Sir regarding the implementation he pointed out the unnecessary memory issues arising when we make use of the class loaders and he asked me to look into the implementations of spring framework, which in turn lead me to byte code engineering library ASM. I re implemented the meta information reading part with the ASM class visitors.

It took appx 2.5 yrs from that point in time for me to do the byte code generation part using ASM. Praseed Sir has designed a language called SLANG in 2010, originally the front end was written in C# and the backend was making use of Reflection APIs of .Net platform (Sorry Java guys we don’t have this feature yet in JDK) and ever since its inception people have ported it to their own favourite languages for the purpose of learning compiler design. Me and Vaisakh decided to port the front end to Java and backend targetting the JVM. For easiness I initially used Javassist (which doesn’t require the knowledge of JVM instruction set) for the byte code generation and later moved to ASM, Vaisakh was using BCEL for the same. Both ASM and BCEL requires the knowledge of the JVM instruction set. And in light of the above implementations I have also taken a presentation about byte code engineering in the Madras JUG.

While preparing for the presentation which I took in Madras JUG I had the idea of writing a small ebook which elaborated the transformations of Java language constructs to byte code and how we use ASM to generate those portions of the byte code. But after the M-JUG event the idea have been long forgotten by me. Today again this idea came in while having some random talks with Vaisakh.

Writing an ebook is hard as well as a tedious process so instead of ebook I will start a page in my blog named byte code engineering, which will have separate blog entries for each independent language construct and its transformations. The page is open to collaboration, which means you can write blogs in your own blogs and We can link it there in the page I created. In the end with enough language constructs covered we can compile it and make an e-book.

Edit: This is not limited to language constructs and its transformations, you can include contents on how to manipulate already existing class files and so on.

Link to Page : https://sarathsoman.wordpress.com/byte-code-engineering/