< prev index next >

jdk/src/java.base/share/classes/java/util/zip/CRC32C.java

Print this page




  27 import java.nio.ByteBuffer;
  28 import java.nio.ByteOrder;
  29 
  30 import jdk.internal.HotSpotIntrinsicCandidate;
  31 import jdk.internal.misc.Unsafe;
  32 import sun.nio.ch.DirectBuffer;
  33 
  34 /**
  35  * A class that can be used to compute the CRC-32C of a data stream.
  36  *
  37  * <p>
  38  * CRC-32C is defined in <a href="http://www.ietf.org/rfc/rfc3720.txt">RFC
  39  * 3720</a>: Internet Small Computer Systems Interface (iSCSI).
  40  * </p>
  41  *
  42  * <p>
  43  * Passing a {@code null} argument to a method in this class will cause a
  44  * {@link NullPointerException} to be thrown.
  45  * </p>
  46  *
  47  * @since 1.9
  48  */
  49 public final class CRC32C implements Checksum {
  50 
  51     /*
  52      * This CRC-32C implementation uses the 'slicing-by-8' algorithm described
  53      * in the paper "A Systematic Approach to Building High Performance
  54      * Software-Based CRC Generators" by Michael E. Kounavis and Frank L. Berry,
  55      * Intel Research and Development
  56      */
  57 
  58     /**
  59      * CRC-32C Polynomial
  60      */
  61     private static final int CRC32C_POLY = 0x1EDC6F41;
  62     private static final int REVERSED_CRC32C_POLY = Integer.reverse(CRC32C_POLY);
  63 
  64     private static final Unsafe UNSAFE = Unsafe.getUnsafe();
  65 
  66     // Lookup tables
  67     // Lookup table for single byte calculations




  27 import java.nio.ByteBuffer;
  28 import java.nio.ByteOrder;
  29 
  30 import jdk.internal.HotSpotIntrinsicCandidate;
  31 import jdk.internal.misc.Unsafe;
  32 import sun.nio.ch.DirectBuffer;
  33 
  34 /**
  35  * A class that can be used to compute the CRC-32C of a data stream.
  36  *
  37  * <p>
  38  * CRC-32C is defined in <a href="http://www.ietf.org/rfc/rfc3720.txt">RFC
  39  * 3720</a>: Internet Small Computer Systems Interface (iSCSI).
  40  * </p>
  41  *
  42  * <p>
  43  * Passing a {@code null} argument to a method in this class will cause a
  44  * {@link NullPointerException} to be thrown.
  45  * </p>
  46  *
  47  * @since 9
  48  */
  49 public final class CRC32C implements Checksum {
  50 
  51     /*
  52      * This CRC-32C implementation uses the 'slicing-by-8' algorithm described
  53      * in the paper "A Systematic Approach to Building High Performance
  54      * Software-Based CRC Generators" by Michael E. Kounavis and Frank L. Berry,
  55      * Intel Research and Development
  56      */
  57 
  58     /**
  59      * CRC-32C Polynomial
  60      */
  61     private static final int CRC32C_POLY = 0x1EDC6F41;
  62     private static final int REVERSED_CRC32C_POLY = Integer.reverse(CRC32C_POLY);
  63 
  64     private static final Unsafe UNSAFE = Unsafe.getUnsafe();
  65 
  66     // Lookup tables
  67     // Lookup table for single byte calculations


< prev index next >