< prev index next >

src/java.base/share/classes/sun/nio/ch/FileLockImpl.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2001, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -24,16 +24,20 @@
  */
 
 package sun.nio.ch;
 
 import java.io.IOException;
-import java.nio.channels.*;
+import java.nio.channels.AsynchronousFileChannel;
+import java.nio.channels.Channel;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.FileChannel;
+import java.nio.channels.FileLock;
 
-public class FileLockImpl
-    extends FileLock
+class FileLockImpl extends FileLock
 {
     private volatile boolean invalid;
+    private volatile FileLockListener listener;
 
     FileLockImpl(FileChannel channel, long position, long size, boolean shared)
     {
         super(channel, position, size, shared);
     }

@@ -41,17 +45,25 @@
     FileLockImpl(AsynchronousFileChannel channel, long position, long size, boolean shared)
     {
         super(channel, position, size, shared);
     }
 
+    void setFileLockListener(FileLockListener listener) {
+        this.listener = listener;
+    }
+
     public boolean isValid() {
         return !invalid;
     }
 
     void invalidate() {
         assert Thread.holdsLock(this);
         invalid = true;
+        FileLockListener fll;
+        if ((fll = listener) != null) {
+            fll.invalidate();
+        }
     }
 
     public synchronized void release() throws IOException {
         Channel ch = acquiredBy();
         if (!ch.isOpen())
< prev index next >