8313874: JNI NewWeakGlobalRef throws exception for null arg
Reviewed-by: dholmes, kbarrett, shade
This commit is contained in:
parent
83adaf5477
commit
028b3ae1b1
@ -2875,7 +2875,7 @@ JNI_ENTRY(jweak, jni_NewWeakGlobalRef(JNIEnv *env, jobject ref))
|
||||
HOTSPOT_JNI_NEWWEAKGLOBALREF_ENTRY(env, ref);
|
||||
Handle ref_handle(thread, JNIHandles::resolve(ref));
|
||||
jweak ret = JNIHandles::make_weak_global(ref_handle, AllocFailStrategy::RETURN_NULL);
|
||||
if (ret == nullptr) {
|
||||
if (ret == nullptr && ref_handle.not_null()) {
|
||||
THROW_OOP_(Universe::out_of_memory_error_c_heap(), nullptr);
|
||||
}
|
||||
HOTSPOT_JNI_NEWWEAKGLOBALREF_RETURN(ret);
|
||||
|
@ -123,9 +123,19 @@ public final class ReturnJNIWeak {
|
||||
}
|
||||
}
|
||||
|
||||
// Verify passing a null value returns null and doesn't throw.
|
||||
private static void testNullValue() {
|
||||
System.out.println("running testNullValue");
|
||||
registerObject(null);
|
||||
if (getObject() != null) {
|
||||
throw new RuntimeException("expected null");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
testSanity();
|
||||
testSurvival();
|
||||
testClear();
|
||||
testNullValue();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user