loaderMaps in LoadCache is a WeakHashMap. But since the secondary map in the loaderMaps, holds a strong reference to the class loaded by the Classloader (key of the loaderMap), the ClassLoader is not collectable.
. . .
I believe if the secondary map held a WeakReference to the Class, all the three tests in the test case will pass.
Yes, of course. Rookie error :-).
I have raised this JIRA.