mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Report JDK classes that modules cannot see as their own load error
A reference to a class of a JDK module outside the platform class
loader, such as jdk.compiler's com.sun.source.tree.Tree, was reported as
"exists in Iris but is hidden", because the host loader (the application
loader in tests) has it. It now has its own category, listed with the
module:
Module jar modules/user.jar uses classes of JDK modules that are not available to modules:
pack.user.User -> com.sun.source.tree.Tree (JDK module jdk.compiler)
Modules can use only the JDK modules of the platform class loader, ...
UnavailableJdkModules maps the packages of every system module that the
boot layer does not define to the boot or platform loader, from module
descriptors only, so nothing is loaded. Classes the platform loader
provides (java.sql, java.compiler) still resolve.
This commit is contained in:
1 parent
57774fade0
commit
ec80683aa1
4 files changed
+122
-5
No files matched your search
@@ -275,6 +275,35 @@ class PackModulesTest {
|
||||
failure(() -> PackModules.load(pack)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void referenceToAJdkModuleOutsideThePlatformLoaderFailsNamingTheModule() {
|
||||
module("pack.user.User", "user:core", using("com.sun.source.tree.Tree", "java.sql.Connection"), NO_STAGES)
|
||||
.writeInto(pack, "user.jar");
|
||||
|
||||
assertEquals("Module jar " + origin("user.jar") + " uses classes of JDK modules that are not available to modules:\n"
|
||||
+ " pack.user.User -> com.sun.source.tree.Tree (JDK module jdk.compiler)\n"
|
||||
+ "Modules can use only the JDK modules of the platform class loader, such as java.base, java.sql and"
|
||||
+ " java.net.http.",
|
||||
failure(() -> PackModules.load(pack)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void oneFailureReportsEveryKindOfUnusableClass() {
|
||||
module("pack.user.User", "user:core", using("org.junit.jupiter.api.Test", "com.sun.source.tree.Tree"), NO_STAGES)
|
||||
.compileAgainstHostOf(Test.class)
|
||||
.writeInto(pack, "user.jar");
|
||||
|
||||
assertEquals("Module jar " + origin("user.jar") + " uses classes that exist in Iris but are hidden from modules:\n"
|
||||
+ " pack.user.User -> org.junit.jupiter.api.Test\n"
|
||||
+ "Modules cannot use Iris's own classes or its copies of libraries; ship the library in a module"
|
||||
+ " jar of the pack, or use the Iris API.\n"
|
||||
+ "Module jar " + origin("user.jar") + " uses classes of JDK modules that are not available to modules:\n"
|
||||
+ " pack.user.User -> com.sun.source.tree.Tree (JDK module jdk.compiler)\n"
|
||||
+ "Modules can use only the JDK modules of the platform class loader, such as java.base, java.sql and"
|
||||
+ " java.net.http.",
|
||||
failure(() -> PackModules.load(pack)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void classesNobodyHasAreReportedWithoutFailingTheLoad(@TempDir Path build) {
|
||||
var optionalLibrary = new TestModuleJar()
|
||||
|
||||
Reference in new issue
Block a user