diff options
| author | 2021-03-04 15:09:00 +0000 | |
|---|---|---|
| committer | 2021-03-04 15:29:25 +0000 | |
| commit | 039e79a2a562cfe9a5b15d87a0b7c842f5ef3c69 (patch) | |
| tree | b316f69b32344e30026b88e652384c55466e09e5 | |
| parent | 719f9314f712bd88dc7e352b2b1b6dbad54070db (diff) | |
Using jniThrowErrnoException in android_os_SharedMemory
Since libnativehelper now has an implementation of jniThrowErrnoException,
this method is now used when a system error occurs to avoid code
duplication.
Bug: 180958753
Test: m
Change-Id: I65d9b58d2cb2d94af97f77a15264137b0c7d0462
| -rw-r--r-- | core/jni/android_os_SharedMemory.cpp | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/core/jni/android_os_SharedMemory.cpp b/core/jni/android_os_SharedMemory.cpp index dc86187d8fea..fe375f4fa359 100644 --- a/core/jni/android_os_SharedMemory.cpp +++ b/core/jni/android_os_SharedMemory.cpp @@ -35,21 +35,6 @@ namespace { jclass errnoExceptionClass; jmethodID errnoExceptionCtor; // MethodID for ErrnoException.<init>(String,I) -void throwErrnoException(JNIEnv* env, const char* functionName, int error) { - ScopedLocalRef<jstring> detailMessage(env, env->NewStringUTF(functionName)); - if (detailMessage.get() == NULL) { - // Not really much we can do here. We're probably dead in the water, - // but let's try to stumble on... - env->ExceptionClear(); - } - - jobject exception = env->NewObject(errnoExceptionClass, - errnoExceptionCtor, - detailMessage.get(), - error); - env->Throw(reinterpret_cast<jthrowable>(exception)); -} - jobject SharedMemory_nCreate(JNIEnv* env, jobject, jstring jname, jint size) { // Name is optional so we can't use ScopedUtfChars for this as it throws NPE on null @@ -65,7 +50,7 @@ jobject SharedMemory_nCreate(JNIEnv* env, jobject, jstring jname, jint size) { } if (fd < 0) { - throwErrnoException(env, "SharedMemory_create", err); + jniThrowErrnoException(env, "SharedMemory_create", err); return nullptr; } |