mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
registerHeldType: a pack module may describe a class the host loads (an exposed package), not one of its own jar
This commit is contained in:
1 parent
60d4deb0e9
commit
8921042fdb
4 files changed
+24
-8
No files matched your search
@@ -40,8 +40,9 @@ public interface FeatureRegistry {
|
||||
void registerSettings(Class<? extends IrisFeature> settingsType);
|
||||
|
||||
/** Describes a class that Iris's own classes hold, such as the clamp of an object placement, so studio shows
|
||||
* its fields as this class declares them. Only built-in modules may register one: the host classes that hold
|
||||
* the class are Iris's, so a pack module's class could never be a field of one. The host reads the class
|
||||
* its fields as this class declares them. The class must be one the host loads: a built-in module's class, or a
|
||||
* class of a package the host exposes to pack modules (a pack module's own classes could never be a field of
|
||||
* one of the host's classes, so registering one fails the load). The host reads the class
|
||||
* with its fields in pack JSON, and the class follows the rules of settings classes. Registering a class twice
|
||||
* changes nothing.
|
||||
*/
|
||||
|
||||
@@ -129,9 +129,9 @@ public final class ModuleRegistry implements FeatureRegistry {
|
||||
checkOpen();
|
||||
Objects.requireNonNull(type, "type");
|
||||
requireRegistering("Held type " + type.getName());
|
||||
if (registering.source() != DiscoveredModule.Source.HOST) {
|
||||
throw new IllegalArgumentException("Held type " + type.getName() + " of module " + registering + " is registered by a"
|
||||
+ " pack module; only built-in modules may describe a class that Iris's own classes hold");
|
||||
if (registering.source() != DiscoveredModule.Source.HOST && type.getClassLoader() == registering.module().getClass().getClassLoader()) {
|
||||
throw new IllegalArgumentException("Held type " + type.getName() + " of module " + registering + " is a class of the pack module's"
|
||||
+ " own jar; only a class the host loads, such as one of an exposed package, can be held by Iris's own classes");
|
||||
}
|
||||
heldTypes.putIfAbsent(type, new HeldTypeRegistration(type, registering));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user