8256018: Adler32/CRC32/CRC32C missing reachabilityFence

Reviewed-by: naoto, alanb
This commit is contained in:
Lance Andersen 2020-11-11 15:34:03 +00:00
parent 436019b8bb
commit 6247736fc9
3 changed files with 22 additions and 7 deletions

View file

@ -24,6 +24,7 @@
*/
package java.util.zip;
import java.lang.ref.Reference;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@ -170,9 +171,13 @@ public final class CRC32C implements Checksum {
return;
}
if (buffer instanceof DirectBuffer) {
crc = updateDirectByteBuffer(crc, ((DirectBuffer) buffer).address(),
pos, limit);
if (buffer.isDirect()) {
try {
crc = updateDirectByteBuffer(crc, ((DirectBuffer) buffer).address(),
pos, limit);
} finally {
Reference.reachabilityFence(buffer);
}
} else if (buffer.hasArray()) {
crc = updateBytes(crc, buffer.array(), pos + buffer.arrayOffset(),
limit + buffer.arrayOffset());