JDK-6321472 : Add CRC32C class, similar to java.util.zip.CRC32
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util.jar
  • Affected Version: 5.0u1
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_10
  • CPU: generic
  • Submitted: 2005-09-08
  • Updated: 2017-11-15
  • Resolved: 2014-11-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b42Fixed
Related Reports
Relates :  
Relates :  
Description
see comments.

Comments
I think that was caused by the "wrong" endianness. I have an implementation that generates the same result.
22-08-2014

SUGGESTED FIX /* * ident "@(#)CRC32C.java 1.1 05/09/07 SMI" * * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ package java.util.zip; import java.util.zip.Checksum; /** * JIST CRC32C Calculator, not part of Java 5.0 SE. * <p> * This class is derived from <a href="http://www.faqs.org/rfcs/rfc3309.html"> * IETF RFC 3309</a>: Stream Control Transmission Protocol (SCTP) Checksum * Change and <a href="http://www.faqs.org/rfcs/rfc3385.html">IETF RFC 3385</a>: * Internet Protocol Small Computer System Interface (iSCSI) Cyclic Redundancy * Check (CRC)/Checksum Considerations. * <p> * This class is NOT thread safe to increase performance. * <p> * @author ###@###.### * @version 1.1, 09/07/05 16:39:45 * @since 1.5.0 */ public class CRC32C implements Checksum { /** CRC32C Constant. */ public final static int CRC32C_POLY = 0x1EDC6F41; /** CRC32C Polynomials. */ private static int[] polys; /** CRC32C Current Value. */ private int value; /** Initialize "static" Class Variables. */ static { polys = new int[256]; for (int inx = 256; --inx > 0; ) { polys[inx] = build(inx); } } /** Initialize non-"static" Instance Variables. */ { value = 0; } /** Default Construction for Mainline Testing. */ /* public CRC32C() {} */ /** * Returns CRC-32C value. */ public final long getValue() { return value; } /** * Resets CRC-32C to initial value. */ public final void reset() { value = 0; } /** * Updates checksum with specified array of bytes. */ public final void update(byte[] b) { update(b, 0, b.length); } /** * Updates CRC-32C with specified array of bytes. */ public final void update(byte[] b, int off, int len) { value = (int)( ((value >>> 24) & 0x0000000ff) | ((value >>> 8) & 0x00000ff00) | ((value << 8) & 0x000ff0000) | ((value << 24) & 0x0ff000000)) ^ 0x0ffffffff; while (--len >= 0) { value = ((value >>> 8) ^ polys[(value ^ (b[off++])) & 0x0ff]); } value = (int)( ((value >>> 24) & 0x0000000ff) | ((value >>> 8) & 0x00000ff00) | ((value << 8) & 0x000ff0000) | ((value << 24) & 0x0ff000000)) ^ 0x0ffffffff; } /** * Updates CRC-32C with specified byte. */ public final void update(int b) { update(new byte[] { (byte)((b >>> 24) & 0x0ff), (byte)((b >>> 16) & 0x0ff), (byte)((b >>> 8) & 0x0ff), (byte)(b & 0x0ff)}, 0, 4); } /** * Reflect a 32 bit quantity. */ private final static int reflect(int b) { return (int)( ((b >>> 31) & 0x000000001) | ((b >>> 29) & 0x000000002) | ((b >>> 27) & 0x000000004) | ((b >>> 25) & 0x000000008) | ((b >>> 23) & 0x000000010) | ((b >>> 21) & 0x000000020) | ((b >>> 19) & 0x000000040) | ((b >>> 17) & 0x000000080) | ((b >>> 15) & 0x000000100) | ((b >>> 13) & 0x000000200) | ((b >>> 11) & 0x000000400) | ((b >>> 9) & 0x000000800) | ((b >>> 7) & 0x000001000) | ((b >>> 5) & 0x000002000) | ((b >>> 3) & 0x000004000) | ((b >>> 1) & 0x000008000) | ((b << 1) & 0x000010000) | ((b << 3) & 0x000020000) | ((b << 5) & 0x000040000) | ((b << 7) & 0x000080000) | ((b << 9) & 0x000100000) | ((b << 11) & 0x000200000) | ((b << 13) & 0x000400000) | ((b << 15) & 0x000800000) | ((b << 17) & 0x001000000) | ((b << 19) & 0x002000000) | ((b << 21) & 0x004000000) | ((b << 23) & 0x008000000) | ((b << 25) & 0x010000000) | ((b << 27) & 0x020000000) | ((b << 29) & 0x040000000) | ((b << 31) & 0x080000000)); } /** * Build CRC32C Table. */ private final static int build(int index) { int i = 0, r = reflect(index); while (++i < 9) { if ((r & 0x080000000) != 0) { r = (r << 1) ^ CRC32C_POLY; } else { r <<= 1; } } return (reflect(r)); } } /* Class End */
08-09-2005