Reflection means ability of a software to analyze itself. In Java, Reflection API provides facility to analyze and change runtime behaviour of a Class, at runtime.
For example, using reflection at the runtime you can determine what method, field, constructor or modifers a class supports.
What is reflect package ?
java.lang.reflect package encapsulates several important interfaces and classes. These classes and interface define methods which are used for reflection.
Some Important Classes of java.lang.reflect package
|What it does ?
|allow you to dynamically create and manipulate arrays
|gives information about constructor of a class
|provide information about field
|provide information about method
|provide information about class and member access modifier
|supports dynamic proxy classes
Apart from these classes
java.lang.Class is another very important class used in Reflection API.
Uses of Reflection
- Developing IDE
- Debugging and Test tools
- Loading drivers and providing dynamic information
Disadvantages of Reflection
- Low performance
- Security risk
- Violation of Oops concept