# HG changeset patch # User dxu # Date 1351246862 -3600 # Node ID 3510b4bf90ee3e97e78544ada21e5628f679b94f # Parent 5acca3d1f124bdf2b134297905630a02da3741ce 4239752: FileSystem should be a platform-specific class to avoid native code Reviewed-by: alanb, dholmes, erikj, jgish diff -r 5acca3d1f124 -r 3510b4bf90ee jdk/make/java/java/Exportedfiles.gmk --- a/jdk/make/java/java/Exportedfiles.gmk Thu Oct 25 17:34:24 2012 -0700 +++ b/jdk/make/java/java/Exportedfiles.gmk Fri Oct 26 11:21:02 2012 +0100 @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2012, 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 @@ -66,6 +66,7 @@ java/util/prefs/FileSystemPreferences.java \ java/io/Console.java \ java/io/FileDescriptor.java \ + java/io/DefaultFileSystem.java \ java/io/InputStream.java \ java/io/FileInputStream.java \ java/io/FileOutputStream.java \ @@ -142,6 +143,7 @@ java/io/Console.java \ java/io/FileSystem.java \ java/io/FileDescriptor.java \ + java/io/DefaultFileSystem.java \ java/io/InputStream.java \ java/io/FileInputStream.java \ java/io/FileOutputStream.java \ diff -r 5acca3d1f124 -r 3510b4bf90ee jdk/make/java/java/FILES_c.gmk --- a/jdk/make/java/java/FILES_c.gmk Thu Oct 25 17:34:24 2012 -0700 +++ b/jdk/make/java/java/FILES_c.gmk Fri Oct 26 11:21:02 2012 +0100 @@ -1,5 +1,5 @@ # -# Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1996, 2012, 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 @@ -32,7 +32,6 @@ Compiler.c \ Console_md.c \ Double.c \ - FileSystem_md.c \ FileDescriptor_md.c \ FileInputStream.c \ FileInputStream_md.c \ diff -r 5acca3d1f124 -r 3510b4bf90ee jdk/make/java/java/FILES_java.gmk --- a/jdk/make/java/java/FILES_java.gmk Thu Oct 25 17:34:24 2012 -0700 +++ b/jdk/make/java/java/FILES_java.gmk Fri Oct 26 11:21:02 2012 +0100 @@ -1,5 +1,5 @@ # -# Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1996, 2012, 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 @@ -438,6 +438,7 @@ java/io/File.java \ java/io/FileSystem.java \ java/io/FileDescriptor.java \ + java/io/DefaultFileSystem.java \ java/io/FilenameFilter.java \ java/io/FileFilter.java \ java/io/FilePermission.java \ diff -r 5acca3d1f124 -r 3510b4bf90ee jdk/make/java/java/mapfile-vers --- a/jdk/make/java/java/mapfile-vers Thu Oct 25 17:34:24 2012 -0700 +++ b/jdk/make/java/java/mapfile-vers Fri Oct 26 11:21:02 2012 +0100 @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2012, 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 @@ -87,7 +87,6 @@ Java_java_io_FileOutputStream_open; Java_java_io_FileOutputStream_write; Java_java_io_FileOutputStream_writeBytes; - Java_java_io_FileSystem_getFileSystem; Java_java_io_ObjectInputStream_bytesToDoubles; Java_java_io_ObjectInputStream_bytesToFloats; Java_java_io_ObjectOutputStream_doublesToBytes; diff -r 5acca3d1f124 -r 3510b4bf90ee jdk/makefiles/CompileJavaClasses.gmk --- a/jdk/makefiles/CompileJavaClasses.gmk Thu Oct 25 17:34:24 2012 -0700 +++ b/jdk/makefiles/CompileJavaClasses.gmk Fri Oct 26 11:21:02 2012 +0100 @@ -312,7 +312,8 @@ JDK_BASE_HEADER_CLASSES:=java.lang.Integer \ java.lang.Long \ java.net.SocketOptions \ - sun.nio.ch.IOStatus + sun.nio.ch.IOStatus \ + java.io.FileSystem JDK_BASE_HEADER_JAVA_FILES:=$(patsubst %,$(JDK_TOPDIR)/src/share/classes/%.java,\ $(subst .,/,$(JDK_BASE_HEADER_CLASSES))) diff -r 5acca3d1f124 -r 3510b4bf90ee jdk/makefiles/mapfiles/libjava/mapfile-vers --- a/jdk/makefiles/mapfiles/libjava/mapfile-vers Thu Oct 25 17:34:24 2012 -0700 +++ b/jdk/makefiles/mapfiles/libjava/mapfile-vers Fri Oct 26 11:21:02 2012 +0100 @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2012, 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 @@ -87,7 +87,6 @@ Java_java_io_FileOutputStream_open; Java_java_io_FileOutputStream_write; Java_java_io_FileOutputStream_writeBytes; - Java_java_io_FileSystem_getFileSystem; Java_java_io_ObjectInputStream_bytesToDoubles; Java_java_io_ObjectInputStream_bytesToFloats; Java_java_io_ObjectOutputStream_doublesToBytes; diff -r 5acca3d1f124 -r 3510b4bf90ee jdk/src/share/classes/java/io/File.java --- a/jdk/src/share/classes/java/io/File.java Thu Oct 25 17:34:24 2012 -0700 +++ b/jdk/src/share/classes/java/io/File.java Fri Oct 26 11:21:02 2012 +0100 @@ -153,7 +153,7 @@ /** * The FileSystem object representing the platform's local file system. */ - private static final FileSystem fs = FileSystem.getFileSystem(); + private static final FileSystem fs = DefaultFileSystem.getFileSystem(); /** * This abstract pathname's normalized pathname string. A normalized diff -r 5acca3d1f124 -r 3510b4bf90ee jdk/src/share/classes/java/io/FileSystem.java --- a/jdk/src/share/classes/java/io/FileSystem.java Thu Oct 25 17:34:24 2012 -0700 +++ b/jdk/src/share/classes/java/io/FileSystem.java Fri Oct 26 11:21:02 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2012, 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 @@ -32,13 +32,6 @@ abstract class FileSystem { - /** - * Return the FileSystem object representing this platform's local - * filesystem. - */ - public static native FileSystem getFileSystem(); - - /* -- Normalization and construction -- */ /** diff -r 5acca3d1f124 -r 3510b4bf90ee jdk/src/solaris/classes/java/io/DefaultFileSystem.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/solaris/classes/java/io/DefaultFileSystem.java Fri Oct 26 11:21:02 2012 +0100 @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2012, 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 + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.io; + +/** + * + * @since 1.8 + */ +class DefaultFileSystem { + + /** + * Return the FileSystem object for Unix-based platform. + */ + public static FileSystem getFileSystem() { + return new UnixFileSystem(); + } +} diff -r 5acca3d1f124 -r 3510b4bf90ee jdk/src/solaris/native/java/io/FileSystem_md.c --- a/jdk/src/solaris/native/java/io/FileSystem_md.c Thu Oct 25 17:34:24 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/* - * Copyright (c) 1998, 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 - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "jni.h" -#include "jni_util.h" -#include "java_io_FileSystem.h" - - -JNIEXPORT jobject JNICALL -Java_java_io_FileSystem_getFileSystem(JNIEnv *env, jclass ignored) -{ - return JNU_NewObjectByName(env, "java/io/UnixFileSystem", "()V"); -} diff -r 5acca3d1f124 -r 3510b4bf90ee jdk/src/windows/classes/java/io/DefaultFileSystem.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/windows/classes/java/io/DefaultFileSystem.java Fri Oct 26 11:21:02 2012 +0100 @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2012, 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 + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.io; + +/** + * + * @since 1.8 + */ +class DefaultFileSystem { + + /** + * Return the FileSystem object for Windows platform. + */ + public static FileSystem getFileSystem() { + return new WinNTFileSystem(); + } +} diff -r 5acca3d1f124 -r 3510b4bf90ee jdk/src/windows/native/java/io/FileSystem_md.c --- a/jdk/src/windows/native/java/io/FileSystem_md.c Thu Oct 25 17:34:24 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -/* - * Copyright (c) 1998, 2012, 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 - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include -#include "jni.h" -#include "jni_util.h" - -JNIEXPORT jobject JNICALL -Java_java_io_FileSystem_getFileSystem(JNIEnv *env, jclass ignored) -{ - return JNU_NewObjectByName(env, "java/io/WinNTFileSystem", "()V"); -}