jdk/src/share/classes/java/nio/channels/FileLock.java

Print this page
rev 2483 : 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
6911261: Project Coin: Retrofit Automatic Resource Management (ARM) support onto platform APIs
6962571: Infinite loop in printing out Throwable stack traces with circular references
Reviewed-by: darcy, alanb
Contributed-by: jjb@google.com

*** 114,124 **** * @author Mark Reinhold * @author JSR-51 Expert Group * @since 1.4 */ ! public abstract class FileLock { private final Channel channel; private final long position; private final long size; private final boolean shared; --- 114,124 ---- * @author Mark Reinhold * @author JSR-51 Expert Group * @since 1.4 */ ! public abstract class FileLock implements AutoCloseable { private final Channel channel; private final long position; private final long size; private final boolean shared;
*** 297,306 **** --- 297,317 ---- * If an I/O error occurs */ public abstract void release() throws IOException; /** + * This method invokes the {@link #release} method. It was added + * to the class so that it could be used in conjunction with the + * automatic resource management block construct. + * + * @since 1.7 + */ + public final void close() throws IOException { + release(); + } + + /** * Returns a string describing the range, type, and validity of this lock. * * @return A descriptive string */ public final String toString() {