|
Quick Lists
|
|
Bug ID:
|
5086661
|
|
Votes
|
0
|
|
Synopsis
|
JDK 1.5's temporary native libraries may not be deleted on VM exit
|
|
Category
|
java:classes_lang
|
|
Reported Against
|
tiger
|
|
Release Fixed
|
|
|
State
|
6-Fix Understood,
bug
|
|
Priority:
|
5-Very Low
|
|
Related Bugs
|
4240589
,
4171239
|
|
Submit Date
|
13-AUG-2004
|
|
Description
|
JDK 1.5's temporary native libraries may not be deleted on VM exit
In JDK 1.5 the concept of a temporary native library is implemented in
javax/management/loading/Mlet.java.
It used java.io.File.deleteOnExit() on the temporary native library to
indicate the file should be deleted when Java VM exits.
Unfortunately there is a prohibition against deleting an open shared
library on HPUX. The unlink() system call will fail with errno==ETXTBSY
on HPUX. As a result, on HPUX and possibly other operating systems
the temporary native library files used by Mlet often are not deleted.
(Solaris operating system does not appear to be impacted by this issue.)
The JDK 1.5's VM shutdown sequence does not unload any remaining shared
libraries. Also the deleteOnExit() hook is run too early, when the Java
daemon threads are still running and may be registering additional
deleteOnExit entries. A race condition is possible.
To implement this feature properly the VM should unload any remaining
open shared libraries in its shutdown process. Only after the shared
libraries are closed should the deleteOnExit() hook be run.
(Incident Review ID: 296806)
======================================================================
|
|
Work Around
|
J2SE does support the forced unloading of native library during the VM
shutdown.
An application wishing to use this functionality needs to call:
Runtime.runFinalizersOnExit(true);
This will force the ClassLoader finalize method to run which will
unload all native libraries that have been loaded into the processes
address space.
This should work around the bug that is being reported here.
xxxxx@xxxxx 10/25/04 20:30 GMT
|
|
Evaluation
|
There does not appear to be any way to achieve the semantics required by the JMX API here without changing the JVM, at least on HPUX. The Java API doesn't provide a way to unload a library explicitly, so even if the JMX implementation tried to use Runtime.addShutdownHook instead of File.deleteOnExit, there would be nothing useful it could put in that hook to make the file deletion work. The JVM change suggested in the Description appears to be the only way to make this work. This could potentially be an HPUX-specific change, though.
xxxxx@xxxxx 2004-08-17
J2SE does support the forced unloading of native library when the VM
is exited.
An application wishing to use this functionality needs to call
Runtime.runFinalizersOnExit(true);
This will force the ClassLoader finalize method to run which will
unload all native libraries that have been loaded into the processes
address space.
This should work around the bug that is being reported here.
xxxxx@xxxxx 10/25/04 20:30 GMT
|
|
Comments
|
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |