GuardUnsafeAccess(JavaThread* thread, jobject _obj) : _thread(thread) { if (JNIHandles::resolve(_obj) == NULL) { // native/off-heap access which may raise SIGBUS if accessing // memory mapped file data in a region of the file which has // been truncated and is now invalid _thread->set_doing_unsafe_access(true); _active = true; } else { _active = false; } }
~GuardUnsafeAccess() { if (_active) { _thread->set_doing_unsafe_access(false); } }