358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 // Compact 379 380 relPut(b); 381 b.position(13); 382 b.compact(); 383 b.flip(); 384 relGet(b, 13); 385 386 // Exceptions 387 388 relPut(b); 389 b.limit(b.capacity() / 2); 390 b.position(b.limit()); 391 392 tryCatch(b, BufferUnderflowException.class, new Runnable() { 393 public void run() { 394 b.get(); 395 }}); 396 397 tryCatch(b, BufferOverflowException.class, new Runnable() { 688 689 b.clear(); 690 rb.rewind(); 691 b.put(rb); 692 693 694 // For byte buffers, test both the direct and non-direct cases 695 ByteBuffer ob 696 = (b.isDirect() 697 ? ByteBuffer.allocate(rb.capacity()) 698 : ByteBuffer.allocateDirect(rb.capacity())); 699 rb.rewind(); 700 ob.put(rb); 701 702 703 relPut(b); // Required by testViews 704 705 } 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 | 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 // Compact 382 383 relPut(b); 384 b.position(13); 385 b.compact(); 386 b.flip(); 387 relGet(b, 13); 388 389 // Exceptions 390 391 relPut(b); 392 b.limit(b.capacity() / 2); 393 b.position(b.limit()); 394 395 tryCatch(b, BufferUnderflowException.class, new Runnable() { 396 public void run() { 397 b.get(); 398 }}); 399 400 tryCatch(b, BufferOverflowException.class, new Runnable() { 691 692 b.clear(); 693 rb.rewind(); 694 b.put(rb); 695 696 697 // For byte buffers, test both the direct and non-direct cases 698 ByteBuffer ob 699 = (b.isDirect() 700 ? ByteBuffer.allocate(rb.capacity()) 701 : ByteBuffer.allocateDirect(rb.capacity())); 702 rb.rewind(); 703 ob.put(rb); 704 705 706 relPut(b); // Required by testViews 707 708 } 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 |