lz4/lz4-java

Delete of native lib doesn't work on Windows

broneill opened this issue · 2 comments

This is a duplicate of issue #102, which was closed without actually being fixed. When loading a native library on Windows, the file is locked and cannot be deleted. Attempting to use the "delete on exit" feature doesn't actually work, because the delete attempt occurs before the native library is unloaded.

As far as I searched the Web, there is no reliable way to delete a temporary native library at exit on Windows.
https://stackoverflow.com/questions/33226381/cannot-delete-a-temporary-file-when-it-is-used-to-load-a-system-library
https://bugs.java.com/bugdatabase/view_bug.do?bug_id=5086661
The only seemingly possible solution would be to call Runtime.runFinalizersOnExit(true);, but this method is deprecated, and I am not sure a library like lz4-java should call this kind of method that might affect the whole program.

However, I found this approach in sqlite-jdbc might help solve the problem. I will investigate it more.

Fixed by 08b3bff.