Dear Serviceability list, I recently ran into an issue discussed in 2009 ( http://mail.openjdk.java.net/pipermail/serviceability-dev/2009-February/000736.html) where the JVMTI events CompiledMethodLoad and DynamicCodeGenerated are emitted after the VM has switched to the dead phase. Is there a bug for this issue somewhere (I was unable to find one).
I suggest we fix the issue by shutting down the service thread just before emitting the VMDeath event in hotspot/src/share/vm/runtime/java.cpp:before_exit. I have put a patch here http://cr.openjdk.java.net/~cvarming/service_thread.hotspot.00/. With the patch before_exit request the service thread to shut down in much the same way before_exit requests the watcher thread to shut down. The service thread will complete any outstanding work before recognizing the request to shut down. The patch also fixes a minor issue with the watcher thread where enrolling a task after shutdown can start a new watcher thread. The patch also contains a test with a JVMTI agent that checks that events are fired in the right phases as specified in the JVMTI doc ( http://docs.oracle.com/javase/8/docs/platform/jvmti/jvmti.html). I started with a few basic events. I can add more events if desired. I also had to fix make/common/TestFilesCompilation.gmk in the top repo to enable C++ for tests with native code. See http://cr.openjdk.java.net/~cvarming/service_thread.toplevel.00/ Let me know what you think, Carsten