RFR: 8283013: Simplify Arguments::parse_argument() [v3]
Ioi Lam
iklam at openjdk.java.net
Wed Mar 30 20:39:19 UTC 2022
On Wed, 30 Mar 2022 20:34:57 GMT, Ioi Lam <iklam at openjdk.org> wrote:
>> src/hotspot/share/runtime/arguments.cpp line 1069:
>>
>>> 1067:
>>> 1068: size_t name_len = size_t(arg - name);
>>> 1069: JVMFlag* flag = find_jvm_flag(name, name_len);
>>
>> Consider -XX:@blah
>> I think the name_len could be 0 if the preceding while loop did not increment the arg pointer.
>> But I think it is ok because find_jvm_flag would return NULL on a zero name_len.
>> Is it correct?
>
> The code does handle the case where `name_len==0`, but I added a new check anyway to make the code easier to understand.
I tested a few cases and the results are the same before/after adding the `name_len` check.
$ java -XX:SharedBaseAddress=0x10000000 --version
java 19-internal 2022-09-20
Java(TM) SE Runtime Environment (slowdebug build 19-internal-adhoc.iklam.ken)
Java HotSpot(TM) 64-Bit Server VM (slowdebug build 19-internal-adhoc.iklam.ken, mixed mode)
$ java -XX:XSharedBaseAddress=0x10000000 --version
Unrecognized VM option 'XSharedBaseAddress=0x10000000'
Did you mean 'SharedBaseAddress=<value>'? Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
$ java -XX:@SharedBaseAddress=0x10000000 --version
Unrecognized VM option '@SharedBaseAddress=0x10000000'
Did you mean 'SharedBaseAddress=<value>'? Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
$ java -XX:=0x10000000 --version
Unrecognized VM option '=0x10000000'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
$ java -XX:@=0x10000000 --version
Unrecognized VM option '@=0x10000000'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7916
More information about the hotspot-dev
mailing list