mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-02 02:34:24 +00:00
Document module names, duplicate classes and the load summary
Drop version gating as an open question: packs ship their module jars and nothing is downloaded, so compatibility is the pack publisher's responsibility. Describe the duplicate-class rule including multi-release jars, the per-pack log summary, and the adapter's job of routing System.Logger output.
This commit is contained in:
1 parent
b137bc6d92
commit
862f4d19be
3 files changed
+57
-19
No files matched your search
+5
-2
@@ -28,6 +28,9 @@ types that carry them and lists what the Iris adapter still owes.
|
|||||||
Stage bodies hold no invocation state. Everything per placement or chunk travels through the
|
Stage bodies hold no invocation state. Everything per placement or chunk travels through the
|
||||||
context, outputs and accumulators.
|
context, outputs and accumulators.
|
||||||
|
|
||||||
|
There is no API version gating. Packs ship their module jars, so their compatibility with the
|
||||||
|
running Iris is the pack publisher's responsibility.
|
||||||
|
|
||||||
## Requirements for the Iris adapter
|
## Requirements for the Iris adapter
|
||||||
|
|
||||||
- Port the engine as ordinary modules. Keep `iris:*` stage ids stable once packs or addons
|
- Port the engine as ordinary modules. Keep `iris:*` stage ids stable once packs or addons
|
||||||
@@ -42,6 +45,8 @@ context, outputs and accumulators.
|
|||||||
- Preserve unknown persisted mantle layers or fail explicitly.
|
- Preserve unknown persisted mantle layers or fail explicitly.
|
||||||
- Load each pack's jars with `PackModules`, pass them with the built-in modules to
|
- Load each pack's jars with `PackModules`, pass them with the built-in modules to
|
||||||
`LoadedModules.load`, and close `PackModules` only after nothing built from it is in use.
|
`LoadedModules.load`, and close `PackModules` only after nothing built from it is in use.
|
||||||
|
- Route `System.Logger` output (logger `com.volmit.host.PackModules`) to the server log, so the
|
||||||
|
per-pack module summary is visible.
|
||||||
- Make built-in modules visible to the loader that defines the API, or pack jars cannot require
|
- Make built-in modules visible to the loader that defines the API, or pack jars cannot require
|
||||||
their stages.
|
their stages.
|
||||||
|
|
||||||
@@ -50,5 +55,3 @@ context, outputs and accumulators.
|
|||||||
- Per-stage reach declarations, replacing the removed modifier radii.
|
- Per-stage reach declarations, replacing the removed modifier radii.
|
||||||
- Per-stage RNG streams, so adding a module does not shift other modules' random draws.
|
- Per-stage RNG streams, so adding a module does not shift other modules' random draws.
|
||||||
- Terrain/biome providers, pack transformations, structure assembly and the runtime family.
|
- Terrain/biome providers, pack transformations, structure assembly and the runtime family.
|
||||||
- Version gating: modules do not declare which API version they target, so an incompatible jar
|
|
||||||
fails with a linkage error at load or later at install or run time.
|
|
||||||
@@ -33,9 +33,9 @@ flowchart TD
|
|||||||
|
|
||||||
## Module loading
|
## Module loading
|
||||||
|
|
||||||
The `IrisModule` implementation is the module's entry point. `info()` returns its id and
|
The `IrisModule` implementation is the module's entry point. `info()` returns its id, display
|
||||||
version; there is no separate descriptor. A pack keeps its modules in `<pack>/modules/*.jar`,
|
name and version; there is no separate descriptor. A pack keeps its modules in
|
||||||
one module per jar.
|
`<pack>/modules/*.jar`, one module per jar.
|
||||||
|
|
||||||
A jar names its entry class in `META-INF/services/com.volmit.IrisModule`, the provider format of
|
A jar names its entry class in `META-INF/services/com.volmit.IrisModule`, the provider format of
|
||||||
`ServiceLoader`. The host reads that file from the jar itself rather than calling
|
`ServiceLoader`. The host reads that file from the jar itself rather than calling
|
||||||
@@ -52,17 +52,30 @@ which jar a broken provider came from. The rejected alternatives:
|
|||||||
|
|
||||||
1. Lists regular files ending in `.jar` in `<pack>/modules`, sorted by file name. A missing
|
1. Lists regular files ending in `.jar` in `<pack>/modules`, sorted by file name. A missing
|
||||||
directory means no modules.
|
directory means no modules.
|
||||||
2. Reads each jar's entry point file. Comments (`#`) and blank lines are ignored; zero or more
|
2. Reads each jar's entry point file and its class names. Comments (`#`) and blank lines are
|
||||||
than one class name fails.
|
ignored; zero or more than one entry class name fails.
|
||||||
3. Creates one `URLClassLoader` for all jars of the pack, parent = the loader of `IrisModule`.
|
3. Fails if a class is in two jars, naming the class and both jars. Nothing has been defined yet.
|
||||||
4. Loads each entry class, checks that it implements `IrisModule` and comes from its own jar,
|
4. Creates one `URLClassLoader` for all jars of the pack, parent = the loader of `IrisModule`.
|
||||||
|
5. Loads each entry class, checks that it implements `IrisModule` and comes from its own jar,
|
||||||
instantiates it with the public no-argument constructor and calls `info()`.
|
instantiates it with the public no-argument constructor and calls `info()`.
|
||||||
|
6. Logs one INFO summary of the pack's modules.
|
||||||
|
|
||||||
One loader per pack, not per jar, because `requires(...)` takes another module's stage constant.
|
One loader per pack, not per jar, because `requires(...)` takes another module's stage constant.
|
||||||
A pack jar that requires a stage of another pack jar must see its classes. Packs stay isolated
|
A pack jar that requires a stage of another pack jar must see its classes. Packs stay isolated
|
||||||
from each other, and built-in modules visible to the API's loader are visible to every pack. The
|
from each other, and built-in modules visible to the API's loader are visible to every pack. The
|
||||||
cost: two jars of one pack that contain the same class name share the first one in file name
|
cost is a shared class namespace: with two copies of a class, the loader would silently use the
|
||||||
order. The entry-class check catches this for entry classes only.
|
one first in file name order. Step 3 turns that into a load error, so two jars that shade the same
|
||||||
|
library must relocate it, and shared code belongs in one module that the others require.
|
||||||
|
|
||||||
|
The class check reads jars the way the loader does. `module-info.class` is ignored. A
|
||||||
|
multi-release jar (`Multi-Release: true`) contributes each class once, under its base name, from
|
||||||
|
the highest `META-INF/versions/N` that the running JDK selects; a versioned copy of a class in one
|
||||||
|
jar therefore clashes with the plain class in another. In a jar without that manifest attribute the
|
||||||
|
loader never reads `META-INF/versions`, so those entries are skipped.
|
||||||
|
|
||||||
|
There is no version gating. Packs ship their module jars and Iris never downloads any, so whether
|
||||||
|
a jar works with the running Iris is the pack publisher's responsibility. An incompatible jar
|
||||||
|
fails with a linkage error at load, install or run time.
|
||||||
|
|
||||||
Closing `PackModules` closes the loader. Classes loaded before that keep working, so the host
|
Closing `PackModules` closes the loader. Classes loaded before that keep working, so the host
|
||||||
must drop `LoadedModules` and everything else built from the pack first.
|
must drop `LoadedModules` and everything else built from the pack first.
|
||||||
@@ -71,6 +84,11 @@ Each module reaches `LoadedModules.load` as a `DiscoveredModule`: the module and
|
|||||||
jar path relative to the pack or "host classpath" for built-ins. Duplicate module ids and foreign
|
jar path relative to the pack or "host classpath" for built-ins. Duplicate module ids and foreign
|
||||||
stage namespaces name the origin. Every jar error names the jar.
|
stage namespaces name the origin. Every jar error names the jar.
|
||||||
|
|
||||||
|
The load summary goes through `System.getLogger(PackModules.class.getName())`, so the host can
|
||||||
|
route it with a `System.LoggerFinder`. It lists display name, id, version and jar for each module
|
||||||
|
in load order, or says the pack has no module jars. `PackModulesSummary` builds the text and is
|
||||||
|
tested on its own.
|
||||||
|
|
||||||
## Stages
|
## Stages
|
||||||
|
|
||||||
A stage is a constant created by `Stage.placement`, `Stage.placementBlock` or `Stage.chunk`. Its
|
A stage is a constant created by `Stage.placement`, `Stage.placementBlock` or `Stage.chunk`. Its
|
||||||
@@ -197,8 +215,8 @@ Unknown persisted layers must be preserved or fail explicitly.
|
|||||||
|
|
||||||
## Not implemented
|
## Not implemented
|
||||||
|
|
||||||
- Iris host wiring: version gating, JSON decoding and validation, schema generation, resource
|
- Iris host wiring: JSON decoding and validation, schema generation, resource loaders, platform
|
||||||
loaders, platform block adapters, storage and codecs.
|
block adapters, storage and codecs.
|
||||||
- Reach. The old per-modifier `writeRadius` and `mantleRadius` are gone with the modifiers. The
|
- Reach. The old per-modifier `writeRadius` and `mantleRadius` are gone with the modifiers. The
|
||||||
host must prepare the whole area a pipeline may touch. Per-stage reach is an open question.
|
host must prepare the whole area a pipeline may touch. Per-stage reach is an open question.
|
||||||
- Legacy random compatibility. Seed offsets and draw order must be matched by the adapter where
|
- Legacy random compatibility. Seed offsets and draw order must be matched by the adapter where
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ them in `install`. Other modules order themselves against those constants.
|
|||||||
public final class MossModule implements IrisModule {
|
public final class MossModule implements IrisModule {
|
||||||
public static final PlacementStage<Void> SPREAD = Stage.placement("example:moss/spread");
|
public static final PlacementStage<Void> SPREAD = Stage.placement("example:moss/spread");
|
||||||
|
|
||||||
public ModuleInfo info() { return ModuleInfo.of("example:moss", "1.0.0"); }
|
public ModuleInfo info() { return ModuleInfo.of("example:moss", "Moss", "1.0.0"); }
|
||||||
|
|
||||||
public void install(StageGraph graph) {
|
public void install(StageGraph graph) {
|
||||||
graph.define(SPREAD)
|
graph.define(SPREAD)
|
||||||
@@ -55,8 +55,13 @@ modules/moss.jar
|
|||||||
com/example/moss/MossSettings.class
|
com/example/moss/MossSettings.class
|
||||||
```
|
```
|
||||||
|
|
||||||
`info()` gives the module id and version. The id's namespace is the namespace of every stage the
|
`info()` gives the module id, display name and version. The id's namespace is the namespace of
|
||||||
module defines.
|
every stage the module defines; the name is what logs show. A class may appear in only one jar of
|
||||||
|
a pack, so shaded libraries need relocating.
|
||||||
|
|
||||||
|
Iris never downloads modules and does not check which API version a jar was built for. A pack
|
||||||
|
ships its module jars, and keeping them compatible with the Iris version it targets is the pack
|
||||||
|
publisher's job.
|
||||||
|
|
||||||
## Host side
|
## Host side
|
||||||
|
|
||||||
@@ -76,8 +81,19 @@ try (var pack = PackModules.load(packRoot)) {
|
|||||||
|
|
||||||
`PackModules.load` reads one entry point per jar, in jar file name order, and loads every jar
|
`PackModules.load` reads one entry point per jar, in jar file name order, and loads every jar
|
||||||
of the pack through one class loader. Closing it closes that loader. A pack without a `modules`
|
of the pack through one class loader. Closing it closes that loader. A pack without a `modules`
|
||||||
directory has no modules. Errors name the jar: no entry point, several entry points, or an entry
|
directory has no modules. Errors name the jar: no entry point, several entry points, a class that
|
||||||
class that cannot be loaded, is not an `IrisModule`, is not in that jar, or fails to construct.
|
is also in another jar of the pack (both jars are named), or an entry class that cannot be loaded,
|
||||||
|
is not an `IrisModule`, is not in that jar, or fails to construct.
|
||||||
|
|
||||||
|
A successful load logs one INFO summary through `System.Logger`:
|
||||||
|
|
||||||
|
```
|
||||||
|
Pack overworld uses 2 modules:
|
||||||
|
Moss (example:moss 1.0.0) from modules/moss.jar
|
||||||
|
Stilts (iris:stilt 2.1.0) from modules/stilt.jar
|
||||||
|
```
|
||||||
|
|
||||||
|
A pack without jars logs `Pack overworld uses no modules: no jars in its modules directory`.
|
||||||
|
|
||||||
`LoadedModules.load` installs every module, catalogs the settings types named in `when(...)`
|
`LoadedModules.load` installs every module, catalogs the settings types named in `when(...)`
|
||||||
together with geometry and mantle registrations, and resolves both pipelines. Graph errors
|
together with geometry and mantle registrations, and resolves both pipelines. Graph errors
|
||||||
@@ -112,7 +128,8 @@ invocations and must not keep views or mutable state.
|
|||||||
|
|
||||||
The tests cover graph resolution and every error path, fusion, activation cascade, outputs,
|
The tests cover graph resolution and every error path, fusion, activation cascade, outputs,
|
||||||
rejection and rollback, and install-order determinism. `PackModulesTest` compiles real module
|
rejection and rollback, and install-order determinism. `PackModulesTest` compiles real module
|
||||||
jars into a temporary pack and loads them, including every jar error. The example ports in
|
jars into a temporary pack and loads them, including every jar error and duplicate classes in
|
||||||
|
plain and multi-release jars. `PackModulesSummaryTest` checks the log text. The example ports in
|
||||||
`src/test/java/com/volmit/example` rebuild preparation, anchoring, block writes, stilt and snow
|
`src/test/java/com/volmit/example` rebuild preparation, anchoring, block writes, stilt and snow
|
||||||
as separate modules, add a third-party moss module, and add a two-module chunk pipeline. There is
|
as separate modules, add a third-party moss module, and add a two-module chunk pipeline. There is
|
||||||
no Minecraft integration or production storage in these tests.
|
no Minecraft integration or production storage in these tests.
|
||||||
Reference in new issue
Block a user