src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java
changeset 48748 4d716bc7ed54
parent 48224 be0df5ab3093
child 49897 117501815bed
--- a/src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java	Mon Feb 05 11:35:56 2018 -0800
+++ b/src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java	Mon Feb 05 15:08:46 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -1083,49 +1083,19 @@
 
     // -- Locks --
 
-
-
     // keeps track of locks on this file
     private volatile FileLockTable fileLockTable;
 
-    // indicates if file locks are maintained system-wide (as per spec)
-    private static boolean isSharedFileLockTable;
-
-    // indicates if the disableSystemWideOverlappingFileLockCheck property
-    // has been checked
-    private static volatile boolean propertyChecked;
-
-    // The lock list in J2SE 1.4/5.0 was local to each FileChannel instance so
-    // the overlap check wasn't system wide when there were multiple channels to
-    // the same file. This property is used to get 1.4/5.0 behavior if desired.
-    private static boolean isSharedFileLockTable() {
-        if (!propertyChecked) {
-            synchronized (FileChannelImpl.class) {
-                if (!propertyChecked) {
-                    String value = GetPropertyAction.privilegedGetProperty(
-                            "sun.nio.ch.disableSystemWideOverlappingFileLockCheck");
-                    isSharedFileLockTable = ((value == null) || value.equals("false"));
-                    propertyChecked = true;
-                }
-            }
-        }
-        return isSharedFileLockTable;
-    }
-
     private FileLockTable fileLockTable() throws IOException {
         if (fileLockTable == null) {
             synchronized (this) {
                 if (fileLockTable == null) {
-                    if (isSharedFileLockTable()) {
-                        int ti = threads.add();
-                        try {
-                            ensureOpen();
-                            fileLockTable = FileLockTable.newSharedFileLockTable(this, fd);
-                        } finally {
-                            threads.remove(ti);
-                        }
-                    } else {
-                        fileLockTable = new SimpleFileLockTable();
+                    int ti = threads.add();
+                    try {
+                        ensureOpen();
+                        fileLockTable = new FileLockTable(this, fd);
+                    } finally {
+                        threads.remove(ti);
                     }
                 }
             }
@@ -1229,59 +1199,6 @@
         fileLockTable.remove(fli);
     }
 
-    // -- File lock support --
-
-    /**
-     * A simple file lock table that maintains a list of FileLocks obtained by a
-     * FileChannel. Use to get 1.4/5.0 behaviour.
-     */
-    private static class SimpleFileLockTable extends FileLockTable {
-        // synchronize on list for access
-        private final List<FileLock> lockList = new ArrayList<FileLock>(2);
-
-        public SimpleFileLockTable() {
-        }
-
-        private void checkList(long position, long size)
-            throws OverlappingFileLockException
-        {
-            assert Thread.holdsLock(lockList);
-            for (FileLock fl: lockList) {
-                if (fl.overlaps(position, size)) {
-                    throw new OverlappingFileLockException();
-                }
-            }
-        }
-
-        public void add(FileLock fl) throws OverlappingFileLockException {
-            synchronized (lockList) {
-                checkList(fl.position(), fl.size());
-                lockList.add(fl);
-            }
-        }
-
-        public void remove(FileLock fl) {
-            synchronized (lockList) {
-                lockList.remove(fl);
-            }
-        }
-
-        public List<FileLock> removeAll() {
-            synchronized(lockList) {
-                List<FileLock> result = new ArrayList<FileLock>(lockList);
-                lockList.clear();
-                return result;
-            }
-        }
-
-        public void replace(FileLock fl1, FileLock fl2) {
-            synchronized (lockList) {
-                lockList.remove(fl1);
-                lockList.add(fl2);
-            }
-        }
-    }
-
     // -- Native methods --
 
     // Creates a new mapping