All publications
Systems & Internals
Dynamic Code Execution in Java & Android
Reflection, proxies and class loaders — how programs run code they didn't know about at compile time.
Summary
Java and Android can do something that feels impossible: run code that didn't exist when the app was built. This article walks through the three mechanisms that make it work — reflection, dynamic proxies and custom class loaders — and where each one earns its place in real systems like plugins, mocking and hot-loading.
How can an app execute code it has never seen? This piece demystifies the runtime machinery — reflection, proxies and class loaders — that powers plugin systems, dependency injection and dynamic frameworks.
Key ideas
- 01 Reflection lets you inspect and invoke members the compiler never linked.
- 02 Dynamic proxies synthesize interface implementations at runtime — the backbone of many frameworks.
- 03 Custom class loaders can load and isolate code that ships separately from the app.
- 04 Together they enable plugins, mocking and runtime extension — with real trade-offs in safety and speed.