[kaffe] CVS kaffe (robilad): Bugfixes for mauve and Resynced with GNU Classpath: jeroen's cleanup
Kaffe CVS
cvs-commits at kaffe.org
Wed Mar 9 17:12:02 PST 2005
PatchSet 5513
Date: 2005/03/10 01:07:25
Author: robilad
Branch: HEAD
Tag: (none)
Log:
Bugfixes for mauve and Resynced with GNU Classpath: jeroen's cleanup
2005-03-10 Dalibor Topic <robilad at kaffe.org>
* libraries/javalib/gnu/java/nio/channels/FileChannelImpl.java
(FileChannelImpl(Sting, int)): Removed.
(FileChannelImpl(File, int)) Added. Check if opened file is a directory.
* libraries/javalib/java/io/FileInputStream.java (FileInputStream):
Fixed javadocs. Call FileChannelImpl(File, int).
* libraries/javalib/java/io/FileOutputStream.java (FileInputStream):
Call FileChannelImpl(File, int).
* libraries/javalib/java/io/RandomAccessFile.java (RandomAccessFile):
Call FileChannelImpl(File, int). Switched constructors around.
Resynced with GNU Classpath.
2005-03-03 Jeroen Frijters <jeroen at frijters.net>
* java/io/FileInputStream.java (FileInputStream(File)),
java/io/FileOutputStream.java (FileOutputStream(File)):
Removed unnecessary File.isDirectory() check.
Members:
ChangeLog:1.3687->1.3688
libraries/javalib/gnu/java/nio/channels/FileChannelImpl.java:1.4->1.5
libraries/javalib/java/io/FileInputStream.java:1.20->1.21
libraries/javalib/java/io/FileOutputStream.java:1.17->1.18
libraries/javalib/java/io/RandomAccessFile.java:1.29->1.30
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3687 kaffe/ChangeLog:1.3688
--- kaffe/ChangeLog:1.3687 Wed Mar 9 12:43:18 2005
+++ kaffe/ChangeLog Thu Mar 10 01:07:25 2005
@@ -1,3 +1,26 @@
+2005-03-10 Dalibor Topic <robilad at kaffe.org>
+
+ * libraries/javalib/gnu/java/nio/channels/FileChannelImpl.java
+ (FileChannelImpl(Sting, int)): Removed.
+ (FileChannelImpl(File, int)) Added. Check if opened file is a directory.
+
+ * libraries/javalib/java/io/FileInputStream.java (FileInputStream):
+ Fixed javadocs. Call FileChannelImpl(File, int).
+
+ * libraries/javalib/java/io/FileOutputStream.java (FileInputStream):
+ Call FileChannelImpl(File, int).
+
+ * libraries/javalib/java/io/RandomAccessFile.java (RandomAccessFile):
+ Call FileChannelImpl(File, int). Switched constructors around.
+
+ Resynced with GNU Classpath.
+
+ 2005-03-03 Jeroen Frijters <jeroen at frijters.net>
+
+ * java/io/FileInputStream.java (FileInputStream(File)),
+ java/io/FileOutputStream.java (FileOutputStream(File)):
+ Removed unnecessary File.isDirectory() check.
+
2005-03-09 Dalibor Topic <robilad at kaffe.org>
Resynced with GNU Classpath.
Index: kaffe/libraries/javalib/gnu/java/nio/channels/FileChannelImpl.java
diff -u kaffe/libraries/javalib/gnu/java/nio/channels/FileChannelImpl.java:1.4 kaffe/libraries/javalib/gnu/java/nio/channels/FileChannelImpl.java:1.5
--- kaffe/libraries/javalib/gnu/java/nio/channels/FileChannelImpl.java:1.4 Sat Feb 19 16:24:48 2005
+++ kaffe/libraries/javalib/gnu/java/nio/channels/FileChannelImpl.java Thu Mar 10 01:07:27 2005
@@ -41,6 +41,7 @@
import gnu.classpath.Configuration;
import gnu.java.nio.FileLockImpl;
+import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -101,10 +102,16 @@
}
/* Open a file. MODE is a combination of the above mode flags. */
- public FileChannelImpl (String path, int mode) throws FileNotFoundException
+ public FileChannelImpl (File file, int mode) throws FileNotFoundException
{
+ final String path = file.getPath();
fd = open (path, mode);
this.mode = mode;
+
+ // First open the file and then check if it is a a directory
+ // to avoid race condition.
+ if (file.isDirectory())
+ throw new FileNotFoundException(file.getPath() + " is a directory");
}
/* Used by init() (native code) */
Index: kaffe/libraries/javalib/java/io/FileInputStream.java
diff -u kaffe/libraries/javalib/java/io/FileInputStream.java:1.20 kaffe/libraries/javalib/java/io/FileInputStream.java:1.21
--- kaffe/libraries/javalib/java/io/FileInputStream.java:1.20 Sat Feb 19 15:04:15 2005
+++ kaffe/libraries/javalib/java/io/FileInputStream.java Thu Mar 10 01:07:28 2005
@@ -76,7 +76,8 @@
* @param name The name of the file this stream should read from
*
* @exception SecurityException If read access to the file is not allowed
- * @exception FileNotFoundException If the file does not exist.
+ * @exception FileNotFoundException If the file does not exist
+ * or if it is a directory
*/
public FileInputStream(String name) throws FileNotFoundException
{
@@ -97,7 +98,8 @@
* @param file The <code>File</code> object this stream should read from
*
* @exception SecurityException If read access to the file is not allowed
- * @exception FileNotFoundException If the file does not exist.
+ * @exception FileNotFoundException If the file does not exist
+ * or if it is a directory.
*/
public FileInputStream(File file) throws FileNotFoundException
{
@@ -105,10 +107,7 @@
if (s != null)
s.checkRead(file.getPath());
- if (file.isDirectory())
- throw new FileNotFoundException(file.getPath() + " is a directory");
-
- ch = new FileChannelImpl (file.getPath(), FileChannelImpl.READ);
+ ch = new FileChannelImpl (file, FileChannelImpl.READ);
}
/**
Index: kaffe/libraries/javalib/java/io/FileOutputStream.java
diff -u kaffe/libraries/javalib/java/io/FileOutputStream.java:1.17 kaffe/libraries/javalib/java/io/FileOutputStream.java:1.18
--- kaffe/libraries/javalib/java/io/FileOutputStream.java:1.17 Sat Feb 19 15:04:15 2005
+++ kaffe/libraries/javalib/java/io/FileOutputStream.java Thu Mar 10 01:07:28 2005
@@ -155,13 +155,10 @@
if (s != null)
s.checkWrite(file.getPath());
- if (file.isDirectory())
- throw new FileNotFoundException(file.getPath() + " is a directory");
-
- ch = new FileChannelImpl (file.getPath(), (append
- ? FileChannelImpl.WRITE
- | FileChannelImpl.APPEND
- : FileChannelImpl.WRITE));
+ ch = new FileChannelImpl (file, (append
+ ? FileChannelImpl.WRITE
+ | FileChannelImpl.APPEND
+ : FileChannelImpl.WRITE));
}
/**
Index: kaffe/libraries/javalib/java/io/RandomAccessFile.java
diff -u kaffe/libraries/javalib/java/io/RandomAccessFile.java:1.29 kaffe/libraries/javalib/java/io/RandomAccessFile.java:1.30
--- kaffe/libraries/javalib/java/io/RandomAccessFile.java:1.29 Sat Feb 19 15:04:15 2005
+++ kaffe/libraries/javalib/java/io/RandomAccessFile.java Thu Mar 10 01:07:28 2005
@@ -86,38 +86,12 @@
* illegal value
* @exception SecurityException If the requested access to the file
* is not allowed
- * @exception IOException If any other error occurs
+ * @exception FileNotFoundException If the file is a directory, or
+ * any other error occurs
*/
public RandomAccessFile (File file, String mode)
throws FileNotFoundException
{
- this (file.getPath(), mode);
- }
-
- /**
- * This method initializes a new instance of <code>RandomAccessFile</code>
- * to read from the specified file name with the specified access mode.
- * The access mode is either "r" for read only access, "rw" for read
- * write access, "rws" for synchronized read/write access of both
- * content and metadata, or "rwd" for read/write access
- * where only content is required to be synchronous.
- * <p>
- * Note that a <code>SecurityManager</code> check is made prior to
- * opening the file to determine whether or not this file is allowed to
- * be read or written.
- *
- * @param fileName The name of the file to read and/or write
- * @param mode "r", "rw", "rws", or "rwd"
- *
- * @exception IllegalArgumentException If <code>mode</code> has an
- * illegal value
- * @exception SecurityException If the requested access to the file
- * is not allowed
- * @exception FileNotFoundException If any other error occurs
- */
- public RandomAccessFile (String fileName, String mode)
- throws FileNotFoundException
- {
int fdmode;
if (mode.equals("r"))
fdmode = FileChannelImpl.READ;
@@ -136,6 +110,8 @@
else
throw new IllegalArgumentException ("invalid mode: " + mode);
+ final String fileName = file.getPath();
+
// The obligatory SecurityManager stuff
SecurityManager s = System.getSecurityManager();
if (s != null)
@@ -146,10 +122,38 @@
s.checkWrite(fileName);
}
- ch = new FileChannelImpl (fileName, fdmode);
+ ch = new FileChannelImpl (file, fdmode);
fd = new FileDescriptor(ch);
out = new DataOutputStream (new FileOutputStream (fd));
in = new DataInputStream (new FileInputStream (fd));
+ }
+
+ /**
+ * This method initializes a new instance of <code>RandomAccessFile</code>
+ * to read from the specified file name with the specified access mode.
+ * The access mode is either "r" for read only access, "rw" for read
+ * write access, "rws" for synchronized read/write access of both
+ * content and metadata, or "rwd" for read/write access
+ * where only content is required to be synchronous.
+ * <p>
+ * Note that a <code>SecurityManager</code> check is made prior to
+ * opening the file to determine whether or not this file is allowed to
+ * be read or written.
+ *
+ * @param fileName The name of the file to read and/or write
+ * @param mode "r", "rw", "rws", or "rwd"
+ *
+ * @exception IllegalArgumentException If <code>mode</code> has an
+ * illegal value
+ * @exception SecurityException If the requested access to the file
+ * is not allowed
+ * @exception FileNotFoundException If the file is a directory or
+ * any other error occurs
+ */
+ public RandomAccessFile (String fileName, String mode)
+ throws FileNotFoundException
+ {
+ this (new File(fileName), mode);
}
/**
More information about the kaffe
mailing list