jdk/test/java/nio/Buffer/Order-X.java.template
author bpb
Fri, 24 Jul 2015 11:52:30 -0700
changeset 31873 87b015c2cd36
parent 31723 2e16a59cc5cb
child 38321 ff5b89346438
permissions -rw-r--r--
8065556: (bf) Buffer.position and other methods should include detail in IAE Summary: Add messages to IAEs which have none. Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31723
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
     1
/*
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
     4
 *
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
     8
 *
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    13
 * accompanied this code).
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    14
 *
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    18
 *
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    21
 * questions.
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    22
 */
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    23
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    24
/* Type-specific source code for unit test
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    25
 *
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    26
 * Regenerate the OrderX classes via genOrder.sh whenever this file changes.
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    27
 * We check in the generated source files so that the test tree can be used
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    28
 * independently of the rest of the source tree.
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    29
 */
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    30
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    31
#warn This file is preprocessed before being compiled
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    32
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    33
import java.nio.*;
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    34
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    35
public class Order$Type$ extends Order {
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    36
    private static void ck$Type$Buffer($Type$Buffer buf, ByteOrder expected) {
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    37
        ck(buf.asReadOnlyBuffer().order(), expected);
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    38
        ck(buf.duplicate().order(), expected);
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    39
        ck(buf.slice().order(), expected);
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    40
    }
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    41
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    42
    static void ck$Type$Buffer() {
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    43
        $type$[] array = new $type$[LENGTH];
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    44
        $Type$Buffer buf = $Type$Buffer.wrap(array);
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    45
        ck(buf.order(), nord);
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    46
        ck$Type$Buffer(buf, nord);
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    47
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    48
        buf = $Type$Buffer.wrap(array, LENGTH/2, LENGTH/2);
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    49
        ck(buf.order(), nord);
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    50
        ck$Type$Buffer(buf, nord);
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    51
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    52
        buf = $Type$Buffer.allocate(LENGTH);
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    53
        ck(buf.order(), nord);
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    54
        ck$Type$Buffer(buf, nord);
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    55
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    56
        ck$Type$Buffer(ByteBuffer.allocate(LENGTH).as$Type$Buffer(), be);
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    57
        ck$Type$Buffer(ByteBuffer.allocateDirect(LENGTH).as$Type$Buffer(), be);
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    58
    }
2e16a59cc5cb 8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
diff changeset
    59
}