Basic HTML version of Foils prepared May 19 99

Foil 35 The Reflection API

From Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. by Geoffrey Fox, Nancy McCracken, 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 Mon Jul 5 1999