The purpose of an if statement condition, it is java21-ConcurrentHashMap-transfer method code:2463Line

1 week ago 5
ARTICLE AD BOX
// transfer 2463line if (i < 0 || i >= n || i + n >= nextn) { ********* here int sc; if (finishing) { nextTable = null; table = nextTab; sizeCtl = (n << 1) - (n >>> 1); return; } if (U.compareAndSetInt(this, SIZECTL, sc = sizeCtl, sc - 1)) { if ((sc - 2) != resizeStamp(n) << RESIZE_STAMP_SHIFT) return; finishing = advance = true; i = n; // recheck before commit } }

Condition 1, "i < 0", I can understand it.
Condition 2, "i >= n", I can't think of a special case; it feels like it can't happen.
Condition 3, "i + n >= nextn", is the same.
Are conditions 2 and 3 for defensive programming?

Thanks!!!

Read Entire Article