Discovering Interface Information

Just as you can retrieve information on a class, you can use the Reflection APIs to interrogate an interface. You can find out what interfaces it extends, what methods it declares, and the data members it defines.

Interface Reflection: Code Example

Because there are so many important interfaces, and because your object, like the RemoteObject in Listing 13.1, may implement one or more interfaces, it is important to be able to use reflection on interfaces. Listing 13.3 shows a program to interrogate an interface. This code is similar to the two previous examples.

Code Listing 13.3. Using Reflection APIs to Interrogate an Interface (Reflector3.java)
 import java.lang.reflect.*; class ClassBrowser3 { public boolean ...

Get PURE Java™ 2 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.