Revert "Add missing null check to String::ToCharArray"
Does not work with the interpreter.
Bug: 25641543
This reverts commit 952d608062eec2d7f47f9b45dba935ad8b4d23e5.
Change-Id: Ic112fa69c7ddd119cbccc5b65007b5ee4dfccd09
diff --git a/runtime/mirror/string.cc b/runtime/mirror/string.cc
index be869d4..45610dc 100644
--- a/runtime/mirror/string.cc
+++ b/runtime/mirror/string.cc
@@ -254,11 +254,7 @@
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;
}
diff --git a/test/061-out-of-memory/expected.txt b/test/061-out-of-memory/expected.txt
index c31980c..ca87629 100644
--- a/test/061-out-of-memory/expected.txt
+++ b/test/061-out-of-memory/expected.txt
@@ -4,5 +4,4 @@
testOomeLarge succeeded
testOomeSmall beginning
testOomeSmall succeeded
-Got expected toCharArray OOM
tests succeeded
diff --git a/test/061-out-of-memory/src/Main.java b/test/061-out-of-memory/src/Main.java
index 52373d3..c812c81 100644
--- a/test/061-out-of-memory/src/Main.java
+++ b/test/061-out-of-memory/src/Main.java
@@ -26,7 +26,6 @@
testHugeArray();
testOomeLarge();
testOomeSmall();
- testOomeToCharArray();
System.out.println("tests succeeded");
}
@@ -107,22 +106,4 @@
}
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");
- }
- }
}