7123170: JCK vm/jvmti/ResourceExhausted/resexh001/resexh00101/ tests fails since 7u4 b02
Summary: The JVMTI ResourceExhausted events must be generated in all places where OOME is thrown
Reviewed-by: acorn, coleenp, dcubed, dholmes, dsamersoff, jwilhelm, tonyp
Contributed-by: serguei.spitsyn@oracle.com
--- a/hotspot/src/share/vm/oops/arrayKlass.cpp Mon Mar 12 15:28:07 2012 -0700
+++ b/hotspot/src/share/vm/oops/arrayKlass.cpp Wed Mar 14 20:06:48 2012 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -153,6 +153,7 @@
}
if (length > arrayOopDesc::max_array_length(T_ARRAY)) {
report_java_out_of_memory("Requested array size exceeds VM limit");
+ JvmtiExport::post_array_size_exhausted();
THROW_OOP_0(Universe::out_of_memory_error_array_size());
}
int size = objArrayOopDesc::object_size(length);
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp Mon Mar 12 15:28:07 2012 -0700
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp Wed Mar 14 20:06:48 2012 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -669,6 +669,7 @@
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");
+ JvmtiExport::post_array_size_exhausted();
THROW_OOP_0(Universe::out_of_memory_error_array_size());
}
int size = objArrayOopDesc::object_size(length);
--- a/hotspot/src/share/vm/oops/objArrayKlass.cpp Mon Mar 12 15:28:07 2012 -0700
+++ b/hotspot/src/share/vm/oops/objArrayKlass.cpp Wed Mar 14 20:06:48 2012 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -68,6 +68,7 @@
return a;
} else {
report_java_out_of_memory("Requested array size exceeds VM limit");
+ JvmtiExport::post_array_size_exhausted();
THROW_OOP_0(Universe::out_of_memory_error_array_size());
}
} else {
--- a/hotspot/src/share/vm/oops/typeArrayKlass.cpp Mon Mar 12 15:28:07 2012 -0700
+++ b/hotspot/src/share/vm/oops/typeArrayKlass.cpp Wed Mar 14 20:06:48 2012 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -93,6 +93,7 @@
return t;
} else {
report_java_out_of_memory("Requested array size exceeds VM limit");
+ JvmtiExport::post_array_size_exhausted();
THROW_OOP_0(Universe::out_of_memory_error_array_size());
}
} else {
--- a/hotspot/src/share/vm/prims/jvmtiExport.hpp Mon Mar 12 15:28:07 2012 -0700
+++ b/hotspot/src/share/vm/prims/jvmtiExport.hpp Wed Mar 14 20:06:48 2012 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -324,6 +324,12 @@
record_vm_internal_object_allocation(object);
}
}
+ inline static void post_array_size_exhausted() {
+ if (should_post_resource_exhausted()) {
+ post_resource_exhausted(JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR,
+ "Requested array size exceeds VM limit");
+ }
+ }
static void cleanup_thread (JavaThread* thread) KERNEL_RETURN;