From ed483ab38b3e0b1e8169d6f17c6b3b6e40e79354 Mon Sep 17 00:00:00 2001 From: Dan Xu Date: Fri, 26 Oct 2012 11:21:02 +0100 Subject: [PATCH] 4239752: FileSystem should be a platform-specific class to avoid native code Reviewed-by: alanb, dholmes, erikj, jgish --- jdk/make/java/java/Exportedfiles.gmk | 4 +++- jdk/make/java/java/FILES_c.gmk | 3 +-- jdk/make/java/java/FILES_java.gmk | 3 ++- jdk/make/java/java/mapfile-vers | 3 +-- jdk/makefiles/CompileJavaClasses.gmk | 3 ++- jdk/makefiles/mapfiles/libjava/mapfile-vers | 3 +-- jdk/src/share/classes/java/io/File.java | 2 +- jdk/src/share/classes/java/io/FileSystem.java | 9 +------- .../java/io/DefaultFileSystem.java} | 21 +++++++++++------- .../java/io/DefaultFileSystem.java} | 22 ++++++++++++------- 10 files changed, 39 insertions(+), 34 deletions(-) rename jdk/src/solaris/{native/java/io/FileSystem_md.c => classes/java/io/DefaultFileSystem.java} (79%) rename jdk/src/windows/{native/java/io/FileSystem_md.c => classes/java/io/DefaultFileSystem.java} (78%) diff --git a/jdk/make/java/java/Exportedfiles.gmk b/jdk/make/java/java/Exportedfiles.gmk index 3a7c8b3ff10..f6d3c3ae1de 100644 --- a/jdk/make/java/java/Exportedfiles.gmk +++ b/jdk/make/java/java/Exportedfiles.gmk @@ -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 @@ FILES_export = \ 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 @@ FILES_export = \ 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 --git a/jdk/make/java/java/FILES_c.gmk b/jdk/make/java/java/FILES_c.gmk index be698cd70b0..aa48464771b 100644 --- a/jdk/make/java/java/FILES_c.gmk +++ b/jdk/make/java/java/FILES_c.gmk @@ -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 @@ FILES_c = \ Compiler.c \ Console_md.c \ Double.c \ - FileSystem_md.c \ FileDescriptor_md.c \ FileInputStream.c \ FileInputStream_md.c \ diff --git a/jdk/make/java/java/FILES_java.gmk b/jdk/make/java/java/FILES_java.gmk index efbf73b744d..246acf3e3aa 100644 --- a/jdk/make/java/java/FILES_java.gmk +++ b/jdk/make/java/java/FILES_java.gmk @@ -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_JAVA_java = \ 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 --git a/jdk/make/java/java/mapfile-vers b/jdk/make/java/java/mapfile-vers index 42ec3ca7277..97938361c99 100644 --- a/jdk/make/java/java/mapfile-vers +++ b/jdk/make/java/java/mapfile-vers @@ -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 @@ SUNWprivate_1.1 { 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 --git a/jdk/makefiles/CompileJavaClasses.gmk b/jdk/makefiles/CompileJavaClasses.gmk index 879ffadfed1..c3a5eab9237 100644 --- a/jdk/makefiles/CompileJavaClasses.gmk +++ b/jdk/makefiles/CompileJavaClasses.gmk @@ -312,7 +312,8 @@ $(eval $(call SetupJavaCompilation,BUILD_JDK,\ 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 --git a/jdk/makefiles/mapfiles/libjava/mapfile-vers b/jdk/makefiles/mapfiles/libjava/mapfile-vers index 42ec3ca7277..97938361c99 100644 --- a/jdk/makefiles/mapfiles/libjava/mapfile-vers +++ b/jdk/makefiles/mapfiles/libjava/mapfile-vers @@ -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 @@ SUNWprivate_1.1 { 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 --git a/jdk/src/share/classes/java/io/File.java b/jdk/src/share/classes/java/io/File.java index 3c0fafca5c1..dd313dd97d0 100644 --- a/jdk/src/share/classes/java/io/File.java +++ b/jdk/src/share/classes/java/io/File.java @@ -153,7 +153,7 @@ public class File /** * 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 --git a/jdk/src/share/classes/java/io/FileSystem.java b/jdk/src/share/classes/java/io/FileSystem.java index 0afed180da8..9baaa3cc187 100644 --- a/jdk/src/share/classes/java/io/FileSystem.java +++ b/jdk/src/share/classes/java/io/FileSystem.java @@ -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 @@ package java.io; abstract class FileSystem { - /** - * Return the FileSystem object representing this platform's local - * filesystem. - */ - public static native FileSystem getFileSystem(); - - /* -- Normalization and construction -- */ /** diff --git a/jdk/src/solaris/native/java/io/FileSystem_md.c b/jdk/src/solaris/classes/java/io/DefaultFileSystem.java similarity index 79% rename from jdk/src/solaris/native/java/io/FileSystem_md.c rename to jdk/src/solaris/classes/java/io/DefaultFileSystem.java index af4aaba6428..8e8cf081f01 100644 --- a/jdk/src/solaris/native/java/io/FileSystem_md.c +++ b/jdk/src/solaris/classes/java/io/DefaultFileSystem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -23,13 +23,18 @@ * questions. */ -#include "jni.h" -#include "jni_util.h" -#include "java_io_FileSystem.h" +package java.io; +/** + * + * @since 1.8 + */ +class DefaultFileSystem { -JNIEXPORT jobject JNICALL -Java_java_io_FileSystem_getFileSystem(JNIEnv *env, jclass ignored) -{ - return JNU_NewObjectByName(env, "java/io/UnixFileSystem", "()V"); + /** + * Return the FileSystem object for Unix-based platform. + */ + public static FileSystem getFileSystem() { + return new UnixFileSystem(); + } } diff --git a/jdk/src/windows/native/java/io/FileSystem_md.c b/jdk/src/windows/classes/java/io/DefaultFileSystem.java similarity index 78% rename from jdk/src/windows/native/java/io/FileSystem_md.c rename to jdk/src/windows/classes/java/io/DefaultFileSystem.java index bd813e7dbf0..9256dca151d 100644 --- a/jdk/src/windows/native/java/io/FileSystem_md.c +++ b/jdk/src/windows/classes/java/io/DefaultFileSystem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -23,12 +23,18 @@ * questions. */ -#include -#include "jni.h" -#include "jni_util.h" +package java.io; -JNIEXPORT jobject JNICALL -Java_java_io_FileSystem_getFileSystem(JNIEnv *env, jclass ignored) -{ - return JNU_NewObjectByName(env, "java/io/WinNTFileSystem", "()V"); +/** + * + * @since 1.8 + */ +class DefaultFileSystem { + + /** + * Return the FileSystem object for Windows platform. + */ + public static FileSystem getFileSystem() { + return new WinNTFileSystem(); + } }