Utility Methods

   

Utility Methods

The preceding sections have focused on the aspects of Reflection you are most likely to use. Namely, locating a constructor, creating an instance, locating and invoking a method, and locating a field. The other methods in Class, Constructor, Method, and Field provide additional utilities for object discovery that are important, but probably not as widely used.

Besides the methods already covered, Class allows you to query an entity for information about its position in the class hierarchy. This includes learning the interfaces implemented by a class or extended by an interface ( getInterfaces ), or the superclass of any class ( getSuperclass ). You can also get the name of an entity, the modifiers included in its declaration, and its package assignment. The need for this level of detail is not widespread, but it is invaluable in tools such as the class browsers found in many IDE applications.

The java.lang.reflect package also includes the Array class. This class consists solely of static methods that are available for dynamically creating and accessing arrays of any primitive or object type.

   


Special Edition Using Java 2 Standard Edition
Special Edition Using Java 2, Standard Edition (Special Edition Using...)
ISBN: 0789724685
EAN: 2147483647
Year: 1999
Pages: 353

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net