Commit Graph
12 Commits
Author SHA1 Message Date
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
piexel d78a66772a Port a slice of the Iris placement lifecycle as example modules
Prepare/transforms, anchor height, block writes, stilt and snow are rebuilt as
independent iris:* modules, plus a third-party moss module that integrates via
requires, softAfter and a typed output. A two-module chunk example proves the
generic machinery outside placement.
2026-10-05 17:23:31 +02:00
piexel eeb5486098 Replace fixed placement hooks with a module-owned stage graph
Modules now define every stage themselves through IrisModule.install(StageGraph):
typed stage constants, hard requires(...) on other modules' constants, soft
ordering by id, when(...) activation and typed outputs. Placement and chunk
generation resolve on the same machinery; adjacent per-block stages fuse into
one block pass.

The host-defined PlacementModifier hooks, string Dependencies, GenerationPlan,
PlacementPipeline, DependencyOrder and OccurrenceOrder are removed.
2026-10-05 17:23:31 +02:00
piexel 9043d93fbd Baseline IrisApi draft before stage-graph redesign 2026-10-05 17:01:18 +02:00