The Java Reflection API provides a set of classes to support
introspection of classes and objects in the JVM. Subject to security
checks, the following operations can be performed:
- construct new class instances and new arrays
- access and modify fields of an object or class
- access and invoke methods and constructors of an object or class
- access and modify elements of arrays
I believe the reflection model has not changed much between JDK 1.1 and 1.2. The standard API is restricted mainly to introspection. Other extensions allowing behavioral reflection (ability to alter behavior at runtime) and structural reflection (ability to alter structure of classes, objects, etc.) have been proposed.
We will ignore arrays for now and concentrate on the other reflective features of classes. After some terminology and background, we start with a few examples, then give an overview of the API, security issues, implementation, and then discuss several topics in detail.