Search code examples
java-9java-platform-module-systemjava-module

Naming convention for java 9 modules


What's the naming convention for java 9 modules? Let's say my package name is me.jasonyeo.awesome.project, and whenever I create a module-info.java file in IDEA, it would suggest me to name it awesome.project

Is that the convention? Or should I name it me.jasonyeo.awesome.project?


Solution

  • It seems, IDEA’s suggestion is based on the fact the Java’s builtin modules have two components, e.g. java.base or java.desktop, but that doesn’t make a good suggestion for 3rd party modules.

    JLS §6.1, Declarations says:

    The name of a module should correspond to the name of its principal exported package. 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 still start with the reversed form of an Internet domain with which its author is associated.

    Example 6.1-2. Unique Module Names

    com.nighthacks.scrabble
    org.openjdk.compiler
    net.jcip.annotations
    

    You may find the cited part faster using the direct link to the example

    So your assumption is right, the recommended module name is me.jasonyeo.awesome.project, not awesome.project.