1800 // group should have the destroyed bit set before waiters are notified). |
1800 // group should have the destroyed bit set before waiters are notified). |
1801 ensure_join(this); |
1801 ensure_join(this); |
1802 assert(!this->has_pending_exception(), "ensure_join should have cleared"); |
1802 assert(!this->has_pending_exception(), "ensure_join should have cleared"); |
1803 |
1803 |
1804 // 6282335 JNI DetachCurrentThread spec states that all Java monitors |
1804 // 6282335 JNI DetachCurrentThread spec states that all Java monitors |
1805 // held by this thread must be released. A detach operation must only |
1805 // held by this thread must be released. The spec does not distinguish |
1806 // get here if there are no Java frames on the stack. Therefore, any |
1806 // between JNI-acquired and regular Java monitors. We can only see |
1807 // owned monitors at this point MUST be JNI-acquired monitors which are |
1807 // regular Java monitors here if monitor enter-exit matching is broken. |
1808 // pre-inflated and in the monitor cache. |
|
1809 // |
1808 // |
1810 // ensure_join() ignores IllegalThreadStateExceptions, and so does this. |
1809 // Optionally release any monitors for regular JavaThread exits. This |
1811 if (exit_type == jni_detach && JNIDetachReleasesMonitors) { |
1810 // is provided as a work around for any bugs in monitor enter-exit |
1812 assert(!this->has_last_Java_frame(), "detaching with Java frames?"); |
1811 // matching. This can be expensive so it is not enabled by default. |
|
1812 // ObjectMonitor::Knob_ExitRelease is a superset of the |
|
1813 // JNIDetachReleasesMonitors option. |
|
1814 // |
|
1815 // ensure_join() ignores IllegalThreadStateExceptions, and so does |
|
1816 // ObjectSynchronizer::release_monitors_owned_by_thread(). |
|
1817 if ((exit_type == jni_detach && JNIDetachReleasesMonitors) || |
|
1818 ObjectMonitor::Knob_ExitRelease) { |
|
1819 // Sanity check even though JNI DetachCurrentThread() would have |
|
1820 // returned JNI_ERR if there was a Java frame. JavaThread exit |
|
1821 // should be done executing Java code by the time we get here. |
|
1822 assert(!this->has_last_Java_frame(), |
|
1823 "should not have a Java frame when detaching or exiting"); |
1813 ObjectSynchronizer::release_monitors_owned_by_thread(this); |
1824 ObjectSynchronizer::release_monitors_owned_by_thread(this); |
1814 assert(!this->has_pending_exception(), "release_monitors should have cleared"); |
1825 assert(!this->has_pending_exception(), "release_monitors should have cleared"); |
1815 } |
1826 } |
1816 |
1827 |
1817 // These things needs to be done while we are still a Java Thread. Make sure that thread |
1828 // These things needs to be done while we are still a Java Thread. Make sure that thread |