widenPass

private fun widenPass(buf: ByteArray, len: Int, rename: OverlayRename?, parts: OverlayParts?): ByteArray?

Widen a single class file so the REPL can reach non-public members. Two coordinated edits, one pass:

  1. JVM ACC flags: anything not public → public (no final removal — REPL needs access, not inheritance). This is what the K2 frontend reads for JAVA classes (Minecraft), and it's what the runtime link would need too (though runtime actually goes through the indy AccessBridge, which ignores access).

  2. @kotlin.Metadata visibility: for KOTLIN classes the frontend reads member visibility from the metadata proto (DeserializedClassDescriptor / MemberDeserializer: Flags.VISIBILITY.get(...)), NOT from ACC flags — so an ACC-only widen leaves Kotlin private/protected still closed. flipping the proto (private/protected/private-to-this → public; internal is handled by PlainEngine's friend weave, public untouched) is the only lever. See rewriteMetadata.

A non-null rename adds intermediary -> mojmap class names as a third edit, in bytecode and metadata alike. It costs the copy path (rebuilt constant pool), and with no raw-byte transfer what is not parsed is not written — so CODE (Kotlin's inliner reads inline bodies from the class file) and FRAMES (they name types) must be read.

Returns widened bytes if anything changed, null if the class was already fully open (skip writing). ClassWriter(cr, 0) copy path when not renaming. Accepts a shared read buffer to avoid per-class allocation.