RFR: 8286694: Incorrect argument processing in java launcher

Yasumasa Suenaga ysuenaga at openjdk.java.net
Mon May 16 12:35:48 UTC 2022


On Mon, 16 May 2022 06:58:22 GMT, David Holmes <dholmes at openjdk.org> wrote:

> Simply considering the compiler warning shouldn't `(arg+2) == NULL` actually be `arg[2] == '\0'` ? as we are looking to see if this arg is only three characters: '-', 'J' and '\0'

Yeah, I thought that first, but I think better of keeping similar code because the result (element of `nargv`) will be used as loop condition (see description of this PR).

In addition, subsequent codes consider this case (`-J` only)  to be an error as following:


1633     for (i = 0; i < argc; i++) {
1634         char *arg = argv[i];
1635         if (arg[0] == '-' && arg[1] == 'J') {
1636             if (arg[2] == '\0') {
1637                 JLI_ReportErrorMessage(ARG_ERROR3);
1638                 exit(1);
1639             }
1640             *nargv++ = arg + 2;
1641         }
1642     }


However `jargv` is builtin arguments, not user specified arguments as I wrote the description of this PR. So I think we can ignore it, but it would be nice if we can see it in trace logs.

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

PR: https://git.openjdk.java.net/jdk/pull/8694


More information about the core-libs-dev mailing list