harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r430755 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/lang/String.java test/java/org/apache/harmony/luni/tests/java/lang/StringTest.java
Date Fri, 11 Aug 2006 10:37:36 GMT
Author: tellison
Date: Fri Aug 11 03:37:35 2006
New Revision: 430755

URL: http://svn.apache.org/viewvc?rev=430755&view=rev
Log:
Apply patch HARMONY-1157 ([classlib][luni] String(byte[] bytes, int offset, int length, String
charsetName) throws wrong exceptions)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/String.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/String.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/String.java?rev=430755&r1=430754&r2=430755&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/String.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/String.java
Fri Aug 11 03:37:35 2006
@@ -343,12 +343,8 @@
 		// start + length could overflow, start/length maybe MaxInt
 		if (start >= 0 && 0 <= length && length <= data.length - start)
{
 			offset = 0;
-			Charset charset;
-			try {
-				charset = Charset.forName(encoding);
-			} catch (UnsupportedCharsetException e) {
-				throw new UnsupportedEncodingException();
-			}
+			Charset charset = getCharset(encoding);
+			
 			int result;
 			CharBuffer cb = charset
 					.decode(ByteBuffer.wrap(data, start, length));

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringTest.java?rev=430755&r1=430754&r2=430755&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StringTest.java
Fri Aug 11 03:37:35 2006
@@ -16,6 +16,7 @@
 
 package org.apache.harmony.luni.tests.java.lang;
 
+import java.io.UnsupportedEncodingException;
 import java.lang.reflect.Constructor;
 
 import junit.framework.TestCase;
@@ -104,6 +105,13 @@
     public void test_Constructor$BIILjava_lang_String() throws Exception {
         String s = new String(new byte[] { 65, 66, 67, 68, 69 }, 0, 5, "8859_1");
         assertEquals("Incorrect string returned: " + s, "ABCDE", s);
+        
+        try {
+        	new String(new byte[] { 65, 66, 67, 68, 69 }, 0, 5, "");
+        	fail("Should throw UnsupportedEncodingException");
+        } catch (UnsupportedEncodingException e) {
+        	//expected
+        }
     }
 
     /**



Mime
View raw message