author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 58242 | 94bb65cb37d3 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
54823
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
2 |
* Copyright (c) 2000, 2019, 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 java.nio; |
|
27 |
||
7025
6e002f9a2899
6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents:
6128
diff
changeset
|
28 |
import java.io.FileDescriptor; |
49210
7c795d301dbf
8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents:
48847
diff
changeset
|
29 |
import java.lang.ref.Reference; |
54823
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
30 |
import java.util.Objects; |
33674
566777f73c32
8140606: Update library code to use internal Unsafe
chegar
parents:
32143
diff
changeset
|
31 |
import jdk.internal.misc.Unsafe; |
6128
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
32 |
|
2 | 33 |
|
34 |
/** |
|
35 |
* A direct byte buffer whose content is a memory-mapped region of a file. |
|
36 |
* |
|
37 |
* <p> Mapped byte buffers are created via the {@link |
|
38 |
* java.nio.channels.FileChannel#map FileChannel.map} method. This class |
|
39 |
* extends the {@link ByteBuffer} class with operations that are specific to |
|
40 |
* memory-mapped file regions. |
|
41 |
* |
|
42 |
* <p> A mapped byte buffer and the file mapping that it represents remain |
|
43 |
* valid until the buffer itself is garbage-collected. |
|
44 |
* |
|
45 |
* <p> The content of a mapped byte buffer can change at any time, for example |
|
46 |
* if the content of the corresponding region of the mapped file is changed by |
|
47 |
* this program or another. Whether or not such changes occur, and when they |
|
48 |
* occur, is operating-system dependent and therefore unspecified. |
|
49 |
* |
|
44844
b2b4d98404ba
8179364: update "<a name=" in java.base module to use id attribute
jjg
parents:
44369
diff
changeset
|
50 |
* <a id="inaccess"></a><p> All or part of a mapped byte buffer may become |
2 | 51 |
* inaccessible at any time, for example if the mapped file is truncated. An |
52 |
* attempt to access an inaccessible region of a mapped byte buffer will not |
|
53 |
* change the buffer's content and will cause an unspecified exception to be |
|
54 |
* thrown either at the time of the access or at some later time. It is |
|
55 |
* therefore strongly recommended that appropriate precautions be taken to |
|
56 |
* avoid the manipulation of a mapped file by this program, or by a |
|
57 |
* concurrently running program, except to read or write the file's content. |
|
58 |
* |
|
59 |
* <p> Mapped byte buffers otherwise behave no differently than ordinary direct |
|
60 |
* byte buffers. </p> |
|
61 |
* |
|
62 |
* |
|
63 |
* @author Mark Reinhold |
|
64 |
* @author JSR-51 Expert Group |
|
65 |
* @since 1.4 |
|
66 |
*/ |
|
67 |
||
68 |
public abstract class MappedByteBuffer |
|
69 |
extends ByteBuffer |
|
70 |
{ |
|
71 |
||
72 |
// This is a little bit backwards: By rights MappedByteBuffer should be a |
|
73 |
// subclass of DirectByteBuffer, but to keep the spec clear and simple, and |
|
74 |
// for optimization purposes, it's easier to do it the other way around. |
|
75 |
// This works because DirectByteBuffer is a package-private class. |
|
76 |
||
7025
6e002f9a2899
6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents:
6128
diff
changeset
|
77 |
// For mapped buffers, a FileDescriptor that may be used for mapping |
6e002f9a2899
6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents:
6128
diff
changeset
|
78 |
// operations if valid; null if the buffer is not mapped. |
6e002f9a2899
6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents:
6128
diff
changeset
|
79 |
private final FileDescriptor fd; |
2 | 80 |
|
57804 | 81 |
// A flag true if this buffer is mapped against non-volatile |
82 |
// memory using one of the extended FileChannel.MapMode modes, |
|
83 |
// MapMode.READ_ONLY_SYNC or MapMode.READ_WRITE_SYNC and false if |
|
84 |
// it is mapped using any of the other modes. This flag only |
|
85 |
// determines the behavior of force operations. |
|
86 |
private final boolean isSync; |
|
87 |
||
2 | 88 |
// This should only be invoked by the DirectByteBuffer constructors |
89 |
// |
|
90 |
MappedByteBuffer(int mark, int pos, int lim, int cap, // package-private |
|
57804 | 91 |
FileDescriptor fd, boolean isSync) { |
2 | 92 |
super(mark, pos, lim, cap); |
7025
6e002f9a2899
6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents:
6128
diff
changeset
|
93 |
this.fd = fd; |
57804 | 94 |
this.isSync = isSync; |
95 |
} |
|
96 |
||
97 |
MappedByteBuffer(int mark, int pos, int lim, int cap, // package-private |
|
98 |
boolean isSync) { |
|
99 |
super(mark, pos, lim, cap); |
|
100 |
this.fd = null; |
|
101 |
this.isSync = isSync; |
|
2 | 102 |
} |
103 |
||
104 |
MappedByteBuffer(int mark, int pos, int lim, int cap) { // package-private |
|
105 |
super(mark, pos, lim, cap); |
|
7025
6e002f9a2899
6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents:
6128
diff
changeset
|
106 |
this.fd = null; |
57804 | 107 |
this.isSync = false; |
2 | 108 |
} |
109 |
||
54823
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
110 |
// Returns the distance (in bytes) of the buffer start from the |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
111 |
// largest page aligned address of the mapping less than or equal |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
112 |
// to the start address. |
6128
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
113 |
private long mappingOffset() { |
54823
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
114 |
return mappingOffset(0); |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
115 |
} |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
116 |
|
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
117 |
// Returns the distance (in bytes) of the buffer element |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
118 |
// identified by index from the largest page aligned address of |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
119 |
// the mapping less than or equal to the element address. Computed |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
120 |
// each time to avoid storing in every direct buffer. |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
121 |
private long mappingOffset(int index) { |
6128
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
122 |
int ps = Bits.pageSize(); |
54823
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
123 |
long indexAddress = address + index; |
54904
c1143a0d4e22
8224042: Add private alignDown method to MappedByteBuffer
adinn
parents:
54823
diff
changeset
|
124 |
long baseAddress = alignDown(indexAddress, ps); |
54823
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
125 |
return indexAddress - baseAddress; |
6128
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
126 |
} |
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
127 |
|
54823
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
128 |
// Given an offset previously obtained from calling |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
129 |
// mappingOffset() returns the largest page aligned address of the |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
130 |
// mapping less than or equal to the buffer start address. |
6128
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
131 |
private long mappingAddress(long mappingOffset) { |
54823
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
132 |
return mappingAddress(mappingOffset, 0); |
6128
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
133 |
} |
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
134 |
|
54823
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
135 |
// Given an offset previously otained from calling |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
136 |
// mappingOffset(index) returns the largest page aligned address |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
137 |
// of the mapping less than or equal to the address of the buffer |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
138 |
// element identified by index. |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
139 |
private long mappingAddress(long mappingOffset, long index) { |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
140 |
long indexAddress = address + index; |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
141 |
return indexAddress - mappingOffset; |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
142 |
} |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
143 |
|
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
144 |
// given a mappingOffset previously otained from calling |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
145 |
// mappingOffset() return that offset added to the buffer |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
146 |
// capacity. |
6128
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
147 |
private long mappingLength(long mappingOffset) { |
54823
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
148 |
return mappingLength(mappingOffset, (long)capacity()); |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
149 |
} |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
150 |
|
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
151 |
// given a mappingOffset previously otained from calling |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
152 |
// mappingOffset(index) return that offset added to the supplied |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
153 |
// length. |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
154 |
private long mappingLength(long mappingOffset, long length) { |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
155 |
return length + mappingOffset; |
6128
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
156 |
} |
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
157 |
|
54904
c1143a0d4e22
8224042: Add private alignDown method to MappedByteBuffer
adinn
parents:
54823
diff
changeset
|
158 |
// align address down to page size |
c1143a0d4e22
8224042: Add private alignDown method to MappedByteBuffer
adinn
parents:
54823
diff
changeset
|
159 |
private static long alignDown(long address, int pageSize) { |
c1143a0d4e22
8224042: Add private alignDown method to MappedByteBuffer
adinn
parents:
54823
diff
changeset
|
160 |
// pageSize must be a power of 2 |
c1143a0d4e22
8224042: Add private alignDown method to MappedByteBuffer
adinn
parents:
54823
diff
changeset
|
161 |
return address & ~(pageSize - 1); |
c1143a0d4e22
8224042: Add private alignDown method to MappedByteBuffer
adinn
parents:
54823
diff
changeset
|
162 |
} |
c1143a0d4e22
8224042: Add private alignDown method to MappedByteBuffer
adinn
parents:
54823
diff
changeset
|
163 |
|
2 | 164 |
/** |
57804 | 165 |
* Tells whether this buffer was mapped against a non-volatile |
166 |
* memory device by passing one of the sync map modes {@link |
|
167 |
* jdk.nio.mapmode.ExtendedMapMode#READ_ONLY_SYNC |
|
168 |
* ExtendedMapModeMapMode#READ_ONLY_SYNC} or {@link |
|
169 |
* jdk.nio.mapmode.ExtendedMapMode#READ_ONLY_SYNC |
|
170 |
* ExtendedMapMode#READ_WRITE_SYNC} in the call to {@link |
|
171 |
* java.nio.channels.FileChannel#map FileChannel.map} or was |
|
172 |
* mapped by passing one of the other map modes. |
|
173 |
* |
|
174 |
* @return true if the file was mapped using one of the sync map |
|
175 |
* modes, otherwise false. |
|
176 |
*/ |
|
177 |
private boolean isSync() { |
|
178 |
return isSync; |
|
179 |
} |
|
180 |
||
181 |
/** |
|
2 | 182 |
* Tells whether or not this buffer's content is resident in physical |
183 |
* memory. |
|
184 |
* |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
27292
diff
changeset
|
185 |
* <p> A return value of {@code true} implies that it is highly likely |
2 | 186 |
* that all of the data in this buffer is resident in physical memory and |
187 |
* may therefore be accessed without incurring any virtual-memory page |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
27292
diff
changeset
|
188 |
* faults or I/O operations. A return value of {@code false} does not |
2 | 189 |
* necessarily imply that the buffer's content is not resident in physical |
190 |
* memory. |
|
191 |
* |
|
192 |
* <p> The returned value is a hint, rather than a guarantee, because the |
|
193 |
* underlying operating system may have paged out some of the buffer's data |
|
194 |
* by the time that an invocation of this method returns. </p> |
|
195 |
* |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
27292
diff
changeset
|
196 |
* @return {@code true} if it is likely that this buffer's content |
2 | 197 |
* is resident in physical memory |
198 |
*/ |
|
199 |
public final boolean isLoaded() { |
|
48847
da4b1106787e
8191416: (bf) DirectByteBuffer extends MappedByteBuffer, confuses instanceof tests
bpb
parents:
47216
diff
changeset
|
200 |
if (fd == null) { |
da4b1106787e
8191416: (bf) DirectByteBuffer extends MappedByteBuffer, confuses instanceof tests
bpb
parents:
47216
diff
changeset
|
201 |
return true; |
da4b1106787e
8191416: (bf) DirectByteBuffer extends MappedByteBuffer, confuses instanceof tests
bpb
parents:
47216
diff
changeset
|
202 |
} |
57804 | 203 |
// a sync mapped buffer is always loaded |
204 |
if (isSync()) { |
|
205 |
return true; |
|
206 |
} |
|
2 | 207 |
if ((address == 0) || (capacity() == 0)) |
208 |
return true; |
|
6128
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
209 |
long offset = mappingOffset(); |
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
210 |
long length = mappingLength(offset); |
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
211 |
return isLoaded0(mappingAddress(offset), length, Bits.pageCount(length)); |
2 | 212 |
} |
213 |
||
12696
74ad88cf81e2
7168505: (bf) MappedByteBuffer.load does not load buffer's content into memory
alanb
parents:
7668
diff
changeset
|
214 |
// not used, but a potential target for a store, see load() for details. |
74ad88cf81e2
7168505: (bf) MappedByteBuffer.load does not load buffer's content into memory
alanb
parents:
7668
diff
changeset
|
215 |
private static byte unused; |
74ad88cf81e2
7168505: (bf) MappedByteBuffer.load does not load buffer's content into memory
alanb
parents:
7668
diff
changeset
|
216 |
|
2 | 217 |
/** |
218 |
* Loads this buffer's content into physical memory. |
|
219 |
* |
|
220 |
* <p> This method makes a best effort to ensure that, when it returns, |
|
221 |
* this buffer's content is resident in physical memory. Invoking this |
|
222 |
* method may cause some number of page faults and I/O operations to |
|
223 |
* occur. </p> |
|
224 |
* |
|
225 |
* @return This buffer |
|
226 |
*/ |
|
227 |
public final MappedByteBuffer load() { |
|
48847
da4b1106787e
8191416: (bf) DirectByteBuffer extends MappedByteBuffer, confuses instanceof tests
bpb
parents:
47216
diff
changeset
|
228 |
if (fd == null) { |
da4b1106787e
8191416: (bf) DirectByteBuffer extends MappedByteBuffer, confuses instanceof tests
bpb
parents:
47216
diff
changeset
|
229 |
return this; |
da4b1106787e
8191416: (bf) DirectByteBuffer extends MappedByteBuffer, confuses instanceof tests
bpb
parents:
47216
diff
changeset
|
230 |
} |
57804 | 231 |
// no need to load a sync mapped buffer |
232 |
if (isSync()) { |
|
233 |
return this; |
|
234 |
} |
|
2 | 235 |
if ((address == 0) || (capacity() == 0)) |
236 |
return this; |
|
6128
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
237 |
long offset = mappingOffset(); |
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
238 |
long length = mappingLength(offset); |
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
239 |
load0(mappingAddress(offset), length); |
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
240 |
|
12696
74ad88cf81e2
7168505: (bf) MappedByteBuffer.load does not load buffer's content into memory
alanb
parents:
7668
diff
changeset
|
241 |
// Read a byte from each page to bring it into memory. A checksum |
74ad88cf81e2
7168505: (bf) MappedByteBuffer.load does not load buffer's content into memory
alanb
parents:
7668
diff
changeset
|
242 |
// is computed as we go along to prevent the compiler from otherwise |
74ad88cf81e2
7168505: (bf) MappedByteBuffer.load does not load buffer's content into memory
alanb
parents:
7668
diff
changeset
|
243 |
// considering the loop as dead code. |
6128
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
244 |
Unsafe unsafe = Unsafe.getUnsafe(); |
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
245 |
int ps = Bits.pageSize(); |
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
246 |
int count = Bits.pageCount(length); |
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
247 |
long a = mappingAddress(offset); |
12696
74ad88cf81e2
7168505: (bf) MappedByteBuffer.load does not load buffer's content into memory
alanb
parents:
7668
diff
changeset
|
248 |
byte x = 0; |
49210
7c795d301dbf
8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents:
48847
diff
changeset
|
249 |
try { |
7c795d301dbf
8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents:
48847
diff
changeset
|
250 |
for (int i=0; i<count; i++) { |
7c795d301dbf
8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents:
48847
diff
changeset
|
251 |
// TODO consider changing to getByteOpaque thus avoiding |
7c795d301dbf
8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents:
48847
diff
changeset
|
252 |
// dead code elimination and the need to calculate a checksum |
7c795d301dbf
8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents:
48847
diff
changeset
|
253 |
x ^= unsafe.getByte(a); |
7c795d301dbf
8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents:
48847
diff
changeset
|
254 |
a += ps; |
7c795d301dbf
8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents:
48847
diff
changeset
|
255 |
} |
7c795d301dbf
8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents:
48847
diff
changeset
|
256 |
} finally { |
7c795d301dbf
8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents:
48847
diff
changeset
|
257 |
Reference.reachabilityFence(this); |
6128
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
258 |
} |
12696
74ad88cf81e2
7168505: (bf) MappedByteBuffer.load does not load buffer's content into memory
alanb
parents:
7668
diff
changeset
|
259 |
if (unused != 0) |
74ad88cf81e2
7168505: (bf) MappedByteBuffer.load does not load buffer's content into memory
alanb
parents:
7668
diff
changeset
|
260 |
unused = x; |
6128
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
261 |
|
2 | 262 |
return this; |
263 |
} |
|
264 |
||
265 |
/** |
|
266 |
* Forces any changes made to this buffer's content to be written to the |
|
267 |
* storage device containing the mapped file. |
|
268 |
* |
|
269 |
* <p> If the file mapped into this buffer resides on a local storage |
|
270 |
* device then when this method returns it is guaranteed that all changes |
|
271 |
* made to the buffer since it was created, or since this method was last |
|
272 |
* invoked, will have been written to that device. |
|
273 |
* |
|
274 |
* <p> If the file does not reside on a local device then no such guarantee |
|
275 |
* is made. |
|
276 |
* |
|
277 |
* <p> If this buffer was not mapped in read/write mode ({@link |
|
55466
a6411f1e63f3
8226203: MappedByteBuffer.force method may have no effect on implementation specific map modes
adinn
parents:
54904
diff
changeset
|
278 |
* java.nio.channels.FileChannel.MapMode#READ_WRITE}) then |
a6411f1e63f3
8226203: MappedByteBuffer.force method may have no effect on implementation specific map modes
adinn
parents:
54904
diff
changeset
|
279 |
* invoking this method may have no effect. In particular, the |
a6411f1e63f3
8226203: MappedByteBuffer.force method may have no effect on implementation specific map modes
adinn
parents:
54904
diff
changeset
|
280 |
* method has no effect for buffers mapped in read-only or private |
a6411f1e63f3
8226203: MappedByteBuffer.force method may have no effect on implementation specific map modes
adinn
parents:
54904
diff
changeset
|
281 |
* mapping modes. This method may or may not have an effect for |
a6411f1e63f3
8226203: MappedByteBuffer.force method may have no effect on implementation specific map modes
adinn
parents:
54904
diff
changeset
|
282 |
* implementation-specific mapping modes. </p> |
2 | 283 |
* |
284 |
* @return This buffer |
|
285 |
*/ |
|
286 |
public final MappedByteBuffer force() { |
|
48847
da4b1106787e
8191416: (bf) DirectByteBuffer extends MappedByteBuffer, confuses instanceof tests
bpb
parents:
47216
diff
changeset
|
287 |
if (fd == null) { |
da4b1106787e
8191416: (bf) DirectByteBuffer extends MappedByteBuffer, confuses instanceof tests
bpb
parents:
47216
diff
changeset
|
288 |
return this; |
da4b1106787e
8191416: (bf) DirectByteBuffer extends MappedByteBuffer, confuses instanceof tests
bpb
parents:
47216
diff
changeset
|
289 |
} |
57804 | 290 |
if (isSync) { |
291 |
return force(0, limit()); |
|
292 |
} |
|
6128
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
293 |
if ((address != 0) && (capacity() != 0)) { |
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
294 |
long offset = mappingOffset(); |
7025
6e002f9a2899
6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents:
6128
diff
changeset
|
295 |
force0(fd, mappingAddress(offset), mappingLength(offset)); |
6128
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
296 |
} |
2 | 297 |
return this; |
298 |
} |
|
299 |
||
54823
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
300 |
/** |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
301 |
* Forces any changes made to a region of this buffer's content to |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
302 |
* be written to the storage device containing the mapped |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
303 |
* file. The region starts at the given {@code index} in this |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
304 |
* buffer and is {@code length} bytes. |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
305 |
* |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
306 |
* <p> If the file mapped into this buffer resides on a local |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
307 |
* storage device then when this method returns it is guaranteed |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
308 |
* that all changes made to the selected region buffer since it |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
309 |
* was created, or since this method was last invoked, will have |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
310 |
* been written to that device. The force operation is free to |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
311 |
* write bytes that lie outside the specified region, for example |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
312 |
* to ensure that data blocks of some device-specific granularity |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
313 |
* are transferred in their entirety. |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
314 |
* |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
315 |
* <p> If the file does not reside on a local device then no such |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
316 |
* guarantee is made. |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
317 |
* |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
318 |
* <p> If this buffer was not mapped in read/write mode ({@link |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
319 |
* java.nio.channels.FileChannel.MapMode#READ_WRITE}) then |
55466
a6411f1e63f3
8226203: MappedByteBuffer.force method may have no effect on implementation specific map modes
adinn
parents:
54904
diff
changeset
|
320 |
* invoking this method may have no effect. In particular, the |
a6411f1e63f3
8226203: MappedByteBuffer.force method may have no effect on implementation specific map modes
adinn
parents:
54904
diff
changeset
|
321 |
* method has no effect for buffers mapped in read-only or private |
a6411f1e63f3
8226203: MappedByteBuffer.force method may have no effect on implementation specific map modes
adinn
parents:
54904
diff
changeset
|
322 |
* mapping modes. This method may or may not have an effect for |
a6411f1e63f3
8226203: MappedByteBuffer.force method may have no effect on implementation specific map modes
adinn
parents:
54904
diff
changeset
|
323 |
* implementation-specific mapping modes. </p> |
54823
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
324 |
* |
58242
94bb65cb37d3
8230648: Replace @exception tag with @throws in java.base
jboes
parents:
57804
diff
changeset
|
325 |
* @param index |
94bb65cb37d3
8230648: Replace @exception tag with @throws in java.base
jboes
parents:
57804
diff
changeset
|
326 |
* The index of the first byte in the buffer region that is |
94bb65cb37d3
8230648: Replace @exception tag with @throws in java.base
jboes
parents:
57804
diff
changeset
|
327 |
* to be written back to storage; must be non-negative |
94bb65cb37d3
8230648: Replace @exception tag with @throws in java.base
jboes
parents:
57804
diff
changeset
|
328 |
* and less than limit() |
54823
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
329 |
* |
58242
94bb65cb37d3
8230648: Replace @exception tag with @throws in java.base
jboes
parents:
57804
diff
changeset
|
330 |
* @param length |
94bb65cb37d3
8230648: Replace @exception tag with @throws in java.base
jboes
parents:
57804
diff
changeset
|
331 |
* The length of the region in bytes; must be non-negative |
94bb65cb37d3
8230648: Replace @exception tag with @throws in java.base
jboes
parents:
57804
diff
changeset
|
332 |
* and no larger than limit() - index |
54823
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
333 |
* |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
334 |
* @throws IndexOutOfBoundsException |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
335 |
* if the preconditions on the index and length do not |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
336 |
* hold. |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
337 |
* |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
338 |
* @return This buffer |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
339 |
* |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
340 |
* @since 13 |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
341 |
*/ |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
342 |
public final MappedByteBuffer force(int index, int length) { |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
343 |
if (fd == null) { |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
344 |
return this; |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
345 |
} |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
346 |
if ((address != 0) && (limit() != 0)) { |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
347 |
// check inputs |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
348 |
Objects.checkFromIndexSize(index, length, limit()); |
57804 | 349 |
if (isSync) { |
350 |
// simply force writeback of associated cache lines |
|
351 |
Unsafe.getUnsafe().writebackMemory(address + index, length); |
|
352 |
} else { |
|
353 |
// force writeback via file descriptor |
|
354 |
long offset = mappingOffset(index); |
|
355 |
force0(fd, mappingAddress(offset, index), mappingLength(offset, length)); |
|
356 |
} |
|
54823
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
357 |
} |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
358 |
return this; |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
359 |
} |
1b940da275d2
8221696: MappedByteBuffer.force method to specify range
adinn
parents:
49210
diff
changeset
|
360 |
|
6128
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
361 |
private native boolean isLoaded0(long address, long length, int pageCount); |
f95e5fdc1a65
6934977: (bf) MappedByteBuffer.load can SIGBUS if file is truncated
alanb
parents:
5506
diff
changeset
|
362 |
private native void load0(long address, long length); |
7025
6e002f9a2899
6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents:
6128
diff
changeset
|
363 |
private native void force0(FileDescriptor fd, long address, long length); |
27292
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
364 |
|
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
365 |
// -- Covariant return type overrides |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
366 |
|
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
367 |
/** |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
368 |
* {@inheritDoc} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
369 |
*/ |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
370 |
@Override |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
371 |
public final MappedByteBuffer position(int newPosition) { |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
372 |
super.position(newPosition); |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
373 |
return this; |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
374 |
} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
375 |
|
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
376 |
/** |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
377 |
* {@inheritDoc} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
378 |
*/ |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
379 |
@Override |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
380 |
public final MappedByteBuffer limit(int newLimit) { |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
381 |
super.limit(newLimit); |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
382 |
return this; |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
383 |
} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
384 |
|
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
385 |
/** |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
386 |
* {@inheritDoc} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
387 |
*/ |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
388 |
@Override |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
389 |
public final MappedByteBuffer mark() { |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
390 |
super.mark(); |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
391 |
return this; |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
392 |
} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
393 |
|
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
394 |
/** |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
395 |
* {@inheritDoc} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
396 |
*/ |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
397 |
@Override |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
398 |
public final MappedByteBuffer reset() { |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
399 |
super.reset(); |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
400 |
return this; |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
401 |
} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
402 |
|
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
403 |
/** |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
404 |
* {@inheritDoc} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
405 |
*/ |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
406 |
@Override |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
407 |
public final MappedByteBuffer clear() { |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
408 |
super.clear(); |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
409 |
return this; |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
410 |
} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
411 |
|
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
412 |
/** |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
413 |
* {@inheritDoc} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
414 |
*/ |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
415 |
@Override |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
416 |
public final MappedByteBuffer flip() { |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
417 |
super.flip(); |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
418 |
return this; |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
419 |
} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
420 |
|
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
421 |
/** |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
422 |
* {@inheritDoc} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
423 |
*/ |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
424 |
@Override |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
425 |
public final MappedByteBuffer rewind() { |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
426 |
super.rewind(); |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
427 |
return this; |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
25859
diff
changeset
|
428 |
} |
2 | 429 |
} |