String.java: Don't throw UnsupportedEncodingException.

* java/lang/String.java: Don't throw
	UnsupportedEncodingException.

From-SVN: r26577
This commit is contained in:
Tom Tromey 1999-04-21 12:12:39 +00:00 committed by Tom Tromey
parent b323effe6d
commit 9d9cf1661d
2 changed files with 23 additions and 2 deletions

View 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>.

View 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)