RFR: 8352184: Jtreg tests using CommandLineOptionTest.getVMTypeOption() and optionsvalidation.JVMOptionsUtils fail on static JDK [v2]
Jiangli Zhou
jiangli at openjdk.org
Mon Mar 24 20:28:07 UTC 2025
On Mon, 24 Mar 2025 07:02:33 GMT, David Holmes <dholmes at openjdk.org> wrote:
> The way we construct the VM info string is rather clunky and does not scale when you want to add more information like this.
Agree.
> Short of rewriting it to dynamically create the final string from its constituent parts, couldn't this change more simply replace the return statements with an assignment to a local and then append static if needed i.e something like:
>
> ```
> char* ret;
> ...
> ret = CDSConfig::is_using_archive() ? "interpreted mode, sharing" : "interpreted mode";
> ...
> // If static then append static
> if (is_vm_statically_linked() {
> const char* static_str = ", static";
> const char* buf = malloc(strlen(ret) + strlen(static_str);
> strcpy(buf, ret);
> strcat(buf, static_str);
> }
> ```
>
> ??
If we allocate memory dynamically for vm_info string in the static case, how about we further simplify the code to handle the CDS case as well? I updated the change, please let me know if that looks cleaner to you.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/24171#issuecomment-2749312616
More information about the hotspot-runtime-dev
mailing list