On Mon, 24 Mar 2025 07:02:33 GMT, David Holmes <dhol...@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