harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r439958 - in /incubator/harmony/enhanced/classlib/trunk/modules/text/src: main/java/java/text/Bidi.java test/java/org/apache/harmony/text/tests/java/text/BidiTest.java
Date Mon, 04 Sep 2006 07:13:51 GMT
Author: pyang
Date: Mon Sep  4 00:13:50 2006
New Revision: 439958

URL: http://svn.apache.org/viewvc?view=rev&rev=439958
Log:
Patch applied for HARMONY-1031 ([classlib][text]compatibility: Bidi expected IAE)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Bidi.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Bidi.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Bidi.java?view=diff&rev=439958&r1=439957&r2=439958
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Bidi.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Bidi.java
Mon Sep  4 00:13:50 2006
@@ -483,21 +483,25 @@
 	 */
 	public static void reorderVisually(byte[] levels, int levelStart,
 			Object[] objects, int objectStart, int count) {
-		try {
-			byte[] realLevels = new byte[count];
-			System.arraycopy(levels, levelStart, realLevels, 0, count);
+        if (count < 0 || levelStart < 0 || objectStart < 0
+                || count > levels.length - levelStart
+                || count > objects.length - objectStart) {
+            throw new IllegalArgumentException("Invalid ranges (levels="
+                    + levels.length + ", levelStart=" + levelStart
+                    + ", objects=" + objects.length + ", objectStart="
+                    + objectStart + ", count=" + count + ")");
+        }
+        byte[] realLevels = new byte[count];
+        System.arraycopy(levels, levelStart, realLevels, 0, count);
 
-			int[] indices = BidiWrapper.ubidi_reorderVisual(realLevels, count);
+        int[] indices = BidiWrapper.ubidi_reorderVisual(realLevels, count);
 
-			LinkedList<Object> result = new LinkedList<Object>();
-			for (int i = 0; i < count; i++) {
-				result.addLast(objects[objectStart + indices[i]]);
-			}
+        LinkedList<Object> result = new LinkedList<Object>();
+        for (int i = 0; i < count; i++) {
+            result.addLast(objects[objectStart + indices[i]]);
+        }
 
-			System.arraycopy(result.toArray(), 0, objects, objectStart, count);
-		} catch (ArrayIndexOutOfBoundsException e) {
-			throw new IllegalArgumentException();
-		}
+        System.arraycopy(result.toArray(), 0, objects, objectStart, count);
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java?view=diff&rev=439958&r1=439957&r2=439958
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java
Mon Sep  4 00:13:50 2006
@@ -923,6 +923,14 @@
 		} catch (NullPointerException e) {
 			// expected
 		}
+        
+        try {
+            Bidi.reorderVisually(new byte[] { 2, 1, 3, 0 }, 1, s, 0, -1);
+            fail("should throw IAE");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
 	}
     
     public void testGetRuns() {



Mime
View raw message