Class ByteBuddyPatchRegistry

java.lang.Object
me.tamkungz.nilkit.tooling.bytebuddy.ByteBuddyPatchRegistry

public final class ByteBuddyPatchRegistry extends Object
Composes and installs ByteBuddyPatch instances.

Two execution paths are supported:

  • NilLoader pre-load transformation, requiring no self-attach.
  • Instrumentation/AgentBuilder with retransformation for already loaded classes.

This makes the same patch definition usable both like a traditional Mixin (before class definition) and like a runtime agent when Instrumentation exists.

  • Constructor Details

    • ByteBuddyPatchRegistry

      public ByteBuddyPatchRegistry()
  • Method Details

    • register

      public ByteBuddyPatchRegistry register(ByteBuddyPatch patch)
    • unregister

      public boolean unregister(String id)
    • clear

      public void clear()
    • snapshot

      public List<ByteBuddyPatch> snapshot()
    • isEmpty

      public boolean isEmpty()
    • installNilLoaderBridge

      public void installNilLoaderBridge()
      Installs one catch-all NilLoader transformer. Register this during premain/hijack, before NilLoader closes transformer registration.

      Patches themselves remain dynamic: a patch registered later still affects classes that have not yet been defined.

    • transformBytes

      public byte[] transformBytes(ClassLoader loader, String binaryClassName, byte[] originalBytes)
      Transforms a raw class file without loading the class. Useful for NilLoader and for tests/tools that patch byte arrays directly.
    • installOn

      public ByteBuddyPatchRegistry.Installation installOn(Instrumentation instrumentation)
      Installs all registered patches as one retransformation-capable Byte Buddy agent. The returned handle can later be reset.