Key Classes of the Reflection API

To accomplish the task of introspection, the Java API provides java.lang.Class and several classes in the java.lang.reflect package, including Constructor, Method, and Field. These classes are used to obtain information about their respective characteristics from an object. The following sections introduce you to the three key classes in the java.lang.reflect package. This discussion covers the major methods of each class (refer to the Java API documentation for a complete listing). Examples later in the chapter build on this introduction to the Reflection API to demonstrate how you use these classes in conjunction with java.lang.Class to support runtime discovery in your programs.

The Constructor Class

A Constructor ...

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.