ModJarCache

internal object ModJarCache

The disk side of ModJarCollector: turns a code root with no file behind it into a repacked jar, and decides when that jar is stale.

Staleness is keyed on the CONTAINER jar, not on the mod version — a debug build that keeps its version number still moves the container's size|mtime.

Functions

Link copied to clipboard
private fun backingPath(fs: FileSystem, m: String): Path?
Link copied to clipboard
private fun cacheName(mc: ModCode): String

Cache file name. Carries no VERSION: the name must survive an update so the rebuild overwrites instead of orphaning. Staleness is the stamp's job.

Link copied to clipboard
private fun containerOf(root: Path): File?

The real on-disk jar behind root. A JiJ root nests UnionFileSystem ->jij: PathFileSystem -> UnionFileSystem -> real file; each layer names its backing path reflectively (loader classes, not on the common compile classpath).

Link copied to clipboard

cache jar name -> container stamp. One file, not a .stamp per jar: sidecars would go stale themselves, and nothing here deletes cache files.

Link copied to clipboard

Repack a virtual root's .class tree into a JAR, keyed by cacheName, published by atomic rename.

Link copied to clipboard
private fun stampFile(): File
Link copied to clipboard
private fun stampOf(c: File): String

path|size|mtime, the overlay stamp's shape. File.lastModified() is a filesystem timestamp, so unlike a zip entry's DOS field it needs no timezone and survives one changing.

Link copied to clipboard
private fun writeJar(root: Path, dest: File)

Every .class and .kotlin_module under root, as a STORED jar published by atomic rename.

Link copied to clipboard

Only what THIS run resolved, so a jar whose key moved on stops being reused. The file itself stays.

Link copied to clipboard
private fun writeStoredEntry(jos: JarOutputStream, root: Path, src: Path, seen: MutableSet<String>)

Copy one class file into jos as a STORED entry. Duplicate paths (a union/overlay FS can surface the same class twice) are dropped — putNextEntry would throw — and an unreadable file is skipped rather than failing the whole repack.