When a memory allocation failure occurs in JNI calls such as New<PrimitiveType>Array, NewStringUTF, or NewDirectByteBuffer, an OutOfMemoryError (OOME) is thrown.
Similarly, when a memory allocation failure occurs in native memory allocation method such as malloc, calloc, or "new (std::nothrow)", we should consider throwing OOME. This can be done either by calling the JNI ThrowNew method, or by returning an error code to the Java caller and having the Java code throw OOME. Generally, the former is preferred.
This is an umbrella task. As we find issues, we will file a bug for each area of the code and link it as a blocking issue.
Similarly, when a memory allocation failure occurs in native memory allocation method such as malloc, calloc, or "new (std::nothrow)", we should consider throwing OOME. This can be done either by calling the JNI ThrowNew method, or by returning an error code to the Java caller and having the Java code throw OOME. Generally, the former is preferred.
This is an umbrella task. As we find issues, we will file a bug for each area of the code and link it as a blocking issue.
- relates to
-
JDK-8316020 ☂ Check memory allocation for null return value
-
- Open
-