jdk/test/java/nio/Buffer/BasicLong.java
author prappo
Mon, 16 May 2016 09:54:01 +0100
changeset 37913 3cc95b690353
parent 36933 3e6453e2d833
permissions -rw-r--r--
8156931: java.nio.Buffer tests cleanup Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
36933
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
     2
 * Copyright (c) 2000, 2016, 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 BasicLong
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 long[] VALUES = {
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    41
        Long.MIN_VALUE,
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    42
        (long) -1,
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    43
        (long) 0,
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    44
        (long) 1,
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
    45
        Long.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(LongBuffer 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)((long)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(LongBuffer 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)((long)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(LongBuffer 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)((long)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(LongBuffer b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        int n = b.capacity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        long[] a = new long[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)((long)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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    private static void relPut(LongBuffer b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        int n = b.capacity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        b.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        for (int i = 0; i < n; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            b.put((long)ic(i));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        b.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    private static void absPut(LongBuffer b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        int n = b.capacity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        b.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        for (int i = 0; i < n; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            b.put(i, (long)ic(i));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        b.limit(n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        b.position(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    private static void bulkPutArray(LongBuffer b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        int n = b.capacity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        b.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        long[] a = new long[n + 7];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        for (int i = 0; i < n; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            a[i + 7] = (long)ic(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        b.put(a, 7, n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        b.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    private static void bulkPutBuffer(LongBuffer b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        int n = b.capacity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        b.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        LongBuffer c = LongBuffer.allocate(n + 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        c.position(7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        for (int i = 0; i < n; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            c.put((long)ic(i));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        c.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        c.position(7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        b.put(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        b.flip();
31873
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   128
        try {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   129
            b.put(b);
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   130
            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
   131
        } catch (IllegalArgumentException e) {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   132
            if (e.getMessage() == null) {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   133
                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
   134
                     + " put into same buffer");
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   135
            }
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   136
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    //6231529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    private static void callReset(LongBuffer b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        b.position(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        b.mark();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        b.duplicate().reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        b.asReadOnlyBuffer().reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    // 6221101-6234263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    private static void putBuffer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        final int cap = 10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        LongBuffer direct1 = ByteBuffer.allocateDirect(cap).asLongBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        LongBuffer nondirect1 = ByteBuffer.allocate(cap).asLongBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        direct1.put(nondirect1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        LongBuffer direct2 = ByteBuffer.allocateDirect(cap).asLongBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        LongBuffer nondirect2 = ByteBuffer.allocate(cap).asLongBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        nondirect2.put(direct2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        LongBuffer direct3 = ByteBuffer.allocateDirect(cap).asLongBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        LongBuffer direct4 = ByteBuffer.allocateDirect(cap).asLongBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        direct3.put(direct4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        LongBuffer nondirect3 = ByteBuffer.allocate(cap).asLongBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        LongBuffer nondirect4 = ByteBuffer.allocate(cap).asLongBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        nondirect3.put(nondirect4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    private static void checkSlice(LongBuffer b, LongBuffer slice) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        ck(slice, 0, slice.position());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        ck(slice, b.remaining(), slice.limit());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        ck(slice, b.remaining(), slice.capacity());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        if (b.isDirect() != slice.isDirect())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            fail("Lost direction", slice);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        if (b.isReadOnly() != slice.isReadOnly())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            fail("Lost read-only", slice);
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
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
1634
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   313
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   314
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   315
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   316
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   317
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   318
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   319
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   320
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   321
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   322
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   323
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   324
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   325
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   326
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   327
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   328
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   329
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   330
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   331
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   332
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   333
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   334
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   335
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   336
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   337
36933
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   338
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   339
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   340
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   341
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   342
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   343
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   344
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   345
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   346
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   347
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   348
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   349
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   350
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   351
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   352
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   353
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   354
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   355
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   356
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   357
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   358
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   359
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   360
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   361
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   362
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   363
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
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   435
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   436
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   437
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   438
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   439
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   440
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   441
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   442
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   443
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   444
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   445
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   446
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   447
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   448
4502
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   449
    private static void fail(String problem,
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   450
                             LongBuffer xb, LongBuffer yb,
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   451
                             long x, long y) {
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   452
        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
   453
    }
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   454
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   455
    private static void catchIllegalArgument(Buffer b, Runnable thunk) {
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   456
        tryCatch(b, IllegalArgumentException.class, thunk);
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   457
    }
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   458
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   459
    private static void catchReadOnlyBuffer(Buffer b, Runnable thunk) {
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   460
        tryCatch(b, ReadOnlyBufferException.class, thunk);
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
    private static void catchIndexOutOfBounds(Buffer b, Runnable thunk) {
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   464
        tryCatch(b, IndexOutOfBoundsException.class, thunk);
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
    private static void catchIndexOutOfBounds(long[] t, Runnable thunk) {
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   468
        tryCatch(t, IndexOutOfBoundsException.class, thunk);
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
14001
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   471
    private static void tryCatch(Buffer b, Class<?> ex, Runnable thunk) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        boolean caught = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
            thunk.run();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        } catch (Throwable x) {
1634
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   476
            if (ex.isAssignableFrom(x.getClass())) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
                caught = true;
1634
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   478
            } else {
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   479
                fail(x.getMessage() + " not expected");
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   480
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        }
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   482
        if (!caught) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
            fail(ex.getName() + " not thrown", b);
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   484
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   487
    private static void tryCatch(long[] t, Class<?> ex, Runnable thunk) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        tryCatch(LongBuffer.wrap(t), ex, thunk);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    public static void test(int level, final LongBuffer b, boolean direct) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        show(level, b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        if (direct != b.isDirect())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
            fail("Wrong direction", b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        // Gets and puts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        relPut(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        relGet(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        absGet(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        bulkGet(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        absPut(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        relGet(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        absGet(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        bulkGet(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        bulkPutArray(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        relGet(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        bulkPutBuffer(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        relGet(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
2593
76032557be03 6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new buffer
alanb
parents: 1639
diff changeset
   538
76032557be03 6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new buffer
alanb
parents: 1639
diff changeset
   539
76032557be03 6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new buffer
alanb
parents: 1639
diff changeset
   540
13563
13c8e8f0302b 7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
luchsh
parents: 5506
diff changeset
   541
13c8e8f0302b 7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
luchsh
parents: 5506
diff changeset
   542
13c8e8f0302b 7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
luchsh
parents: 5506
diff changeset
   543
13c8e8f0302b 7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
luchsh
parents: 5506
diff changeset
   544
13c8e8f0302b 7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
luchsh
parents: 5506
diff changeset
   545
13c8e8f0302b 7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
luchsh
parents: 5506
diff changeset
   546
13c8e8f0302b 7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
luchsh
parents: 5506
diff changeset
   547
13c8e8f0302b 7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
luchsh
parents: 5506
diff changeset
   548
13c8e8f0302b 7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
luchsh
parents: 5506
diff changeset
   549
13c8e8f0302b 7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
luchsh
parents: 5506
diff changeset
   550
13c8e8f0302b 7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
luchsh
parents: 5506
diff changeset
   551
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        // Compact
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        relPut(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        b.position(13);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        b.compact();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        b.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        relGet(b, 13);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        // Exceptions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        relPut(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
        b.limit(b.capacity() / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        b.position(b.limit());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   566
        tryCatch(b, BufferUnderflowException.class, () -> b.get());
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   567
        tryCatch(b, BufferOverflowException.class, () -> b.put((long)42));
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   568
        // 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
   569
        catchIndexOutOfBounds(b, () -> b.get(b.limit()));
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   570
        catchIndexOutOfBounds(b, () -> b.get(-1));
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   571
        catchIndexOutOfBounds(b, () -> b.put(b.limit(), (long)42));
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   572
        tryCatch(b, InvalidMarkException.class,
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   573
                () -> b.position(0).mark().compact().reset());
1634
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 2
diff changeset
   574
31873
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   575
        try {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   576
            b.position(b.limit() + 1);
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   577
            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
   578
        } catch (IllegalArgumentException e) {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   579
            if (e.getMessage() == null) {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   580
                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
   581
                     + " position beyond limit");
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   582
            }
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   583
        }
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   584
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   585
        try {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   586
            b.position(-1);
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   587
            fail("IllegalArgumentException expected for negative position");
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   588
        } catch (IllegalArgumentException e) {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   589
            if (e.getMessage() == null) {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   590
                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
   591
                     + " negative position");
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   592
            }
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   593
        }
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   594
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   595
        try {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   596
            b.limit(b.capacity() + 1);
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   597
            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
   598
        } catch (IllegalArgumentException e) {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   599
            if (e.getMessage() == null) {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   600
                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
   601
                     + " limit beyond capacity");
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   602
            }
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   603
        }
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   604
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   605
        try {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   606
            b.limit(-1);
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   607
            fail("IllegalArgumentException expected for negative limit");
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   608
        } catch (IllegalArgumentException e) {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   609
            if (e.getMessage() == null) {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   610
                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
   611
                     + " negative limit");
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   612
            }
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   613
        }
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   614
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        // Values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
        b.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
        b.put((long)0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        b.put((long)-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        b.put((long)1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        b.put(Long.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        b.put(Long.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        b.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        ck(b, b.get(), 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        ck(b, b.get(), (long)-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
        ck(b, b.get(), 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
        ck(b, b.get(), Long.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
        ck(b, b.get(), Long.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
31873
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   668
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   669
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   670
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   671
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   672
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        // Comparison
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
        b.rewind();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        LongBuffer b2 = LongBuffer.allocate(b.capacity());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        b2.put(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
        b2.flip();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
        b.position(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
        b2.position(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        if (!b.equals(b2)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
            for (int i = 2; i < b.limit(); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
                long x = b.get(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
                long y = b2.get(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
                if (x != y
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
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   691
                    ) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
                    out.println("[" + i + "] " + x + " != " + y);
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   693
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
            fail("Identical buffers not equal", b, b2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
        }
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   697
        if (b.compareTo(b2) != 0) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
            fail("Comparison to identical buffer != 0", b, b2);
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   699
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
        b.limit(b.limit() + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
        b.position(b.limit() - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
        b.put((long)99);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
        b.rewind();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
        b2.rewind();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
        if (b.equals(b2))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
            fail("Non-identical buffers equal", b, b2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
        if (b.compareTo(b2) <= 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
            fail("Comparison to shorter buffer <= 0", b, b2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
        b.limit(b.limit() - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
        b.put(2, (long)42);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
        if (b.equals(b2))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
            fail("Non-identical buffers equal", b, b2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
        if (b.compareTo(b2) <= 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
            fail("Comparison to lesser buffer <= 0", b, b2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
4502
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   717
        // Check equals and compareTo with interesting values
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   718
        for (long x : VALUES) {
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   719
            LongBuffer xb = LongBuffer.wrap(new long[] { x });
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   720
            if (xb.compareTo(xb) != 0) {
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   721
                fail("compareTo not reflexive", xb, xb, x, x);
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   722
            }
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   723
            if (!xb.equals(xb)) {
4502
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   724
                fail("equals not reflexive", xb, xb, x, x);
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   725
            }
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   726
            for (long y : VALUES) {
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   727
                LongBuffer yb = LongBuffer.wrap(new long[] { y });
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   728
                if (xb.compareTo(yb) != - yb.compareTo(xb)) {
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   729
                    fail("compareTo not anti-symmetric",
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   730
                         xb, yb, x, y);
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   731
                }
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   732
                if ((xb.compareTo(yb) == 0) != xb.equals(yb)) {
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   733
                    fail("compareTo inconsistent with equals",
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   734
                         xb, yb, x, y);
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   735
                }
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   736
                if (xb.compareTo(yb) != Long.compare(x, y)) {
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   737
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   738
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   739
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   740
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   741
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   742
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   743
                    fail("Incorrect results for LongBuffer.compareTo",
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   744
                         xb, yb, x, y);
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   745
                }
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   746
                if (xb.equals(yb) != ((x == y) || ((x != x) && (y != y)))) {
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   747
                    fail("Incorrect results for LongBuffer.equals",
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   748
                         xb, yb, x, y);
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   749
                }
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   750
            }
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   751
        }
18f387917b89 6903754: (bf) Improve floating-point buffer comparison
martin
parents: 2593
diff changeset
   752
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
        // Sub, dup
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
        relPut(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
        relGet(b.duplicate());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
        b.position(13);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
        relGet(b.duplicate(), 13);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        relGet(b.duplicate().slice(), 13);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        relGet(b.slice(), 13);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
        relGet(b.slice().duplicate(), 13);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
        // Slice
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
        b.position(5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
        LongBuffer sb = b.slice();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
        checkSlice(b, sb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
        b.position(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
        LongBuffer sb2 = sb.slice();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
        checkSlice(sb, sb2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
        if (!sb.equals(sb2))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
            fail("Sliced slices do not match", sb, sb2);
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   774
        if ((sb.hasArray()) && (sb.arrayOffset() != sb2.arrayOffset())) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
            fail("Array offsets do not match: "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
                 + sb.arrayOffset() + " != " + sb2.arrayOffset(), sb, sb2);
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   777
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
        // Read-only views
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
        b.rewind();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
        final LongBuffer rb = b.asReadOnlyBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
        if (!b.equals(rb))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
            fail("Buffer not equal to read-only view", b, rb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
        show(level + 1, rb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   818
        catchReadOnlyBuffer(b, () -> relPut(rb));
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   819
        catchReadOnlyBuffer(b, () -> absPut(rb));
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   820
        catchReadOnlyBuffer(b, () -> bulkPutArray(rb));
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   821
        catchReadOnlyBuffer(b, () -> bulkPutBuffer(rb));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
14001
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   823
        // put(LongBuffer) should not change source position
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   824
        final LongBuffer src = LongBuffer.allocate(1);
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   825
        catchReadOnlyBuffer(b, () -> rb.put(src));
14001
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   826
        ck(src, src.position(), 0);
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   827
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   828
        catchReadOnlyBuffer(b, () -> rb.compact());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
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
14001
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   839
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   840
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   841
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   842
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   843
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   844
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   845
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   846
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   847
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   848
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   849
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   850
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   851
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   852
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   853
e8e8413ad49a 7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents: 13563
diff changeset
   854
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
        if (rb.getClass().getName().startsWith("java.nio.Heap")) {
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   856
            catchReadOnlyBuffer(b, () -> rb.array());
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   857
            catchReadOnlyBuffer(b, () -> rb.arrayOffset());
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   858
            if (rb.hasArray()) {
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   859
                fail("Read-only heap buffer's backing array is accessible", rb);
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   860
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
        // Bulk puts from read-only buffers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
        b.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
        rb.rewind();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
        b.put(rb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
        relPut(b);                       // Required by testViews
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
36933
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   881
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   882
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   883
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   884
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 31873
diff changeset
   885
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
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
    public static void test(final long [] ba) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
        int offset = 47;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
        int length = 900;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
        final LongBuffer b = LongBuffer.wrap(ba, offset, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
        show(0, b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
        ck(b, b.capacity(), ba.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
        ck(b, b.position(), offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
        ck(b, b.limit(), offset + length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
        // 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
   941
        catchIndexOutOfBounds(ba, () -> LongBuffer.wrap(ba, -1, ba.length));
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   942
        catchIndexOutOfBounds(ba, () -> LongBuffer.wrap(ba, ba.length + 1, ba.length));
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   943
        catchIndexOutOfBounds(ba, () -> LongBuffer.wrap(ba, 0, -1));
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   944
        catchIndexOutOfBounds(ba, () -> LongBuffer.wrap(ba, 0, ba.length + 1));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
        // A NullPointerException will be thrown if the array is null.
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   947
        tryCatch(ba, NullPointerException.class,
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   948
                () -> LongBuffer.wrap((long []) null, 0, 5));
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   949
        tryCatch(ba, NullPointerException.class,
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   950
                () -> LongBuffer.wrap((long []) null));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
    private static void testAllocate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
        // An IllegalArgumentException will be thrown for negative capacities.
37913
3cc95b690353 8156931: java.nio.Buffer tests cleanup
prappo
parents: 36933
diff changeset
   955
        catchIllegalArgument((Buffer) null, () -> LongBuffer.allocate(-1));
31873
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   956
        try {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   957
            LongBuffer.allocate(-1);
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   958
        } catch (IllegalArgumentException e) {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   959
            if (e.getMessage() == null) {
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   960
                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
   961
                     + " attempt to allocate negative capacity buffer");
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   962
            }
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   963
        }
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   964
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   965
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   966
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   967
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   968
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   969
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   970
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 14342
diff changeset
   971
2
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
    public static void test() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
        testAllocate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
        test(0, LongBuffer.allocate(7 * 1024), false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
        test(0, LongBuffer.wrap(new long[7 * 1024], 0, 7 * 1024), false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
        test(new long[1024]);
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
        callReset(LongBuffer.allocate(10));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
        putBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
}