-
Bug
-
Resolution: Fixed
-
P4
-
9, 17
-
b08
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
If a module M `exports` a service interface, and a module that has an optional dependency (`requires static`) on M contains an implementation of the service interface (`provides ... with ...`), then at run time, module resolution will fail if M is not on the module path or not required by another module via a non-optional dependency.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a module that includes a service interface (foo)
2. Create an executable second module with a service implementation implementing the service from the first module but without using the service and an optional dependency (requires static) on the first module (bar)
3. Execute the second module with or without the first module on the module path
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
For the second module to execute
ACTUAL -
Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Module bar does not read a module that exports foo
---------- BEGIN SOURCE ----------
foo/foo/Foo.java:
package foo;
public interface Foo {
public String name();
}
foo/module-info.java:
module foo {
exports foo;
}
bar/bar/Bar.java:
package bar;
import foo.Foo;
public class Bar implements Foo {
public String name() {
return "Bar";
}
}
bar/bar/Main.java:
package bar;
public class Main {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
bar/module-info.java:
module bar {
requires static foo;
provides foo.Foo with bar.Bar;
}
bar/META-INF/MANIFEST.MF:
ModuleMainClass: bar.Main
---------- END SOURCE ----------
If a module M `exports` a service interface, and a module that has an optional dependency (`requires static`) on M contains an implementation of the service interface (`provides ... with ...`), then at run time, module resolution will fail if M is not on the module path or not required by another module via a non-optional dependency.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a module that includes a service interface (foo)
2. Create an executable second module with a service implementation implementing the service from the first module but without using the service and an optional dependency (requires static) on the first module (bar)
3. Execute the second module with or without the first module on the module path
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
For the second module to execute
ACTUAL -
Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Module bar does not read a module that exports foo
---------- BEGIN SOURCE ----------
foo/foo/Foo.java:
package foo;
public interface Foo {
public String name();
}
foo/module-info.java:
module foo {
exports foo;
}
bar/bar/Bar.java:
package bar;
import foo.Foo;
public class Bar implements Foo {
public String name() {
return "Bar";
}
}
bar/bar/Main.java:
package bar;
public class Main {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
bar/module-info.java:
module bar {
requires static foo;
provides foo.Foo with bar.Bar;
}
bar/META-INF/MANIFEST.MF:
ModuleMainClass: bar.Main
---------- END SOURCE ----------
- csr for
-
JDK-8347915 Service use or provides in module creates required dependency
-
- Closed
-
- links to
-
Commit(master) openjdk/jdk/1d2eb2fb
-
Review(master) openjdk/jdk/23147