RFR: 8355904: Use variadic macros for J2dTrace [v2]

Alexey Ivanov aivanov at openjdk.org
Mon May 12 12:13:52 UTC 2025


On Mon, 12 May 2025 07:54:23 GMT, Alexey Ushakov <avu at openjdk.org> wrote:

>> There is a trailing comma problem when passing no extra args. I didn't figure out how to solve it without `__VA_OPT__` or compiler-specific tricks, so I moved the string into variadic part, so that it always has at least one parameter.
>
> I think that the benefits (having an arbitrary number of arguments) outweigh the lack of a check for the string argument type. So, I'd let's put some comments here about future use of __VA_OPT__ and integrate this change.

I think we still have the same benefits, and the first argument has to be string… It wasn't enforced at the macro level, but it was suggested by the name of the argument.

https://github.com/openjdk/jdk/blob/867aee60dd12c4ea232aaf03f14a45a3d0f91851/src/java.desktop/share/native/libawt/java2d/Trace.c#L38C38-L38C44

The functions that implement traces, `J2dTraceImpl`, still require that the first argument is a string, therefore we should get a compilation error if the first parameter isn't a string.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/24949#discussion_r2084536439


More information about the client-libs-dev mailing list