JDK-6630027 : URLClassLoader should have an explicit disposal mechanism
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2007-11-15
  • Updated: 2010-05-06
  • Resolved: 2010-05-06
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
This is a special case of of 4950148 which is arguably worth handling separately.

The problems of closing a ClassLoader are understood and described in 4950148.

However, until that bug is fixed, it would be useful to have URLClassLoader implement
Closeable and close() with a more limited specification that it should close any open JarFiles which it is using.  If and when ClassLoader itself implements Closeable, then URLClassLoader.close() can call super.close() to have all the right additional things happen.

See 6558476 for a problem reported against javac, which boils down to the same problem. Currently, the proposed fix for javac is to try and use reflection to access the private fields containing the jar files in order to close them. It would be better if URLClassLoader provided that functionality directly.

Comments
EVALUATION duplicate of 4167874.
06-05-2010