Jesse Glick wrote:
>> Was there a way to forcibly terminate URLClassLoader?
>
> Unfortunately there is not; you can only pray it gets GC'd.
Of course you can write your own ClassLoader subclass which explicitly
reads from, and at some defined point closes, a JarFile. You expect
plugin code is well-behaved so that there are no requests for class or
resource loads after termination - if there are, just throw an exception
and hope for the best.
This is not a perfect workaround, though: Class{,Loader}.getResource (as
opposed to .getResourceAsStream) must return a custom URL (either using
a custom protocol, or constructed with a special protocol handler
object); and no code must open a URL it makes for itself via the
URL(String) constructor, since the JRE's jar-protocol handler caches
JarFile's and IIRC never releases them. To be sure this did not happen
you would need to override the JRE's jar protocol handler. Or call
URLConnection.setUseCaches(false) (mistakenly nonstatic).
-J.
--
[hidden email] netbeans.org ant.apache.org hudson.dev.java.net
http://google.com/search?q=e%5E%28pi*i%29%2B1---------------------------------------------------------------------
To unsubscribe, e-mail:
[hidden email]
For additional commands, e-mail:
[hidden email]