< prev index next >

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

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2001, 2009, 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 --- 1,7 ---- /* ! * 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,39 **** */ package sun.nio.ch; import java.io.IOException; ! import java.nio.channels.*; ! public class FileLockImpl ! extends FileLock { private volatile boolean invalid; FileLockImpl(FileChannel channel, long position, long size, boolean shared) { super(channel, position, size, shared); } --- 24,43 ---- */ package sun.nio.ch; import java.io.IOException; ! 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; ! 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,57 **** --- 45,69 ---- 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 >