< prev index next >

src/java.base/solaris/classes/sun/nio/fs/SolarisFileSystem.java

Print this page
rev 14210 : 8154231: Simplify access to System properties from JDK code
Reviewed-by: rriggs


  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.nio.fs;
  27 
  28 import java.nio.file.*;
  29 import java.io.IOException;
  30 import java.util.*;
  31 import java.security.AccessController;
  32 import sun.security.action.GetPropertyAction;
  33 import static sun.nio.fs.SolarisNativeDispatcher.*;
  34 
  35 /**
  36  * Solaris implementation of FileSystem
  37  */
  38 
  39 class SolarisFileSystem extends UnixFileSystem {
  40     private final boolean hasSolaris11Features;
  41 
  42     SolarisFileSystem(UnixFileSystemProvider provider, String dir) {
  43         super(provider, dir);
  44 
  45         // check os.version
  46         String osversion = AccessController
  47             .doPrivileged(new GetPropertyAction("os.version"));
  48         String[] vers = Util.split(osversion, '.');
  49         assert vers.length >= 2;
  50         int majorVersion = Integer.parseInt(vers[0]);
  51         int minorVersion = Integer.parseInt(vers[1]);
  52         this.hasSolaris11Features =
  53             (majorVersion > 5 || (majorVersion == 5 && minorVersion >= 11));
  54     }
  55 
  56     @Override
  57     boolean isSolaris() {
  58         return true;
  59     }
  60 
  61     @Override
  62     public WatchService newWatchService()
  63         throws IOException
  64     {
  65         // FEN available since Solaris 11
  66         if (hasSolaris11Features) {
  67             return new SolarisWatchService(this);




  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.nio.fs;
  27 
  28 import java.nio.file.*;
  29 import java.io.IOException;
  30 import java.util.*;

  31 import sun.security.action.GetPropertyAction;
  32 import static sun.nio.fs.SolarisNativeDispatcher.*;
  33 
  34 /**
  35  * Solaris implementation of FileSystem
  36  */
  37 
  38 class SolarisFileSystem extends UnixFileSystem {
  39     private final boolean hasSolaris11Features;
  40 
  41     SolarisFileSystem(UnixFileSystemProvider provider, String dir) {
  42         super(provider, dir);
  43 
  44         // check os.version
  45         String osversion = GetPropertyAction.getProperty("os.version");

  46         String[] vers = Util.split(osversion, '.');
  47         assert vers.length >= 2;
  48         int majorVersion = Integer.parseInt(vers[0]);
  49         int minorVersion = Integer.parseInt(vers[1]);
  50         this.hasSolaris11Features =
  51             (majorVersion > 5 || (majorVersion == 5 && minorVersion >= 11));
  52     }
  53 
  54     @Override
  55     boolean isSolaris() {
  56         return true;
  57     }
  58 
  59     @Override
  60     public WatchService newWatchService()
  61         throws IOException
  62     {
  63         // FEN available since Solaris 11
  64         if (hasSolaris11Features) {
  65             return new SolarisWatchService(this);


< prev index next >