what comes first - unloading native libraries or deleteOnExit() files?
843829Nov 21 2009 — edited Dec 9 2009Hi there,
My project is using a wrapper JAR that contains a native library. As soon as a certain class C gets instantiated, the native library is unpacked into a temp directory and loaded with System.load(). After unpacking, the native library file is also registered for deletion on VM termination with File.deleteOnExit().
The native library loads fine, however, but when my program exits the VM does not delete the native library (this is on Win32, by the way).
Obviously, it's only possible to delete the native library if the java VM has unloaded it first, which I'd assume it should do on termination, otherwise it won't be able to delete the file.
Is there an order guaranteed between the VM unloading native libraries and processing the list of files registered for deletion? Is there any way to influence that order?
Cheers,
Uwe