src/java.base/share/classes/sun/nio/ch/FileDispatcher.java
author alanb
Sat, 30 Nov 2019 16:21:19 +0000
changeset 59329 289000934908
parent 49897 117501815bed
permissions -rw-r--r--
8234805: (dc) Remove JNI upcall from DatagramChannel.receive implementation Reviewed-by: dfuchs, chegar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
     1
/*
49897
117501815bed 8202261: (fc) FileChannel.map and RandomAccessFile.setLength should not preallocate space
alanb
parents: 47428
diff changeset
     2
 * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
     4
 *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2057
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2057
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    10
 *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    15
 * accompanied this code).
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    16
 *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2057
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2057
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2057
diff changeset
    23
 * questions.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    24
 */
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    25
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    26
package sun.nio.ch;
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    27
27937
0c9f63e42e91 8064407: (fc) FileChannel transferTo should use TransmitFile on Windows
alanb
parents: 25859
diff changeset
    28
import java.io.FileDescriptor;
0c9f63e42e91 8064407: (fc) FileChannel transferTo should use TransmitFile on Windows
alanb
parents: 25859
diff changeset
    29
import java.io.IOException;
0c9f63e42e91 8064407: (fc) FileChannel transferTo should use TransmitFile on Windows
alanb
parents: 25859
diff changeset
    30
import java.nio.channels.SelectableChannel;
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    31
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    32
abstract class FileDispatcher extends NativeDispatcher {
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    33
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    34
    public static final int NO_LOCK = -1;       // Failed to lock
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    35
    public static final int LOCKED = 0;         // Obtained requested lock
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    36
    public static final int RET_EX_LOCK = 1;    // Obtained exclusive lock
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    37
    public static final int INTERRUPTED = 2;    // Request interrupted
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    38
49897
117501815bed 8202261: (fc) FileChannel.map and RandomAccessFile.setLength should not preallocate space
alanb
parents: 47428
diff changeset
    39
    /**
117501815bed 8202261: (fc) FileChannel.map and RandomAccessFile.setLength should not preallocate space
alanb
parents: 47428
diff changeset
    40
     * Sets or reports this file's position
117501815bed 8202261: (fc) FileChannel.map and RandomAccessFile.setLength should not preallocate space
alanb
parents: 47428
diff changeset
    41
     * If offset is -1, the current position is returned
117501815bed 8202261: (fc) FileChannel.map and RandomAccessFile.setLength should not preallocate space
alanb
parents: 47428
diff changeset
    42
     * otherwise the position is set to offset.
117501815bed 8202261: (fc) FileChannel.map and RandomAccessFile.setLength should not preallocate space
alanb
parents: 47428
diff changeset
    43
     */
117501815bed 8202261: (fc) FileChannel.map and RandomAccessFile.setLength should not preallocate space
alanb
parents: 47428
diff changeset
    44
    abstract long seek(FileDescriptor fd, long offset) throws IOException;
117501815bed 8202261: (fc) FileChannel.map and RandomAccessFile.setLength should not preallocate space
alanb
parents: 47428
diff changeset
    45
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    46
    abstract int force(FileDescriptor fd, boolean metaData) throws IOException;
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    47
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    48
    abstract int truncate(FileDescriptor fd, long size) throws IOException;
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    49
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    50
    abstract long size(FileDescriptor fd) throws IOException;
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    51
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    52
    abstract int lock(FileDescriptor fd, boolean blocking, long pos, long size,
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    53
                       boolean shared) throws IOException;
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    54
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    55
    abstract void release(FileDescriptor fd, long pos, long size)
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    56
        throws IOException;
7025
6e002f9a2899 6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents: 5506
diff changeset
    57
6e002f9a2899 6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents: 5506
diff changeset
    58
    /**
6e002f9a2899 6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents: 5506
diff changeset
    59
     * Returns a dup of fd if a file descriptor is required for
6e002f9a2899 6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents: 5506
diff changeset
    60
     * memory-mapping operations, otherwise returns an invalid
6e002f9a2899 6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents: 5506
diff changeset
    61
     * FileDescriptor (meaning a newly allocated FileDescriptor)
6e002f9a2899 6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents: 5506
diff changeset
    62
     */
6e002f9a2899 6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents: 5506
diff changeset
    63
    abstract FileDescriptor duplicateForMapping(FileDescriptor fd)
6e002f9a2899 6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents: 5506
diff changeset
    64
        throws IOException;
27937
0c9f63e42e91 8064407: (fc) FileChannel transferTo should use TransmitFile on Windows
alanb
parents: 25859
diff changeset
    65
0c9f63e42e91 8064407: (fc) FileChannel transferTo should use TransmitFile on Windows
alanb
parents: 25859
diff changeset
    66
    abstract boolean canTransferToDirectly(SelectableChannel sc);
0c9f63e42e91 8064407: (fc) FileChannel transferTo should use TransmitFile on Windows
alanb
parents: 25859
diff changeset
    67
0c9f63e42e91 8064407: (fc) FileChannel transferTo should use TransmitFile on Windows
alanb
parents: 25859
diff changeset
    68
    abstract boolean transferToDirectlyNeedsPositionLock();
47428
d72d7d55c765 8164900: Add support for O_DIRECT
bpb
parents: 47216
diff changeset
    69
d72d7d55c765 8164900: Add support for O_DIRECT
bpb
parents: 47216
diff changeset
    70
    abstract int setDirectIO(FileDescriptor fd, String path);
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    71
}