Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

what comes first - unloading native libraries or deleteOnExit() files?

843829Nov 21 2009 — edited Dec 9 2009
Hi 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 6 2010
Added on Nov 21 2009
8 comments
970 views