ReflectAccess

Reflection-backed member access for scripts — the part of "access widening" that works on classes that are already loaded (where bytecode modifier-flipping is illegal). Mod code runs with full Java access and net.minecraft lives in the unnamed module, so setAccessible(true) succeeds; GraalJS can't reach java.lang.reflect itself, so these helpers are the bridge.

Fields/methods are resolved by walking the class hierarchy and cached. Numeric arguments coming from JS (which arrive boxed and loosely typed) are coerced to the target field/parameter type.

Functions

Link copied to clipboard
fun getField(target: Any, name: String): Any?
Link copied to clipboard
fun getStaticField(className: String, name: String): Any?
Link copied to clipboard
fun invoke(target: Any, name: String, args: Array<out Any?>): Any?
Link copied to clipboard
fun invokeStatic(className: String, name: String, args: Array<out Any?>): Any?
Link copied to clipboard
fun isFinalField(target: Any, name: String): Boolean

True if name's field on target is final (informational — final instance fields still write).

Link copied to clipboard
fun setField(target: Any, name: String, value: Any?)
Link copied to clipboard
fun setStaticField(className: String, name: String, value: Any?)