Skip to content

Instantly share code, notes, and snippets.

View kriegaex's full-sized avatar

Alexander Kriegisch kriegaex

View GitHub Profile
@kriegaex
kriegaex / BootstrapAgent.java
Last active January 19, 2024 03:52 — forked from joshgord/BootstrapAgent.java
An example agent that intercepts a method of the bootstrap class loader. Tested with Byte Buddy 1.14.11 on JDKs 8 to 21.
package net.bytebuddy;
import net.bytebuddy.agent.ByteBuddyAgent;
import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.dynamic.ClassFileLocator;
import net.bytebuddy.dynamic.loading.ClassInjector;
import net.bytebuddy.implementation.MethodDelegation;
import net.bytebuddy.implementation.bind.annotation.SuperCall;
import net.bytebuddy.matcher.ElementMatchers;