From 9d9cf1661deded9d4030041ba8a4dc6a80df78c7 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 21 Apr 1999 12:12:39 +0000 Subject: [PATCH] String.java: Don't throw UnsupportedEncodingException. * java/lang/String.java: Don't throw UnsupportedEncodingException. From-SVN: r26577 --- libjava/ChangeLog | 3 +++ libjava/java/lang/String.java | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index daba9ef890c..b2b035418ce 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,5 +1,8 @@ 1999-04-21 Tom Tromey + * java/lang/String.java: Don't throw + UnsupportedEncodingException. + * java/lang/natString.cc (getBytes): Correctly size result buffer. From Bryce McKinlay . diff --git a/libjava/java/lang/String.java b/libjava/java/lang/String.java index 1321676d0e5..55cc9cd9410 100644 --- a/libjava/java/lang/String.java +++ b/libjava/java/lang/String.java @@ -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)