Name: dbT83986 Date: 05/14/99
When a finalize() method calls a native function,
the JVM can unload the native library before all
the finalize() methods are called resulting in
a crash.
For this to occur the run finalizers on exit must
be true:
class HelloWorld
{
public HelloWorld()
{
System.loadLibrary("hello");
}
public native void displayHelloWorld();
protected void finalize()
{
displayHelloWorld();
}
public static void main(String[] args)
{
System.runFinalizersOnExit(true);
new HelloWorld().displayHelloWorld();
}
}
The native function displayHelloWorld can be any
function.
It appears that the finalizer for the object that
contains the native library reference is run before
that finalizer for the HelloWorld object.
(Review ID: 57246)
======================================================================