< prev index next >

src/java.base/share/classes/java/nio/Buffer.java

Print this page




 746         mark = -1;
 747     }
 748 
 749     @ForceInline
 750     final void checkSegment() {
 751         if (segment != null) {
 752             segment.checkValidState();
 753         }
 754     }
 755 
 756     static {
 757         // setup access to this package in SharedSecrets
 758         SharedSecrets.setJavaNioAccess(
 759             new JavaNioAccess() {
 760                 @Override
 761                 public JavaNioAccess.BufferPool getDirectBufferPool() {
 762                     return Bits.BUFFER_POOL;
 763                 }
 764 
 765                 @Override
 766                 public ByteBuffer newDirectByteBuffer(long addr, int cap, Object ob, MemorySegmentProxy segment) {
 767                     return new DirectByteBuffer(addr, cap, ob, segment);
 768                 }
 769 
 770                 @Override
 771                 public ByteBuffer newHeapByteBuffer(byte[] hb, int offset, int capacity, MemorySegmentProxy segment) {
 772                     return new HeapByteBuffer(hb, offset, capacity, segment);
 773                 }
 774 
 775                 @Override
 776                 public Object getBufferBase(ByteBuffer bb) {
 777                     return bb.base();
 778                 }
 779 
 780                 @Override
 781                 public long getBufferAddress(ByteBuffer bb) {
 782                     return bb.address;
 783                 }
 784 
 785                 @Override
 786                 public void checkSegment(Buffer buffer) {
 787                     buffer.checkSegment();


 746         mark = -1;
 747     }
 748 
 749     @ForceInline
 750     final void checkSegment() {
 751         if (segment != null) {
 752             segment.checkValidState();
 753         }
 754     }
 755 
 756     static {
 757         // setup access to this package in SharedSecrets
 758         SharedSecrets.setJavaNioAccess(
 759             new JavaNioAccess() {
 760                 @Override
 761                 public JavaNioAccess.BufferPool getDirectBufferPool() {
 762                     return Bits.BUFFER_POOL;
 763                 }
 764 
 765                 @Override
 766                 public ByteBuffer newDirectByteBuffer(long addr, int cap, Object obj, MemorySegmentProxy segment) {
 767                     return new DirectByteBuffer(addr, cap, obj, segment);
 768                 }
 769 
 770                 @Override
 771                 public ByteBuffer newHeapByteBuffer(byte[] hb, int offset, int capacity, MemorySegmentProxy segment) {
 772                     return new HeapByteBuffer(hb, offset, capacity, segment);
 773                 }
 774 
 775                 @Override
 776                 public Object getBufferBase(ByteBuffer bb) {
 777                     return bb.base();
 778                 }
 779 
 780                 @Override
 781                 public long getBufferAddress(ByteBuffer bb) {
 782                     return bb.address;
 783                 }
 784 
 785                 @Override
 786                 public void checkSegment(Buffer buffer) {
 787                     buffer.checkSegment();
< prev index next >