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>
--- 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);