PlugMan

PlugMan

3M Downloads

Can't overwrite plugin file on windows after unload.

EntityReborn opened this issue ยท 4 comments

commented

This can most likely be fixed by calling System.gc() after everything is unloaded. There's a known "bug" where the JVM won't unlock jar files.

commented

I've tested the suggestion, doesn't seem to have any effect.

I'll dig a bit deeper when I have the time, but "forcing" garbage collection from within the plugin isn't the best solution (using the -XX:+DisableExplicitGC flag would make the addition useless).

commented

Ah, I see what was forgotten.
The classloader for that plugin needs to be closed as well, before the GC is called. Adding these lines before the return statement for PluginUtil.unload(Plugin) succeeds for me:

try {
    ((URLClassLoader)plugin.getClass().getClassLoader()).close();
} catch (IOException ex) {
    Logger.getLogger(PluginUtil.class.getName()).log(Level.SEVERE, null, ex);
}
System.gc();

After calling /plugman unload <plugin>, I can actually delete the jar file from the plugin directory.

commented

rylinaux, are you currently present on an IRC network?

commented

I can be found on irc.esper.net under the nick "Ryan".