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;
}
testHugeArray();
testOomeLarge();
testOomeSmall();
- testOomeToCharArray();
System.out.println("tests succeeded");
}
}
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");
- }
- }
}