Loading Page Content...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Reflection is Java's meta-programming mechanism that allows an executing program to inspect, examine, and modify the internal structure and behavior of classes, interfaces, fields, methods, and constructors at runtime—even when their names are unknown at compile time.
Frameworks like Spring, Hibernate, and JUnit rely fundamentally on Reflection for dependency injection, object-relational mapping, and test discovery.
Class<?> ObjectEvery loaded type has a unique Class instance maintained by the JVM ClassLoader. There are 3 ways to obtain it:
Java provides two sets of reflection queries:
getFields() / getMethods(): Returns public members, including those inherited from superclasses.getDeclaredFields() / getDeclaredMethods(): Returns all members (private, protected, default, public) declared directly within this class.Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| Connection Pooling Concepts with HikariCP | Invoking Methods and Accessing Private Fields via Reflection |
Test your understanding of this lesson with 1 questions. Each question has one correct answer.