bytebuffer.java 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Test to make sure JNI implementation catches exceptions.
  2. import java.nio.*;
  3. public class bytebuffer
  4. {
  5. static
  6. {
  7. System.loadLibrary("bytebuffer");
  8. }
  9. public static native void testByteBuffer(ByteBuffer bb);
  10. public static native void testCharBuffer(CharBuffer b);
  11. public static native void testDoubleBuffer(DoubleBuffer b);
  12. public static native void testFloatBuffer(FloatBuffer b);
  13. public static native void testIntBuffer(IntBuffer b);
  14. public static native void testLongBuffer(LongBuffer b);
  15. public static native void testShortBuffer(ShortBuffer b);
  16. public static void main(String[] args)
  17. {
  18. ByteBuffer bb = ByteBuffer.allocate(1024);
  19. testByteBuffer(bb);
  20. testCharBuffer(bb.asCharBuffer());
  21. testDoubleBuffer(bb.asDoubleBuffer());
  22. testFloatBuffer(bb.asFloatBuffer());
  23. testIntBuffer(bb.asIntBuffer());
  24. testLongBuffer(bb.asLongBuffer());
  25. testShortBuffer(bb.asShortBuffer());
  26. testCharBuffer(CharBuffer.allocate(1024));
  27. testDoubleBuffer(DoubleBuffer.allocate(1024));
  28. testFloatBuffer(FloatBuffer.allocate(1024));
  29. testIntBuffer(IntBuffer.allocate(1024));
  30. testLongBuffer(LongBuffer.allocate(1024));
  31. testShortBuffer(ShortBuffer.allocate(1024));
  32. }
  33. }