Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8298170

Introduce a macro for exception check, free and return

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 17, 20
    • client-libs
    • None
    • In Review
    • generic
    • generic

      We have a number of places in the codebase following this pattern :

      java.desktop/share/native/libawt/awt/image/BufImgSurfaceData.c:371: if ((*env)->ExceptionCheck(env))
      java.desktop/share/native/libawt/awt/image/BufImgSurfaceData.c-372- {
      java.desktop/share/native/libawt/awt/image/BufImgSurfaceData.c-373- free(cData);
      java.desktop/share/native/libawt/awt/image/BufImgSurfaceData.c-374- return (ColorData*)NULL;

      java.security.jgss/share/native/libj2gss/NativeUtil.c:609: if ((*env)->ExceptionCheck(env)) {
      java.security.jgss/share/native/libj2gss/NativeUtil.c-610- free(value);
      java.security.jgss/share/native/libj2gss/NativeUtil.c-611- return;

      java.smartcardio/share/native/libj2pcsc/pcsc.c:163: if ((*env)->ExceptionCheck(env)) {
      java.smartcardio/share/native/libj2pcsc/pcsc.c-164- free(tab);
      java.smartcardio/share/native/libj2pcsc/pcsc.c-165- return NULL;
      java.smartcardio/share/native/libj2pcsc/pcsc.c-166- }

      jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_convert.c:1625: if ((*env)->ExceptionCheck(env)) {
      jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_convert.c-1626- free(ckParamPtr);
      jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_convert.c-1627- return NULL;
      jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_convert.c-1628- }

      ...

      This could be simplified by providing a macro JNU_CHECK_EXCEPTION_FREE_RETURN (additionally to the existing JNU_CHECK_EXCEPTION_RETURN).

            mbaesken Matthias Baesken
            mbaesken Matthias Baesken
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: