Reflection
7 Topics
1
Reflection Basics
Understand the Java Reflection API, its capabilities, and security/performance implications.
Tests fundamental principles: how reflection bypasses access modifiers, performance overhead, and security manager restrictions.
2
Class Object
Learn how to obtain and use java.lang.Class instances.
Commonly tested on the three ways to obtain a Class instance and the difference between .class and getClass().
3
Inspecting Fields
Inspect class variables, read values, and write to fields using reflection.
Tests getField() vs getDeclaredField(), and accessing private fields using setAccessible(true).
4
Inspecting Methods
Query methods, inspect signatures, and invoke methods dynamically using reflection.
Focuses on Method.invoke() execution, type mapping parameters, and handling InvocationTargetException.
5
Inspecting Constructors
Inspect constructors and access parameter definitions using reflection.
Commonly tested on constructor lookup and instantiating classes with parameters.
6
Creating Instances
Instantiate classes dynamically using Constructor.newInstance().
Compares Class.newInstance() (deprecated) with Constructor.newInstance() and details exception handling.
7
Reflection Use Cases
Explore real-world applications of reflection in frameworks like Spring, JUnit, and Jackson.
Focuses on architectural trade-offs: when to use reflection vs. code generation, and the cost of runtime reflection.