summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2005-07-26 09:40:20 +0000
committerMark Wielaard <mark@klomp.org>2005-07-26 09:40:20 +0000
commit801784077cc530b8d0bb89b09fb15e0ea11bce1b (patch)
treec28cfd7828e21d563b660093f491584a4c190656
parent0fef40994f49c259cb03a7bfa74ea8c83c04a030 (diff)
downloadclasspath-801784077cc530b8d0bb89b09fb15e0ea11bce1b.tar.gz
* gnu/java/nio/channels/FileChannelImpl.java (description):
New final field. (FileChannelImpl): Set description. (init): Likewise. (toString): New method. All methods add parameters when throwing IllegalArgumentException. * native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c (open): Add filename to FileNotFoundException.
-rw-r--r--ChangeLog11
-rw-r--r--gnu/java/nio/channels/FileChannelImpl.java47
-rw-r--r--native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c11
3 files changed, 51 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index f2ab333dd..3f5af48a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2005-07-26 Mark Wielaard <mark@klomp.org>
+
+ * gnu/java/nio/channels/FileChannelImpl.java (description):
+ New final field.
+ (FileChannelImpl): Set description.
+ (init): Likewise.
+ (toString): New method.
+ All methods add parameters when throwing IllegalArgumentException.
+ * native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c
+ (open): Add filename to FileNotFoundException.
+
2005-07-26 Jeroen Frijters <jeroen@frijters.net>
* NEWS: Added comment about new VMProxy class.
diff --git a/gnu/java/nio/channels/FileChannelImpl.java b/gnu/java/nio/channels/FileChannelImpl.java
index f3f60c3ec..1ae6960c1 100644
--- a/gnu/java/nio/channels/FileChannelImpl.java
+++ b/gnu/java/nio/channels/FileChannelImpl.java
@@ -88,9 +88,9 @@ public final class FileChannelImpl extends FileChannel
init();
- in = new FileChannelImpl(0,READ);
- out = new FileChannelImpl(1,WRITE);
- err = new FileChannelImpl(2,WRITE);
+ in = new FileChannelImpl(0, READ);
+ out = new FileChannelImpl(1, WRITE);
+ err = new FileChannelImpl(2, WRITE);
}
/**
@@ -105,6 +105,8 @@ public final class FileChannelImpl extends FileChannel
private int mode;
+ final String description;
+
/* Open a file. MODE is a combination of the above mode flags. */
/* This is a static factory method, so that VM implementors can decide
* substitute subclasses of FileChannelImpl. */
@@ -117,7 +119,8 @@ public final class FileChannelImpl extends FileChannel
private FileChannelImpl(File file, int mode)
throws FileNotFoundException
{
- final String path = file.getPath();
+ String path = file.getPath();
+ description = path;
fd = open (path, mode);
this.mode = mode;
@@ -134,7 +137,7 @@ public final class FileChannelImpl extends FileChannel
/* ignore it */
}
- throw new FileNotFoundException(path + " is a directory");
+ throw new FileNotFoundException(description + " is a directory");
}
}
@@ -151,6 +154,7 @@ public final class FileChannelImpl extends FileChannel
{
this.fd = fd;
this.mode = mode;
+ this.description = "descriptor(" + fd + ")";
}
private native int open (String path, int mode) throws FileNotFoundException;
@@ -191,7 +195,7 @@ public final class FileChannelImpl extends FileChannel
throws IOException
{
if (position < 0)
- throw new IllegalArgumentException ();
+ throw new IllegalArgumentException ("position: " + position);
long oldPosition = implPosition ();
position (position);
int result = read(dst);
@@ -242,7 +246,7 @@ public final class FileChannelImpl extends FileChannel
throws IOException
{
if (position < 0)
- throw new IllegalArgumentException ();
+ throw new IllegalArgumentException ("position: " + position);
if (!isOpen ())
throw new ClosedChannelException ();
@@ -300,10 +304,11 @@ public final class FileChannelImpl extends FileChannel
throw new NonWritableChannelException();
}
else
- throw new IllegalArgumentException ();
+ throw new IllegalArgumentException ("mode: " + mode);
if (position < 0 || size < 0 || size > Integer.MAX_VALUE)
- throw new IllegalArgumentException ();
+ throw new IllegalArgumentException ("position: " + position
+ + ", size: " + size);
return mapImpl(nmode, position, (int) size);
}
@@ -348,7 +353,8 @@ public final class FileChannelImpl extends FileChannel
{
if (position < 0
|| count < 0)
- throw new IllegalArgumentException ();
+ throw new IllegalArgumentException ("position: " + position
+ + ", count: " + count);
if (!isOpen ())
throw new ClosedChannelException ();
@@ -411,7 +417,8 @@ public final class FileChannelImpl extends FileChannel
{
if (position < 0
|| count < 0)
- throw new IllegalArgumentException ();
+ throw new IllegalArgumentException ("position: " + position
+ + ", count: " + count);
if (!isOpen ())
throw new ClosedChannelException ();
@@ -441,7 +448,8 @@ public final class FileChannelImpl extends FileChannel
{
if (position < 0
|| size < 0)
- throw new IllegalArgumentException ();
+ throw new IllegalArgumentException ("position: " + position
+ + ", size: " + size);
if (!isOpen ())
throw new ClosedChannelException ();
@@ -482,7 +490,8 @@ public final class FileChannelImpl extends FileChannel
{
if (position < 0
|| size < 0)
- throw new IllegalArgumentException ();
+ throw new IllegalArgumentException ("position: " + position
+ + ", size: " + size);
if (!isOpen ())
throw new ClosedChannelException ();
@@ -516,7 +525,7 @@ public final class FileChannelImpl extends FileChannel
throws IOException
{
if (newPosition < 0)
- throw new IllegalArgumentException ();
+ throw new IllegalArgumentException ("newPostition: " + newPosition);
if (!isOpen ())
throw new ClosedChannelException ();
@@ -531,7 +540,7 @@ public final class FileChannelImpl extends FileChannel
throws IOException
{
if (size < 0)
- throw new IllegalArgumentException ();
+ throw new IllegalArgumentException ("size: " + size);
if (!isOpen ())
throw new ClosedChannelException ();
@@ -544,4 +553,12 @@ public final class FileChannelImpl extends FileChannel
return this;
}
+
+ public String toString()
+ {
+ return (this.getClass()
+ + "[fd=" + fd
+ + ",mode=" + mode + ","
+ + description + "]");
+ }
}
diff --git a/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c b/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c
index 32d4cf00d..93a7b26b5 100644
--- a/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c
+++ b/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c
@@ -204,17 +204,22 @@ Java_gnu_java_nio_channels_FileChannelImpl_open (JNIEnv * env,
#endif
TARGET_NATIVE_FILE_OPEN (filename, native_fd, flags, permissions, result);
- JCL_free_cstring (env, name, filename);
if (result != TARGET_NATIVE_OK)
{
- /* We can only throw FileNotFoundException. */
+ char message[256]; /* Fixed size we don't need to malloc. */
+ char *error_string = TARGET_NATIVE_LAST_ERROR_STRING ();
+
+ snprintf(message, 256, "%s: %s", error_string, filename);
+ /* We are only allowed to throw FileNotFoundException. */
JCL_ThrowException (env,
"java/io/FileNotFoundException",
- TARGET_NATIVE_LAST_ERROR_STRING ());
+ message);
+ JCL_free_cstring (env, name, filename);
return TARGET_NATIVE_MATH_INT_INT64_CONST_MINUS_1;
}
+ JCL_free_cstring (env, name, filename);
return native_fd;
}