Reflection API:-
- Working with classes and interfaces of java.lang.Reflect.
- Working with classes and interfaces of java.lang.Reflect.
- Java lang is default package of java. But its sub packages are not default packages.
c language is set of functions. (.h files).
c++ is set of classes and functions (.h files).
Java is set of classes and interfaces (packages).
- Reflection means mirror image to perform a mirror image operations on a given Java class or interface to gather detail of them like member variables, names, super class names and etc., we use reflection API.
- Reflection API can develop
- class Browsers
- Debuggers
- GUI Builders
These are part of IDE softwares.
Class Browser:-
- Using Class Browser Software we can gather internal details about given class.
Debugging:-
- Debugging is a process of fixing the problem by tracing flow of execution. while developing this debugger software developers will use Reflection API.
GUI Builder:-
- A GUI Builder is a application which allows the programmer to develop GUI screens based on drag and drop operations. In this application to show the properties of selected components Reflection API support is required.
- IDE softwares contain Class Browsers, Debuggers and GUI Builders. So Reflection API is very useful to develop IDE softwares in java.
Editors for Java
1. Traditional Editors - Notepad, wordpad,ms-dos editor for windows
- ui , pico ,ed for linux/unix
2. Third Party Editors/Modern Editors
- Ecllipse developed by Ecllipse Organization
- RAD developed by IBM
- NetBeans developed by Jet Brains + Sun Microsystems
- JBuilder developed by Borland
- code to get list of interfaces implemented by given class
- code to get list of interfaces implemented by given class
1. Class c = Class.forName("Test");
2. Class inter[]=c.getInterfaces();
3. for(int i=0; i<inter.length;++i)
2. Class inter[]=c.getInterfaces();
3. for(int i=0; i<inter.length;++i)
{
String iname = inter[i].getName();
System.out.println("\t"+ iname);
}
inter[]
|--------- |
|class obj | 0
|--------- |
|class obj | 1
|--------- |
|class obj | 2
|--------- |
Class Test implements x,y,z
{
// variables
// methods
}
- Reflection API programs can act as mirror devices for a given java class/interface.