Reflection API is a collection of classes and interfaces given by SUN ,to get a meta data of a class at runtime. For example, we have a runtime class and we want to get name, instance variables, instance methods … of that class at runtime, we have to use Reflection API .

Using reflection API we can get some of the following information of a class or interface at runtime .


1) Name of the class
2) Immediate super class of a class
3) Super class hierarchy of a current class
4) Modifiers of a current class
5) Data members of a current class
6) Constructors of a class
7) Methods of a class
8) Modifiers of a interface
9) Super interface of current interface

To deal with reflection based programming, we have to import the package java.lang.reflect.* . Reflect is one of the sub package of java.lang and it won’t be imported by default.


For the following real time applications reflection API will be used

1) To develop class browsers
2) To develop language debuggers
3) To develop GUI builders

class browsers are nothing but a normal java applications that allows to retrieve internal details of a class. These applications are mostly used with IDE’s such as NetBeans, Eclipse.

For example, while you are typing java program in IDE you get some suggestions, because of class browsers. Debuggers are used to monitor the execution flow of application.GUI builders are used to develop GUI applications in drag and drop fashion.