== Class identity = name + defining loader == same name: true same Class object: false c1 loader: 'plugin-v1' (com.ankurm.classloaders.PluginLoader) c2 loader: 'plugin-v2' (com.ankurm.classloaders.PluginLoader) both usable as Plugin (the interface is shared via the parent): p1.run() = Hello from GreeterPlugin v1 p2.run() = Hello from GreeterPlugin v2 c2.cast(p1): Cannot cast com.acme.GreeterPlugin to com.acme.GreeterPlugin == The cast that fails even though the names match == ClassCastException: class com.acme.GreeterPlugin cannot be cast to class com.ankurm.classloaders.api.Plugin (com.acme.GreeterPlugin is in unnamed module of loader 'plugin-bad' @; com.ankurm.classloaders.api.Plugin is in unnamed module of loader 'app') == Hot reload: a fresh loader per version == Hello from GreeterPlugin v1 Hello from GreeterPlugin v2 Hello from GreeterPlugin v1 (the same class name, three times, three different Class objects) == Unloading: a loader is collectable only when nothing reachable points into it == plugin dropped, nothing else references it -> loader collected: true plugin instance stored in static Registry -> loader collected: false Registry cleared -> (new loader) collected: true