Add module display names, reject duplicate pack classes, log pack modules

ModuleInfo gains a required, non-blank display name next to id and
version: ModuleInfo.of(id, name, version).

PackModules now fails when a class is in two jars of one pack, naming
the class and both jars. ModuleJar indexes class names while it reads
the entry point, so the check runs before the pack class loader exists
and nothing is half-loaded. Jars are read with the runtime's
multi-release version, like the loader reads them: a versioned class
counts once under its base name; module-info.class and anything under
META-INF/ are ignored.

A successful load logs one INFO summary through System.Logger with the
display name, id, version and jar of each module, or a line saying the
pack has no module jars. PackModulesSummary builds the text and is
tested without a logging backend.
This commit is contained in:
piexel committed 2026-10-05 18:02:31 +02:00
1 parent 4fa6ddcd7a
commit b137bc6d92
19 files changed
+328 -53

No files matched your search

+10 -4
View File
@@ -3,17 +3,23 @@ package com.volmit;
import com.volmit.resource.ResourceId;
import java.util.Objects;
/** Module identity. Stages a module defines must use the namespace of its id. */
public record ModuleInfo(ResourceId id, String version) {
/** Module identity. Stages a module defines must use the namespace of its id. The name is for
* people, for example in load logs; the id is what the host and other modules match on.
*/
public record ModuleInfo(ResourceId id, String name, String version) {
public ModuleInfo {
Objects.requireNonNull(id, "id");
Objects.requireNonNull(name, "name");
Objects.requireNonNull(version, "version");
if (name.isBlank()) {
throw new IllegalArgumentException("Blank module name: " + id);
}
if (version.isBlank()) {
throw new IllegalArgumentException("Blank module version: " + id);
}
}
public static ModuleInfo of(String id, String version) {
return new ModuleInfo(ResourceId.parse(id), version);
public static ModuleInfo of(String id, String name, String version) {
return new ModuleInfo(ResourceId.parse(id), name, version);
}
}