jdk/src/java.base/share/classes/java/util/zip/CRC32C.java
changeset 28064 cd22a60e9459
parent 27804 4659e70271c4
child 31671 362e0c0acece
equal deleted inserted replaced
28063:997c263dff16 28064:cd22a60e9459
   202     }
   202     }
   203 
   203 
   204     /**
   204     /**
   205      * Updates the CRC-32C checksum with the specified array of bytes.
   205      * Updates the CRC-32C checksum with the specified array of bytes.
   206      */
   206      */
   207     @SuppressWarnings("deprecation") // Unsafe.{getInt, getLong}
       
   208     private static int updateBytes(int crc, byte[] b, int off, int end) {
   207     private static int updateBytes(int crc, byte[] b, int off, int end) {
   209 
   208 
   210         // Do only byte reads for arrays so short they can't be aligned
   209         // Do only byte reads for arrays so short they can't be aligned
   211         // or if bytes are stored with a larger witdh than one byte.,%
   210         // or if bytes are stored with a larger witdh than one byte.,%
   212         if (end - off >= 8 && Unsafe.ARRAY_BYTE_INDEX_SCALE == 1) {
   211         if (end - off >= 8 && Unsafe.ARRAY_BYTE_INDEX_SCALE == 1) {
   226             for (; off < (end - Long.BYTES); off += Long.BYTES) {
   225             for (; off < (end - Long.BYTES); off += Long.BYTES) {
   227                 int firstHalf;
   226                 int firstHalf;
   228                 int secondHalf;
   227                 int secondHalf;
   229                 if (Unsafe.ADDRESS_SIZE == 4) {
   228                 if (Unsafe.ADDRESS_SIZE == 4) {
   230                     // On 32 bit platforms read two ints instead of a single 64bit long
   229                     // On 32 bit platforms read two ints instead of a single 64bit long
   231                     firstHalf = UNSAFE.getInt(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
   230                     firstHalf = UNSAFE.getInt(b, (long)Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
   232                     secondHalf = UNSAFE.getInt(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + off
   231                     secondHalf = UNSAFE.getInt(b, (long)Unsafe.ARRAY_BYTE_BASE_OFFSET + off
   233                                                + Integer.BYTES);
   232                                                + Integer.BYTES);
   234                 } else {
   233                 } else {
   235                     long value = UNSAFE.getLong(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
   234                     long value = UNSAFE.getLong(b, (long)Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
   236                     if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
   235                     if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
   237                         firstHalf = (int) value;
   236                         firstHalf = (int) value;
   238                         secondHalf = (int) (value >>> 32);
   237                         secondHalf = (int) (value >>> 32);
   239                     } else { // ByteOrder.BIG_ENDIAN
   238                     } else { // ByteOrder.BIG_ENDIAN
   240                         firstHalf = (int) (value >>> 32);
   239                         firstHalf = (int) (value >>> 32);