A ClassInfo.release(ClassLoader) method that releases all cached information for classes loaded by the specified class loader might do it. Commons logging has something like this on LogFactory, although commons logging is probably not what you want to be using as a model for how to do this right (http://articles.qos.ch/classloader.html
). Commons logging also uses its own internal weak hash map implementation to avoid holding hard references to cached loggers. Using something similar might be a bit better, in that no explicit release is needed when the webapp context is destroyed.
How much of a performance penalty will this cause? I don't have any problems with the cache while the classloader is live but clearing it when the classloader dies would be good. ;)