AccessBridge

Bootstrap methods for invokedynamic call sites emitted by the access-widening bytecode transform in ScriptWeave. Each bootstrap resolves a private/protected/package-private member via privateLookupIn and returns a ConstantCallSite, which the JIT can inline.

This class lives on the game loader (not impl/), so script classes loaded by the masking loader can resolve it via parent delegation — same cross-loader pattern as ReplBridge and PatchEnterCallback.

The call-site MethodType is not the real signature. Widening a member's access is only half the job: a call site whose descriptor names an inaccessible class is rejected while the JVM resolves that descriptor, before any bootstrap here runs (e.g. a descriptor naming package-private kotlin.collections.EmptyMap is rejected). So the transform erases every inaccessible reference type in the call-site descriptor to Object and passes the real names through as string bootstrap arguments instead.

Two consequences for every bootstrap below:

  • type cannot be trusted for the member's real type — the field bootstraps read it reflectively via findField, the method bootstraps take it from the desc argument.
  • Every returned handle is asType'd to type, which inserts the casts between the erased Object view and the real types.

Constructors

Link copied to clipboard
private constructor()

Companion properties

Link copied to clipboard

Companion functions

Link copied to clipboard
private open fun backingField(cls: Class<*>, method: String, mt: MethodType, hasReceiver: Boolean, caller: MethodHandles.Lookup, cause: NoSuchMethodException): MethodHandle
A Kotlin private val has a backing field and no accessor, yet the metadata flip makes the frontend emit getXxx() against it — resolve such a call to the field instead.
Link copied to clipboard
private open fun capitalize(s: String): String
Kotlin capitalizes ASCII only, so URL and _options keep their head.
Link copied to clipboard
open fun checkCast(caller: MethodHandles.Lookup, invokedName: String, type: MethodType, owner: String): CallSite
Bootstrap checkcast.
Link copied to clipboard
open fun classConstant(caller: MethodHandles.Lookup, name: String, type: Class<*>, owner: String): Class<*>
Bootstrap a class literal, ::class, as a dynamic constant.
Link copied to clipboard
open fun construct(caller: MethodHandles.Lookup, invokedName: String, type: MethodType, owner: String, desc: String): CallSite
Bootstrap a constructor call; desc is the constructor's own, and the instance comes back as the call's result.
Link copied to clipboard
private open fun declaredField(c: Class<*>, field: String, wantStatic: Boolean): Field
c's own field of the wanted kind, or null.
Link copied to clipboard
open fun fieldGet(caller: MethodHandles.Lookup, invokedName: String, type: MethodType, owner: String, field: String): CallSite
Bootstrap a GETFIELD call site.
Link copied to clipboard
open fun fieldSet(caller: MethodHandles.Lookup, invokedName: String, type: MethodType, owner: String, field: String): CallSite
Bootstrap a PUTFIELD call site.
Link copied to clipboard
private open fun findField(ref: Class<*>, field: String, wantStatic: Boolean): Field
The field ref resolves field to.
Link copied to clipboard
private open fun findMethodOwner(ref: Class<*>, method: String, mt: MethodType): Class<*>
The class in ref's hierarchy that declares method with mt's parameter types — the method analogue of findField.
Link copied to clipboard
private open fun getterName(prop: String): String
JvmAbi.getterName: an is-prefixed property is already its own getter.
Link copied to clipboard
open fun instanceOf(caller: MethodHandles.Lookup, invokedName: String, type: MethodType, owner: String): CallSite
Bootstrap instanceof: isInstance is the same test, null failing it.
Link copied to clipboard
private open fun interfaceClosure(ref: Class<*>): Iterable<Class<*>>
Every interface reachable from ref, breadth-first.
Link copied to clipboard
private open fun isCompanion(cls: Class<*>, host: Class<*>): Boolean
Whether cls is host's companion object, which the host holds in a static field.
Link copied to clipboard
private open fun isPrefixed(name: String): Boolean
JvmAbi.startsWithIsPrefix: is followed by anything that is not a lower-case letter.
Link copied to clipboard
private open fun lookupIn(cls: Class<*>, caller: MethodHandles.Lookup): MethodHandles.Lookup
privateLookupIn on cls, or caller where its module refuses to open — java.base being the one that does.
Link copied to clipboard
open fun newArray(caller: MethodHandles.Lookup, invokedName: String, type: MethodType, owner: String): CallSite
Bootstrap anewarray: owner is the element class, and the array a real array of it, so storing anything else still throws ArrayStoreException.
Link copied to clipboard
private open fun resolve(owner: String, caller: MethodHandles.Lookup): Class<*>
Link copied to clipboard
private open fun setterName(prop: String): String
JvmAbi.setterName: the is is dropped rather than kept — isEmpty sets via setEmpty.
Link copied to clipboard
open fun staticCall(caller: MethodHandles.Lookup, invokedName: String, type: MethodType, owner: String, method: String, desc: String): CallSite
Bootstrap an INVOKESTATIC call site; the real signature is in desc, the declaring class resolved via findMethodOwner.
Link copied to clipboard
open fun staticFieldGet(caller: MethodHandles.Lookup, invokedName: String, type: MethodType, owner: String, field: String): CallSite
Bootstrap a GETSTATIC call site.
Link copied to clipboard
open fun staticFieldSet(caller: MethodHandles.Lookup, invokedName: String, type: MethodType, owner: String, field: String): CallSite
Bootstrap a PUTSTATIC call site.
Link copied to clipboard
open fun superCall(caller: MethodHandles.Lookup, invokedName: String, type: MethodType, owner: String, method: String, desc: String): CallSite
Bootstrap a super.method(...) call, opened like every other member: invokespecial from the declaring class findMethodOwner finds selects what the snippet's call would have — the first declaration up from the class the call names.
Link copied to clipboard
open fun virtualCall(caller: MethodHandles.Lookup, invokedName: String, type: MethodType, owner: String, method: String, desc: String): CallSite
Bootstrap an INVOKEVIRTUAL/INVOKEINTERFACE call site; the real signature is in desc, the declaring class resolved via findMethodOwner.