The latest expert opinions, articles, and guides for the Java professional.

Performance Comparison of cglib, Javassist, JDK Proxy and Byte Buddy


In the first post on runtime code generation in Java, we looked at Java’s strong and static type system. Then we learned about different libraries for code generation and we had a closer look at Byte Buddy, a library of my own efforts.

Today we want to compare the different libraries in a benchmark. In the end, a shiny API will not be the only criteria for a best choice in code generation library. A library’s runtime performance might be an even more important factor, especially if the generated code takes up a crucial position within the running application.

We generate a microbenchmark and see if the performance of the different frameworks will allow us to draw any conclusion about which approach is better.

Read more

Using Byte Buddy to Implement Annotation-Driven Java


Last week, we looked into Java’s strong and static type system. We stipulated that such types make our code more expressive, but at the same time limit third-party frameworks in offering POJO-centric APIs.

Today, we’ll look at some limitations of different Java runtime code generation libraries, including the well-known javassist. And the reasons why a typesafe domain specific language for code generation could be really useful.

Read more

How to Make Java More Dynamic with Runtime Java Code Generation


The ongoing POJO-revolution is a form of code generation that disseminates in the Java landscape. Many modern Java libraries and frameworks do their magic by defining on-demand classes during a Java application’s runtime.
With the goal to design a transparent library that won’t weaken the type system of our application, we look at a sample annotation based security framework and go over the typical approaches to runtime code generation on JVM.

Read more