DevNotes
Support
Java · 10 chapters

Reflection

The Class class, obtaining Class objects, class loading internals, inspecting classes, constructors, fields and methods, annotations and dynamic proxies (JDK vs CGLIB).

CHAPTER 01

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.

5 min · 6 Q&A · 6 examples
CHAPTER 02

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.

5 min · 8 Q&A · 9 examples
CHAPTER 03

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.

5 min · 7 Q&A · 12 examples
CHAPTER 04

Class Loading and Class.forName() Internals

Lazy loading, the Bootstrap/Platform/Application class loaders, parent delegation, loading → linking → initialization, and Class.forName() vs loadClass().

8 min · 10 Q&A · 11 examples
CHAPTER 05

The Class API

Inspecting class metadata — getName vs getSimpleName vs getCanonicalName, packages, superclass, interfaces, modifiers, isXxx() checks, isAssignableFrom and class loaders.

6 min · 11 Q&A · 20 examples
CHAPTER 06

Constructors in Reflection

The Constructor API — getConstructors vs getDeclaredConstructors, private constructors, newInstance() with arguments, constructor metadata, exceptions and how frameworks create objects.

6 min · 6 Q&A · 23 examples
CHAPTER 07

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.

7 min · 7 Q&A · 18 examples
CHAPTER 08

Methods in Reflection

The Method API — getMethods vs getDeclaredMethods, invoking public, private, static and parameterized methods, return values, overloads, InvocationTargetException and framework usage.

7 min · 8 Q&A · 24 examples
CHAPTER 09

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.

6 min · 10 Q&A · 23 examples
CHAPTER 10

Dynamic Proxies

Intercepting method calls at runtime — Proxy, InvocationHandler, a logging proxy, how Spring AOP and @Transactional work, and JDK proxies vs CGLIB.

7 min · 11 Q&A · 11 examples