Java Zero to All All questionsPractise free
Interview questions › JVM Internals & Runtime › JVM Architecture

When and why would you deliberately break parent delegation with a custom or child-first class loader?

Level IV · SeniorJVM Architecture
Short answer

Servlet containers like Tomcat use child-first loading so each deployed web app can bundle its own version of a library without the container's version winning, giving per-application isolation and hot redeploy.

Explanation

Plugin systems and OSGi do the same to support conflicting dependency versions in one JVM. The danger is class loader leaks: if a redeploy leaves a stray reference into the old loader, none of its classes can be unloaded and Metaspace grows until OOM.

Common mistakes
  • Breaking delegation without a reason (plugin isolation, app servers).
  • Ignoring class-loader leaks when redeploying.

Can you say this out loud in two minutes? Drill it in a timed mock interview, with flashcards and runnable code for JVM Architecture.

Practise free

More on JVM Architecture