RFR: 8352184: Jtreg tests using CommandLineOptionTest.getVMTypeOption() and optionsvalidation.JVMOptionsUtils fail on static JDK
David Holmes
dholmes at openjdk.org
Mon Mar 24 07:05:13 UTC 2025
On Sat, 22 Mar 2025 03:46:38 GMT, Jiangli Zhou <jiangli at openjdk.org> wrote:
> Please review following changes, thanks.
>
> - Add `static` to the vm_info for static JDK. The `-version` output now contains `static` on static JDK, e.g.:
>
>
> $ static-jdk/bin/java -version
> openjdk version "25-internal" 2025-09-16
> OpenJDK Runtime Environment (fastdebug build 25-internal-adhoc.jianglizhou.jdk)
> OpenJDK 64-Bit Server VM (fastdebug build 25-internal-adhoc.jianglizhou.jdk, mixed mode, static, sharing)
>
> $ jdk/bin/java -version
> openjdk version "25-internal" 2025-09-16
> OpenJDK Runtime Environment (fastdebug build 25-internal-adhoc.jianglizhou.jdk)
> OpenJDK 64-Bit Server VM (fastdebug build 25-internal-adhoc.jianglizhou.jdk, mixed mode, sharing)
>
>
> Following changes resolve jtreg test failures on static JDK due to '-server|-client|-minimal|-zero' flag added by `CommandLineOptionTest.getVMTypeOption()` or `optionsvalidation.JVMOptionsUtils`. '-server|-client|-minimal|-zero' flags are unrecognized on static JDK (please see https://bugs.openjdk.org/browse/JDK-8350982).
>
> - Add `jdk.test.lib.Platform.isStatic()`, which checks for `static` in `java.vm.info` system property to determine if current test is running on static JDK.
> - Change `CommandLineOptionTest` to only call `getVMTypeOption()` on regular JDK (`!Platform.isStatic()`).
> - Change `optionsvalidation.JVMOptionsUtils` to only set VMType to '-server|-client|-minimal' on regular JDK ( `!Platform.isStatic()`.
The way we construct the VM info string is rather clunky and does not scale when you want to add more information like this. 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);
}
??
-------------
PR Review: https://git.openjdk.org/jdk/pull/24171#pullrequestreview-2709300484
More information about the core-libs-dev
mailing list