Why is this an issue?
By convention, a Java class' physical location (source directories) and its logical representation (packages) should be kept in sync. Thus a Java
file located at "src/org/bar/Foo.java"
should have a package of "org.bar"
.
Unfortunately, this convention is not enforced by Java compilers, and nothing prevents a developer from making the "Foo.java" class part of the
"com.apple" package, which could degrade the maintainability of both the class and its application.
Similarly, source placed in a folder with dots in its name instead of having the equivalent folder structure will compile but cause problems at run
time. For instance, code with a package declaration of org.foo.bar
that is placed in org/foo.bar
will compile, but the
classloader will always search for the class into the folder based on package structure, and will consequently expect sources to be in
org/foo/bar
folder. foo.bar
is therefore not a proper folder name for sources.