changeset 5854:d050fbf914d8

8031427: AllocObject and Unsafe.allocateInstance segfault for primitive types Summary: The fix just throws an InstantiationException if the Klass is NULL. Reviewed-by: coleenp, twisti, jrose Contributed-by: gdub <duboscq@ssw.jku.at>
author gdub
date Thu, 23 Jan 2014 16:02:14 -0500
parents 7444c21b8b71
children 5944dba4badc 2e7b5143763f
files src/share/vm/prims/jni.cpp
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/prims/jni.cpp	Thu Jan 23 09:45:38 2014 -0800
+++ b/src/share/vm/prims/jni.cpp	Thu Jan 23 16:02:14 2014 -0500
@@ -1355,6 +1355,10 @@
 
 static instanceOop alloc_object(jclass clazz, TRAPS) {
   KlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)));
+  if (k == NULL) {
+    ResourceMark rm(THREAD);
+    THROW_(vmSymbols::java_lang_InstantiationException(), NULL);
+  }
   k()->check_valid_for_instantiation(false, CHECK_NULL);
   InstanceKlass::cast(k())->initialize(CHECK_NULL);
   instanceOop ih = InstanceKlass::cast(k())->allocate_instance(THREAD);