[patch #2] String.getBytes()

Bryce McKinlay bryce@albatross.co.nz
Wed Apr 21 02:16:00 GMT 1999


According to the JDK 1.2 docs, getBytes() isn't supposed to throw an
UnsupportedEncodingException. I have confirmed this with JDK 1.2/javac

regards

  [ bryce ]

RCS file: /cvs/java/libgcj/libjava/java/lang/String.java,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 String.java
--- String.java 1999/04/07 14:52:38     1.1.1.1
+++ String.java 1999/04/21 09:12:58
@@ -132,9 +132,16 @@
   public native void getChars (int srcBegin, int srcEnd,
                               char[] dst, int dstBegin);

-  public byte[] getBytes () throws UnsupportedEncodingException
+  public byte[] getBytes ()
   {
-    return getBytes (System.getProperty("file.encoding", "8859_1"));
+    try
+      {
+        return getBytes (System.getProperty("file.encoding",
"8859_1"));
+      }
+    catch (UnsupportedEncodingException x)
+      {
+        // shouldn't happen
+      }
   }




More information about the Java mailing list