author | alanb |
Wed, 28 Aug 2013 15:50:03 +0100 | |
changeset 19607 | bee007586d06 |
parent 16921 | e70261f11307 |
child 23010 | 6dadb192ad81 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
7668 | 2 |
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.nio.ch; |
|
27 |
||
28 |
import java.io.*; |
|
29 |
||
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
30 |
class FileDispatcherImpl extends FileDispatcher |
2 | 31 |
{ |
32 |
||
33 |
static { |
|
19607
bee007586d06
8022594: Potential deadlock in <clinit> of sun.nio.ch.Util/IOUtil
alanb
parents:
16921
diff
changeset
|
34 |
IOUtil.load(); |
2 | 35 |
init(); |
36 |
} |
|
37 |
||
7515
43202796198e
6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents:
7025
diff
changeset
|
38 |
FileDispatcherImpl(boolean append) { |
43202796198e
6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents:
7025
diff
changeset
|
39 |
/* append is ignored */ |
43202796198e
6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents:
7025
diff
changeset
|
40 |
} |
43202796198e
6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents:
7025
diff
changeset
|
41 |
|
43202796198e
6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents:
7025
diff
changeset
|
42 |
FileDispatcherImpl() { |
43202796198e
6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents:
7025
diff
changeset
|
43 |
} |
43202796198e
6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents:
7025
diff
changeset
|
44 |
|
2 | 45 |
int read(FileDescriptor fd, long address, int len) throws IOException { |
46 |
return read0(fd, address, len); |
|
47 |
} |
|
48 |
||
16921
e70261f11307
8012019: (fc) Thread.interrupt triggers hang in FileChannelImpl.pread (win)
alanb
parents:
7668
diff
changeset
|
49 |
int pread(FileDescriptor fd, long address, int len, long position) |
e70261f11307
8012019: (fc) Thread.interrupt triggers hang in FileChannelImpl.pread (win)
alanb
parents:
7668
diff
changeset
|
50 |
throws IOException |
e70261f11307
8012019: (fc) Thread.interrupt triggers hang in FileChannelImpl.pread (win)
alanb
parents:
7668
diff
changeset
|
51 |
{ |
2 | 52 |
return pread0(fd, address, len, position); |
53 |
} |
|
54 |
||
55 |
long readv(FileDescriptor fd, long address, int len) throws IOException { |
|
56 |
return readv0(fd, address, len); |
|
57 |
} |
|
58 |
||
59 |
int write(FileDescriptor fd, long address, int len) throws IOException { |
|
60 |
return write0(fd, address, len); |
|
61 |
} |
|
62 |
||
16921
e70261f11307
8012019: (fc) Thread.interrupt triggers hang in FileChannelImpl.pread (win)
alanb
parents:
7668
diff
changeset
|
63 |
int pwrite(FileDescriptor fd, long address, int len, long position) |
e70261f11307
8012019: (fc) Thread.interrupt triggers hang in FileChannelImpl.pread (win)
alanb
parents:
7668
diff
changeset
|
64 |
throws IOException |
2 | 65 |
{ |
66 |
return pwrite0(fd, address, len, position); |
|
67 |
} |
|
68 |
||
69 |
long writev(FileDescriptor fd, long address, int len) |
|
70 |
throws IOException |
|
71 |
{ |
|
72 |
return writev0(fd, address, len); |
|
73 |
} |
|
74 |
||
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
75 |
int force(FileDescriptor fd, boolean metaData) throws IOException { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
76 |
return force0(fd, metaData); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
77 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
78 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
79 |
int truncate(FileDescriptor fd, long size) throws IOException { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
80 |
return truncate0(fd, size); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
81 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
82 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
83 |
long size(FileDescriptor fd) throws IOException { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
84 |
return size0(fd); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
85 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
86 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
87 |
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:
2
diff
changeset
|
88 |
boolean shared) throws IOException |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
89 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
90 |
return lock0(fd, blocking, pos, size, shared); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
91 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
92 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
93 |
void release(FileDescriptor fd, long pos, long size) throws IOException { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
94 |
release0(fd, pos, size); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
95 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
96 |
|
2 | 97 |
void close(FileDescriptor fd) throws IOException { |
98 |
close0(fd); |
|
99 |
} |
|
100 |
||
101 |
void preClose(FileDescriptor fd) throws IOException { |
|
102 |
preClose0(fd); |
|
103 |
} |
|
104 |
||
7025
6e002f9a2899
6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents:
5506
diff
changeset
|
105 |
FileDescriptor duplicateForMapping(FileDescriptor fd) { |
6e002f9a2899
6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents:
5506
diff
changeset
|
106 |
// file descriptor not required for mapping operations; okay |
6e002f9a2899
6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents:
5506
diff
changeset
|
107 |
// to return invalid file descriptor. |
6e002f9a2899
6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents:
5506
diff
changeset
|
108 |
return new FileDescriptor(); |
6e002f9a2899
6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents:
5506
diff
changeset
|
109 |
} |
6e002f9a2899
6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents:
5506
diff
changeset
|
110 |
|
2 | 111 |
// -- Native methods -- |
112 |
||
113 |
static native int read0(FileDescriptor fd, long address, int len) |
|
114 |
throws IOException; |
|
115 |
||
116 |
static native int pread0(FileDescriptor fd, long address, int len, |
|
117 |
long position) throws IOException; |
|
118 |
||
119 |
static native long readv0(FileDescriptor fd, long address, int len) |
|
120 |
throws IOException; |
|
121 |
||
122 |
static native int write0(FileDescriptor fd, long address, int len) |
|
123 |
throws IOException; |
|
124 |
||
125 |
static native int pwrite0(FileDescriptor fd, long address, int len, |
|
126 |
long position) throws IOException; |
|
127 |
||
128 |
static native long writev0(FileDescriptor fd, long address, int len) |
|
129 |
throws IOException; |
|
130 |
||
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
131 |
static native int force0(FileDescriptor fd, boolean metaData) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
132 |
throws IOException; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
133 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
134 |
static native int truncate0(FileDescriptor fd, long size) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
135 |
throws IOException; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
136 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
137 |
static native long size0(FileDescriptor fd) throws IOException; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
138 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
139 |
static native int lock0(FileDescriptor fd, boolean blocking, long pos, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
140 |
long size, boolean shared) throws IOException; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
141 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
142 |
static native void release0(FileDescriptor fd, long pos, long size) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
143 |
throws IOException; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
144 |
|
2 | 145 |
static native void close0(FileDescriptor fd) throws IOException; |
146 |
||
147 |
static native void preClose0(FileDescriptor fd) throws IOException; |
|
148 |
||
149 |
static native void closeIntFD(int fd) throws IOException; |
|
150 |
||
151 |
static native void init(); |
|
152 |
||
153 |
} |