Java Reference
In-Depth Information
number of key restrictions of the Java platform. Developers should not make
direct use of the Unsafe class under any circumstances.
he java.awt.peer package
The interfaces in the java.awt.peer package are part of the Java platform but
are documented for use by AWT implementors only. Applications that use
these interfaces directly are not portable.
Implementation-speciic features
Portable code must not rely on features specific to a single implementation. For
example, Microsoft distributed a version of the Java runtime system that
included a number of additional methods that were not part of the Java plat‐
form as defined by the specifications. Any program that depends on such
extensions is obviously not portable to other platforms.
Implementation-speciic bugs
Just as portable code must not depend on implementation-specific features, it
must not depend on implementation-specific bugs. If a class or method
behaves differently than the specification says it should, a portable program
cannot rely on this behavior, which may be different on different platforms,
and ultimately may be fixed.
Implementation-speciic behavior
Sometimes different platforms and different implementations present different
behaviors, all of which are legal according to the Java specification. Portable
code must not depend on any one specific behavior. For example, the Java spec‐
ification does not indicate whether threads of equal priority share the CPU or if
one long-running thread can starve another thread at the same priority. If an
application assumes one behavior or the other, it may not run properly on all
Standard extensions
Portable code can rely on standard extensions to the Java platform, but, if it
does so, it should clearly specify which extensions it uses and exit cleanly with
an appropriate error message when run on a system that does not have the
extensions installed.
Complete programs
Any portable Java program must be complete and self-contained: it must sup‐
ply all the classes it uses, except core platform and standard extension classes.
Deining system classes
Portable Java code never defines classes in any of the system or standard exten‐
sion packages. Doing so violates the protection boundaries of those packages
and exposes package-visible implementation details.
Hardcoded ilenames
A portable program contains no hardcoded file or directory names. This is
because different platforms have significantly different filesystem organizations
Search WWH ::

Custom Search