Merge
authoralanb
Sat, 07 Jun 2008 16:11:57 +0100
changeset 696 4790b8660847
parent 690 0bf7af5e8a3b (current diff)
parent 695 8be301e3f6e7 (diff)
child 697 fb86c99b92a2
child 704 b27452376a28
Merge
--- a/jdk/src/share/classes/sun/nio/ch/NativeThreadSet.java	Fri Jun 06 15:16:19 2008 -0700
+++ b/jdk/src/share/classes/sun/nio/ch/NativeThreadSet.java	Sat Jun 07 16:11:57 2008 +0100
@@ -43,7 +43,7 @@
     //
     int add() {
         long th = NativeThread.current();
-        if (th <= 0)
+        if (th == -1)
             return -1;
         synchronized (this) {
             int start = 0;
--- a/jdk/src/solaris/classes/sun/nio/ch/NativeThread.java	Fri Jun 06 15:16:19 2008 -0700
+++ b/jdk/src/solaris/classes/sun/nio/ch/NativeThread.java	Sat Jun 07 16:11:57 2008 +0100
@@ -34,14 +34,14 @@
 // upon which Java threads are built, and defines a simple signal mechanism
 // that can be used to release a native thread from a blocking I/O operation.
 // On systems that do not require this type of signalling, the current() method
-// always returns zero and the signal(long) method has no effect.
+// always returns -1 and the signal(long) method has no effect.
 
 
 class NativeThread {
 
     // Returns an opaque token representing the native thread underlying the
     // invoking Java thread.  On systems that do not require signalling, this
-    // method always returns zero.
+    // method always returns -1.
     //
     static native long current();
 
--- a/jdk/src/solaris/native/java/io/UnixFileSystem_md.c	Fri Jun 06 15:16:19 2008 -0700
+++ b/jdk/src/solaris/native/java/io/UnixFileSystem_md.c	Sat Jun 07 16:11:57 2008 +0100
@@ -58,70 +58,6 @@
                                   "path", "Ljava/lang/String;");
 }
 
-
-/* -- Large-file support -- */
-
-/* LINUX_FIXME: ifdef __solaris__ here is wrong.  We need to move the
- * definition of stat64 into a solaris_largefile.h and create a
- * linux_largefile.h with a good stat64 structure to compile on
- * glibc2.0 based systems.
- */
-#if defined(__solaris__) && !defined(_LFS_LARGEFILE) || !_LFS_LARGEFILE
-
-/* The stat64 structure must be provided for systems without large-file support
-   (e.g., Solaris 2.5.1).  These definitions are copied from the Solaris 2.6
-   <sys/stat.h> and <sys/types.h> files.
- */
-
-typedef longlong_t      off64_t;        /* offsets within files */
-typedef u_longlong_t    ino64_t;        /* expanded inode type  */
-typedef longlong_t      blkcnt64_t;     /* count of file blocks */
-
-struct  stat64 {
-        dev_t   st_dev;
-        long    st_pad1[3];
-        ino64_t st_ino;
-        mode_t  st_mode;
-        nlink_t st_nlink;
-        uid_t   st_uid;
-        gid_t   st_gid;
-        dev_t   st_rdev;
-        long    st_pad2[2];
-        off64_t st_size;
-        timestruc_t st_atim;
-        timestruc_t st_mtim;
-        timestruc_t st_ctim;
-        long    st_blksize;
-        blkcnt64_t st_blocks;
-        char    st_fstype[_ST_FSTYPSZ];
-        long    st_pad4[8];
-};
-
-#endif  /* !_LFS_LARGEFILE */
-
-typedef int (*STAT64)(const char *, struct stat64 *);
-
-#if defined(__linux__) && defined(_LARGEFILE64_SOURCE)
-static STAT64 stat64_ptr = &stat64;
-#else
-static STAT64 stat64_ptr = NULL;
-#endif
-
-#ifndef __linux__
-#ifdef __GNUC__
-static void init64IO(void) __attribute__((constructor));
-#else
-#pragma init(init64IO)
-#endif
-#endif
-
-static void init64IO(void) {
-    void *handle = dlopen(0, RTLD_LAZY);
-    stat64_ptr = (STAT64) dlsym(handle, "_stat64");
-    dlclose(handle);
-}
-
-
 /* -- Path operations -- */
 
 extern int canonicalize(char *path, const char *out, int len);
@@ -151,18 +87,10 @@
 static jboolean
 statMode(const char *path, int *mode)
 {
-    if (stat64_ptr) {
-        struct stat64 sb;
-        if (((*stat64_ptr)(path, &sb)) == 0) {
-            *mode = sb.st_mode;
-            return JNI_TRUE;
-        }
-    } else {
-        struct stat sb;
-        if (stat(path, &sb) == 0) {
-            *mode = sb.st_mode;
-            return JNI_TRUE;
-        }
+    struct stat64 sb;
+    if (stat64(path, &sb) == 0) {
+        *mode = sb.st_mode;
+        return JNI_TRUE;
     }
     return JNI_FALSE;
 }
@@ -266,16 +194,9 @@
     jlong rv = 0;
 
     WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
-        if (stat64_ptr) {
-            struct stat64 sb;
-            if (((*stat64_ptr)(path, &sb)) == 0) {
-                rv = 1000 * (jlong)sb.st_mtime;
-            }
-        } else {
-            struct stat sb;
-            if (stat(path, &sb) == 0) {
-                rv = 1000 * (jlong)sb.st_mtime;
-            }
+        struct stat64 sb;
+        if (stat64(path, &sb) == 0) {
+            rv = 1000 * (jlong)sb.st_mtime;
         }
     } END_PLATFORM_STRING(env, path);
     return rv;
@@ -289,16 +210,9 @@
     jlong rv = 0;
 
     WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
-        if (stat64_ptr) {
-            struct stat64 sb;
-            if (((*stat64_ptr)(path, &sb)) == 0) {
-                rv = sb.st_size;
-            }
-        } else {
-            struct stat sb;
-            if (stat(path, &sb) == 0) {
-                rv = sb.st_size;
-            }
+        struct stat64 sb;
+        if (stat64(path, &sb) == 0) {
+            rv = sb.st_size;
         }
     } END_PLATFORM_STRING(env, path);
     return rv;
@@ -447,15 +361,6 @@
     return rv;
 }
 
-
-/* Bug in solaris /usr/include/sys/time.h? */
-#ifdef __solaris__
-extern int utimes(const char *, const struct timeval *);
-#elif defined(__linux___)
-extern int utimes(const char *, struct timeval *);
-#endif
-
-
 JNIEXPORT jboolean JNICALL
 Java_java_io_UnixFileSystem_setLastModifiedTime(JNIEnv *env, jobject this,
                                                 jobject file, jlong time)
@@ -463,47 +368,22 @@
     jboolean rv = JNI_FALSE;
 
     WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
-        struct timeval tv[2];
-#ifdef __solaris__
-        timestruc_t ts;
+        struct stat64 sb;
 
-        if (stat64_ptr) {
-            struct stat64 sb;
-            if (((*stat64_ptr)(path, &sb)) == 0)
-                ts = sb.st_atim;
-            else
-                goto error;
-        } else {
-            struct stat sb;
-            if (stat(path, &sb) == 0)
-                ts = sb.st_atim;
-            else
-                goto error;
-        }
-#endif
+        if (stat64(path, &sb) == 0) {
+            struct timeval tv[2];
 
-        /* Preserve access time */
-#ifdef __linux__
-        struct stat sb;
+            /* Preserve access time */
+            tv[0].tv_sec = sb.st_atime;
+            tv[0].tv_usec = 0;
 
-        if (stat(path, &sb) == 0) {
+            /* Change last-modified time */
+            tv[1].tv_sec = time / 1000;
+            tv[1].tv_usec = (time % 1000) * 1000;
 
-        tv[0].tv_sec = sb.st_atime;
-        tv[0].tv_usec = 0;
+            if (utimes(path, tv) == 0)
+                rv = JNI_TRUE;
         }
-#else
-        tv[0].tv_sec = ts.tv_sec;
-        tv[0].tv_usec = ts.tv_nsec / 1000;
-#endif
-
-        /* Change last-modified time */
-        tv[1].tv_sec = time / 1000;
-        tv[1].tv_usec = (time % 1000) * 1000;
-
-        if (utimes(path, tv) >= 0)
-            rv = JNI_TRUE;
-
-    error: ;
     } END_PLATFORM_STRING(env, path);
 
     return rv;
--- a/jdk/src/windows/classes/sun/nio/ch/NativeThread.java	Fri Jun 06 15:16:19 2008 -0700
+++ b/jdk/src/windows/classes/sun/nio/ch/NativeThread.java	Sat Jun 07 16:11:57 2008 +0100
@@ -31,7 +31,7 @@
 
 class NativeThread {
 
-    static long current() { return 0; }
+    static long current() { return -1; }
 
     static void signal(long nt) { }
 
--- a/jdk/src/windows/native/java/io/WinNTFileSystem_md.c	Fri Jun 06 15:16:19 2008 -0700
+++ b/jdk/src/windows/native/java/io/WinNTFileSystem_md.c	Sat Jun 07 16:11:57 2008 +0100
@@ -229,26 +229,29 @@
 JNICALL Java_java_io_WinNTFileSystem_checkAccess(JNIEnv *env, jobject this,
                                                  jobject file, jint access)
 {
-    jboolean rv = JNI_FALSE;
-    int mode;
+    DWORD attr;
     WCHAR *pathbuf = fileToNTPath(env, file, ids.path);
     if (pathbuf == NULL)
         return JNI_FALSE;
+    attr = GetFileAttributesW(pathbuf);
+    free(pathbuf);
+    if (attr == INVALID_FILE_ATTRIBUTES)
+        return JNI_FALSE;
     switch (access) {
     case java_io_FileSystem_ACCESS_READ:
     case java_io_FileSystem_ACCESS_EXECUTE:
-        mode = 4;
-        break;
+        return JNI_TRUE;
     case java_io_FileSystem_ACCESS_WRITE:
-        mode = 2;
-        break;
-    default: assert(0);
+        /* Read-only attribute ignored on directories */
+        if ((attr & FILE_ATTRIBUTE_DIRECTORY) ||
+            (attr & FILE_ATTRIBUTE_READONLY) == 0)
+            return JNI_TRUE;
+        else
+            return JNI_FALSE;
+    default:
+        assert(0);
+        return JNI_FALSE;
     }
-    if (_waccess(pathbuf, mode) == 0) {
-        rv = JNI_TRUE;
-    }
-    free(pathbuf);
-    return rv;
 }
 
 JNIEXPORT jboolean JNICALL
--- a/jdk/test/java/io/File/SetLastModified.java	Fri Jun 06 15:16:19 2008 -0700
+++ b/jdk/test/java/io/File/SetLastModified.java	Sat Jun 07 16:11:57 2008 +0100
@@ -22,11 +22,13 @@
  */
 
 /* @test
-   @bug 4091757
+   @bug 4091757 6652379
    @summary Basic test for setLastModified method
  */
 
 import java.io.*;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
 
 
 public class SetLastModified {
@@ -95,13 +97,24 @@
         if (f.setLastModified(nt))
             throw new Exception("Succeeded on non-existent file: " + f);
 
-        OutputStream o = new FileOutputStream(f);
-        o.write('x');
-        o.close();
-        ot = f.lastModified();
-        if (!f.setLastModified(nt))
-            throw new Exception("setLastModified failed on file: " + f);
-        ck(f, nt, f.lastModified());
+        // set/check last modified on files of size 1, 1GB+1, 2GB+1, ..
+        // On Windows we only test with a tiny file as that platform doesn't
+        // support sparse files by default and so the test takes too long.
+        final long G = 1024L * 1024L * 1024L;
+        final long MAX_POSITION =
+            System.getProperty("os.name").startsWith("Windows") ? 0L : 3L*G;
+        long pos = 0L;
+        while (pos <= MAX_POSITION) {
+            FileChannel fc = new FileOutputStream(f).getChannel();
+            fc.position(pos).write(ByteBuffer.wrap("x".getBytes()));
+            fc.close();
+            ot = f.lastModified();
+            System.out.format("check with file size: %d\n", f.length());
+            if (!f.setLastModified(nt))
+                throw new Exception("setLastModified failed on file: " + f);
+            ck(f, nt, f.lastModified());
+            pos += G;
+        }
 
         if (!f.delete()) throw new Exception("Can't delete test file " + f);
         if (!d2.delete()) throw new Exception("Can't delete test directory " + d2);
--- a/jdk/test/java/io/File/SetReadOnly.java	Fri Jun 06 15:16:19 2008 -0700
+++ b/jdk/test/java/io/File/SetReadOnly.java	Sat Jun 07 16:11:57 2008 +0100
@@ -22,7 +22,7 @@
  */
 
 /* @test
-   @bug 4091757
+   @bug 4091757 4939819
    @summary Basic test for setReadOnly method
  */
 
@@ -59,8 +59,15 @@
             throw new Exception(f + ": Cannot create directory");
         if (!f.setReadOnly())
             throw new Exception(f + ": Failed on directory");
-        if (f.canWrite())
-            throw new Exception(f + ": Directory is writeable");
+        // The readonly attribute on Windows does not make a folder read-only
+        if (System.getProperty("os.name").startsWith("Windows")) {
+            if (!f.canWrite())
+                throw new Exception(f + ": Directory is not writeable");
+        } else {
+            if (f.canWrite())
+                throw new Exception(f + ": Directory is writeable");
+        }
+
         if (!f.delete())
             throw new Exception(f + ": Cannot delete directory");
 
--- a/jdk/test/java/nio/channels/AsyncCloseAndInterrupt.java	Fri Jun 06 15:16:19 2008 -0700
+++ b/jdk/test/java/nio/channels/AsyncCloseAndInterrupt.java	Sat Jun 07 16:11:57 2008 +0100
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 4460583 4470470 4840199 6419424
+ * @bug 4460583 4470470 4840199 6419424 6710579 6596323
  * @summary Comprehensive test of asynchronous closing and interruption
  * @author Mark Reinhold
  */
@@ -582,7 +582,7 @@
             log.println("WARNING: transferFrom/close not tested");
             return;
         }
-        if ((op == TRANSFER_TO) && TestUtil.onSolaris()) {
+        if ((op == TRANSFER_TO) && !TestUtil.onWindows()) {
             log.println("WARNING: transferTo/close not tested");
             return;
         }