PACKAGES
Unique Package Names
7.7
then within that compilation unit the simple name
Vector
and the fully qualified
name
java.util.Vector
refer to the same type.
When Java packages are stored in a file system ( 7.2.1), the host system may
choose to enforce the restriction that it is a compile time error if a type is not
found in a file under a name composed of the type name plus an extension (such
as
.java
or
.jav
) if either of the following is true:
The type is referred to by code in other compilation units of the package in
which the type is declared.
The type is declared
public
(and therefore is potentially accessible from
code in other packages).
This restriction implies that there must be at most one such type per compilation
unit. This restriction makes it easy for a Java compiler and Java Virtual Machine
to find a named class within a package; for example, the source code for a
public
type
wet.sprocket.Toad
would be found in a file
Toad.java
in the directory
wet/sprocket
, and the corresponding object code would be found in the file
Toad.class
in the same directory.
When Java packages are stored in a database ( 7.2.2), the host system need
not enforce such restrictions.
In practice, many Java programmers choose to put each class or interface type
in its own compilation unit, whether or not it is
public
or is referred to by code in
other compilation units.
7.7 Unique Package Names
Did I ever tell you that Mrs. McCave
Had twenty three sons and she named them all Dave ?
Well, she did. And that wasn't a smart thing to do. . . .
Dr. Seuss (Theodore Geisel),
Too Many Daves
(1961)
Developers should take steps to avoid the possibility of two published packages
having the same name by choosing
unique package names
for packages that are
widely distributed. This allows packages to be easily and automatically installed
and catalogued. This section specifies a standard convention, not enforced by a
Java compiler, for generating such unique package names. Java systems are
encouraged to provide automatic support for converting a set of packages from
local and casual package names to the unique name format described here.
If unique package names are not used, then package name conflicts may arise
far from the point of creation of either of the conflicting packages. This may
125
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved