Class ByteBuddyHelper

java.lang.Object
me.tamkungz.nilkit.tooling.ByteBuddyHelper

public final class ByteBuddyHelper extends Object
NilKit's Byte Buddy entry point.

For one-off generation, use byteBuddy() or subclass(Class). For Mixin-style class patching, register ByteBuddyPatch objects in patches() and install either the NilLoader bridge during premain or an Instrumentation bridge.

Nothing in the SDK startup path calls ByteBuddyAgent.install(). Self-attachment remains explicit because many JVMs disable or restrict it.

  • Method Details

    • byteBuddy

      public static net.bytebuddy.ByteBuddy byteBuddy()
      Creates an unrestricted Byte Buddy entry point for advanced use.
    • patches

      public static ByteBuddyPatchRegistry patches()
      Global composable patch registry used by the convenience methods below.
    • register

      public static ByteBuddyPatchRegistry register(ByteBuddyPatch patch)
      Registers a Mixin-style patch in the global registry.
    • installNilLoaderBridge

      public static void installNilLoaderBridge()
      Installs the global registry into NilLoader's pre-load transformer chain. Call during premain/hijack, before transformer registration is closed.
    • installPatches

      public static ByteBuddyPatchRegistry.Installation installPatches(Instrumentation instrumentation)
      Installs the global registry on existing Instrumentation. The installation is retransformation-capable and can be reset through the returned handle.
    • instrumentationOrNull

      public static Instrumentation instrumentationOrNull()
      Returns already-installed Byte Buddy instrumentation, or null if the agent is not installed. This method never attempts self-attachment.
    • installInstrumentation

      public static Instrumentation installInstrumentation()
      Explicitly asks Byte Buddy to self-attach and returns Instrumentation. Prefer instrumentation supplied by the loader/agent when available.
    • isInstrumentationAvailable

      public static boolean isInstrumentationAvailable()
      Returns true if Byte Buddy's agent is already installed.
    • subclass

      public static <T> net.bytebuddy.dynamic.DynamicType.Builder<T> subclass(Class<T> baseType)
      Starts a subclass builder without forcing callers to create ByteBuddy first.
    • makeSubclass

      public static <T> Class<? extends T> makeSubclass(Class<T> baseType)
      Generates and loads an empty subclass using a wrapper class loader.