OSDN Git Service

Make the inlined String.charAt throw detailed exceptions.
authorElliott Hughes <enh@google.com>
Sat, 4 Dec 2010 00:37:54 +0000 (16:37 -0800)
committerElliott Hughes <enh@google.com>
Sat, 4 Dec 2010 00:37:54 +0000 (16:37 -0800)
Part of my general push for better exceptions. I'll add a unit test to libcore,
but until we lose the dexopt brain damage, we won't be able to see it (dexopt
can't optimize JUnit tests, so we get no coverage of inline natives on our
continuous builds; http://b/3003994).

Change-Id: I3af757751534747fa4b3cc725b0914a8f7b3d45d

vm/InlineNative.c

index 9db97ba..c426d4d 100644 (file)
@@ -137,7 +137,8 @@ static bool javaLangString_charAt(u4 arg0, u4 arg1, u4 arg2, u4 arg3,
     //LOGI("String.charAt this=0x%08x index=%d\n", arg0, arg1);
     count = dvmGetFieldInt((Object*) arg0, STRING_FIELDOFF_COUNT);
     if ((s4) arg1 < 0 || (s4) arg1 >= count) {
-        dvmThrowException("Ljava/lang/StringIndexOutOfBoundsException;", NULL);
+        dvmThrowExceptionFmt("Ljava/lang/StringIndexOutOfBoundsException;",
+            "index=%d length=%d", arg1, count);
         return false;
     } else {
         offset = dvmGetFieldInt((Object*) arg0, STRING_FIELDOFF_OFFSET);