test/jdk/sun/misc/CopyMemory.java
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 36966 jdk/test/sun/misc/CopyMemory.java@4209c9e19c45
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2007, 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: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
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
/* @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @bug 6565543
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * @summary Minimal test for unsafe.copyMemory() and unsafe.setMemory()
36966
4209c9e19c45 8153737: Unsupported Module
chegar
parents: 30820
diff changeset
    27
 * @modules java.base/sun.nio.ch
4209c9e19c45 8153737: Unsupported Module
chegar
parents: 30820
diff changeset
    28
 *          jdk.unsupported
30046
cf2c86e1819e 8078334: Mark regression tests using randomness
darcy
parents: 5506
diff changeset
    29
 * @key randomness
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.lang.reflect.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.nio.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import sun.misc.Unsafe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import sun.nio.ch.DirectBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
public class CopyMemory {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    private final static int BUFFER_SIZE = 1024;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    private final static int N = 16 * 1024;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    private final static int FILLER = 0x55;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    private final static int FILLER2 = 0x33;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    private final static Random random = new Random();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    private static void set(byte[] b, int ofs, int len, int value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        for (int i = 0; i < len; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
            b[ofs + i] = (byte)value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private static void check(byte[] b, int ofs, int len, int value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        for (int i = 0; i < len; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
            int r = b[ofs + i] & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
            if (r != value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
                throw new RuntimeException("mismatch");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    private static void set(Unsafe unsafe, long addr, int ofs, int len, int value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        for (int i = 0; i < len; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
            unsafe.putByte(null, addr + ofs + i, (byte)value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    private static void check(Unsafe unsafe, long addr, int ofs, int len, int value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        for (int i = 0; i < len; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            int r = unsafe.getByte(null, addr + ofs + i) & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            if (r != value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                throw new RuntimeException("mismatch");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    private static final List<ByteBuffer> buffers = new ArrayList<ByteBuffer>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    private static long getMemory(int n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        ByteBuffer b = ByteBuffer.allocateDirect(n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        if (b instanceof DirectBuffer == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            throw new RuntimeException("Not a direct buffer");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        buffers.add(b); // make sure the buffer does not get GCed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        return ((DirectBuffer)b).address();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    private static void testSetByteArray(Unsafe unsafe) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        System.out.println("Testing setMemory() for byte[]...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        byte[] b = new byte[BUFFER_SIZE];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        for (int i = 0; i < N; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            set(b, 0, BUFFER_SIZE, FILLER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            int ofs = random.nextInt(BUFFER_SIZE / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            int len = random.nextInt(BUFFER_SIZE / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            int val = random.nextInt(256);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            unsafe.setMemory(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs, len, (byte)val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            check(b, 0, ofs - 1, FILLER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            check(b, ofs, len, val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            check(b, ofs + len, BUFFER_SIZE - (ofs + len), FILLER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    private static void testSetRawMemory(Unsafe unsafe) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        System.out.println("Testing setMemory() for raw memory...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        long b = getMemory(BUFFER_SIZE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        for (int i = 0; i < N; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            set(unsafe, b, 0, BUFFER_SIZE, FILLER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            int ofs = random.nextInt(BUFFER_SIZE / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            int len = random.nextInt(BUFFER_SIZE / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            int val = random.nextInt(256);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            unsafe.setMemory(null, b + ofs, len, (byte)val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            check(unsafe, b, 0, ofs - 1, FILLER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            check(unsafe, b, ofs, len, val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            check(unsafe, b, ofs + len, BUFFER_SIZE - (ofs + len), FILLER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    private static void testCopyByteArrayToByteArray(Unsafe unsafe) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        System.out.println("Testing copyMemory() for byte[] to byte[]...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        byte[] b1 = new byte[BUFFER_SIZE];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        byte[] b2 = new byte[BUFFER_SIZE];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        for (int i = 0; i < N; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            set(b1, 0, BUFFER_SIZE, FILLER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            set(b2, 0, BUFFER_SIZE, FILLER2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            int ofs = random.nextInt(BUFFER_SIZE / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            int len = random.nextInt(BUFFER_SIZE / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            int val = random.nextInt(256);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            set(b1, ofs, len, val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            int ofs2 = random.nextInt(BUFFER_SIZE / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            unsafe.copyMemory(b1, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                b2, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs2, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            check(b2, 0, ofs2 - 1, FILLER2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            check(b2, ofs2, len, val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            check(b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    private static void testCopyByteArrayToRawMemory(Unsafe unsafe) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        System.out.println("Testing copyMemory() for byte[] to raw memory...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        byte[] b1 = new byte[BUFFER_SIZE];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        long b2 = getMemory(BUFFER_SIZE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        for (int i = 0; i < N; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            set(b1, 0, BUFFER_SIZE, FILLER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            set(unsafe, b2, 0, BUFFER_SIZE, FILLER2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            int ofs = random.nextInt(BUFFER_SIZE / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            int len = random.nextInt(BUFFER_SIZE / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            int val = random.nextInt(256);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            set(b1, ofs, len, val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            int ofs2 = random.nextInt(BUFFER_SIZE / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            unsafe.copyMemory(b1, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                null, b2 + ofs2, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            check(unsafe, b2, 0, ofs2 - 1, FILLER2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            check(unsafe, b2, ofs2, len, val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            check(unsafe, b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    private static void testCopyRawMemoryToByteArray(Unsafe unsafe) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        System.out.println("Testing copyMemory() for raw memory to byte[]...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        long b1 = getMemory(BUFFER_SIZE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        byte[] b2 = new byte[BUFFER_SIZE];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        for (int i = 0; i < N; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            set(unsafe, b1, 0, BUFFER_SIZE, FILLER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            set(b2, 0, BUFFER_SIZE, FILLER2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            int ofs = random.nextInt(BUFFER_SIZE / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            int len = random.nextInt(BUFFER_SIZE / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            int val = random.nextInt(256);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            set(unsafe, b1, ofs, len, val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            int ofs2 = random.nextInt(BUFFER_SIZE / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            unsafe.copyMemory(null, b1 + ofs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                b2, Unsafe.ARRAY_BYTE_BASE_OFFSET + ofs2, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            check(b2, 0, ofs2 - 1, FILLER2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            check(b2, ofs2, len, val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            check(b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
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
    private static void testCopyRawMemoryToRawMemory(Unsafe unsafe) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        System.out.println("Testing copyMemory() for raw memory to raw memory...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        long b1 = getMemory(BUFFER_SIZE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        long b2 = getMemory(BUFFER_SIZE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        for (int i = 0; i < N; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            set(unsafe, b1, 0, BUFFER_SIZE, FILLER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            set(unsafe, b2, 0, BUFFER_SIZE, FILLER2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            int ofs = random.nextInt(BUFFER_SIZE / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            int len = random.nextInt(BUFFER_SIZE / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            int val = random.nextInt(256);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            set(unsafe, b1, ofs, len, val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            int ofs2 = random.nextInt(BUFFER_SIZE / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            unsafe.copyMemory(null, b1 + ofs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                null, b2 + ofs2, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            check(unsafe, b2, 0, ofs2 - 1, FILLER2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            check(unsafe, b2, ofs2, len, val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            check(unsafe, b2, ofs2 + len, BUFFER_SIZE - (ofs2 + len), FILLER2);
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
    private static Unsafe getUnsafe() throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        Field f = Unsafe.class.getDeclaredField("theUnsafe");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        f.setAccessible(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        return (Unsafe)f.get(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    public static void main(String[] args) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        Unsafe unsafe = getUnsafe();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        testSetByteArray(unsafe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        testSetRawMemory(unsafe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        testCopyByteArrayToByteArray(unsafe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        testCopyByteArrayToRawMemory(unsafe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        testCopyRawMemoryToByteArray(unsafe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        testCopyRawMemoryToRawMemory(unsafe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        System.out.println("OK");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
}