2005-05-30 Bryce McKinlay <mckinlay@redhat.com>
authorbryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 30 May 2005 16:02:38 +0000 (16:02 +0000)
committerbryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 30 May 2005 16:02:38 +0000 (16:02 +0000)
PR libgcj/21821
* gnu/java/nio/channels/natFileChannelPosix.cc (open): Don't use
MAXPATHLEN. Format exception message using a StringBuffer instead.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@100364 138bc75d-0d04-0410-961f-82ee72b054a4

libjava/ChangeLog
libjava/gnu/java/nio/channels/natFileChannelPosix.cc

index 4d7f6da..ca9f2f4 100644 (file)
@@ -1,3 +1,9 @@
+2005-05-30  Bryce McKinlay  <mckinlay@redhat.com>
+
+       PR libgcj/21821
+       * gnu/java/nio/channels/natFileChannelPosix.cc (open): Don't use
+       MAXPATHLEN. Format exception message using a StringBuffer instead.
+
 2005-05-29  Michael Koch  <konqueror@gmx.de>
 
        PR libgcj/20273:
index 742201b..24b6396 100644 (file)
@@ -37,6 +37,7 @@ details.  */
 #include <java/lang/NullPointerException.h>
 #include <java/lang/System.h>
 #include <java/lang/String.h>
+#include <java/lang/StringBuffer.h>
 #include <java/lang/Thread.h>
 #include <java/nio/ByteBuffer.h>
 #include <java/nio/MappedByteBufferImpl.h>
@@ -168,13 +169,13 @@ FileChannelImpl::open (jstring path, jint jflags)
     }
   if (fd == -1)
     {
-      char msg[MAXPATHLEN + 200];
       // We choose the formatting here for JDK compatibility, believe
       // it or not.
-      sprintf (msg, "%.*s (%.*s)",
-              MAXPATHLEN + 150, buf,
-              40, strerror (errno));
-      throw new ::java::io::FileNotFoundException (JvNewStringLatin1 (msg));
+      ::java::lang::StringBuffer *msg = new ::java::lang::StringBuffer (path);
+      msg->append (JvNewStringUTF (" ("));
+      msg->append (JvNewStringUTF (strerror (errno)));
+      msg->append (JvNewStringUTF (")"));
+      throw new ::java::io::FileNotFoundException (msg->toString ());
     }
 
   _Jv_platform_close_on_exec (fd);