# raphw/byte-buddy

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/raphw-byte-buddy).**

6,856 stars · 850 forks · Java · Apache-2.0

## Links

- GitHub: https://github.com/raphw/byte-buddy
- Homepage: https://bytebuddy.net
- awesome-repositories: https://awesome-repositories.com/repository/raphw-byte-buddy.md

## Topics

`byte-code` `dynamic-proxy` `instrumentation` `java` `java-agent` `java-library` `java-virtual-machine`

## Description

Byte Buddy is a runtime code generation and bytecode manipulation library for Java. It provides a fluent API for creating and modifying Java classes during execution, enabling developers to define class structures, methods, and fields programmatically without requiring a compiler or direct bytecode assembly.

The library supports agent-based class transformation, allowing loaded classes to be modified during JVM startup or runtime through a Java agent that intercepts class loading. It offers bytecode-level method interception for fine-grained control over method behavior, annotation-based code weaving for metadata injection, and automatic stack map frame computation required by the JVM verifier. Byte Buddy also includes a class file pool abstraction for efficient caching and reuse of bytecode across multiple transformations, along with dynamic class loading integration for loading generated classes into the JVM.

Beyond its core identity as a bytecode manipulation tool, Byte Buddy enables runtime class creation, modification, and generation, as well as dynamic proxy creation and testing mock generation. It functions as an instrumentation library for weaving monitoring, tracing, or mocking logic into classes, and provides a Java agent framework for transforming loaded classes during application startup or execution. The library's capabilities extend to application code instrumentation, method override with fixed logic, and runtime bytecode transformation of already-loaded classes.

## Tags

### Software Engineering & Architecture

- [Bytecode Manipulation](https://awesome-repositories.com/f/software-engineering-architecture/bytecode-manipulation.md) — Directly edits Java bytecode to add, replace, or remove methods and fields in classes.
- [Bytecode-Level Interceptors](https://awesome-repositories.com/f/software-engineering-architecture/method-interception-proxies/bytecode-level-interceptors.md) — Offers bytecode-level method interception for fine-grained control over method behavior.
- [Method Interception Proxies](https://awesome-repositories.com/f/software-engineering-architecture/method-interception-proxies.md) — Generates proxy classes at runtime that delegate method calls to custom handlers.

### Part of an Awesome List

- [Bytecode Manipulation](https://awesome-repositories.com/f/awesome-lists/devtools/bytecode-manipulation.md) — Offers low-level bytecode editing capabilities for adding, replacing, or removing methods and fields.
- [Java Agents](https://awesome-repositories.com/f/awesome-lists/devtools/java-frameworks/java-agents.md) — Provides a Java agent API for transforming loaded classes during application startup or execution.
- [Code Generation and Bytecode](https://awesome-repositories.com/f/awesome-lists/devtools/code-generation-and-bytecode.md) — Runtime code generation for the Java virtual machine.

### Data & Databases

- [Arbitrary Structure Class Generators](https://awesome-repositories.com/f/data-databases/data-structure-definitions/data-class-generators/generated-class-customization/arbitrary-structure-class-generators.md) — Generates new Java classes during execution with arbitrary structures beyond simple proxies. ([source](https://bytebuddy.net))

### Development Tools & Productivity

- [Code Instrumentation Utilities](https://awesome-repositories.com/f/development-tools-productivity/code-instrumentation-utilities.md) — Weaves monitoring, tracing, or mocking logic into classes for observability or testing. ([source](https://github.com/raphw/byte-buddy/wiki/Projects-using-Byte-Buddy))
- [Runtime Annotation Weavers](https://awesome-repositories.com/f/development-tools-productivity/task-metadata-annotators/annotation-metadata-transformers/runtime-annotation-weavers.md) — Supports adding, removing, or modifying annotations during bytecode transformations for instrumentation.

### Programming Languages & Runtimes

- [Runtime Bytecode Instrumentation](https://awesome-repositories.com/f/programming-languages-runtimes/compiler-interpreter-internals/compiler-infrastructure/intermediate-representations/bytecode/runtime-bytecode-instrumentation.md) — Modifies bytecode of already-loaded classes during execution, including through a Java agent. ([source](https://bytebuddy.net/))
- [Bytecode Generators](https://awesome-repositories.com/f/programming-languages-runtimes/dynamic-class-creation/bytecode-generators.md) — Generates new Java classes from scratch at runtime by producing bytecode directly.
- [Java Agent Class Transformers](https://awesome-repositories.com/f/programming-languages-runtimes/dynamic-class-creation/class-loading-mechanisms/class-loading-interception/java-agent-class-transformers.md) — Provides a Java agent framework for transforming loaded classes during JVM startup or execution.
- [Runtime Class Constructors](https://awesome-repositories.com/f/programming-languages-runtimes/dynamic-class-creation/runtime-class-constructors.md) — Creates new Java classes from scratch during execution without needing a compiler. ([source](https://bytebuddy.net/))
- [Runtime Class Modifications](https://awesome-repositories.com/f/programming-languages-runtimes/dynamic-class-creation/runtime-class-modifications.md) — Alters behavior of loaded classes at runtime by adding, replacing, or removing methods and fields. ([source](https://bytebuddy.net))
- [Runtime Instrumentation Agents](https://awesome-repositories.com/f/programming-languages-runtimes/runtime-instrumentation-agents.md) — Transforms loaded classes during JVM startup or runtime via a Java agent for monitoring or profiling.
- [Type-Driven Bytecode Generators](https://awesome-repositories.com/f/programming-languages-runtimes/source-code-compilers/bytecode-generation/type-driven-bytecode-generators.md) — Generates Java bytecode at runtime by manipulating type structures through a fluent API.
- [Runtime Bytecode Compilation](https://awesome-repositories.com/f/programming-languages-runtimes/source-code-compilers/runtime-bytecode-compilation.md) — Creates or modifies Java classes at runtime without a compiler, enabling dynamic behavior.
- [Bytecode Generators](https://awesome-repositories.com/f/programming-languages-runtimes/source-code-generators/bytecode-generators.md) — Generates and modifies Java bytecode at runtime without requiring a compiler or source code.
- [Fixed Logic Method Overrides](https://awesome-repositories.com/f/programming-languages-runtimes/class-method-overrides/fixed-logic-method-overrides.md) — Replaces method implementations with constant return values or custom bytecode via matchers. ([source](https://bytebuddy.net/))
- [Custom Class Loader Integrations](https://awesome-repositories.com/f/programming-languages-runtimes/dynamic-class-creation/class-loading-mechanisms/custom-class-loader-integrations.md) — Loads generated or modified classes into the JVM using custom class loaders.
- [Runtime Mock Generators](https://awesome-repositories.com/f/programming-languages-runtimes/go-mocking-libraries/interface-mock-generators/runtime-mock-generators.md) — Generates mock or stub classes at runtime for unit testing with controlled behavior.

### System Administration & Monitoring

- [Instrumentation Libraries](https://awesome-repositories.com/f/system-administration-monitoring/instrumentation-libraries.md) — Weaves monitoring, tracing, and mocking logic into Java classes for observability and testing.

### Web Development

- [Type Manipulation Fluent APIs](https://awesome-repositories.com/f/web-development/api-bridges/browser-api-wrappers/fluent-api-wrappers/type-manipulation-fluent-apis.md) — Provides a fluent API for creating and modifying Java classes during execution without bytecode assembly.
