< prev index next >

src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java

Print this page




 923 
 924     private static final int MAP_RO = 0;
 925     private static final int MAP_RW = 1;
 926     private static final int MAP_PV = 2;
 927 
 928     public MappedByteBuffer map(MapMode mode, long position, long size)
 929         throws IOException
 930     {
 931         ensureOpen();
 932         if (mode == null)
 933             throw new NullPointerException("Mode is null");
 934         if (position < 0L)
 935             throw new IllegalArgumentException("Negative position");
 936         if (size < 0L)
 937             throw new IllegalArgumentException("Negative size");
 938         if (position + size < 0)
 939             throw new IllegalArgumentException("Position + size overflow");
 940         if (size > Integer.MAX_VALUE)
 941             throw new IllegalArgumentException("Size exceeds Integer.MAX_VALUE");
 942 
 943         int imode;
 944         if (mode == MapMode.READ_ONLY)
 945             imode = MAP_RO;
 946         else if (mode == MapMode.READ_WRITE)
 947             imode = MAP_RW;
 948         else if (mode == MapMode.PRIVATE)
 949             imode = MAP_PV;
 950         else
 951             throw new UnsupportedOperationException();
 952         if ((mode != MapMode.READ_ONLY) && !writable)
 953             throw new NonWritableChannelException();
 954         if (!readable)
 955             throw new NonReadableChannelException();
 956 
 957         long addr = -1;
 958         int ti = -1;
 959         try {
 960             beginBlocking();
 961             ti = threads.add();
 962             if (!isOpen())
 963                 return null;
 964 
 965             long mapSize;
 966             int pagePosition;
 967             synchronized (positionLock) {
 968                 long filesize;
 969                 do {
 970                     filesize = nd.size(fd);
 971                 } while ((filesize == IOStatus.INTERRUPTED) && isOpen());




 923 
 924     private static final int MAP_RO = 0;
 925     private static final int MAP_RW = 1;
 926     private static final int MAP_PV = 2;
 927 
 928     public MappedByteBuffer map(MapMode mode, long position, long size)
 929         throws IOException
 930     {
 931         ensureOpen();
 932         if (mode == null)
 933             throw new NullPointerException("Mode is null");
 934         if (position < 0L)
 935             throw new IllegalArgumentException("Negative position");
 936         if (size < 0L)
 937             throw new IllegalArgumentException("Negative size");
 938         if (position + size < 0)
 939             throw new IllegalArgumentException("Position + size overflow");
 940         if (size > Integer.MAX_VALUE)
 941             throw new IllegalArgumentException("Size exceeds Integer.MAX_VALUE");
 942 
 943         int imode = -1;
 944         if (mode == MapMode.READ_ONLY)
 945             imode = MAP_RO;
 946         else if (mode == MapMode.READ_WRITE)
 947             imode = MAP_RW;
 948         else if (mode == MapMode.PRIVATE)
 949             imode = MAP_PV;
 950         assert (imode >= 0);

 951         if ((mode != MapMode.READ_ONLY) && !writable)
 952             throw new NonWritableChannelException();
 953         if (!readable)
 954             throw new NonReadableChannelException();
 955 
 956         long addr = -1;
 957         int ti = -1;
 958         try {
 959             beginBlocking();
 960             ti = threads.add();
 961             if (!isOpen())
 962                 return null;
 963 
 964             long mapSize;
 965             int pagePosition;
 966             synchronized (positionLock) {
 967                 long filesize;
 968                 do {
 969                     filesize = nd.size(fd);
 970                 } while ((filesize == IOStatus.INTERRUPTED) && isOpen());


< prev index next >