Commit Graph
11 Commits
Author SHA1 Message Date
piexel 97ac2a2982 Read settings per column with every level as its own entry, add the mantle pipeline, host types and the one-option shorthand
Settings no longer resolve to one value per type. FeatureSettings.at(type, x, z) returns one entry per
level that declares the type at that column (dimension, region, surface biome, placement), each with
its level, source and value; levels stack and a module decides what several mean. Conditional stage
bodies receive every configured entry. Chunk and mantle runners collect a chunk's settings themselves,
so a stage runs when any column of the chunk configures it.

Work that writes the mantle or reaches beyond its chunk moves to a new MANTLE pipeline (Stage.mantle,
MantleRunner) that the host runs around a chunk before it generates. Chunk stages may no longer declare
a reach or mantle writes and see the mantle read-only.

Built-in settings may hold host types the host describes itself (ModuleHost.describingHostTypesIn,
ValueKind.HostKind); pack modules cannot. FeatureSchema.shorthand() names the only option of settings
packs may write as a bare value.
2026-10-08 11:31:03 +02:00
piexel 4cb718f706 Enforce namespace ownership: reserved namespaces and module-prefixed stage ids
- LoadedModules.load takes the host's reserved namespaces (such as iris);
  a pack module whose id uses one fails, naming its jar and the namespace.
- A module defines only stages whose ids start with its own id and '/'.
  Module ids may no longer contain '/', so ids cannot nest and every
  stage id has exactly one possible owner.
- Object feature ids and mantle keys must use the registering module's
  namespace; ModuleRegistry.register(DiscoveredModule) scopes registration.
- A settings type named in when(...) needs a feature id in the namespace
  of some module naming it, so modules can still condition on another
  module's settings.
2026-10-05 21:31:55 +02:00
piexel 6263075ecd Read module info once at discovery and keep it in DiscoveredModule
DiscoveredModule is now a final class holding the module, the ModuleInfo
read when the module was found (pack jar or builtIn) and its origin.
Graph install, load errors, the pack summary and optional-package
filtering use only that stored value.
2026-10-05 21:26:35 +02:00
piexel f6b08a0303 Fail the load when a module uses a JDK package that is not exported to it
A class such as jdk.internal.misc.Unsafe passed the reference check,
because the platform loader finds it, but java.base does not export
jdk.internal.misc to unnamed modules, so the module failed with an
IllegalAccessError once the code ran. It is now a load error with its
own group:

  Module jar modules/user.jar uses classes of JDK packages that are not exported to modules:
    pack.user.User -> jdk.internal.misc.Unsafe (package jdk.internal.misc of java.base is not exported)
  Use the supported alternative where there is one, such as sun.misc.Unsafe from jdk.unsupported
  instead of jdk.internal.misc.Unsafe. Otherwise the server must be started with
  --add-exports <module>/<package>=ALL-UNNAMED.

NonExportedJdkPackages asks the boot layer's platform and boot loader
modules whether they export each package to an unnamed module that no
export names, so qualified exports do not count and a server started
with --add-exports <module>/<package>=ALL-UNNAMED passes, as it would at
run time. Nothing is loaded. sun.misc (jdk.unsupported) and java.lang
stay usable. The check runs first among classes outside the pack: the
module decides access whichever loader finds the class.

The --add-exports case runs in its own JVM, the addExportsTest task
(tag jdk-add-exports), which check depends on; the other tests run
without the flag. TestModuleJar can pass --add-exports to javac.
2026-10-05 21:10:53 +02:00
piexel ec80683aa1 Report JDK classes that modules cannot see as their own load error
A reference to a class of a JDK module outside the platform class
loader, such as jdk.compiler's com.sun.source.tree.Tree, was reported as
"exists in Iris but is hidden", because the host loader (the application
loader in tests) has it. It now has its own category, listed with the
module:

  Module jar modules/user.jar uses classes of JDK modules that are not available to modules:
    pack.user.User -> com.sun.source.tree.Tree (JDK module jdk.compiler)
  Modules can use only the JDK modules of the platform class loader, ...

UnavailableJdkModules maps the packages of every system module that the
boot layer does not define to the boot or platform loader, from module
descriptors only, so nothing is loaded. Classes the platform loader
provides (java.sql, java.compiler) still resolve.
2026-10-05 20:59:45 +02:00
piexel 57774fade0 Let modules declare optional packages that need no missing-class warning
A module whose bundled library references optional integrations got a
WARNING on every pack load, with no way to say the classes are expected
to be absent. ModuleInfo now carries optionalPackages, set with
withOptionalPackages("org.slf4j", ...); ModuleInfo.of(id, name, version)
still declares none. Each package covers its subpackages.

Missing classes of a jar inside its own module's optional packages are
dropped from the warning and from PackModules.missingClasses(); other
jars are unaffected. The declaration comes from info(), so it is applied
after the entry classes exist. Load errors (hidden Iris classes, classes
missing from exposed packages) are decided before that and never depend
on it.

Package-name validation and whole-package matching move from
ExposedPackages to a new API value, PackageName, used by both.
2026-10-05 20:58:38 +02:00
piexel 13a9300ab4 Let the host expose extra packages, such as built-in modules, to packs
A single API_PACKAGE_PREFIX made built-in modules in Iris packages
(art.arcane.iris...) invisible, so pack jars could not require their
stages. ExposedPackages now holds the packages packs may use: always
the API (IrisModule's package), plus what the host passes to the new
PackModules.load(packRoot, exposedHostPackages). Names must be package
names (trailing dot accepted) and match whole packages only.

ApiAndJdkClassLoader becomes ExposedHostClassLoader and routes classes
and resources of every exposed package to the host loader. A jar that
ships a class of any exposed package fails; the compileOnly API hint
stays for the API, other packages get their own message. That check
moves from ModuleJar to PackClassCheck. A reference missing from any
exposed package is the "different build" error.

Tests use a built-in module in example.builtin, outside com.volmit.,
which a pack jar can require only when that package is exposed.
2026-10-05 20:30:20 +02:00
piexel 98bd9a9c12 Let pack jars use classes nobody has, as optional dependencies
The class check was stricter than the JVM: a bundled library that
references optional integrations failed the whole pack, although that
code only runs when the classes exist. Each missing reference is now
classified:

- the host has the class but hides it (Iris internals, Iris's copy of
  a library): load error, saying modules cannot use Iris's classes;
- missing from the API: load error, as before (different Iris build);
- nobody has it: the pack loads. PackModules.missingClasses() lists
  the classes per jar and the load logs one capped WARNING per pack,
  formatted by MissingClassesWarning.

Reference resolution moves from PackClassCheck to PackReferenceCheck.
2026-10-05 20:27:24 +02:00
piexel 1553959cf4 Limit pack modules to the API, the JDK and their own pack
The pack class loader's parent is now ApiAndJdkClassLoader: com.volmit.
classes and resources come from the API's loader, everything else from
the platform loader, so modules no longer see Iris internals or the
libraries Iris bundles.

Before any class is defined, a pack load now fails when a jar holds a
com.volmit. class, and when a class references a class that is not in
the API, the JDK or a jar of the pack (read with java.lang.classfile).
Linkage errors while installing name the module's jar. ModuleInfo names
and versions reject line breaks and other control characters.
2026-10-05 18:24:53 +02:00
piexel b137bc6d92 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.
2026-10-05 18:02:31 +02:00
piexel 6388173f19 Load pack modules from <pack>/modules jars
A module jar names its IrisModule class in
META-INF/services/com.volmit.IrisModule. PackModules scans
<pack>/modules/*.jar in file name order, loads all jars of a pack
through one URLClassLoader whose parent is the API's loader, and
closes it when the pack unloads.

Modules now reach LoadedModules as DiscoveredModule (module plus
origin), so errors name the offending jar: missing or multiple entry
points, broken entry classes, duplicate module ids and foreign stage
namespaces.
2026-10-05 17:48:58 +02:00