[ #306535 ] JavaService never calls DetachCurrentThread
Date: 2006-12-27 12:25
Submitted By: Staffan Larsen (staffanlarsen)
Assigned To: Nobody (None)
Category: Service Runtime
Summary: JavaService never calls DetachCurrentThread
Detailed description: After calling JNI_CreateJavaVM and then invoking the Java main-method,
JavaService should call DetachCurrentThread otherwise the JVM will be left in
an unspecified state (this causes crashes with JRockit).
After the call to JNI_CreateJavaVM, the current thread is attached to the JVM.
The main-method could potentially spawn other threads and then return. If no
call is made to DetachCurrentThread after the main-method returns, the thread
is still attached to the JVM, although it may not be running at all. This is
confusing to the JVM which may try to access the thread (since it is attached),
but receives errors when doing so. JRockit will when this happens play the
better-safe-than-sorry game and exit the JVM with a fatal error.
It should be easy to modify StartJavaService() to call DetachCurrentThread.
/Staffan Larsen, JRockit Development Team