Top Description Fields Constructors Methods
java.util.zip

public final Class CRC32C

extends Object
implements Checksum
Class Inheritance
All Implemented Interfaces
java.util.zip.Checksum
Imports
java.nio.ByteBuffer, .ByteOrder, jdk.internal.misc.Unsafe, jdk.internal.util.Preconditions, jdk.internal.vm.annotation.IntrinsicCandidate, sun.nio.ch.DirectBuffer

A class that can be used to compute the CRC-32C of a data stream.

CRC-32C is defined in RFC 3720: Internet Small Computer Systems Interface (iSCSI).

Passing a null argument to a method in this class will cause a NullPointerException to be thrown.

Since
9
External Specification
https://www.rfc-editor.org/info/rfc3720

Field Summary

Modifier and TypeField and Description
private static final int[]
private static final int[]
private static final int[]
private static final int[]
private static final int[]
private static final int[]
private static final int[]
private static final int[]
private static final int[]
private static final int[][]
private int
crc

Calculated CRC-32C value

private static final int
CRC32C_POLY

CRC-32C Polynomial

private static final int
private static final Unsafe

Constructor Summary

AccessConstructor and Description
public
CRC32C()

Creates a new CRC32C object.

Method Summary

Modifier and TypeMethod and Description
public long
getValue()

Implements java.util.zip.Checksum.getValue.

Returns CRC-32C value.

public void
reset()

Implements java.util.zip.Checksum.reset.

Resets CRC-32C to initial value.

public void
update(int
the byte to update the checksum with
b
)

Implements java.util.zip.Checksum.update.

Updates the CRC-32C checksum with the specified byte (the low eight bits of the argument b).

public void
update(byte[]
the byte array to update the checksum with
b
,
int
the start offset of the data
off
,
int
the number of bytes to use for the update
len
)

Implements java.util.zip.Checksum.update.

Updates the CRC-32C checksum with the specified array of bytes.

public void
update(ByteBuffer
the ByteBuffer to update the checksum with
buffer
)

Overrides default java.util.zip.Checksum.update.

Updates the CRC-32C checksum with the bytes from the specified buffer.

private static int
updateBytes(int crc, byte[] b, int off, int end)

Updates the CRC-32C checksum with the specified array of bytes.

private static int
updateDirectByteBuffer(int crc, long address, int off, int end)

Updates the CRC-32C checksum reading from the specified address.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

byteTableback to summary
private static final int[] byteTable
byteTable0back to summary
private static final int[] byteTable0
byteTable1back to summary
private static final int[] byteTable1
byteTable2back to summary
private static final int[] byteTable2
byteTable3back to summary
private static final int[] byteTable3
byteTable4back to summary
private static final int[] byteTable4
byteTable5back to summary
private static final int[] byteTable5
byteTable6back to summary
private static final int[] byteTable6
byteTable7back to summary
private static final int[] byteTable7
byteTablesback to summary
private static final int[][] byteTables
crcback to summary
private int crc

Calculated CRC-32C value

CRC32C_POLYback to summary
private static final int CRC32C_POLY

CRC-32C Polynomial

REVERSED_CRC32C_POLYback to summary
private static final int REVERSED_CRC32C_POLY
UNSAFEback to summary
private static final Unsafe UNSAFE

Constructor Detail

CRC32Cback to summary
public CRC32C()

Creates a new CRC32C object.

Method Detail

getValueback to summary
public long getValue()

Implements java.util.zip.Checksum.getValue.

Returns CRC-32C value.

Returns:long

Doc from java.util.zip.Checksum.getValue.

the current checksum value

Annotations
@Override
resetback to summary
public void reset()

Implements java.util.zip.Checksum.reset.

Resets CRC-32C to initial value.

Annotations
@Override
updateback to summary
public void update(int b)

Implements java.util.zip.Checksum.update.

Updates the CRC-32C checksum with the specified byte (the low eight bits of the argument b).

Parameters
b:int

Doc from java.util.zip.Checksum.update.

the byte to update the checksum with

Annotations
@Override
updateback to summary
public void update(byte[] b, int off, int len)

Implements java.util.zip.Checksum.update.

Updates the CRC-32C checksum with the specified array of bytes.

Parameters
b:byte[]

Doc from java.util.zip.Checksum.update.

the byte array to update the checksum with

off:int

Doc from java.util.zip.Checksum.update.

the start offset of the data

len:int

Doc from java.util.zip.Checksum.update.

the number of bytes to use for the update

Annotations
@Override
Exceptions
ArrayIndexOutOfBoundsException:
if off is negative, or len is negative, or off+len is negative or greater than the length of the array b.
updateback to summary
public void update(ByteBuffer buffer)

Overrides default java.util.zip.Checksum.update.

Updates the CRC-32C checksum with the bytes from the specified buffer. The checksum is updated with the remaining bytes in the buffer, starting at the buffer's position. Upon return, the buffer's position will be updated to its limit; its limit will not have been changed.

Parameters
buffer:ByteBuffer

Doc from java.util.zip.Checksum.update.

the ByteBuffer to update the checksum with

Annotations
@Override
updateBytesback to summary
private static int updateBytes(int crc, byte[] b, int off, int end)

Updates the CRC-32C checksum with the specified array of bytes.

Annotations
@IntrinsicCandidate
updateDirectByteBufferback to summary
private static int updateDirectByteBuffer(int crc, long address, int off, int end)

Updates the CRC-32C checksum reading from the specified address.

Annotations
@IntrinsicCandidate