MixinPlan

internal class MixinPlan(val claimed: Set<String>, val work: Map<File, List<Pair<String, String?>>>, val present: Set<String>, val rename: OverlayRename?, val renameFor: RenameFor)

What the mixin overlay will contain, resolved before any jar is written so this one builds alongside the shards.

Constructors

Link copied to clipboard
constructor(claimed: Set<String>, work: Map<File, List<Pair<String, String?>>>, present: Set<String>, rename: OverlayRename?, renameFor: RenameFor)

Properties

Link copied to clipboard

Entry names this jar owns, always whole nest groups. The shards carry them too and that is fine — this jar sits ahead of them in classpath order and wins, exactly as the overlay already wins over the source jars behind it. What K2 rejects is a nest group SPLIT across two units, never a duplicated one.

Link copied to clipboard
private val present: Set<String>

Internal names the compile classpath carries. A grafted implements naming anything else makes the TARGET unusable — "cannot access X which is a supertype of Y" — and a runtime-synthesized mixin's interface is in no jar.

Link copied to clipboard
private val rename: OverlayRename?

The rename as a TABLE: reading Mixin's intermediary answers back into mojmap. Global by nature — it translates names, and a name means the same thing whichever jar it was read from.

Link copied to clipboard
private val renameFor: RenameFor

The rename as a DECISION: whether this jar's bytes get rewritten at all. Per jar, because mc-symbols is already mojmap — rename would find nothing to map in it, but only after parsing every method body and rebuilding every constant pool. 79% of what this overlay grafts comes from that one jar.

Link copied to clipboard
val size: Int
Link copied to clipboard
private val work: Map<File, List<Pair<String, String?>>>

Functions

Link copied to clipboard
fun build(tmp: Path): Int

Graft each target's added declarations onto its own source bytes and write the result to tmp. Returns the number of classes written.

Link copied to clipboard
private fun declaresAny(iface: String, keys: Set<String>): Boolean

Whether iface or anything it extends declares one of keys, as emitGraft keys them.

Link copied to clipboard
private fun emitGraft(base: ByteArray, added: MixinProbe.Decls, interfaces: List<String>): Graft

Re-emit base with the added declarations appended, opened by revealAccess — they are added after widenClassFile ran, so nothing else would open them. Descriptors come from the intermediary side and are renamed on the way in; bodies are aconst_null; athrow, since this jar is only ever compiled against.

Link copied to clipboard
private fun graftEntries(zf: ZipFile, own: OverlayRename?, items: List<Pair<String, String?>>, jos: JarOutputStream): Int
Link copied to clipboard
private fun graftJar(jar: File, items: List<Pair<String, String?>>, jos: JarOutputStream): Int

A failing jar costs only its own targets — what it already wrote stays, and the caller's count reports the shortfall against the plan.

Link copied to clipboard
private fun rebuild(base: ByteArray, target: String?, own: OverlayRename?): ByteArray

Every claimed entry is emitted, grafted or not: a nest group arriving half from here and half from the shard behind us is the split K2 rejects. The widen matches the shard's, so a duplicate costs its bytes and nothing else.

Link copied to clipboard
private fun writeStored(jos: JarOutputStream, entry: String, bytes: ByteArray)