# HG changeset patch # User gdub # Date 1390510934 18000 # Node ID d050fbf914d871a096c49c52729850415324cf94 # Parent 7444c21b8b710b06d8fe26cf128ad6994691914b 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 diff -r 7444c21b8b71 -r d050fbf914d8 src/share/vm/prims/jni.cpp --- 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);