Java Technology Home Page
A-Z Index

Java Developer Connection(SM)
Online Training

Downloads, APIs, Documentation
Java Developer Connection
Tutorials, Tech Articles, Training
Online Support
Community Discussion
News & Events from Everywhere
Products from Everywhere
How Java Technology is Used Worldwide
 
Training Index

JavaBeansTM Short Course
Reflective Programming with Freud

By MageLang Institute

[Tutorial Contents]
[Behavior] [Help] [API Docs] [Solution]

Skeleton Code

Use of the reflection API is important when creating tools. They need to be able to inspect Java Beans to see how they work. This exercise shows you how to duplicate javap functionality through the use of the Reflection/Introspection capabilities of Java.

Perform the following tasks:

  1. Import the reflection library.

  2. The skeleton code currently lists class variables and constructors of any class requested. It is your job to have it also list all the methods. The framework is included, you only need to complete the listClassMethods method.

  3. Within listClassMethods: for each method of the class, list the modifiers, return type, name, and parameter types.

As time permits, you can do other things with this. To name just a few:

  • Sort each list.
  • Group private, protected, and public items together.
  • For classes in java.lang, chop that part of their name off.
  • Catch security exceptions so this will run unsigned in an applet, without generating lots of stack traces.
  • List only those methods that accept a user provided parameter list.
The task numbers above are linked to the step-by-step help page. Also available is a complete solution to the problem, and expected behavior, to demonstrate it.
Copyright © 1997 MageLang Institute. All Rights Reserved.

[ This page was updated: 10-Nov-99 ]

Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first.
Sun Microsystems, Inc.
Copyright © 1995-99 Sun Microsystems, Inc.
All Rights Reserved. Legal Terms. Privacy Policy.