summaryrefslogtreecommitdiff
path: root/libjava/testsuite/libjava.jni/bytebuffer.java
blob: 0e541123f55c7965dc07d5c107a3f566c76836bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Test to make sure JNI implementation catches exceptions.

import java.nio.*;

public class bytebuffer
{
  static
  {
    System.loadLibrary("bytebuffer");
  }

  public static native void testByteBuffer(ByteBuffer bb);
  public static native void testCharBuffer(CharBuffer b);
  public static native void testDoubleBuffer(DoubleBuffer b);
  public static native void testFloatBuffer(FloatBuffer b);
  public static native void testIntBuffer(IntBuffer b);
  public static native void testLongBuffer(LongBuffer b);
  public static native void testShortBuffer(ShortBuffer b);

  public static void main(String[] args)
  {
    ByteBuffer bb = ByteBuffer.allocate(1024);
    testByteBuffer(bb);
    testCharBuffer(bb.asCharBuffer());
    testDoubleBuffer(bb.asDoubleBuffer());
    testFloatBuffer(bb.asFloatBuffer());
    testIntBuffer(bb.asIntBuffer());
    testLongBuffer(bb.asLongBuffer());
    testShortBuffer(bb.asShortBuffer());

    testCharBuffer(CharBuffer.allocate(1024));
    testDoubleBuffer(DoubleBuffer.allocate(1024));
    testFloatBuffer(FloatBuffer.allocate(1024));
    testIntBuffer(IntBuffer.allocate(1024));
    testLongBuffer(LongBuffer.allocate(1024));
    testShortBuffer(ShortBuffer.allocate(1024));
  }
}