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 ...

Get Special Edition Using Java 2 Standard Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.