From 6ccac5dcaef59b64c598b75ab583fe836066a38c Mon Sep 17 00:00:00 2001 From: martin Date: Mon, 29 Jun 2009 14:42:12 -0700 Subject: [PATCH] 6850957: Honor -XX:OnOutOfMemoryError when array size exceeds VM limit Summary: call report_java_out_of_memory("Requested array size exceeds VM limit") Reviewed-by: tbell, dholmes, alanb, ysr Contributed-by: jeremymanson@google.com --- src/share/vm/oops/arrayKlass.cpp | 1 + src/share/vm/oops/instanceKlass.cpp | 1 + src/share/vm/oops/objArrayKlass.cpp | 1 + src/share/vm/oops/typeArrayKlass.cpp | 1 + 4 files changed, 4 insertions(+) diff --git a/src/share/vm/oops/arrayKlass.cpp b/src/share/vm/oops/arrayKlass.cpp index 8dde4799a..0584e8e7e 100644 --- a/src/share/vm/oops/arrayKlass.cpp +++ b/src/share/vm/oops/arrayKlass.cpp @@ -140,6 +140,7 @@ objArrayOop arrayKlass::allocate_arrayArray(int n, int length, TRAPS) { THROW_0(vmSymbols::java_lang_NegativeArraySizeException()); } if (length > arrayOopDesc::max_array_length(T_ARRAY)) { + report_java_out_of_memory("Requested array size exceeds VM limit"); THROW_OOP_0(Universe::out_of_memory_error_array_size()); } int size = objArrayOopDesc::object_size(length); diff --git a/src/share/vm/oops/instanceKlass.cpp b/src/share/vm/oops/instanceKlass.cpp index ddf9a6f4a..c2b554829 100644 --- a/src/share/vm/oops/instanceKlass.cpp +++ b/src/share/vm/oops/instanceKlass.cpp @@ -508,6 +508,7 @@ bool instanceKlass::implements_interface(klassOop k) const { objArrayOop instanceKlass::allocate_objArray(int n, int length, TRAPS) { if (length < 0) THROW_0(vmSymbols::java_lang_NegativeArraySizeException()); if (length > arrayOopDesc::max_array_length(T_OBJECT)) { + report_java_out_of_memory("Requested array size exceeds VM limit"); THROW_OOP_0(Universe::out_of_memory_error_array_size()); } int size = objArrayOopDesc::object_size(length); diff --git a/src/share/vm/oops/objArrayKlass.cpp b/src/share/vm/oops/objArrayKlass.cpp index 3f56d9c1f..b7d067426 100644 --- a/src/share/vm/oops/objArrayKlass.cpp +++ b/src/share/vm/oops/objArrayKlass.cpp @@ -39,6 +39,7 @@ objArrayOop objArrayKlass::allocate(int length, TRAPS) { assert(a->is_parsable(), "Can't publish unless parsable"); return a; } else { + report_java_out_of_memory("Requested array size exceeds VM limit"); THROW_OOP_0(Universe::out_of_memory_error_array_size()); } } else { diff --git a/src/share/vm/oops/typeArrayKlass.cpp b/src/share/vm/oops/typeArrayKlass.cpp index f5d53faa8..68d67f1cc 100644 --- a/src/share/vm/oops/typeArrayKlass.cpp +++ b/src/share/vm/oops/typeArrayKlass.cpp @@ -80,6 +80,7 @@ typeArrayOop typeArrayKlass::allocate(int length, TRAPS) { assert(t->is_parsable(), "Don't publish unless parsable"); return t; } else { + report_java_out_of_memory("Requested array size exceeds VM limit"); THROW_OOP_0(Universe::out_of_memory_error_array_size()); } } else { -- GitLab