PatchBridge

Bootstrap-resident trampoline. Injected into the bootstrap classloader via Instrumentation.appendToBootstrapClassLoaderSearch. A patched vanilla method carries an inlined INVOKESTATIC PatchBridge.fireEnter(slot, key, self, args) at its head, or PatchBridge.fireExit(slot, key, ...) at every exit (woven by ByteBuddy Advice); slot indexes the Handler the game classloader registered, key is only carried through to it.

One registry serves every phase: slot and key are both minted per INSTALL, so the game side hands the key back as the patch id while the slot stays this class's business.

fireEnter / fireExit observe; fireIntercept / fireModify return a value the advice assigns. All four share one rule: a handler that throws is caught here, and the answer degrades to whatever leaves the patched method untouched.

Re-entrancy is unguarded, deliberately. A handler that reaches the method it patched fires it again until the stack ends — the caller's mistake, and their own stack trace names it. A latch would also drop the nested fires a patch on a recursive method exists to see, and would cost every patch to protect one from itself. The exception is the dispatch path below, which every OTHER patch runs through: weaving that breaks patches its installer never wrote, so Patches refuses it.

Pure JDK only — must never reference any net.minecraft.* / loader class, so that the one copy on the bootstrap loader keeps a single identity across every module layer that patched MC methods live in. NeoForge ModuleClassLoader and Fabric KnotClassLoader both delegate this package to bootstrap.

Constructors

Link copied to clipboard
private constructor()

Properties

Link copied to clipboard
open var ARMED: Boolean
Whether user patches may take effect.
Link copied to clipboard
private open var SLOTS: Array<Handler>
Handlers by woven slot.

Functions

Link copied to clipboard
open fun fireEnter(slot: Int, key: String, self: Any, args: Array<Any>)
Target of the inlined INVOKESTATIC woven at the head of an entry-patched method.
Link copied to clipboard
open fun fireExit(slot: Int, key: String, self: Any, args: Array<Any>, returned: Any, thrown: Throwable)
Target of the inlined INVOKESTATIC woven at every exit of an exit-patched method, including the exceptional one.
Link copied to clipboard
open fun fireIntercept(slot: Int, key: String, sig: MethodType, self: Any, args: Array<Any>): Any
Target of the inlined INVOKESTATIC woven at the head of an intercept-patched method.
Link copied to clipboard
open fun fireModify(slot: Int, key: String, sig: MethodType, self: Any, args: Array<Any>, returned: Any, thrown: Throwable): Any
Target of the inlined INVOKESTATIC woven at every exit of a modify-patched method.
Link copied to clipboard
private open fun handler(slot: Int): Handler
The handler in slot: null once unregistered, and for advice stranded past its own removal.
Link copied to clipboard
open fun register(slot: Int, h: Handler)
Register the handler for a patch slot.
Link copied to clipboard
open fun unregister(slot: Int)
Drop the handler for a patch slot, so a removed patch leaves nothing behind on the bootstrap loader.