mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +00:00
Document tooling parts, the class check partition and ModuleJarCheck --platform
This commit is contained in:
1 parent
e999af0082
commit
480e5485ac
3 files changed
+97
-4
No files matched your search
@@ -10,6 +10,7 @@ types that carry them and lists what the Iris adapter still owes.
|
||||
| Module identity and composition | `IrisModule`, `ModuleInfo`, `StageGraph` |
|
||||
| Loading and unloading a pack | host `LoadedPack`, `ModuleHost` |
|
||||
| Module jars in a pack | `META-INF/services/com.volmit.IrisModule`, host `PackModules` (jar copies), `DiscoveredModule`, `MissingClasses` |
|
||||
| Platform tooling parts of a jar | manifest `Iris-Tooling-Parts`, host `ToolingPart`, `ToolingPlatform`, `PlatformApi`, `ModuleHost.runningOn`, `ToolingPartLoader`, `ModuleJarCheck --platform` |
|
||||
| Namespace ownership | module-prefixed stage, feature and mantle ids, `ModuleInfo.ownsStage`/`ownsId`; no reserved namespaces |
|
||||
| Randomness independent of other modules | `StageContext.random()`, host `StageStreams`, invocation seed passed to the runners |
|
||||
| Random values identical on every JDK | `WorldRandom`, pinned by `WorldRandomTest` |
|
||||
@@ -85,6 +86,16 @@ naming the jar and the classes. A class nobody has (an optional dependency) only
|
||||
its package is one the jar's manifest declares optional (`Iris-Optional-Packages`, read by the host's
|
||||
`ModuleJar`). That declaration never excuses a load error.
|
||||
|
||||
A jar can carry tooling for one platform, such as Bukkit, as a part named in its manifest (`Iris-Tooling-Parts:
|
||||
<platform>=<entry class> ...`): the entry class's package and subpackages. Parts are not generation code. Generation code
|
||||
that uses a part class fails the pack load ("Generation code cannot use the bukkit part; move the call into the part").
|
||||
A host that runs on a platform (`ModuleHost.runningOn`) checks that platform's parts at pack load: they may use their own
|
||||
packages, the platform's api and what modules can use, and not Iris internals, the server's own classes
|
||||
(`net.minecraft`, `org.bukkit.craftbukkit`, `com.mojang`), `com.volmit.host` or another part. Other platforms' parts are
|
||||
skipped unread. The host opens a part through its own class loader (`ToolingPartLoader`, a child of the pack's), which
|
||||
the adapter creates and closes; the generation loader never sees `com.volmit.tooling.<platform>`. Enabling a part,
|
||||
and what it mounts, is the adapter's. `ModuleJarCheck --platform=<name>:<platform api jar>` makes a build check the parts.
|
||||
|
||||
Stage bodies and service providers keep no state; what a module keeps for a world lives in that world's state store,
|
||||
created once per type and world. A world's state lives while the world runs with one pack snapshot: a hotload or a
|
||||
reload of the pack's resources starts the world again with empty state. A service names how its providers combine
|
||||
|
||||
@@ -83,15 +83,16 @@ API):
|
||||
directory means no modules.
|
||||
3. Copies them into a fresh temporary directory (see "Jar copies"). Every later step reads the
|
||||
copies; messages name the originals.
|
||||
4. Reads each jar's entry point file and its class files. Comments (`#`) and blank lines are
|
||||
ignored; zero entry class names fail, several load in the order listed.
|
||||
4. Reads each jar's entry point file, its class files and its manifest's tooling parts (see "Tooling parts"). Comments
|
||||
(`#`) and blank lines are ignored; zero entry class names fail, several load in the order listed.
|
||||
5. Fails if a jar holds a class of an exposed package, naming the jar and the first such class.
|
||||
6. Fails if a class is in two jars, naming the class and both jars.
|
||||
7. Resolves every class each class uses (see below). A class that Iris has but hides, a class of a
|
||||
JDK module packs cannot see or of a JDK package packs may not use, or a class missing from an
|
||||
exposed package fails the load, listing
|
||||
each referencing and referenced class per jar and kind. Classes that nobody has are collected
|
||||
per jar. Nothing has been defined up to here.
|
||||
per jar. Generation code that uses a tooling part's class fails too; the classes of a part are judged apart, or
|
||||
skipped (see "Tooling parts"). Nothing has been defined up to here.
|
||||
8. Creates one `URLClassLoader` for all copies, parent = `ExposedHostClassLoader`.
|
||||
9. 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()`, once.
|
||||
@@ -283,6 +284,51 @@ exactly once, when the module is discovered (`DiscoveredModule.builtIn`, or step
|
||||
everything afterwards uses the stored value, so a module whose `info()` changes between calls cannot
|
||||
give the host two answers. Errors about a module name its origin. Every jar error names the jar.
|
||||
|
||||
### Tooling parts
|
||||
|
||||
A module's platform tooling (the Bukkit studio, importers that read the server's structure files) cannot live in the pack
|
||||
loader, which cannot see the platform: step 7 rejects every class Iris's loader has but does not expose, and Bukkit is
|
||||
one. It also must not run on every server. The jar therefore names each part's entry class per platform in its manifest:
|
||||
|
||||
```
|
||||
Iris-Tooling-Parts: bukkit=art.arcane.iris.tools.bukkit.StudioPart bukkit=art.arcane.iris.tools.bukkit.ImportPart
|
||||
```
|
||||
|
||||
A part is the entry class's package with its subpackages. Entries of one platform may repeat, even in one package; any
|
||||
other overlap fails when the jar is read (step 4), as does a malformed entry or an entry class the jar lacks, so no class
|
||||
is ever in two parts. The manifest is right for the same reason as `Iris-Optional-Packages`: the declaration decides
|
||||
which loader defines a package, which is class loading mechanics of the jar and not a module's identity. The rejected
|
||||
alternatives: a service file per platform cannot name a package, and the class check needs the partition before anything
|
||||
loads; an annotation means scanning every class; a second jar per platform makes a module two artifacts and the pack
|
||||
loader would still have to skip it.
|
||||
|
||||
**The class check partitions the jar** (`ToolingPartition`, used by `PackReferenceCheck`):
|
||||
|
||||
- Generation classes are checked as before, and may not use a part class of any platform. The failure names both classes:
|
||||
"Generation code cannot use the bukkit part; move the call into the part."
|
||||
- Part classes are not generation code. When the host runs on a platform (`ModuleHost.runningOn(PlatformApi)`), that
|
||||
platform's parts are checked at pack load, so a broken part fails early while its class still loads lazily. The check
|
||||
takes what a part may see: its own packages, generation classes, the platform's api packages (which must exist in the
|
||||
platform's loader), and whatever generation code may see. Denied packages fail first: a part may not use Iris
|
||||
internals, the server's own classes or the host, or another part's classes. A class the host exposes to modules is
|
||||
never denied, which is how `art.arcane.iris.builtin` stays usable inside the denied `art.arcane.iris`.
|
||||
- Parts of other platforms are skipped unread, as are all parts when the host runs on no platform. `ModuleJarCheck`
|
||||
does the same at build time, with `--platform=<name>:<platform api jar>` standing in for the platform's loader.
|
||||
|
||||
`ToolingPlatform` describes a platform as a value: its name, the package prefixes of its api and the denied prefixes.
|
||||
`ToolingPlatform.BUKKIT` is Paper's. `PlatformApi` pairs it with the loader that holds the api classes, which the check
|
||||
asks by class file, so nothing loads.
|
||||
|
||||
**`ToolingPartLoader`** is a child of the pack's loader, one per part. It defines the part's own packages itself, child
|
||||
first, from the same jar copy; refuses denied packages with a `ClassNotFoundException`; hands the platform's api packages
|
||||
to the platform's loader; and asks the pack's loader for everything else. Being a child of the pack's loader is the point:
|
||||
the part then gets the same `Class` objects the modules registered, where a sibling loader would turn a resource the jar
|
||||
defines into a `ClassCastException`. The caller opens and closes it; closing it never closes the pack's loader.
|
||||
|
||||
`ExposedPackages` carves out every `com.volmit.tooling.<platform>` package like `com.volmit.host`: only a part sees a
|
||||
platform's tooling api. `com.volmit.tooling` itself, the neutral api, stays exposed. Enabling parts lazily, mounting their
|
||||
commands and listeners, and disabling them belongs to the platform adapter, not to the host.
|
||||
|
||||
### Namespaces
|
||||
|
||||
A module owns its id: `ns:name`, with no `/` in the name. It may define only stages whose ids start
|
||||
|
||||
@@ -535,7 +535,8 @@ jar, without loading it: for a build that writes a module jar and wants to fail
|
||||
refuse. A build that checks against a full copy of an exposed library, while the host's jar strips some
|
||||
of its classes, passes the stripped ones too (`check(jar, exposedHostPackages, leftOutClasses)`, or
|
||||
`--left-out=<file>` on the command line; one Ant pattern or class per line): a jar that references one
|
||||
fails, naming the class.
|
||||
fails, naming the class. `--platform=<name>:<path to the platform api jar>`, such as `--platform=bukkit:libs/paper-api.jar`,
|
||||
also checks the jar's tooling parts of that platform (see below); without it parts are skipped and the output lists them.
|
||||
|
||||
A module compiles against the Iris API (`com.volmit:iris-api`) as `compileOnly` (Maven: `provided`) and never ships it;
|
||||
Iris provides the API at runtime. At runtime a module can use the Iris API (`com.volmit.*` except the host side,
|
||||
@@ -580,6 +581,36 @@ Iris never downloads modules and does not check which API version a jar was buil
|
||||
ships its module jars, and keeping them compatible with the Iris version it targets is the pack
|
||||
publisher's job.
|
||||
|
||||
### Tooling parts
|
||||
|
||||
A module's commands, editors and importers that need a platform (Bukkit, say) ship in the same jar as a tooling part.
|
||||
The manifest names each part's entry class per platform, several entries separated by spaces:
|
||||
|
||||
```kotlin
|
||||
tasks.jar {
|
||||
manifest { attributes("Iris-Tooling-Parts" to "bukkit=art.arcane.iris.tools.bukkit.StudioPart") }
|
||||
}
|
||||
```
|
||||
|
||||
A part is the entry class's package and its subpackages, and a class belongs to one part at most: entries of different
|
||||
platforms, or of nested packages, may not overlap. A malformed entry, or an entry class the jar does not hold, fails the
|
||||
pack load naming the jar and the entry.
|
||||
|
||||
The jar's classes split in two. Generation code, everything outside the parts, is checked as above, and it may not use a
|
||||
part class: the load fails with "Generation code cannot use the bukkit part; move the call into the part", naming both
|
||||
classes. Part classes are not generation code. A host that runs on a platform (`ModuleHost.runningOn`) checks that
|
||||
platform's parts when the pack loads, and skips the parts of other platforms unread. A part can use its own packages,
|
||||
the platform's api, and what generation code can use, including the pack's own generation classes. It cannot use Iris
|
||||
internals (`art.arcane.iris.*`, except what the host exposes, such as `art.arcane.iris.builtin`), `net.minecraft`,
|
||||
`org.bukkit.craftbukkit`, `com.mojang`, `com.volmit.host`, or another part.
|
||||
|
||||
The host loads a part through its own class loader, `ToolingPartLoader`, a child of the pack's. It defines the part's
|
||||
classes from the same jar copy, hands the platform's api packages to the platform's loader and everything else to the
|
||||
pack's loader, so a part gets the same `Class` objects the modules registered. The adapter opens it
|
||||
(`LoadedPack.openToolingPart`) and closes it before the pack; closing it leaves the pack's loader open. The generation
|
||||
loader never sees `com.volmit.tooling.<platform>`, the platform parts of the tooling api; `com.volmit.tooling` itself stays
|
||||
visible.
|
||||
|
||||
## Settings for studio
|
||||
|
||||
Modules describe their settings in the settings classes themselves. Module jars ship no JSON Schema
|
||||
@@ -855,6 +886,11 @@ describes them for studio and resolves the three pipelines. It returns a complet
|
||||
releases the pack's class loader and its jar copies. `PackModules` and `LoadedModules`, which it
|
||||
uses, stay available for tests and special cases.
|
||||
|
||||
A host that runs on a platform tells `ModuleHost.runningOn(new PlatformApi(ToolingPlatform.BUKKIT, loader))` which
|
||||
loader holds the platform's api classes. A load then checks the pack's tooling parts of that platform;
|
||||
`LoadedPack.toolingParts()` lists them, and `openToolingPart(part)` gives a `ToolingPartLoader` whose
|
||||
`loadEntryClass()` is the part to instantiate. Close it before the pack.
|
||||
|
||||
The host derives one seed per placement or chunk, from the world seed and the placement's stable
|
||||
identity or the chunk position, and passes it to the runner. Each stage's stream comes from that
|
||||
seed and the stage id (`StageStreams` documents the derivation). Stages cannot reach a shared stream.
|
||||
|
||||
Reference in new issue
Block a user