Re: RFR: JDK-8298170 : Introduce a macro for exception check, free and return

2022-12-28 Thread Matthias Baesken
On Tue, 6 Dec 2022 15:20:26 GMT, Matthias Baesken  wrote:

> We have a number of places in the codebase  where a macro could help when we 
> check an exception and afterwrads free something and return.

okay, if keeping the block in the code that contains free and return, we 
probably just stay with what we have


if ((*env)->ExceptionCheck(env)) {
  free(xyz);
  return val;
}

-

PR: https://git.openjdk.org/jdk/pull/11539


Re: RFR: JDK-8298170 : Introduce a macro for exception check, free and return

2022-12-09 Thread Roger Riggs
On Fri, 9 Dec 2022 12:23:04 GMT, Matthias Baesken  wrote:

> Hi Roger , the new proposed version JNU_CHECK_EXCEPTION_DO is now almost as 
> lengthy as the original coding, Is it really worth it introducing a macro 
> when it gets so lengthy ?

Its easier to understand the flow and cleanup being done if its visible in the 
source. 
I (or new readers) don't have to go unwrap the macro to know what's going to 
happen.

-

PR: https://git.openjdk.org/jdk/pull/11539


Re: RFR: JDK-8298170 : Introduce a macro for exception check, free and return

2022-12-09 Thread Matthias Baesken
On Tue, 6 Dec 2022 15:20:26 GMT, Matthias Baesken  wrote:

> We have a number of places in the codebase  where a macro could help when we 
> check an exception and afterwrads free something and return.

Hi Roger , the new proposed version  JNU_CHECK_EXCEPTION_DO  is now almost as 
lengthy as the original coding, Is it really worth it introducing a macro when 
it gets so lengthy ?

-

PR: https://git.openjdk.org/jdk/pull/11539


Re: RFR: JDK-8298170 : Introduce a macro for exception check, free and return

2022-12-07 Thread Thomas Stuefe
On Wed, 7 Dec 2022 16:27:43 GMT, Roger Riggs  wrote:

> 
> Good idea, though perhaps the return (and value if any) could be explicit in 
> the macro invocation, instead of implicit (plus arg). A single macro would 
> suffice, instead of multiples.
> 
> Usage Example:
> 
> ```
> JNU_CHECK_EXCEPTION_DO(env, { 
>  free(tab); 
>  return;
>})
> ```

Neat. I like that.

-

PR: https://git.openjdk.org/jdk/pull/11539


Re: RFR: JDK-8298170 : Introduce a macro for exception check, free and return

2022-12-07 Thread Roger Riggs
On Tue, 6 Dec 2022 15:20:26 GMT, Matthias Baesken  wrote:

> We have a number of places in the codebase  where a macro could help when we 
> check an exception and afterwrads free something and return.

Good idea, though perhaps the return (and value if any) could be explicit in 
the macro invocation, instead of implicit (plus arg).  A single macro would 
suffice, instead of multiples.

Usage Example:

JNU_CHECK_EXCEPTION_DO(env, { 
 free(tab); 
 return;
   })

Or put the invocation and return all on one line.

-

PR: https://git.openjdk.org/jdk/pull/11539


Re: RFR: JDK-8298170 : Introduce a macro for exception check, free and return

2022-12-07 Thread Matthias Baesken
On Tue, 6 Dec 2022 20:40:34 GMT, Roger Riggs  wrote:

> The existing code more obviously handles memory deallocation.

Thomas Stuefe suggested something like this


JNU_CHECK_EXCEPTION_DO(env, action)
JNU_CHECK_EXCEPTION_DO_AND_RETURN(env, action, retval)


usage example: 
`JNU_CHECK_EXCEPTION_DO(env, { free(tab); })`

This would make the free-ing more clear, and should also work for 2 free-calls, 
we a have places like this in the codebase. What do you think about this?

-

PR: https://git.openjdk.org/jdk/pull/11539


Re: RFR: JDK-8298170 : Introduce a macro for exception check, free and return

2022-12-06 Thread Roger Riggs
On Tue, 6 Dec 2022 15:20:26 GMT, Matthias Baesken  wrote:

> We have a number of places in the codebase  where a macro could help when we 
> check an exception and afterwrads free something and return.

The existing (and new) macro naming doesn't make clear that it always returns 
from the function.  The presence of "RETURN" in the name only means there is a 
return value.
The existing code more obviously handles memory deallocation.

-

PR: https://git.openjdk.org/jdk/pull/11539


Re: RFR: JDK-8298170 : Introduce a macro for exception check, free and return

2022-12-06 Thread Phil Race
On Tue, 6 Dec 2022 15:20:26 GMT, Matthias Baesken  wrote:

> We have a number of places in the codebase  where a macro could help when we 
> check an exception and afterwrads free something and return.

I'm OK with the idea and the specific desktop change.
I'll leave the rest to the appropriate component teams.
Seems this needs > 1 reviewer tho' because of the different areas.

-

Marked as reviewed by prr (Reviewer).

PR: https://git.openjdk.org/jdk/pull/11539


RFR: JDK-8298170 : Introduce a macro for exception check, free and return

2022-12-06 Thread Matthias Baesken
We have a number of places in the codebase  where a macro could help when we 
check an exception and afterwrads free something and return.

-

Commit messages:
 - JDK-8298170

Changes: https://git.openjdk.org/jdk/pull/11539/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk=11539=00
  Issue: https://bugs.openjdk.org/browse/JDK-8298170
  Stats: 87 lines in 7 files changed: 32 ins; 39 del; 16 mod
  Patch: https://git.openjdk.org/jdk/pull/11539.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/11539/head:pull/11539

PR: https://git.openjdk.org/jdk/pull/11539