MaskingClassLoader
Classloader for the REPL's Kotlin scripting stack.
It hosts the entire Kotlin scripting stack (kotlin-compiler-embeddable + scripting + stdlib + reflect + script-runtime) plus the REPL impl's own Kotlin classes, on a self-managed URLClassLoader that lives OFF the FML/securejarhandler module path. That is mandatory on NeoForge: putting kotlin-compiler-embeddable on the module path makes securejarhandler throw "Invalid package name: 'native' is not a Java identifier" at boot (the compiler ships a package org.jetbrains.kotlin.native.interop, and native is a Java keyword).
The compiler (org.jetbrains.kotlin.*), the shaded intellij/etc. inside compiler-embeddable, and the REPL impl classes under ...repl.impl.* are ALWAYS child-first (masking-owned). The JDK, MC, and the mod's own non-impl classes are ALWAYS parent-first so they keep a single shared identity with the game loader.
The kotlin RUNTIME (kotlin.* stdlib/reflect) is version-regime dependent
A REPL snippet must exchange kotlin objects (lambdas = Function0, Pair, Sequence, …) with the game's mods, which use the GAME loader's kotlin. If the masking loader defines its OWN copy of those classes, a snippet value is a DIFFERENT class from the mod's parameter type → LinkageError. One shared kotlin identity is the only fully-safe unification, and it needs the versions to line up — hence Regime, overridable with mcp.kotlin.regime=auto|share|split.
A feature that would otherwise need a JVM agent
Because every masking-owned class is defined right here in findClass, this loader is the single door those classes' bytes come through — which makes java.lang.instrument unnecessary for anything scoped to them. So the preload working-set capture works on a JVM launched WITHOUT -Djdk.attach.allowAttachSelf / -XX:+EnableDynamicAgentLoading: definedClassNames answers "what did this loader define?" from its own bookkeeping.
The live-patch engine (Patches.onEnter/onExit) still needs the agent and still dies without those flags: it retransforms already-loaded net.minecraft.* classes on the GAME loader and injects a jar into the bootstrap loader — neither is something a classloader can do for itself.
Parameters
the masking classpath (our extracted kotlin stack + repl.impl + mod jar)
the game loader
Types
Kotlin-identity regime, decided once from (our bundled kotlin C, the parent/game kotlin P).
The whole snippet chain in ONE hop: game-identity names to the game loader, the rest to masking, and only a miss in both retries a hybrid server's plugins (PluginBridge). One loader, not one per concern: every snippet class load walks this, and each level costs a lock + findLoadedClass.
Properties
Functions
Our own urls first: the compiler and our own kotlin.
Every binary name this loader has DEFINED (not merely delegated), for the preload working-set capture. findClass is this loader's only definition site.
Every masking-owned class is defined HERE (see the class doc for what that buys), which is also what makes every successfully defined name recordable for definedClassNames.
Unconditionally child-first, unlike ClassLoader.getResource's parent-first default — and unlike loadClass, which stays parent-first for whole namespaces. KotlinJars locates kotlin-stdlib / -script-runtime / -reflect via Class.getResource("<marker>.class") (JvmStatic / ScriptTemplateWithArgs / KClasses), which routes through THIS loader. Parent-first hands back Forge's copy of the marker, whose class lives under a securejarhandler union: URI that KotlinJars cannot turn into a File → "Unable to find kotlin stdlib". Our urls hold only the kotlin stack + repl.impl (+ the mod jar), so MC/JDK resources still fall through to the parent.
P as "major.minor" for the snippet compiler's -api-version/-language-version in SPLIT; null in SHARE_ALL, where the two kotlins are one and no pin is needed.
One kotlin identity with the mods; falls back to our own copy for anything the parent lacks — or can no longer answer for, its loader being closed (see SnippetLoader.load).
Parent loader for a compiled snippet: a single SnippetLoader over masking. ReplHost passes this as the eval baseClassLoader.