Java applications, especially large Java applications, usually need to dynamically load classes or jar. urlclassloader provides this function, which allows us to load in the following ways:
* File: (load from the file system directory)
* Jar package: (load from jar package)
* Http: (load from a remote HTTP Service)
A common problem is that after the class file or resources resource file is updated, We need to reload these classes or jar files. Theoretically, when the application clears references to the loaded objects, the garbage collector will collect these objects and then reload the new JAR file, create a new urlclassloader for loading. But there is a problem here,That is, we do not know when the Garbage Collector will collect unreferenced objects, especially in windows, because files opened in Windows cannot be deleted or replaced.
InJava 7 build 48In, urlclassloader provides the close () method to release all opened resources, which saves developers a lot of time to solve this problem.
Reference: https://blogs.oracle.com/CoreJavaTechTips/entry/closing_a_urlclassloader