Before we being reflections we should note the following:
Now we can proceed further.
Retrieving Class Objects
First things first. Before you can find out anything about a class, you must first retrieve its corresponding
Getting the Class Name
It's easy to find out the name of a
Discovering Class Modifiers
This section shows you the methods you need to call to find out what modifiers a particular class has.
Finding Superclasses
In this section you'll learn how to retrieve all of the
Identifying the Interfaces Implemented by a Class
If you want to find out what interfaces a class implements, then check out this section.
Examining Interfaces
In this section you'll learn how to tell if a
Identifying Class Fields
This section shows you how to discover what fields belong to a class, and how to find out more about these fields by accessing
Discovering Class Constructors
This section, which introduces the
Obtaining Method Information
To find out about a class's methods, you need to retrieve the corresponding
Now we can proceed further.
Examining Classes
Following is required to examine a class:First things first. Before you can find out anything about a class, you must first retrieve its corresponding
Class
object.It's easy to find out the name of a
Class
object. All you have to do is invoke the getName
method.This section shows you the methods you need to call to find out what modifiers a particular class has.
In this section you'll learn how to retrieve all of the
Class
objects for the ancestors of a given class.If you want to find out what interfaces a class implements, then check out this section.
In this section you'll learn how to tell if a
Class
object represents an interface or a class. You'll also get some tips on how to get more information about an interface.This section shows you how to discover what fields belong to a class, and how to find out more about these fields by accessing
Field
objects.This section, which introduces the
Constructor
class, explains how to get information about a class's contructors.To find out about a class's methods, you need to retrieve the corresponding
Method
objects. This section shows you how to do this.Manipulating Objects
Software development tools, such as GUI builders and debuggers, need to manipulate objects at run time. For example, a GUI builder may allow the end-user to select aButton
from a menu of components, create the Button
object, and then click the Button
while running the application within the GUI builder. If you're in the business of creating software development tools, you'll want to take advantage of the reflection API features described in this lesson. - Creating Objects
How can you create an object if you don't know its class name until run time? You'll find the answer in this section. - Getting Field Values
In this section you'll learn how to get the values of an object's fields, even if you don't know the name of the object, or even its class, until run time. - Setting Field Values
Not only can you get field values at run time, you can also set them. This section shows you how. - Invoking Methods
This section shows you how to dynamically invoke methods. Given an object, you can find out what methods its class defines, and then invoke the methods.
Creating Objects
- Using No-Argument Constructors
- Using Constructors that Have Arguments
- Getting Field Values
- Setting Field Values
- Invoking Methods
No comments:
Post a Comment