Signatures

internal object Signatures

Name and signature normalization, shared by patch resolution (Patch) and by the diagnostics it throws.

Two directions, split by what each one can guarantee:

  • runtime -> mojmap (typeToMojmap, methodToMojmap, render) — DISPLAY. The only direction that works for the short names a script writes (ItemStack, Properties), since the forward map is FQN-keyed. Type names demap on their own; method names need an owner, so the overloads holding one answer where the owner-free Mappings.reverseMethod must refuse. A wrong name here is cosmetic.

  • mojmap -> runtime (runtimeNamesOf) — RESOLUTION, where a wrong answer silently targets nothing. This one is load-bearing, and it is deliberately NOT the reverse direction; see its own doc.

On a mojmap runtime there are no mappings at all, so both degenerate to the identity and dev / Fabric-production / Forge-SRG / spigot collapse into one code path with no branches.

Functions

Link copied to clipboard
fun hierarchy(target: Class<*>): List<Class<*>>

target + every superclass + the transitive interface closure, breadth-first. Deliberately uncached: a cache keyed by Class would strong-reference it and pin its loader, and snippet classes DO unload (ReplHost builds a fresh evaluator per eval precisely so they can). One walk per patch install is microseconds.

Link copied to clipboard
fun matches(actualRuntime: List<String>, want: List<String>): Boolean

Does a method's runtime parameter list satisfy every wanted slot?

Link copied to clipboard

m's mojmap name, using the owner the string overload does not have. The cheap owner-free answer where it is unambiguous; otherwise Mappings.namedMethodOn, climbed because an override's mapping row lives under the class it was inherited from, not under the class that declares the override.

fun methodToMojmap(runtimeOwner: String, runtimeMethod: String, line: Int): String

A stack frame's mojmap name, from what StackTraceElement carries. Three tiers, cheapest first: the owner-free answer where it holds; else the owner's same-named methods demapped, taken when they AGREE, since a frame prints no parameters and overloads collapsed onto one obf name are not ambiguous here; else the one LineTable puts at line. Synthetics go first, or a bridge — whose descriptor matches no row — demaps to itself and outvotes the real method.

Link copied to clipboard
private fun mp(): Mappings?

The live mappings, or null when the runtime is already mojmap — in which case every conversion below is the identity.

Link copied to clipboard

The parameter types of a loaded method, in runtime names (Foo[] / Outer$Inner spelling).

fun paramsOf(md: MethodDescription): List<String>

As above for ByteBuddy's view. actualName, NOT name: the latter is the binary form ([LFoo;), which would not compare equal to Method's typeName and would silently match nothing.

Link copied to clipboard
fun render(mojmapName: String, runtimeParams: List<String>): String

A method's mojmap signature text, e.g. use(Level, Player). This is BOTH the dedup key for the "exactly one signature" rule and one line of the candidate list in an error message, and it must stay one function: what the rule collapses is exactly what the error must not list twice.

Link copied to clipboard
fun runtimeNamesOf(target: Class<*>, mojmapMethod: String): Set<String>

Every RUNTIME name mojmapMethod can carry on target or any ancestor — the forward direction, and the only sound way to pick a patch target on an obf runtime.

Link copied to clipboard
fun slotMatches(actualMojmap: String, want: String): Boolean

Does one already-mojmap parameter type satisfy one wanted slot?

Link copied to clipboard
fun typeToMojmap(runtime: String): String

Runtime type name -> mojmap, array dimensions preserved (class_1799[] ->…ItemStack[]). Unmapped names — primitives, JDK, mod and library classes — pass through unchanged, which is correct for them: they are already written the same way in both namespaces.