Blocks :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
The intent of URLClassLoader.close() is to release all resources opened by the loader, such that any jar files referenced by the URLClassLoader can be deleted. By itself, URLClassLoader now does that, but if you use a URLClassLoader with ServiceLoader, then the ServiceLoader will open additional handles onto any jar files, such that on Windows you can no longer delete jar files after calling URLClassLoader.close. This is because URLClassLoader uses private instances of JarFile to access jar files, but ServiceLoader uses ClassLoader.getResources to open service config files, which returns URLs, and ServiceLoader then uses url.openInputStream() which creates and uses instance of URLJarFile, which are /not/ closed when URLClassLoader.close is called. URLClassLoader (actually URLClassPath) and ServiceLoader need to coordinate on the handle used to access jar files, such that URLClassLoader can honor its contract to release resources when URLClassLoader.close is called.
|