]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
String.java: Don't throw UnsupportedEncodingException.
authorTom Tromey <tromey@cygnus.com>
Wed, 21 Apr 1999 12:12:39 +0000 (12:12 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Wed, 21 Apr 1999 12:12:39 +0000 (12:12 +0000)
* java/lang/String.java: Don't throw
UnsupportedEncodingException.

From-SVN: r26577

libjava/ChangeLog
libjava/java/lang/String.java

index daba9ef890c2c96cfe0d08d097a38926ba2988e0..b2b035418ce6e045fb640521d85eebc96155bcc8 100644 (file)
@@ -1,5 +1,8 @@
 1999-04-21  Tom Tromey  <tromey@cygnus.com>
 
+       * java/lang/String.java: Don't throw
+       UnsupportedEncodingException.
+
        * java/lang/natString.cc (getBytes): Correctly size result
        buffer.  From Bryce McKinlay <bryce@albatross.co.nz>.
 
index 1321676d0e52a5c58e81e1d4942c098216c64f36..55cc9cd9410bf7da2dd9e7b40118284a20ad2ae8 100644 (file)
@@ -132,9 +132,27 @@ public final class String
   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)
+      {
+       // This probably shouldn't happen, but could if file.encoding
+       // is somehow changed to a value we don't understand.
+       try
+         {
+           return getBytes ("8859_1");
+         }
+       catch (UnsupportedEncodingException x2)
+         {
+           // This really shouldn't happen, because the 8859_1
+           // encoding should always be available.
+           throw new InternalError ("couldn't find 8859_1 encoder");
+         }
+      }
   }
 
   public native byte[] getBytes (String enc)