This is the mail archive of the java-discuss@sourceware.cygnus.com mailing list for the GCJ project. See the GCJ home page for more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[patch] String.getBytes()


The patch below fixes String.getBytes()

regards

  [ bryce ]

<test case>

import java.io.*;

public class GetBytes
{
  public static void main(String args[]) throws
UnsupportedEncodingException
  {
    String t = "reason.otago.ac.nz";
    byte[] buf = t.getBytes();
    System.out.print(Integer.toString(buf.length));
    System.out.println(" <-- should not be zero");
  }
}

<patch>

RCS file: /cvs/java/libgcj/libjava/java/lang/natString.cc,v
retrieving revision 1.3
diff -u -r1.3 natString.cc
--- natString.cc        1999/04/16 18:34:58     1.3
+++ natString.cc        1999/04/21 08:39:29
@@ -487,8 +487,8 @@
     }
   if (bufpos == buflen)
     return buffer;
-  jbyteArray result = JvNewByteArray(bufpos);
-  memcpy (elements (result), elements (buffer), bufpos);
+  jbyteArray result = JvNewByteArray(buflen);
+  memcpy (elements (result), elements (buffer), buflen);
   return result;
 }