Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

Reflection: A New Way to Discover Information about Java classes

By Dan Becker
2003-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.


[c:\]java Inspector java.lang.Integer
class java.lang.Integer
extends java.lang.Number
extends java.lang.Object
implements java.io.Serializable
[c:\]_

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


 | Bookmark
Related Tutorials:
» All about JAXP, Part 1
» Make Database Queries Without the Database
» Load List Values for Improved Efficiency
» 2 Ways To Implement Session Tracking
» A Simple Way to Read an XML File in Java
» Develop Aspect-Oriented Java Applications with Eclipse and AJDT