mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-29 01:04:29 +00:00
Let the host expose extra packages, such as built-in modules, to packs
A single API_PACKAGE_PREFIX made built-in modules in Iris packages (art.arcane.iris...) invisible, so pack jars could not require their stages. ExposedPackages now holds the packages packs may use: always the API (IrisModule's package), plus what the host passes to the new PackModules.load(packRoot, exposedHostPackages). Names must be package names (trailing dot accepted) and match whole packages only. ApiAndJdkClassLoader becomes ExposedHostClassLoader and routes classes and resources of every exposed package to the host loader. A jar that ships a class of any exposed package fails; the compileOnly API hint stays for the API, other packages get their own message. That check moves from ModuleJar to PackClassCheck. A reference missing from any exposed package is the "different build" error. Tests use a built-in module in example.builtin, outside com.volmit., which a pack jar can require only when that package is exposed.
This commit is contained in:
1 parent
98bd9a9c12
commit
13a9300ab4
11 files changed
+396
-121
No files matched your search
@@ -22,7 +22,7 @@ final class PackReferenceCheck {
|
||||
|
||||
/** Where the pack loader would find a referenced class. */
|
||||
private enum Resolution {
|
||||
/** In the pack, a package the host exposes, or the JDK. */
|
||||
/** In the pack, an exposed host package, or the JDK. */
|
||||
PROVIDED,
|
||||
/** Nowhere: an optional dependency, which only fails when code that needs it runs. */
|
||||
ABSENT,
|
||||
@@ -53,9 +53,9 @@ final class PackReferenceCheck {
|
||||
|
||||
private final Set<String> packClasses = new HashSet<>();
|
||||
private final Map<String, Resolution> outsidePack = new HashMap<>();
|
||||
private final ApiAndJdkClassLoader host;
|
||||
private final ExposedHostClassLoader host;
|
||||
|
||||
private PackReferenceCheck(List<ModuleJar> jars, ApiAndJdkClassLoader host) {
|
||||
private PackReferenceCheck(List<ModuleJar> jars, ExposedHostClassLoader host) {
|
||||
this.host = host;
|
||||
jars.forEach(jar -> packClasses.addAll(jar.classNames()));
|
||||
}
|
||||
@@ -63,7 +63,7 @@ final class PackReferenceCheck {
|
||||
/** Fails when a jar uses a class Iris hides or a class missing from a package Iris exposes.
|
||||
* Returns the classes nobody has, per jar, for jars that use any.
|
||||
*/
|
||||
static List<MissingClasses> requireResolvable(List<ModuleJar> jars, ApiAndJdkClassLoader host) {
|
||||
static List<MissingClasses> requireResolvable(List<ModuleJar> jars, ExposedHostClassLoader host) {
|
||||
var check = new PackReferenceCheck(jars, host);
|
||||
var references = jars.stream().map(check::resolve).toList();
|
||||
requireNoFailures(references);
|
||||
@@ -88,7 +88,7 @@ final class PackReferenceCheck {
|
||||
|
||||
private Resolution resolveOutsidePack(String className) {
|
||||
if (host.hasClass(className)) return Resolution.PROVIDED;
|
||||
if (ApiAndJdkClassLoader.isApiClass(className)) return Resolution.MISSING_HOST_CLASS;
|
||||
if (host.exposed().exposes(className)) return Resolution.MISSING_HOST_CLASS;
|
||||
if (host.hostHasClass(className)) return Resolution.HIDDEN_HOST_CLASS;
|
||||
return Resolution.ABSENT;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user