On Thu, 27 Jun 2024 18:38:14 GMT, Sonia Zaldana Calles <szald...@openjdk.org> 
wrote:

>> Hi all, 
>> 
>> This PR addresses [8332124](https://bugs.openjdk.org/browse/JDK-8332124) 
>> enabling jcmd to accept "help" as an argument to subcommands. 
>> 
>> Testing: 
>> - [x] Verified running `jcmd 4711 VM.metaspace help` works along with other 
>> subcommands. 
>> - [x] Added test case passes. 
>> 
>> Thanks, 
>> Sonia
>
> Sonia Zaldana Calles has updated the pull request incrementally with three 
> additional commits since the last revision:
> 
>  - Updating copyright header
>  - Modifying usage to --help and -help. Updated ensuing test case to test both
>  - Updating copyright headers

One question. With the current implementation, this is the check in place to 
offer help: 
```strncmp(args, " -help", 6) == 0 || strncmp(args, " --help", 7)```

I could change this to do `strncmp(args, " -h", 3)` instead but this is a bit 
problematic as it would block any future flags that start out with `-h` from 
working.

I've been giving this some thought on how to implement a restrictive way to 
check only for the arguments `-h` or `-help` while also allowing for other 
arguments to be passed afterwards that should be ignored. 

I thought about perhaps using some type of regex matching with ```std:regex``` 
but hotspot doesn't allow the use of global operators new and delete.  I don't 
want to overengineer this piece of logic so I was wondering if there was a 
regex matching utility that I could leverage in HotSpot? 

The alternative would be to make the check more restrictive and not allow for 
arguments after `-h` has been issued i.e. `strcmp(args, "-h") == 0`. 

Thanks for your help!

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

PR Comment: https://git.openjdk.org/jdk/pull/19776#issuecomment-2197092693

Reply via email to