mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8011773: Some tests on Interned String crashed JVM with OOM
Instead of terminating the VM, throw OutOfMemoryError exceptions. Reviewed-by: coleenp, dholmes
This commit is contained in:
parent
6a4aa00cc1
commit
2a692f80bf
6 changed files with 26 additions and 17 deletions
|
@ -315,14 +315,18 @@ Handle java_lang_String::char_converter(Handle java_string, jchar from_char, jch
|
|||
return string;
|
||||
}
|
||||
|
||||
jchar* java_lang_String::as_unicode_string(oop java_string, int& length) {
|
||||
jchar* java_lang_String::as_unicode_string(oop java_string, int& length, TRAPS) {
|
||||
typeArrayOop value = java_lang_String::value(java_string);
|
||||
int offset = java_lang_String::offset(java_string);
|
||||
length = java_lang_String::length(java_string);
|
||||
|
||||
jchar* result = NEW_RESOURCE_ARRAY(jchar, length);
|
||||
for (int index = 0; index < length; index++) {
|
||||
result[index] = value->char_at(index + offset);
|
||||
jchar* result = NEW_RESOURCE_ARRAY_RETURN_NULL(jchar, length);
|
||||
if (result != NULL) {
|
||||
for (int index = 0; index < length; index++) {
|
||||
result[index] = value->char_at(index + offset);
|
||||
}
|
||||
} else {
|
||||
THROW_MSG_0(vmSymbols::java_lang_OutOfMemoryError(), "could not allocate Unicode string");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue