Reflection
The Class class, obtaining Class objects, class loading internals, inspecting classes, constructors, fields and methods, annotations and dynamic proxies (JDK vs CGLIB).
Introduction to Reflection
What Reflection is, why frameworks need it, compile time vs runtime, the reflection workflow, where it is used, and its trade-offs.
The Class Class
The heart of Reflection — java.lang.Class, metadata vs data, one Class object per loaded class, how objects point to it, and who creates it.
Three Ways to Obtain a Class Object
ClassName.class, object.getClass() and Class.forName() — compile time vs runtime, which ones load the class, ClassNotFoundException, and what frameworks use.
Class Loading and Class.forName() Internals
Lazy loading, the Bootstrap/Platform/Application class loaders, parent delegation, loading → linking → initialization, and Class.forName() vs loadClass().
The Class API
Inspecting class metadata — getName vs getSimpleName vs getCanonicalName, packages, superclass, interfaces, modifiers, isXxx() checks, isAssignableFrom and class loaders.
Constructors in Reflection
The Constructor API — getConstructors vs getDeclaredConstructors, private constructors, newInstance() with arguments, constructor metadata, exceptions and how frameworks create objects.
Fields in Reflection
The Field API — getFields vs getDeclaredFields, field metadata, reading and modifying public, private, primitive, static and final fields, and how Jackson and Hibernate populate objects.
Methods in Reflection
The Method API — getMethods vs getDeclaredMethods, invoking public, private, static and parameterized methods, return values, overloads, InvocationTargetException and framework usage.
Annotations and Reflection
Annotations as metadata, custom annotations, SOURCE/CLASS/RUNTIME retention, @Target, reading annotations on classes, methods, fields and constructors, and how Spring, JUnit and Hibernate use them.
Dynamic Proxies
Intercepting method calls at runtime — Proxy, InvocationHandler, a logging proxy, how Spring AOP and @Transactional work, and JDK proxies vs CGLIB.