Basic HTML version of Foils prepared Aug 14 1997

Foil 98 The Reflection API

From JavaBeans CORBA ComponentWare UC Web applications Certificate -- Aug 11,14 97. by Geoffrey C. Fox, Wojtek Furmanski


First one invokes for any Object obj
  • Class cl = obj.getClass()
Second process instance cl of class Class, has methods
  • public Field[] getFields() returns all fields in object
  • public Method[] getMethods() returns all methods in object
  • public Constructor[] getConstructors() returns constructors
These return public instances only
Thirdly process arrays like Field, Method, Constructor etc. which are in java.lang.reflect and have a whole set of methods to find out further information including
  • fl =Field[0]
  • fl.getName() obtains name
  • fl.get(Object obj) gets value of field
  • fl.set(Object obj) sets value of field
  • fl.getType() is type of field etc.



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Thu Jan 8 1998