Details
Description
Loom added the following code in JvmtiEventControllerPrivate::set_event_callbacks:
// Mask to clear normal event bits.
const jlong CLEARING_MASK = (1L >> (TOTAL_MIN_EVENT_TYPE_VAL - TOTAL_MIN_EVENT_TYPE_VAL)) - 1L;
// Avoid cleaning extension event bits.
jlong enabled_bits = CLEARING_MASK & env->env_event_enable()->_event_callback_enabled.get_bits();
But the CLEARING_MASK is computed weirdly/incorrectly:
a) It subtracts TOTAL_MIN_EVENT_TYPE_VAL from itself, always yielding 0;
b) It shifts 1L to the right, which means the subexpression would produce either 0 or 1; or, after -1L, either 0 or -1 (full mask?).
// Mask to clear normal event bits.
const jlong CLEARING_MASK = (1L >> (TOTAL_MIN_EVENT_TYPE_VAL - TOTAL_MIN_EVENT_TYPE_VAL)) - 1L;
// Avoid cleaning extension event bits.
jlong enabled_bits = CLEARING_MASK & env->env_event_enable()->_event_callback_enabled.get_bits();
But the CLEARING_MASK is computed weirdly/incorrectly:
a) It subtracts TOTAL_MIN_EVENT_TYPE_VAL from itself, always yielding 0;
b) It shifts 1L to the right, which means the subexpression would produce either 0 or 1; or, after -1L, either 0 or -1 (full mask?).