27 28 import java.io.FileDescriptor; 29 import java.io.IOException; 30 import java.nio.ByteBuffer; 31 import java.nio.MappedByteBuffer; 32 import java.nio.channels.ClosedByInterruptException; 33 import java.nio.channels.ClosedChannelException; 34 import java.nio.channels.FileChannel; 35 import java.nio.channels.FileLock; 36 import java.nio.channels.FileLockInterruptionException; 37 import java.nio.channels.NonReadableChannelException; 38 import java.nio.channels.NonWritableChannelException; 39 import java.nio.channels.OverlappingFileLockException; 40 import java.nio.channels.ReadableByteChannel; 41 import java.nio.channels.SelectableChannel; 42 import java.nio.channels.WritableByteChannel; 43 import java.security.AccessController; 44 import java.util.ArrayList; 45 import java.util.List; 46 47 import sun.misc.Cleaner; 48 import sun.misc.JavaIOFileDescriptorAccess; 49 import sun.misc.SharedSecrets; 50 import sun.security.action.GetPropertyAction; 51 52 public class FileChannelImpl 53 extends FileChannel 54 { 55 // Memory allocation size for mapping buffers 56 private static final long allocationGranularity; 57 58 // Access to FileDispatcher internals 59 private static final JavaIOFileDescriptorAccess fdAccess = 60 SharedSecrets.getJavaIOFileDescriptorAccess(); 61 62 // Used to make native read and write calls 63 private final FileDispatcher nd; 64 65 // File descriptor 66 private final FileDescriptor fd; 67 68 // File access mode (immutable) 69 private final boolean writable; 958 return Util.newMappedByteBufferR(isize, 959 addr + pagePosition, 960 mfd, 961 um); 962 } else { 963 return Util.newMappedByteBuffer(isize, 964 addr + pagePosition, 965 mfd, 966 um); 967 } 968 } finally { 969 threads.remove(ti); 970 end(IOStatus.checkAll(addr)); 971 } 972 } 973 974 /** 975 * Invoked by sun.management.ManagementFactoryHelper to create the management 976 * interface for mapped buffers. 977 */ 978 public static sun.misc.JavaNioAccess.BufferPool getMappedBufferPool() { 979 return new sun.misc.JavaNioAccess.BufferPool() { 980 @Override 981 public String getName() { 982 return "mapped"; 983 } 984 @Override 985 public long getCount() { 986 return Unmapper.count; 987 } 988 @Override 989 public long getTotalCapacity() { 990 return Unmapper.totalCapacity; 991 } 992 @Override 993 public long getMemoryUsed() { 994 return Unmapper.totalSize; 995 } 996 }; 997 } 998 999 // -- Locks -- | 27 28 import java.io.FileDescriptor; 29 import java.io.IOException; 30 import java.nio.ByteBuffer; 31 import java.nio.MappedByteBuffer; 32 import java.nio.channels.ClosedByInterruptException; 33 import java.nio.channels.ClosedChannelException; 34 import java.nio.channels.FileChannel; 35 import java.nio.channels.FileLock; 36 import java.nio.channels.FileLockInterruptionException; 37 import java.nio.channels.NonReadableChannelException; 38 import java.nio.channels.NonWritableChannelException; 39 import java.nio.channels.OverlappingFileLockException; 40 import java.nio.channels.ReadableByteChannel; 41 import java.nio.channels.SelectableChannel; 42 import java.nio.channels.WritableByteChannel; 43 import java.security.AccessController; 44 import java.util.ArrayList; 45 import java.util.List; 46 47 import jdk.internal.misc.JavaIOFileDescriptorAccess; 48 import jdk.internal.misc.JavaNioAccess; 49 import jdk.internal.misc.SharedSecrets; 50 import sun.misc.Cleaner; 51 import sun.security.action.GetPropertyAction; 52 53 public class FileChannelImpl 54 extends FileChannel 55 { 56 // Memory allocation size for mapping buffers 57 private static final long allocationGranularity; 58 59 // Access to FileDispatcher internals 60 private static final JavaIOFileDescriptorAccess fdAccess = 61 SharedSecrets.getJavaIOFileDescriptorAccess(); 62 63 // Used to make native read and write calls 64 private final FileDispatcher nd; 65 66 // File descriptor 67 private final FileDescriptor fd; 68 69 // File access mode (immutable) 70 private final boolean writable; 959 return Util.newMappedByteBufferR(isize, 960 addr + pagePosition, 961 mfd, 962 um); 963 } else { 964 return Util.newMappedByteBuffer(isize, 965 addr + pagePosition, 966 mfd, 967 um); 968 } 969 } finally { 970 threads.remove(ti); 971 end(IOStatus.checkAll(addr)); 972 } 973 } 974 975 /** 976 * Invoked by sun.management.ManagementFactoryHelper to create the management 977 * interface for mapped buffers. 978 */ 979 public static JavaNioAccess.BufferPool getMappedBufferPool() { 980 return new JavaNioAccess.BufferPool() { 981 @Override 982 public String getName() { 983 return "mapped"; 984 } 985 @Override 986 public long getCount() { 987 return Unmapper.count; 988 } 989 @Override 990 public long getTotalCapacity() { 991 return Unmapper.totalCapacity; 992 } 993 @Override 994 public long getMemoryUsed() { 995 return Unmapper.totalSize; 996 } 997 }; 998 } 999 1000 // -- Locks -- |