test/jdk/java/nio/Buffer/BasicInt.java
author bpb
Wed, 20 Feb 2019 10:57:22 -0800
changeset 53855 7c362992527a
parent 47216 71c04702a3d5
child 53959 1542e63eb537
permissions -rw-r--r--
5029431: (bf) Add absolute bulk put and get methods Reviewed-by: alanb, darcy, chegar, rriggs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
53855
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
     2
 * Copyright (c) 2000, 2019, 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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4502
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4502
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4502
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/* Type-specific source code for unit test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * Regenerate the BasicX classes via genBasic.sh whenever this file changes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * We check in the generated source files so that the test tree can be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * independently of the rest of the source tree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
// -- This file was mechanically generated: Do not edit! -- //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.nio.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
public class BasicInt
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    extends Basic
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
4502
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    40
    private static final int[] VALUES = {
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    41
        Integer.MIN_VALUE,
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    42
        (int) -1,
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    43
        (int) 0,
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    44
        (int) 1,
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    45
        Integer.MAX_VALUE,
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    46
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    47
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    48
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    49
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    50
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    51
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    52
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    53
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    54
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    55
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    56
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    57
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    58
    };
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    59
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    private static void relGet(IntBuffer b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        int n = b.capacity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        for (int i = 0; i < n; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
            ck(b, (long)b.get(), (long)((int)ic(i)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        b.rewind();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    private static void relGet(IntBuffer b, int start) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        int n = b.remaining();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        for (int i = start; i < n; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
            ck(b, (long)b.get(), (long)((int)ic(i)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        b.rewind();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    private static void absGet(IntBuffer b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        int n = b.capacity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        for (int i = 0; i < n; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            ck(b, (long)b.get(), (long)((int)ic(i)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        b.rewind();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    private static void bulkGet(IntBuffer b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        int n = b.capacity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        int[] a = new int[n + 7];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        b.get(a, 7, n);
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
    85
        for (int i = 0; i < n; i++) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            ck(b, (long)a[i + 7], (long)((int)ic(i)));
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
    87
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
53855
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
    90
    private static void absBulkGet(IntBuffer b) {
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
    91
        int n = b.capacity();
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
    92
        int len = n - 7*2;
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
    93
        int[] a = new int[n + 7];
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
    94
        b.position(42);
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
    95
        b.get(7, a, 7, len);
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
    96
        ck(b, b.position() == 42);
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
    97
        for (int i = 0; i < len; i++) {
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
    98
            ck(b, (long)a[i + 7], (long)((int)ic(i)));
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
    99
        }
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   100
    }
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   101
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    private static void relPut(IntBuffer b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        int n = b.capacity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        b.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        for (int i = 0; i < n; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            b.put((int)ic(i));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        b.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    private static void absPut(IntBuffer b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        int n = b.capacity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        b.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        for (int i = 0; i < n; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            b.put(i, (int)ic(i));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        b.limit(n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        b.position(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    private static void bulkPutArray(IntBuffer b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        int n = b.capacity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        b.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        int[] a = new int[n + 7];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        for (int i = 0; i < n; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            a[i + 7] = (int)ic(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        b.put(a, 7, n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        b.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    private static void bulkPutBuffer(IntBuffer b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        int n = b.capacity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        b.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        IntBuffer c = IntBuffer.allocate(n + 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        c.position(7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        for (int i = 0; i < n; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            c.put((int)ic(i));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        c.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        c.position(7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        b.put(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        b.flip();
31873
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   140
        try {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   141
            b.put(b);
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   142
            fail("IllegalArgumentException expected for put into same buffer");
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   143
        } catch (IllegalArgumentException e) {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   144
            if (e.getMessage() == null) {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   145
                fail("Non-null IllegalArgumentException message expected from"
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   146
                     + " put into same buffer");
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   147
            }
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   148
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
53855
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   151
    private static void absBulkPutArray(IntBuffer b) {
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   152
        int n = b.capacity();
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   153
        b.clear();
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   154
        int lim = n - 7;
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   155
        int len = lim - 7;
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   156
        b.limit(lim);
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   157
        int[] a = new int[len + 7];
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   158
        for (int i = 0; i < len; i++)
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   159
            a[i + 7] = (int)ic(i);
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   160
        b.position(42);
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   161
        b.put(7, a, 7, len);
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   162
        ck(b, b.position() == 42);
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   163
    }
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   164
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    //6231529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    private static void callReset(IntBuffer b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        b.position(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        b.mark();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        b.duplicate().reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        b.asReadOnlyBuffer().reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    // 6221101-6234263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    private static void putBuffer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        final int cap = 10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        IntBuffer direct1 = ByteBuffer.allocateDirect(cap).asIntBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        IntBuffer nondirect1 = ByteBuffer.allocate(cap).asIntBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        direct1.put(nondirect1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        IntBuffer direct2 = ByteBuffer.allocateDirect(cap).asIntBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        IntBuffer nondirect2 = ByteBuffer.allocate(cap).asIntBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        nondirect2.put(direct2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        IntBuffer direct3 = ByteBuffer.allocateDirect(cap).asIntBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        IntBuffer direct4 = ByteBuffer.allocateDirect(cap).asIntBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        direct3.put(direct4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        IntBuffer nondirect3 = ByteBuffer.allocate(cap).asIntBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        IntBuffer nondirect4 = ByteBuffer.allocate(cap).asIntBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        nondirect3.put(nondirect4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    private static void checkSlice(IntBuffer b, IntBuffer slice) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        ck(slice, 0, slice.position());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        ck(slice, b.remaining(), slice.limit());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        ck(slice, b.remaining(), slice.capacity());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        if (b.isDirect() != slice.isDirect())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            fail("Lost direction", slice);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        if (b.isReadOnly() != slice.isReadOnly())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            fail("Lost read-only", slice);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
1634
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   339
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   340
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   341
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   342
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   343
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   344
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   345
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   346
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   347
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   348
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   349
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   350
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   351
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   352
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   353
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   354
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   355
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   356
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   357
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   358
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   359
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   360
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   361
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   362
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   363
36933
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   364
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   365
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   366
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   367
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   368
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   369
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   370
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   371
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   372
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   373
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   374
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   375
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   376
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   377
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   378
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   379
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   380
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   381
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   382
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   383
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   384
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   385
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   386
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   387
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   388
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   389
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   390
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   391
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   392
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   393
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   394
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   395
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   396
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   397
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   398
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   399
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   400
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   401
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   402
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   403
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   404
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   405
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   406
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   407
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   408
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   409
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   410
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   411
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   412
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   413
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   414
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   415
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   416
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   417
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   418
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   419
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   420
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   421
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   422
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   423
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   424
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   425
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   426
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   427
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   428
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   429
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   430
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   431
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   432
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   433
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   434
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   435
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   436
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   437
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   438
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   439
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   440
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   441
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   442
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   443
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   444
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   445
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   446
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   447
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   448
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   449
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   450
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   451
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   452
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   453
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   454
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   455
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   456
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   457
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   458
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   459
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   460
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   461
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   462
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   463
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   464
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   465
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   466
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   467
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   468
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   469
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   470
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   471
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   472
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   473
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   474
4502
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   475
    private static void fail(String problem,
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   476
                             IntBuffer xb, IntBuffer yb,
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   477
                             int x, int y) {
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   478
        fail(problem + String.format(": x=%s y=%s", x, y), xb, yb);
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   479
    }
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   480
53855
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   481
    private static void catchNullArgument(Buffer b, Runnable thunk) {
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   482
        tryCatch(b, NullPointerException.class, thunk);
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   483
    }
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   484
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   485
    private static void catchIllegalArgument(Buffer b, Runnable thunk) {
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   486
        tryCatch(b, IllegalArgumentException.class, thunk);
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   487
    }
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   488
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   489
    private static void catchReadOnlyBuffer(Buffer b, Runnable thunk) {
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   490
        tryCatch(b, ReadOnlyBufferException.class, thunk);
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   491
    }
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   492
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   493
    private static void catchIndexOutOfBounds(Buffer b, Runnable thunk) {
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   494
        tryCatch(b, IndexOutOfBoundsException.class, thunk);
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   495
    }
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   496
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   497
    private static void catchIndexOutOfBounds(int[] t, Runnable thunk) {
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   498
        tryCatch(t, IndexOutOfBoundsException.class, thunk);
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   499
    }
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   500
14001
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   501
    private static void tryCatch(Buffer b, Class<?> ex, Runnable thunk) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        boolean caught = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
            thunk.run();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        } catch (Throwable x) {
1634
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   506
            if (ex.isAssignableFrom(x.getClass())) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
                caught = true;
1634
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   508
            } else {
53855
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   509
                String s = x.getMessage();
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   510
                if (s == null)
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   511
                    s = x.getClass().getName();
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   512
                fail(s + " not expected");
1634
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   513
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        }
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   515
        if (!caught) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
            fail(ex.getName() + " not thrown", b);
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   517
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   520
    private static void tryCatch(int[] t, Class<?> ex, Runnable thunk) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        tryCatch(IntBuffer.wrap(t), ex, thunk);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
    public static void test(int level, final IntBuffer b, boolean direct) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        show(level, b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        if (direct != b.isDirect())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
            fail("Wrong direction", b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        // Gets and puts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
        relPut(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
        relGet(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        absGet(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        bulkGet(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        absPut(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        relGet(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        absGet(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        bulkGet(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        bulkPutArray(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        relGet(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        bulkPutBuffer(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        relGet(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
53855
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   549
        absBulkPutArray(b);
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   550
        absBulkGet(b);
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   551
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
2593
76032557be03 6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new buffer
alanb
parents: 1639
diff changeset
   574
76032557be03 6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new buffer
alanb
parents: 1639
diff changeset
   575
76032557be03 6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new buffer
alanb
parents: 1639
diff changeset
   576
13563
13c8e8f0302b 7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
luchsh
parents: 5506
diff changeset
   577
13c8e8f0302b 7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
luchsh
parents: 5506
diff changeset
   578
13c8e8f0302b 7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
luchsh
parents: 5506
diff changeset
   579
13c8e8f0302b 7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
luchsh
parents: 5506
diff changeset
   580
13c8e8f0302b 7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
luchsh
parents: 5506
diff changeset
   581
13c8e8f0302b 7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
luchsh
parents: 5506
diff changeset
   582
13c8e8f0302b 7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
luchsh
parents: 5506
diff changeset
   583
13c8e8f0302b 7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
luchsh
parents: 5506
diff changeset
   584
13c8e8f0302b 7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
luchsh
parents: 5506
diff changeset
   585
13c8e8f0302b 7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
luchsh
parents: 5506
diff changeset
   586
13c8e8f0302b 7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
luchsh
parents: 5506
diff changeset
   587
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        // Compact
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
        relPut(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        b.position(13);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        b.compact();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        b.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
        relGet(b, 13);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
        // Exceptions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
        relPut(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        b.limit(b.capacity() / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        b.position(b.limit());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   602
        tryCatch(b, BufferUnderflowException.class, () -> b.get());
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   603
        tryCatch(b, BufferOverflowException.class, () -> b.put((int)42));
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   604
        // The index must be non-negative and less than the buffer's limit.
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   605
        catchIndexOutOfBounds(b, () -> b.get(b.limit()));
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   606
        catchIndexOutOfBounds(b, () -> b.get(-1));
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   607
        catchIndexOutOfBounds(b, () -> b.put(b.limit(), (int)42));
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   608
        tryCatch(b, InvalidMarkException.class,
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   609
                () -> b.position(0).mark().compact().reset());
1634
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   610
31873
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   611
        try {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   612
            b.position(b.limit() + 1);
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   613
            fail("IllegalArgumentException expected for position beyond limit");
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   614
        } catch (IllegalArgumentException e) {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   615
            if (e.getMessage() == null) {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   616
                fail("Non-null IllegalArgumentException message expected for"
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   617
                     + " position beyond limit");
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   618
            }
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   619
        }
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   620
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   621
        try {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   622
            b.position(-1);
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   623
            fail("IllegalArgumentException expected for negative position");
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   624
        } catch (IllegalArgumentException e) {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   625
            if (e.getMessage() == null) {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   626
                fail("Non-null IllegalArgumentException message expected for"
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   627
                     + " negative position");
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   628
            }
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   629
        }
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   630
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   631
        try {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   632
            b.limit(b.capacity() + 1);
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   633
            fail("IllegalArgumentException expected for limit beyond capacity");
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   634
        } catch (IllegalArgumentException e) {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   635
            if (e.getMessage() == null) {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   636
                fail("Non-null IllegalArgumentException message expected for"
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   637
                     + " limit beyond capacity");
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   638
            }
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   639
        }
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   640
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   641
        try {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   642
            b.limit(-1);
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   643
            fail("IllegalArgumentException expected for negative limit");
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   644
        } catch (IllegalArgumentException e) {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   645
            if (e.getMessage() == null) {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   646
                fail("Non-null IllegalArgumentException message expected for"
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   647
                     + " negative limit");
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   648
            }
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   649
        }
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   650
53855
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   651
        // Exceptions in absolute bulk operations
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   652
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   653
        catchNullArgument(b, () -> b.get(7, null, 0, 42));
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   654
        catchNullArgument(b, () -> b.put(7, (int[])null, 0, 42));
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   655
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   656
        int[] tmpa = new int[42];
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   657
        catchIndexOutOfBounds(b, () -> b.get(7, tmpa, -1, 42));
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   658
        catchIndexOutOfBounds(b, () -> b.get(7, tmpa, 42, 1));
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   659
        catchIndexOutOfBounds(b, () -> b.get(7, tmpa, 41, -1));
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   660
        catchIndexOutOfBounds(b, () -> b.get(-1, tmpa, 0, 1));
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   661
        catchIndexOutOfBounds(b, () -> b.get(b.limit(), tmpa, 0, 1));
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   662
        catchIndexOutOfBounds(b, () -> b.get(b.limit() - 41, tmpa, 0, 42));
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   663
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   664
        catchIndexOutOfBounds(b, () -> b.put(7, tmpa, -1, 42));
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   665
        catchIndexOutOfBounds(b, () -> b.put(7, tmpa, 42, 1));
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   666
        catchIndexOutOfBounds(b, () -> b.put(7, tmpa, 41, -1));
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   667
        catchIndexOutOfBounds(b, () -> b.put(-1, tmpa, 0, 1));
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   668
        catchIndexOutOfBounds(b, () -> b.put(b.limit(), tmpa, 0, 1));
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   669
        catchIndexOutOfBounds(b, () -> b.put(b.limit() - 41, tmpa, 0, 42));
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   670
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        // Values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        b.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
        b.put((int)0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        b.put((int)-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        b.put((int)1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
        b.put(Integer.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
        b.put(Integer.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
        b.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        ck(b, b.get(), 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
        ck(b, b.get(), (int)-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
        ck(b, b.get(), 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
        ck(b, b.get(), Integer.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
        ck(b, b.get(), Integer.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
31873
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   724
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   725
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   726
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   727
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   728
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
        // Comparison
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
        b.rewind();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
        IntBuffer b2 = IntBuffer.allocate(b.capacity());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
        b2.put(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
        b2.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        b.position(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        b2.position(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
        if (!b.equals(b2)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
            for (int i = 2; i < b.limit(); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
                int x = b.get(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
                int y = b2.get(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
                if (x != y
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   747
                    ) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
                    out.println("[" + i + "] " + x + " != " + y);
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   749
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
            fail("Identical buffers not equal", b, b2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
        }
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   753
        if (b.compareTo(b2) != 0) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
            fail("Comparison to identical buffer != 0", b, b2);
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   755
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
        b.limit(b.limit() + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
        b.position(b.limit() - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
        b.put((int)99);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        b.rewind();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        b2.rewind();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
        if (b.equals(b2))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
            fail("Non-identical buffers equal", b, b2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
        if (b.compareTo(b2) <= 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
            fail("Comparison to shorter buffer <= 0", b, b2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
        b.limit(b.limit() - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
        b.put(2, (int)42);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
        if (b.equals(b2))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
            fail("Non-identical buffers equal", b, b2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
        if (b.compareTo(b2) <= 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
            fail("Comparison to lesser buffer <= 0", b, b2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
4502
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   773
        // Check equals and compareTo with interesting values
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   774
        for (int x : VALUES) {
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   775
            IntBuffer xb = IntBuffer.wrap(new int[] { x });
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   776
            if (xb.compareTo(xb) != 0) {
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   777
                fail("compareTo not reflexive", xb, xb, x, x);
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   778
            }
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   779
            if (!xb.equals(xb)) {
4502
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   780
                fail("equals not reflexive", xb, xb, x, x);
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   781
            }
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   782
            for (int y : VALUES) {
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   783
                IntBuffer yb = IntBuffer.wrap(new int[] { y });
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   784
                if (xb.compareTo(yb) != - yb.compareTo(xb)) {
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   785
                    fail("compareTo not anti-symmetric",
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   786
                         xb, yb, x, y);
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   787
                }
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   788
                if ((xb.compareTo(yb) == 0) != xb.equals(yb)) {
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   789
                    fail("compareTo inconsistent with equals",
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   790
                         xb, yb, x, y);
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   791
                }
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   792
                if (xb.compareTo(yb) != Integer.compare(x, y)) {
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   793
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   794
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   795
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   796
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   797
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   798
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   799
                    fail("Incorrect results for IntBuffer.compareTo",
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   800
                         xb, yb, x, y);
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   801
                }
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   802
                if (xb.equals(yb) != ((x == y) || ((x != x) && (y != y)))) {
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   803
                    fail("Incorrect results for IntBuffer.equals",
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   804
                         xb, yb, x, y);
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   805
                }
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   806
            }
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   807
        }
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   808
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
        // Sub, dup
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
        relPut(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
        relGet(b.duplicate());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
        b.position(13);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
        relGet(b.duplicate(), 13);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        relGet(b.duplicate().slice(), 13);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
        relGet(b.slice(), 13);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
        relGet(b.slice().duplicate(), 13);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
        // Slice
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
        b.position(5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
        IntBuffer sb = b.slice();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
        checkSlice(b, sb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
        b.position(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        IntBuffer sb2 = sb.slice();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
        checkSlice(sb, sb2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
        if (!sb.equals(sb2))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
            fail("Sliced slices do not match", sb, sb2);
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   830
        if ((sb.hasArray()) && (sb.arrayOffset() != sb2.arrayOffset())) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
            fail("Array offsets do not match: "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
                 + sb.arrayOffset() + " != " + sb2.arrayOffset(), sb, sb2);
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   833
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
        // Read-only views
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
        b.rewind();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
        final IntBuffer rb = b.asReadOnlyBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
        if (!b.equals(rb))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
            fail("Buffer not equal to read-only view", b, rb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
        show(level + 1, rb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   874
        catchReadOnlyBuffer(b, () -> relPut(rb));
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   875
        catchReadOnlyBuffer(b, () -> absPut(rb));
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   876
        catchReadOnlyBuffer(b, () -> bulkPutArray(rb));
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   877
        catchReadOnlyBuffer(b, () -> bulkPutBuffer(rb));
53855
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   878
        catchReadOnlyBuffer(b, () -> absBulkPutArray(rb));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
14001
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   880
        // put(IntBuffer) should not change source position
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   881
        final IntBuffer src = IntBuffer.allocate(1);
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   882
        catchReadOnlyBuffer(b, () -> rb.put(src));
14001
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   883
        ck(src, src.position(), 0);
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   884
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   885
        catchReadOnlyBuffer(b, () -> rb.compact());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
14001
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   896
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   897
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   898
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   899
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   900
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   901
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   902
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   903
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   904
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   905
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   906
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   907
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   908
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   909
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   910
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   911
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
        if (rb.getClass().getName().startsWith("java.nio.Heap")) {
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   913
            catchReadOnlyBuffer(b, () -> rb.array());
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   914
            catchReadOnlyBuffer(b, () -> rb.arrayOffset());
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   915
            if (rb.hasArray()) {
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   916
                fail("Read-only heap buffer's backing array is accessible", rb);
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   917
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
        // Bulk puts from read-only buffers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
        b.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
        rb.rewind();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
        b.put(rb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
        relPut(b);                       // Required by testViews
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
36933
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   938
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   939
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   940
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   941
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   942
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
53855
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   988
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   989
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   990
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   991
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   992
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   993
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 47216
diff changeset
   994
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
    public static void test(final int [] ba) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
        int offset = 47;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
        int length = 900;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
        final IntBuffer b = IntBuffer.wrap(ba, offset, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
        show(0, b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
        ck(b, b.capacity(), ba.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
        ck(b, b.position(), offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
        ck(b, b.limit(), offset + length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
        // The offset must be non-negative and no larger than <array.length>.
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
  1005
        catchIndexOutOfBounds(ba, () -> IntBuffer.wrap(ba, -1, ba.length));
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
  1006
        catchIndexOutOfBounds(ba, () -> IntBuffer.wrap(ba, ba.length + 1, ba.length));
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
  1007
        catchIndexOutOfBounds(ba, () -> IntBuffer.wrap(ba, 0, -1));
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
  1008
        catchIndexOutOfBounds(ba, () -> IntBuffer.wrap(ba, 0, ba.length + 1));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
        // A NullPointerException will be thrown if the array is null.
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
  1011
        tryCatch(ba, NullPointerException.class,
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
  1012
                () -> IntBuffer.wrap((int []) null, 0, 5));
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
  1013
        tryCatch(ba, NullPointerException.class,
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
  1014
                () -> IntBuffer.wrap((int []) null));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
    private static void testAllocate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
        // An IllegalArgumentException will be thrown for negative capacities.
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
  1019
        catchIllegalArgument((Buffer) null, () -> IntBuffer.allocate(-1));
31873
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
  1020
        try {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
  1021
            IntBuffer.allocate(-1);
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
  1022
        } catch (IllegalArgumentException e) {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
  1023
            if (e.getMessage() == null) {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
  1024
                fail("Non-null IllegalArgumentException message expected for"
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
  1025
                     + " attempt to allocate negative capacity buffer");
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
  1026
            }
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
  1027
        }
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
  1028
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
  1029
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
  1030
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
  1031
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
  1032
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
  1033
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
  1034
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
  1035
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
    public static void test() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
        testAllocate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
        test(0, IntBuffer.allocate(7 * 1024), false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
        test(0, IntBuffer.wrap(new int[7 * 1024], 0, 7 * 1024), false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
        test(new int[1024]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
        callReset(IntBuffer.allocate(10));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
        putBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
}