OSDN Git Service

Revert "Add missing null check to String::ToCharArray"
authorNicolas Geoffray <ngeoffray@google.com>
Fri, 13 Nov 2015 08:16:23 +0000 (08:16 +0000)
committerNicolas Geoffray <ngeoffray@google.com>
Fri, 13 Nov 2015 08:16:23 +0000 (08:16 +0000)
Does not work with the interpreter.

Bug: 25641543

This reverts commit 952d608062eec2d7f47f9b45dba935ad8b4d23e5.

Change-Id: Ic112fa69c7ddd119cbccc5b65007b5ee4dfccd09

runtime/mirror/string.cc
test/061-out-of-memory/expected.txt
test/061-out-of-memory/src/Main.java

index be869d4..45610dc 100644 (file)
@@ -254,11 +254,7 @@ CharArray* String::ToCharArray(Thread* self) {
   StackHandleScope<1> hs(self);
   Handle<String> string(hs.NewHandle(this));
   CharArray* result = CharArray::Alloc(self, GetLength());
-  if (result != nullptr) {
-    memcpy(result->GetData(), string->GetValue(), string->GetLength() * sizeof(uint16_t));
-  } else {
-    self->AssertPendingOOMException();
-  }
+  memcpy(result->GetData(), string->GetValue(), string->GetLength() * sizeof(uint16_t));
   return result;
 }
 
index c31980c..ca87629 100644 (file)
@@ -4,5 +4,4 @@ testOomeLarge beginning
 testOomeLarge succeeded
 testOomeSmall beginning
 testOomeSmall succeeded
-Got expected toCharArray OOM
 tests succeeded
index 52373d3..c812c81 100644 (file)
@@ -26,7 +26,6 @@ public class Main {
         testHugeArray();
         testOomeLarge();
         testOomeSmall();
-        testOomeToCharArray();
         System.out.println("tests succeeded");
     }
 
@@ -107,22 +106,4 @@ public class Main {
         }
         System.out.println("testOomeSmall succeeded");
     }
-
-    private static void testOomeToCharArray() {
-        Object[] o = new Object[1000000];
-        String test = "test";
-        int i = 0;
-        try {
-            for (; i < o.length; ++i) o[i] = new char[1000000];
-        } catch (OutOfMemoryError oom) {}
-        try {
-            for (; i < o.length; ++i) o[i] = new Object();
-        } catch (OutOfMemoryError oom) {}
-        try {
-            test.toCharArray();
-        } catch (OutOfMemoryError oom) {
-            o = null;
-            System.out.println("Got expected toCharArray OOM");
-        }
-    }
 }