This method reads characters into buf. It returns the number of characters read, or 1 if an
EOF is encountered.
The java.lang Subpackages
Java defines several subpackages:
Each is briefly described here.
Java's annotation facility is supported by java.lang.annotation. It defines the Annotation
interface, and the ElementType and RetentionPolicy enumerations. Annotations are described
in Chapter 12.
java.lang.instrument defines features that can be used to add instrumentation to various aspects
of program execution. It defines the Instrumentation and ClassFileTransformer interfaces, and
the ClassDefinition class.
The java.lang.management package provides management support for the JVM and the
execution environment. Using the features in java.lang.management, you can observe and
manage various aspects of program execution.
You learned earlier that the garbage collection facilities in Java automatically determine when
no references exist to an object. The object is then assumed to be no longer needed and its
memory is reclaimed. The classes in the java.lang.ref package provide more flexible control
over the garbage collection process. For example, assume that your program has created
numerous objects that you want to reuse at some later time. You can continue to hold references
to these objects, but that may require too much memory.
Instead, you can define "soft" references to these objects. An object that is "softly reachable"
can be reclaimed by the garbage collector, if available memory runs low. In that case, the
garbage collector sets the "soft" references to that object to null. Otherwise, the garbage
collector saves the object for possible future use.
A programmer has the ability to determine whether a "softly reachable" object has been
reclaimed. If it has been reclaimed, it can be re-created. Otherwise, the object is still available
for reuse. You may also create "weak" and "phantom" references to objects. Discussion of
these and other features of the java.lang.ref package is beyond the scope of this topic.
Search WWH :