8308300: enhance exceptions in MappedMemoryUtils.c

Reviewed-by: alanb, clanger, bpb
This commit is contained in:
Matthias Baesken 2023-05-23 07:43:14 +00:00
parent c4408278d1
commit 69f508a2ac
3 changed files with 18 additions and 5 deletions

View file

@ -176,7 +176,7 @@ JNU_ThrowByNameWithMessageAndLastError
}
/*
* Convenience method.
* Convenience function.
* Call JNU_ThrowByNameWithLastError for java.io.IOException.
*/
JNIEXPORT void JNICALL
@ -185,6 +185,16 @@ JNU_ThrowIOExceptionWithLastError(JNIEnv *env, const char *defaultDetail)
JNU_ThrowByNameWithLastError(env, "java/io/IOException", defaultDetail);
}
/*
* Throw java.io.IOException using a given message and the string
* returned by getLastErrorString to construct the detail string.
*/
JNIEXPORT void JNICALL
JNU_ThrowIOExceptionWithMessageAndLastError(JNIEnv *env, const char *message)
{
JNU_ThrowByNameWithMessageAndLastError(env, "java/io/IOException", message);
}
JNIEXPORT jvalue JNICALL
JNU_CallStaticMethodByName(JNIEnv *env,

View file

@ -92,6 +92,9 @@ JNU_ThrowByNameWithMessageAndLastError
JNIEXPORT void JNICALL
JNU_ThrowIOExceptionWithLastError(JNIEnv *env, const char *defaultDetail);
JNIEXPORT void JNICALL
JNU_ThrowIOExceptionWithMessageAndLastError(JNIEnv *env, const char *message);
/* Convert between Java strings and i18n C strings */
JNIEXPORT const char *
GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy);