8352184: Jtreg tests using CommandLineOptionTest.getVMTypeOption() and optionsvalidation.JVMOptionsUtils fail on static JDK

Reviewed-by: dholmes, shade
This commit is contained in:
Jiangli Zhou 2025-03-27 14:40:02 +00:00
parent c50a0a1fc1
commit 79824c344e
5 changed files with 45 additions and 24 deletions

View File

@ -138,31 +138,41 @@ const char* Abstract_VM_Version::vm_vendor() {
const char* Abstract_VM_Version::vm_info_string() {
const char* mode;
switch (Arguments::mode()) {
case Arguments::_int:
return CDSConfig::is_using_archive() ? "interpreted mode, sharing" : "interpreted mode";
mode = "interpreted mode";
break;
case Arguments::_mixed:
if (CDSConfig::is_using_archive()) {
if (CompilationModeFlag::quick_only()) {
return "mixed mode, emulated-client, sharing";
} else {
return "mixed mode, sharing";
}
if (CompilationModeFlag::quick_only()) {
mode = "mixed mode, emulated-client";
} else {
if (CompilationModeFlag::quick_only()) {
return "mixed mode, emulated-client";
} else {
return "mixed mode";
}
mode = "mixed mode";
}
break;
case Arguments::_comp:
if (CompilationModeFlag::quick_only()) {
return CDSConfig::is_using_archive() ? "compiled mode, emulated-client, sharing" : "compiled mode, emulated-client";
mode = "compiled mode, emulated-client";
} else {
mode = "compiled mode";
}
return CDSConfig::is_using_archive() ? "compiled mode, sharing" : "compiled mode";
break;
default:
ShouldNotReachHere();
}
ShouldNotReachHere();
return "";
const char* static_info = ", static";
const char* sharing_info = ", sharing";
size_t len = strlen(mode) +
(is_vm_statically_linked() ? strlen(static_info) : 0) +
(CDSConfig::is_using_archive() ? strlen(sharing_info) : 0) +
1;
char* vm_info = NEW_C_HEAP_ARRAY(char, len, mtInternal);
// jio_snprintf places null character in the last character.
jio_snprintf(vm_info, len, "%s%s%s", mode,
is_vm_statically_linked() ? static_info : "",
CDSConfig::is_using_archive() ? sharing_info : "");
return vm_info;
}
// NOTE: do *not* use stringStream. this function is called by

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -61,7 +61,10 @@ public class JVMOptionsUtils {
private static Map<String, JVMOption> optionsAsMap;
static {
if (Platform.isServer()) {
if (Platform.isStatic()) {
// -server|-client|-minimal flags are not supported on static JDK.
VMType = null;
} else if (Platform.isServer()) {
VMType = "-server";
} else if (Platform.isClient()) {
VMType = "-client";

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -51,7 +51,7 @@ public class TestMutuallyExclusivePlatformPredicates {
VM_TYPE("isClient", "isServer", "isMinimal", "isZero", "isEmbedded"),
MODE("isInt", "isMixed", "isComp"),
IGNORED("isEmulatedClient", "isDebugBuild", "isFastDebugBuild", "isMusl",
"isSlowDebugBuild", "hasSA", "isRoot", "isTieredSupported",
"isStatic", "isSlowDebugBuild", "hasSA", "isRoot", "isTieredSupported",
"areCustomLoadersSupportedForCDS", "isDefaultCDSArchiveSupported",
"isHardenedOSX", "hasOSXPlistEntries", "isOracleLinux7", "isOnWayland");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -70,6 +70,10 @@ public class Platform {
return vmName.contains("Embedded");
}
public static boolean isStatic() {
return vmInfo.contains("static");
}
public static boolean isEmulatedClient() {
return vmInfo.contains(" emulated-client");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -199,7 +199,9 @@ public abstract class CommandLineOptionTest {
String wrongWarningMessage, ExitCode exitCode, String... options)
throws Throwable {
List<String> finalOptions = new ArrayList<>();
finalOptions.add(CommandLineOptionTest.getVMTypeOption());
if (!Platform.isStatic()) {
finalOptions.add(CommandLineOptionTest.getVMTypeOption());
}
String extraFlagForEmulated = CommandLineOptionTest.getVMTypeOptionForEmulated();
if (extraFlagForEmulated != null) {
finalOptions.add(extraFlagForEmulated);
@ -394,7 +396,9 @@ public abstract class CommandLineOptionTest {
String expectedValue, String optionErrorString,
String... additionalVMOpts) throws Throwable {
List<String> finalOptions = new ArrayList<>();
finalOptions.add(CommandLineOptionTest.getVMTypeOption());
if (!Platform.isStatic()) {
finalOptions.add(CommandLineOptionTest.getVMTypeOption());
}
String extraFlagForEmulated = CommandLineOptionTest.getVMTypeOptionForEmulated();
if (extraFlagForEmulated != null) {
finalOptions.add(extraFlagForEmulated);