--- old/src/java.base/share/classes/java/nio/channels/FileChannel.java 2018-07-19 11:58:58.295303596 +0100 +++ new/src/java.base/share/classes/java/nio/channels/FileChannel.java 2018-07-19 11:58:58.020302768 +0100 @@ -927,6 +927,102 @@ throws IOException; + /** + * Maps a region of this channel's file directly into memory. This + * method operates in much the same way as method #map() except + * that the it expects the file to be associated with a persistent + * memory device. + * + *

A region of a file may be mapped into memory in one of two modes: + *

+ * + * + * + *

For a read-only mapping, this channel must have been opened for + * reading; for a read/write or private mapping, this channel must have + * been opened for both reading and writing. + * + *

The {@link MappedByteBuffer mapped byte buffer} + * returned by this method will have a position of zero and a limit and + * capacity of {@code size}; its mark will be undefined. The buffer and + * the mapping that it represents will remain valid until the buffer itself + * is garbage-collected. + * + *

A mapping, once established, is not dependent upon the file channel + * that was used to create it. Closing the channel, in particular, has no + * effect upon the validity of the mapping. + * + *

Many of the details of memory-mapped files are inherently dependent + * upon the underlying operating system and are therefore unspecified. The + * behavior of this method when the requested region is not completely + * contained within this channel's file is unspecified. + * + *

Writes to the buffer will not necessarily be written back + * immediately from cache to persistent memory. However, writeback + * may be guaranteed by calling the buffer's force method ({@link + * java.nio.MappedByteBuffer#force + * java.nio.MappedByteBuffer.force()}). Buffer get and put + * operations should be much faster than the usual {@link #read + * read} and {@link #write write} methods. + * + * @param mode + + * One of the constants {@link MapMode#READ_ONLY + * READ_ONLY}, {@link MapMode#READ_WRITE READ_WRITE} + * defined in the {@link MapMode} class, according to + * whether the file is to be mapped read-only or + * read/write. Mode {@link MapMode#PRIVATE PRIVATE} is + * not allowed for a persistent mapped buffer. + * + * @param position + * The position within the file at which the mapped region + * is to start; must be non-negative + * + * @param size + * The size of the region to be mapped; must be non-negative and + * no greater than {@link java.lang.Integer#MAX_VALUE} + * + * @return The mapped byte buffer + * + * @throws NonReadableChannelException + * If the {@code mode} is {@link MapMode#READ_ONLY READ_ONLY} but + * this channel was not opened for reading + * + * @throws NonWritableChannelException + * If the {@code mode} is {@link MapMode#READ_WRITE READ_WRITE} or + * {@link MapMode#PRIVATE PRIVATE} but this channel was not opened + * for both reading and writing + * + * @throws IllegalArgumentException + * If the preconditions on the parameters do not hold + * + * @throws IOException + * If some other I/O error occurs + * + * @see java.nio.channels.FileChannel.MapMode + * @see java.nio.MappedByteBuffer + */ + public MappedByteBuffer map_persistent(MapMode mode, + long position, long size) + throws IOException + { + // a default implementation is needed so that subclasses of + // FileChannel created before this API was added fail + // appropriately. + throw new IOException("Unsupported operation: map_persistent"); + } + + // -- Locks -- /**