mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
A module whose bundled library references optional integrations got a
WARNING on every pack load, with no way to say the classes are expected
to be absent. ModuleInfo now carries optionalPackages, set with
withOptionalPackages("org.slf4j", ...); ModuleInfo.of(id, name, version)
still declares none. Each package covers its subpackages.
Missing classes of a jar inside its own module's optional packages are
dropped from the warning and from PackModules.missingClasses(); other
jars are unaffected. The declaration comes from info(), so it is applied
after the entry classes exist. Load errors (hidden Iris classes, classes
missing from exposed packages) are decided before that and never depend
on it.
Package-name validation and whole-package matching move from
ExposedPackages to a new API value, PackageName, used by both.
34 lines
1.2 KiB
Java
34 lines
1.2 KiB
Java
package com.volmit.host;
|
|
|
|
import com.volmit.ModuleInfo;
|
|
import com.volmit.PackageName;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
|
|
/** Classes a module jar uses that neither its pack, Iris nor the JDK has, usually optional
|
|
* dependencies of a library the jar bundles, and that the jar's module does not declare
|
|
* {@linkplain ModuleInfo#optionalPackages() optional}. The jar still loads; code that needs one of
|
|
* these classes throws {@link NoClassDefFoundError} when it runs.
|
|
*
|
|
* @param origin the jar path relative to its pack
|
|
* @param classNames the missing classes as sorted binary names
|
|
*/
|
|
public record MissingClasses(String origin, List<String> classNames) {
|
|
public MissingClasses {
|
|
Objects.requireNonNull(origin, "origin");
|
|
classNames = List.copyOf(classNames);
|
|
}
|
|
|
|
/** These classes without those in any of {@code packages}. */
|
|
MissingClasses outside(List<PackageName> packages) {
|
|
var remaining = classNames.stream()
|
|
.filter(className -> packages.stream().noneMatch(name -> name.contains(className)))
|
|
.toList();
|
|
return new MissingClasses(origin, remaining);
|
|
}
|
|
|
|
boolean isEmpty() {
|
|
return classNames.isEmpty();
|
|
}
|
|
}
|