|Type||Bytecode Engineering Library|
|License||Apache license (version 2)|
Byte Buddy is a Java software library for the manipulation and creation of Java bytecode. Bytecode manipulation can be performed prior to execution or during the runtime of an application. Byte Buddy uses the ObjectWeb ASM library to apply its manipulations but provides a high-level API that avoids the explicit specification of Java bytecode that is required by ObjectWeb ASM. Instead, Byte Buddy uses a domain-specific language to express bytecode manipulation on a high level where the domain language’s verbs lean onto terms of the Java programming language. Byte Buddy is used by a wide-range of commercial and free software products on the Java virtual machine. For example, the library is used by the popular Mockito and Hibernate libraries. Byte Buddy is in particularly popular for creating Java agents, for example by Instana APM  Elastic APM , where code changes are implemented in regular Java code which is used as template for changing a class’s code. Byte Buddy is part of the OpenJDK Quality Outreach  for giving early feedback on upcoming Java releases. The library received a Duke's Choice Award in 2015 and its author was distinguished with an Oracle Groundbreaker Award in 2019.
Using Byte Buddy, the following code creates and loads a class that extends
java.lang.Object and overrides its
toString method to return the string
Class<?> dynamicType = new ByteBuddy() .subclass(Object.class) .method(ElementMatchers.named("toString")) .intercept(FixedValue.value("Hello World!")) .make() .load(getClass().getClassLoader()) .getLoaded(); assertThat(dynamicType.newInstance().toString(), is("Hello World!"));
- ObjectWeb ASM
- Byte Code Engineering Library
- ↑ "Maven usage overview". MvnRepository.
- ↑ "Instana agent description". Instana Inc.
- ↑ "Elastic Search Agent description". Elastic.
- ↑ "Quality outreach". OpenJDK.
- ↑ "JAX Enter article mentioning the award (German)". JAX Enter.
- ↑ "Forbes article on the Groundbreaker award winners of 2019". Forbes.
This article "Byte Buddy" is from Wikipedia. The list of its authors can be seen in its historical. Articles taken from Draft Namespace on Wikipedia could be accessed on Wikipedia's Draft Namespace.