harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r470381 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/lang/String.java test/java/org/apache/harmony/luni/tests/java/lang/String2Test.java
Date Thu, 02 Nov 2006 15:18:00 GMT
Author: hindessm
Date: Thu Nov  2 07:17:59 2006
New Revision: 470381

URL: http://svn.apache.org/viewvc?view=rev&rev=470381
Log:
Applied patch from "[#HARMONY-1111] [classlib][lang] unexpected
IllegalArgumentException for String(byte[], int, int, String)".

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/String2Test.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?view=diff&rev=470381&r1=470380&r2=470381
==============================================================================
--- 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
Thu Nov  2 07:17:59 2006
@@ -360,8 +360,14 @@
             Charset charset = getCharset(encoding);
 
             int result;
-            CharBuffer cb = charset
-                    .decode(ByteBuffer.wrap(data, start, length));
+        	CharBuffer cb;
+            try {
+            	cb = charset.decode(ByteBuffer.wrap(data, start, length));
+            } catch (Exception e) {
+            	// do nothing. according to spec: 
+            	// behavior is unspecified for invalid array
+            	cb = CharBuffer.wrap("\u003f".toCharArray());
+            }
             if ((result = cb.length()) > 0) {
                 value = cb.array();
                 count = result;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/String2Test.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/String2Test.java?view=diff&rev=470381&r1=470380&r2=470381
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/String2Test.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/String2Test.java
Thu Nov  2 07:17:59 2006
@@ -103,7 +103,7 @@
 	/**
 	 * @tests java.lang.String#String(byte[], int, int, java.lang.String)
 	 */
-	public void test_Constructor$BIILjava_lang_String() {
+	public void test_Constructor$BIILjava_lang_String() throws Exception {
 		// Test for method java.lang.String(byte [], int, int, java.lang.String)
 		String s = null;
 		try {
@@ -112,6 +112,8 @@
 			fail("Threw exception : " + e.getMessage());
 		}
 		assertTrue("Incorrect string returned: " + s, s.equals("ABCDE"));
+		//Regression for HARMONY-1111
+		assertNotNull(new String(new byte[] {(byte)0xC0}, 0, 1, "UTF-8"));
 	}
 
 	/**



Mime
View raw message