Modules vs. Packages

Alex Buckley Alex.Buckley at Sun.COM
Wed Feb 4 17:41:12 EST 2009

Hi Evan,

Please DO use the observer list to ask these questions. The addition of 
modules and (indirectly) versioning in the Java language should receive 
as much sunlight as possible.

We should distinguish between packages and modules as logical namespaces 
in the language, and JARs and OS packages (e.g. RPMs) as physical 
containers. It's a shame that packages are so strongly associated with 
directories, since cd'ing into a directory and seeing that it contains 
classfiles leads to thinking that a package contains types. In fact, 
classes belong to packages and the physical representation is a detail.

That said, classes will now belong to modules as well as to packages, so 
you are right to ask how to differentiate. A module can and should be 
versioned, so if your colleague said "class Foo is in version 1.2 of 
com.mesoft.weirding", it's obvious that a module is in play. The 
physical container holding that logical module should be relatively 
obvious from the module system's conventions.

The reverse-DNS notation is so useful for uniqueness that I think the 
language has to recommend its use for module names. But it would be 
interesting to hear ideas for syntax other than dot-delimited identifiers.


Evan Cowden wrote:
> First, If I'm committing some taboo as an observer by writing here or if 
> I am writing about already settled territory, I sincerely apologize.
> This conversation has gotten me wondering: with this system in place, 
> what happens when a teammate tells me that a class is in 
> com.mesoft.weirding?  Should I look for this class:
> In a module?
> In a package?
> In a JAR?
> I am concerned about the addition of the third grouping layer. 
>  Currently, we have full modules (or bundles) as JAR files that provide 
> our macro layer of modularity.  The JAR/WAR/EAR/Bundle/etc. is the 
> larger grouping unit, and for all practical purposes, it defines the 
> module.  Its parts are packages, the smaller grouping unit, familiar to 
> all programmers.  I understand the concern about modularizing legacy 
> code, but trying to shoehorn a third grouping in there feels as if the 
> Postal Service decided that zip codes just aren't cutting it, so we 
> should all just add an extra number to our addresses.
>  - Evan Cowden
> P.S. - If you decide that the additional grouping is absolutely 
> necessary, please - please - develop a naming convention that is 
> different than the dot-delimited, faux-hierarchical standard for packages.

More information about the jsr294-modularity-observer mailing list