jdk/src/java.base/share/classes/java/util/zip/CRC32.java
author martin
Tue, 15 Sep 2015 21:56:04 -0700
changeset 32649 2ee9017c7597
parent 31671 362e0c0acece
child 45434 4582657c7260
permissions -rw-r--r--
8136583: Core libraries should use blessed modifier order Summary: Run blessed-modifier-order script (see bug) Reviewed-by: psandoz, chegar, alanb, plevart
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
27737
0a3fb0529425 6321472: Add CRC-32C API
sherman
parents: 25859
diff changeset
     2
 * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3078
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3078
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3078
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3078
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3078
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.util.zip;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
11113
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
    28
import java.nio.ByteBuffer;
31671
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
    29
import java.util.Objects;
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
    30
11113
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
    31
import sun.nio.ch.DirectBuffer;
31671
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
    32
import jdk.internal.HotSpotIntrinsicCandidate;
11113
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
    33
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * A class that can be used to compute the CRC-32 of a data stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
11113
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
    37
 * <p> Passing a {@code null} argument to a method in this class will cause
27737
0a3fb0529425 6321472: Add CRC-32C API
sherman
parents: 25859
diff changeset
    38
 * a {@link NullPointerException} to be thrown.</p>
11113
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
    39
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * @author      David Connelly
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
public
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
class CRC32 implements Checksum {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    private int crc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     * Creates a new CRC32 object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    public CRC32() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    /**
3078
c491f0d2a8aa 6707281: Adler32.update() JavaDoc is wrong
sherman
parents: 2
diff changeset
    54
     * Updates the CRC-32 checksum with the specified byte (the low
c491f0d2a8aa 6707281: Adler32.update() JavaDoc is wrong
sherman
parents: 2
diff changeset
    55
     * eight bits of the argument b).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     */
27737
0a3fb0529425 6321472: Add CRC-32C API
sherman
parents: 25859
diff changeset
    57
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    public void update(int b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        crc = update(crc, b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    /**
3078
c491f0d2a8aa 6707281: Adler32.update() JavaDoc is wrong
sherman
parents: 2
diff changeset
    63
     * Updates the CRC-32 checksum with the specified array of bytes.
19415
af60b1abf237 7154662: {CRC32, Adler32}.update(byte[] b, int off, int len): undocumented ArrayIndexOutOfBoundsException
sherman
parents: 14342
diff changeset
    64
     *
27737
0a3fb0529425 6321472: Add CRC-32C API
sherman
parents: 25859
diff changeset
    65
     * @throws ArrayIndexOutOfBoundsException
0a3fb0529425 6321472: Add CRC-32C API
sherman
parents: 25859
diff changeset
    66
     *         if {@code off} is negative, or {@code len} is negative, or
0a3fb0529425 6321472: Add CRC-32C API
sherman
parents: 25859
diff changeset
    67
     *         {@code off+len} is negative or greater than the length of
0a3fb0529425 6321472: Add CRC-32C API
sherman
parents: 25859
diff changeset
    68
     *         the array {@code b}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     */
27737
0a3fb0529425 6321472: Add CRC-32C API
sherman
parents: 25859
diff changeset
    70
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    public void update(byte[] b, int off, int len) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        if (b == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        if (off < 0 || len < 0 || off > b.length - len) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            throw new ArrayIndexOutOfBoundsException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        crc = updateBytes(crc, b, off, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    /**
27737
0a3fb0529425 6321472: Add CRC-32C API
sherman
parents: 25859
diff changeset
    82
     * Updates the CRC-32 checksum with the bytes from the specified buffer.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     *
27737
0a3fb0529425 6321472: Add CRC-32C API
sherman
parents: 25859
diff changeset
    84
     * The checksum is updated with the remaining bytes in the buffer, starting
0a3fb0529425 6321472: Add CRC-32C API
sherman
parents: 25859
diff changeset
    85
     * at the buffer's position. Upon return, the buffer's position will be
0a3fb0529425 6321472: Add CRC-32C API
sherman
parents: 25859
diff changeset
    86
     * updated to its limit; its limit will not have been changed.
11113
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
    87
     *
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
    88
     * @since 1.8
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
    89
     */
27737
0a3fb0529425 6321472: Add CRC-32C API
sherman
parents: 25859
diff changeset
    90
    @Override
11113
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
    91
    public void update(ByteBuffer buffer) {
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
    92
        int pos = buffer.position();
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
    93
        int limit = buffer.limit();
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
    94
        assert (pos <= limit);
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
    95
        int rem = limit - pos;
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
    96
        if (rem <= 0)
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
    97
            return;
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
    98
        if (buffer instanceof DirectBuffer) {
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
    99
            crc = updateByteBuffer(crc, ((DirectBuffer)buffer).address(), pos, rem);
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
   100
        } else if (buffer.hasArray()) {
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
   101
            crc = updateBytes(crc, buffer.array(), pos + buffer.arrayOffset(), rem);
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
   102
        } else {
27737
0a3fb0529425 6321472: Add CRC-32C API
sherman
parents: 25859
diff changeset
   103
            byte[] b = new byte[Math.min(buffer.remaining(), 4096)];
0a3fb0529425 6321472: Add CRC-32C API
sherman
parents: 25859
diff changeset
   104
            while (buffer.hasRemaining()) {
0a3fb0529425 6321472: Add CRC-32C API
sherman
parents: 25859
diff changeset
   105
                int length = Math.min(buffer.remaining(), b.length);
0a3fb0529425 6321472: Add CRC-32C API
sherman
parents: 25859
diff changeset
   106
                buffer.get(b, 0, length);
0a3fb0529425 6321472: Add CRC-32C API
sherman
parents: 25859
diff changeset
   107
                update(b, 0, length);
0a3fb0529425 6321472: Add CRC-32C API
sherman
parents: 25859
diff changeset
   108
            }
11113
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
   109
        }
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
   110
        buffer.position(limit);
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
   111
    }
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
   112
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
   113
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * Resets CRC-32 to initial value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     */
27737
0a3fb0529425 6321472: Add CRC-32C API
sherman
parents: 25859
diff changeset
   116
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    public void reset() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        crc = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * Returns CRC-32 value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     */
27737
0a3fb0529425 6321472: Add CRC-32C API
sherman
parents: 25859
diff changeset
   124
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    public long getValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        return (long)crc & 0xffffffffL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
31671
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   129
    @HotSpotIntrinsicCandidate
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 31671
diff changeset
   130
    private static native int update(int crc, int b);
31671
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   131
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   132
    private static int updateBytes(int crc, byte[] b, int off, int len) {
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   133
        updateBytesCheck(b, off, len);
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   134
        return updateBytes0(crc, b, off, len);
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   135
    }
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   136
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   137
    @HotSpotIntrinsicCandidate
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 31671
diff changeset
   138
    private static native int updateBytes0(int crc, byte[] b, int off, int len);
31671
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   139
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   140
    private static void updateBytesCheck(byte[] b, int off, int len) {
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   141
        if (len <= 0) {
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   142
            return;  // not an error because updateBytesImpl won't execute if len <= 0
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   143
        }
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   144
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   145
        Objects.requireNonNull(b);
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   146
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   147
        if (off < 0 || off >= b.length) {
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   148
            throw new ArrayIndexOutOfBoundsException(off);
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   149
        }
11113
f7248a4db8db 7109837: Provide a mechanism for computing an Adler32 checksum for the contents of a ByteBuffer
sherman
parents: 5506
diff changeset
   150
31671
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   151
        int endIndex = off + len - 1;
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   152
        if (endIndex < 0 || endIndex >= b.length) {
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   153
            throw new ArrayIndexOutOfBoundsException(endIndex);
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   154
        }
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   155
    }
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   156
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   157
    private static int updateByteBuffer(int alder, long addr,
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   158
                                        int off, int len) {
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   159
        updateByteBufferCheck(addr);
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   160
        return updateByteBuffer0(alder, addr, off, len);
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   161
    }
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   162
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   163
    @HotSpotIntrinsicCandidate
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 31671
diff changeset
   164
    private static native int updateByteBuffer0(int alder, long addr,
31671
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   165
                                                int off, int len);
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   166
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   167
    private static void updateByteBufferCheck(long addr) {
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   168
        // Performs only a null check because bounds checks
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   169
        // are not easy to do on raw addresses.
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   170
        if (addr == 0L) {
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   171
            throw new NullPointerException();
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   172
        }
362e0c0acece 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents: 27737
diff changeset
   173
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
}