Reflection: A New Way to Discover Information about Java classes
By Dan Becker2003-05-24
An Improved Java 1.02 Reflection Program
The results from running this code example are greatly improved from the first example. Not only do you get a complete class hierarchy, but you also see the interfaces that a class implements. One clue that this program was run under Java 1.1 or later is that the java.lang.Number class implements java.io.Serializable, a new interface introduced in the JDK 1.1.
|
These are simple examples of reflection. Now let's add more advanced introspection techniques to the printType() method. To accomplish this, you need the new features of Java 1.1.
Tutorial Pages:
» Introduction
» Outlining the Class Hierarchy Using Java 1.02
» Querying Interfaces Using Java 1.02
» An Improved Java 1.02 Reflection Program
» Using the Reflection Features of Java 1.1: Modifiers
» Using the Reflection Features of Java 1.1: Fields
» Security Issues
» Conclusion
First published by IBM DeveloperWorks
