This thread is considered a JavaThread if at least 2 of the selected 3 vtable entries match those of a known JavaThread (which is either application thread or AttachListener). Indexes were carefully chosen to work on OpenJDK 8 to 25, both product an debug builds.
| 399 | // match those of a known JavaThread (which is either application thread or AttachListener). |
| 400 | // Indexes were carefully chosen to work on OpenJDK 8 to 25, both product an debug builds. |
| 401 | bool isJavaThread() { |
| 402 | const void** vtbl = vtable(); |
| 403 | return (vtbl[1] == _java_thread_vtbl[1]) + |
| 404 | (vtbl[3] == _java_thread_vtbl[3]) + |
| 405 | (vtbl[5] == _java_thread_vtbl[5]) >= 2; |
| 406 | } |
| 407 | |
| 408 | int state() { |
| 409 | return _thread_state_offset >= 0 ? *(int*) at(_thread_state_offset) : 0; |