Java - Reflection API


Everything in Java is an Object of a Class - including the classes themselves. Any class in Java is an object of java.lang.Class. It is defined its properties and has methods that allow you to work on these properties. This is a very powerful feature of the Java language. It allows your code to work on itself and produce amazing results.
This feature of Java language is covered under the Reflection API. Below, you can find few of the important modules of this Reflection API.

1. Class
2. Member
3. Modifier

On the first sight, Reflection may seem to be an esoteric feature that is rarely used. Why would anyone write code to know anything about class he defined! That may be right for small applications where one develops everything end to end. But in a massive real life application, there are a lot of scenarios where this is required. Frameworks like Spring and Hibernate are rooted in Reflection.


This is a top level introduction to the concepts of Java Reflection API. For more details, you can check out the Java Documentation.
If you want a detailed analysis, you can check out this book.