When refining a buffer of cards, the buffer is first sorted, to improve locality. However, the sort function's return type is wrong. G1RefineBufferedCards::compare_card uses the difference between the cards as the result (negative -> lt, zero -> eq, positive -> gt). But it returns an int, so discards all but the low 32 bits of that difference. This renders the "sort" potentially more of a "randomizer". However, since the pointers being compared are in the card table, the range of the results probably fit in 32bits. Only for really large heaps or small card sizes (after JDK-8272773 made GCCardSizeInBytes configurable) are we likely to lose any bits from the narrowing conversion.