Skip to content

Languages & Runtimes

How does a Java agent work? Building a Java agent from scratch.

with Marco Sussitz

Wednesday 8 July 18:00 – 20:00 Room M4 (40 Seats)

About This Session

Java agents let you modify application behavior at runtime without changing source code. In this hands‑on workshop, you’ll build a small Java agent from scratch using the Instrumentation API and Byte Buddy. We’ll cover premain vs. attach, class transformers, method interception, and safe argument/return value capture. You’ll see how compiled classes look in bytecode (via javap) and how to reason about performance and classloader/module quirks in modern JDKs. By the end, you’ll have a working agent that times and logs specific methods in a sample app, plus a mental model to understand how tools like OpenTelemetry auto‑instrumentation plug into your services. Many developers have used a Java agent before, be it in your mocking frameworks, to find a memory leak, or maybe you have some sort of tracing on your backend via OpenTelemetry. But what is a Java Agent, and how does it function? Would you like to know how to manipulate run-time code and achieve things that are impossible otherwise? In my day-to-day job, I mainly work with Java agents, and in this workshop, I will show you what an agent can do, how they work, and how you can write one yourself. You’ll build a small Java agent from scratch using the Instrumentation API and Byte Buddy. We’ll cover how to attach your agent, the class transformers, method interception, and argument and return value capture. In the end, you will know how tools like OTEL work and have a better understanding of observability.

Topics

  • Java
  • JVM
  • Observability