mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
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.
This commit is contained in:
1 parent
862f4d19be
commit
1553959cf4
11 files changed
+563
-60
No files matched your search
@@ -24,10 +24,23 @@ public record LoadedModules(FeatureCatalog catalog, ResolvedGraph placement, Res
|
||||
var registry = new ModuleRegistry(reservedHostFields);
|
||||
var stages = new StageGraphBuilder();
|
||||
for (var discovered : modules) {
|
||||
stages.install(discovered);
|
||||
discovered.module().register(registry);
|
||||
installModule(discovered, stages, registry);
|
||||
}
|
||||
stages.settingsTypes().forEach(registry::registerSettings);
|
||||
return new LoadedModules(registry.freeze(), stages.resolve(Pipeline.PLACEMENT), stages.resolve(Pipeline.CHUNK));
|
||||
}
|
||||
|
||||
/** The pack load checks that every class a module uses exists, not that every method or field
|
||||
* it uses does, so a jar built against another Iris API can still fail to link here.
|
||||
*/
|
||||
private static void installModule(DiscoveredModule discovered, StageGraphBuilder stages, ModuleRegistry registry) {
|
||||
try {
|
||||
stages.install(discovered);
|
||||
discovered.module().register(registry);
|
||||
} catch (LinkageError error) {
|
||||
throw new IllegalArgumentException("Module " + discovered.module().info().id() + " from "
|
||||
+ discovered.origin() + " failed to link or initialize a class while installing: " + error
|
||||
+ "; a missing method or field means the jar was built against a different Iris API", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user