Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9e82c386 authored by Courtney Goeltzenleuchter's avatar Courtney Goeltzenleuchter
Browse files

Must return after throwing exception

You cannot keep using a JNI env while there's a pending exception.
https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/design.html#exceptions_and_error_codes
Issue discovered with EG15 addition, fixing EGL14 interface for
consistency.

Bug: 124064285
Test: atest android.graphics.cts.EGL14Test
Change-Id: Iba3f1536d5f3b70a8f60b905ba020d9fbe3fda8a
parent 9b5f31b8
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ fromEGLHandle(JNIEnv *_env, jmethodID mid, jobject obj) {
    if (obj == NULL){
        jniThrowException(_env, "java/lang/IllegalArgumentException",
                          "Object is set to null.");
        return nullptr;
    }

    jlong handle = _env->CallLongMethod(obj, mid);
@@ -238,6 +239,7 @@ exit:
    }
    if (_exception) {
        jniThrowException(_env, _exceptionType, _exceptionMessage);
        return false;
    }
    return (jboolean)_returnValue;
}
@@ -335,6 +337,7 @@ exit:
    }
    if (_exception) {
        jniThrowException(_env, _exceptionType, _exceptionMessage);
        return false;
    }
    return (jboolean)_returnValue;
}
@@ -454,6 +457,7 @@ exit:
    }
    if (_exception) {
        jniThrowException(_env, _exceptionType, _exceptionMessage);
        return false;
    }
    return (jboolean)_returnValue;
}
@@ -509,6 +513,7 @@ exit:
    }
    if (_exception) {
        jniThrowException(_env, _exceptionType, _exceptionMessage);
        return false;
    }
    return (jboolean)_returnValue;
}
@@ -582,6 +587,7 @@ exit:
    }
    if (_exception) {
        jniThrowException(_env, _exceptionType, _exceptionMessage);
        return nullptr;
    }
    return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue);
}
@@ -664,6 +670,7 @@ exit:
    }
    if (_exception) {
        jniThrowException(_env, _exceptionType, _exceptionMessage);
        return nullptr;
    }
    return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue);
}
@@ -721,6 +728,7 @@ exit:
    }
    if (_exception) {
        jniThrowException(_env, _exceptionType, _exceptionMessage);
        return nullptr;
    }
    return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue);
}
@@ -731,7 +739,7 @@ android_eglCreatePixmapSurface
  (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jint pixmap, jintArray attrib_list_ref, jint offset) {
    jniThrowException(_env, "java/lang/UnsupportedOperationException",
        "eglCreatePixmapSurface");
    return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, (EGLSurface) 0);
    return nullptr;
}

/* EGLBoolean eglDestroySurface ( EGLDisplay dpy, EGLSurface surface ) */
@@ -800,6 +808,7 @@ exit:
    }
    if (_exception) {
        jniThrowException(_env, _exceptionType, _exceptionMessage);
        return false;
    }
    return (jboolean)_returnValue;
}
@@ -898,6 +907,7 @@ exit:
    }
    if (_exception) {
        jniThrowException(_env, _exceptionType, _exceptionMessage);
        return nullptr;
    }
    return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue);
}
@@ -1034,6 +1044,7 @@ exit:
    }
    if (_exception) {
        jniThrowException(_env, _exceptionType, _exceptionMessage);
        return nullptr;
    }
    return toEGLHandle(_env, eglcontextClass, eglcontextConstructor, _returnValue);
}
@@ -1152,6 +1163,7 @@ exit:
    }
    if (_exception) {
        jniThrowException(_env, _exceptionType, _exceptionMessage);
        return false;
    }
    return (jboolean)_returnValue;
}