Roman Kennke wrote:
> > This test is wrong:
> > +      || (l.getClass().getClassLoader() == null /* 
> application loader
> > */);
> > 
> > If an application instantiates URLClassLoader, it should still be
> > garbage collectable.
> > 
> > I think that he should consider using a cache that uses 
> weak references
> > instead of this test.
> 
> AFAICS, the test is maybe a little aggressive and disallows 
> caching for classes that could even be cached (correct me if I'm
wrong).

No, it assumes that class loaders that are loaded by the boot class
loader are cacheable, but that's not the case. For example, an
application can instantiate a URLClassLoader and that would satify the
above caching test.

> I'd rather avoid dealing with WeakReferences unless 
> really needed.

Yeah, it may not be ideal either. Hmm, maybe we should add a caching
mechanism to ClassLoader?

Regards,
Jeroen

Reply via email to