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


1 First one invokes for any Object obj
  • Class cl = obj.getClass()
2 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
3 These return public instances only
4 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.

in Table To:


© 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