You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JDK9: define a stable automatic module name with Automatic-Module-Name entry in MANIFEST #5618
RxJava does not currently use modules. When we use it in a JDK9 modular application, Java turns the JAR into a so-called automatic module, whose name is derived from the JAR archive name. However, the default name does not follow the recommended module naming conventions (reverse-dns style, module name derived from the main exported package).
It is possible to specify a stable automatic module name through a Automatic-Module-Name manifest entry, while still targeting JDK8:
Automatic-Module-Name: io.reactivex
Selecting a stable module name is very important, because Java does not allow two modules to own the same package, and you may end up with a module hell. The naming issues are well-explained on Stephen Colebourne's blog:
And the comment of Mike Reinhold, chief Java architect:
Strongly recommend that all modules be named according to the reverse Internet domain-name convention. A module's name should correspond to the name of its principal exported API package, which should also follow that convention. If a module does not have such a package, or if for legacy reasons it must have a name that does not correspond to one of its exported packages, then its name should at least start with the reversed form of an Internet domain with which the author is associated.
Currently, to use Mockito you have to use the name derived from the JAR file:
modulecom.example.foo {
requiresmockito.core;
}
If you change this name later to org.mockito (or even change the JAR name), and there will be other modular projects that use Mockito as a dependency under the old mockito.core name, you'll fall into a module hell, because Java will refuse to compile an application that tries to import both mockito.core and org.mockito. From JVM perspective, they will be two distinct modules with the same packages inside, which is illegal.
The second link provided in the original issue description contains a great explanation of the module hell problem.
I see another problem: RxJava 2 is located in io.reactivex package so RxJava 3 can't be in io.reactivex or any of its subpackages if we want to allow them to live side-by-side.
Actually, you can put RxJava 3 into a subpackage. io.reactivex and io.reactivex.rxjava3 is not considered as a package split. It will be also possible to create a module named io.reactivex.rxjava3.
Activity
JakeWharton commentedon Sep 24, 2017
akarnokd commentedon Sep 24, 2017
What is the automatic module name RxJava it receives now? What happens to those who are already using this auto-name in their projects?
JakeWharton commentedon Sep 24, 2017
zyxist commentedon Sep 25, 2017
Currently, to use Mockito you have to use the name derived from the JAR file:
If you change this name later to
org.mockito(or even change the JAR name), and there will be other modular projects that use Mockito as a dependency under the oldmockito.corename, you'll fall into a module hell, because Java will refuse to compile an application that tries to import bothmockito.coreandorg.mockito. From JVM perspective, they will be two distinct modules with the same packages inside, which is illegal.The second link provided in the original issue description contains a great explanation of the module hell problem.
akarnokd commentedon Sep 25, 2017
I see another problem: RxJava 2 is located in
io.reactivexpackage so RxJava 3 can't be inio.reactivexor any of its subpackages if we want to allow them to live side-by-side.zyxist commentedon Sep 25, 2017
Actually, you can put RxJava 3 into a subpackage.
io.reactivexandio.reactivex.rxjava3is not considered as a package split. It will be also possible to create a module namedio.reactivex.rxjava3.akarnokd commentedon Sep 25, 2017
I see. Since this only affects a line in the generated manifest, PR welcome.
akarnokd commentedon Oct 4, 2017
Closing via #5644.