mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
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.
This commit is contained in:
1 parent
e918cd44a8
commit
6388173f19
12 files changed
+606
-29
No files matched your search
@@ -0,0 +1,24 @@
|
||||
package com.volmit.host;
|
||||
|
||||
import com.volmit.IrisModule;
|
||||
import java.util.Objects;
|
||||
|
||||
/** A module and where the host found it. Load errors name the origin so the author knows which
|
||||
* jar to fix.
|
||||
*/
|
||||
public record DiscoveredModule(IrisModule module, String origin) {
|
||||
static final String HOST_CLASSPATH = "host classpath";
|
||||
|
||||
public DiscoveredModule {
|
||||
Objects.requireNonNull(module, "module");
|
||||
Objects.requireNonNull(origin, "origin");
|
||||
if (origin.isBlank()) {
|
||||
throw new IllegalArgumentException("Blank module origin: " + module.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
/** A module that ships with the host instead of a pack. */
|
||||
public static DiscoveredModule builtIn(IrisModule module) {
|
||||
return new DiscoveredModule(module, HOST_CLASSPATH);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user