[
https://issues.apache.org/jira/browse/CODEC-171?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16075134#comment-16075134
]
Simon Spero commented on CODEC-171:
-----------------------------------
This class becomes redundant in JDK 9, which introduces
[java.util.zip.CRC32C|http://download.java.net/java/jdk9/docs/api/java/util/zip/CRC32C.html],
which as one might expect, implements j.u.z.Checksum.
Both implementations use the same basic approach. The main differences are (a)
that the hadoop/Commons Codec implementation has hardcoded lookup tables,
whilst the oracle one calculates them on startup, and (b) a few methods like
these :
{code:java}
/** Updates the CRC-32C checksum with the specified array of bytes. */
@HotSpotIntrinsicCandidate
private static int updateBytes(int crc, byte[] b, int off, int end) {
[...]
}
/**Updates the CRC-32C checksum reading from the specified address. */
@HotSpotIntrinsicCandidate
private static int updateDirectByteBuffer(int crc, long address, int off,
int end) {
[...]
}
{code}
Notice the HotSpotIntrinsicCandidate annotations... on hotspot, the java code
for these methods will almost certainly not get called; instead calls to the
methods will be replaced by architecture specific code, using any available
hardware support.
The commons codec code is useful for jdk 8 and earlier, but should not be used
on 9.
One possible approach would be to generate a multi-release jar with a JDK 9+
specific version of the code that delegates to the native implementation (the
class if final, so delegation is required). Current maven support for MR jars
is... incomplete...
> Add support for CRC32-C
> -----------------------
>
> Key: CODEC-171
> URL: https://issues.apache.org/jira/browse/CODEC-171
> Project: Commons Codec
> Issue Type: Improvement
> Reporter: Brett Okken
> Fix For: 1.11
>
>
> Add a java CRC32-C java.util.zip.Checksum implementation.
> There is a PureJavaCrc32C implementation that is part of
> apache-hadoop-common. It would be great to have that more easily consummable
> with far fewer transitive dependencies.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)