Java package hierarchy is only in the name

One of the minor annoyances of Java is that a package and its parent are as foreign to each other than any other pair of packages.

In practice this means that if I want to split a package (module) into subpackages (why wouldn't I?), all interfaces meant for "internal communication" inside the module must be visible to other packages as well.

A related problem is that there is no such thing as package private interfaces. Sure, the interface itself can be package private, but the method implementations must be public. So if I use a package private interface inside a package, a class unfortunate enough to be public and implement this internal interface must publish the supposedly internal interface methods.

Originally published on 2007-09-21 at http://www.jroller.com/wipu/entry/java_package_hierarchy_is_only under category Java