Skip to content

Conversation

nictas
Copy link
Contributor

@nictas nictas commented Oct 7, 2020

This is how this library is consumed in a Java 11 project:

module foo {
    requires cloudfoundry.client;
    requires cloudfoundry.client.reactor;
    // And the rest of the modules...
}

Unfortunately, this produces the following warning:

Name of automatic module 'cloudfoundry.client' is unstable, it is derived from the module's file name.

That's because when a JAR does not contain a module-info.class Java assigns an automatic module name based on the JAR's name (for example, cloudfoundry-client-4.10.0.RELEASE.jar -> cloudfoundry.client). The cheapest way to remove this warning is to define a custom automatic module name with the help of the maven-jar-plugin. That way, Java wouldn't have to infer the module's name from the name of the JAR.

See http://branchandbound.net/blog/java/2017/12/automatic-module-name/ for more info.

I've used the package names as module names (kind-of), since that's what's recommended by Mark Reinhold (see Proposal: #AutomaticModuleNames (revised)):

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.

With this PR, the library would be consumable in the following way:

module foo {
    requires org.cloudfoundry.client;
    requires org.cloudfoundry.client.reactor;
    requires org.cloudfoundry.operations;
    requires org.cloudfoundry.util;
}

@nictas nictas changed the title Fix compilation with Java 11 and add automatic module names Add automatic module names (JPMS) Oct 7, 2020
@twoseat twoseat added this to the 4.13.0.RELEASE milestone Dec 11, 2020
@twoseat twoseat self-assigned this Dec 11, 2020
@twoseat twoseat closed this in 1798e6c Dec 11, 2020
@nictas nictas deleted the java11 branch December 14, 2020 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants