Skip to content

JDK9: define a stable automatic module name with Automatic-Module-Name entry in MANIFEST #5618

Closed

Description

@zyxist

JDK9 is out and introduces a module system.

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.

Activity

  1. JakeWharton commented on Sep 24, 2017

    @JakeWharton
    Contributor
  2. akarnokd commented on Sep 24, 2017

    @akarnokd
    Member

    What is the automatic module name RxJava it receives now? What happens to those who are already using this auto-name in their projects?

  3. JakeWharton commented on Sep 24, 2017

    @JakeWharton
    Contributor
  4. zyxist commented on Sep 25, 2017

    @zyxist
    Author

    Currently, to use Mockito you have to use the name derived from the JAR file:

    module com.example.foo {
       requires mockito.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.

  5. akarnokd commented on Sep 25, 2017

    @akarnokd
    Member

    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.

  6. zyxist commented on Sep 25, 2017

    @zyxist
    Author

    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.

  7. akarnokd commented on Sep 25, 2017

    @akarnokd
    Member

    I see. Since this only affects a line in the generated manifest, PR welcome.

  8. akarnokd commented on Oct 4, 2017

    @akarnokd
    Member

    Closing via #5644.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions