I am also quite active in open source and as a conference speaker and organizer.

Before that, I was in academia where I did a fair share of statistical analysis what evoked an interest in computer performance. After I left university, I have been working mostly with the JVM where I still enjoy working with performance critical systems but where I also do a lot of enterprise software development.

Hi, Rafael. Would you like to introduce yourself and tell us a little bit about your developer experience?

Today, the library‘s goal is to be the fastest and easiest way to define or modify Java classes at runtime. As a side goal, I wanted to offer some support for Android which was previously lacking a runtime code generation library and I wanted to make it easy to define Java agents.

Proxies are often implemented as subclasses where these annotations disappear as method annotations are never inherited. Many libraries such as Hibernate do however use annotations as part of their API what breaks this pattern. I got stuck and wrote a tiny library as a replacement for cglib which later evolved into what is Byte Buddy today.

Byte Buddy originated out of frustration over cglib , a commonly used library for code generation that got abandoned a few years back. I was working on a proxy component that needed to retain the annotations of the proxied methods.

You are the Team Leader of the Byte Buddy open-source framework. Can you tell what’s the goal of Byte Buddy?

In 2013, you wrote the cglib: The missing manual article. How does Byte Buddy compare to cglib or javassist?

I wrote this article as a heavy user of code generation libraries in open source and to share a bit of my knowledge of cglib which is not supplemented by any documentation. I still believe that this is one major issue of code generation libraries; due to the lack of documentation, many people fear using them for not understanding how they work despite their usefulness.

Other than Byte Buddy, cglib is limited to creating subclasses of existing types where it can override existing methods. Byte Buddy gives you full freedom in defining additional fields or methods and allows you to implement methods arbitrarily. In practice, this often results in thinner byte code and better performance.

Also, Byte Buddy does not require you to include any library-specific classes into the generated code what is crucial for OSGi-environments. Also, this will become a necessity when working with Java 9 modules which the authors of cglib did of course not anticipate 15 years back.

Javassist has a proxy API that is similar to cglib which does, however, come with the identical limitations. Additionally, Javassist allows for arbitrary modifications of classes using a different API by supplying Java code as strings. While this approach gives you full freedom, it is very vulnerable to API-changes which then yield runtime errors and also opens up to code-injection when processing user input, similar to SQL-injection when using JDBC.