8031427: AllocObject and Unsafe.allocateInstance segfault for primitive types
authorgdub
Thu, 23 Jan 2014 16:02:14 -0500
changeset 22532 1fc87ea15795
parent 22531 f3c6f25d2072
child 22533 76088853a2eb
child 22534 520f7a937396
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>
hotspot/src/share/vm/prims/jni.cpp
--- a/hotspot/src/share/vm/prims/jni.cpp	Thu Jan 23 09:45:38 2014 -0800
+++ b/hotspot/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);