Skip to content

Commit 79824c3

Browse files
committed
8352184: Jtreg tests using CommandLineOptionTest.getVMTypeOption() and optionsvalidation.JVMOptionsUtils fail on static JDK
Reviewed-by: dholmes, shade
1 parent c50a0a1 commit 79824c3

File tree

5 files changed

+45
-24
lines changed

5 files changed

+45
-24
lines changed

src/hotspot/share/runtime/abstract_vm_version.cpp

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -138,31 +138,41 @@ const char* Abstract_VM_Version::vm_vendor() {
138138

139139

140140
const char* Abstract_VM_Version::vm_info_string() {
141+
const char* mode;
141142
switch (Arguments::mode()) {
142143
case Arguments::_int:
143-
return CDSConfig::is_using_archive() ? "interpreted mode, sharing" : "interpreted mode";
144+
mode = "interpreted mode";
145+
break;
144146
case Arguments::_mixed:
145-
if (CDSConfig::is_using_archive()) {
146-
if (CompilationModeFlag::quick_only()) {
147-
return "mixed mode, emulated-client, sharing";
148-
} else {
149-
return "mixed mode, sharing";
150-
}
147+
if (CompilationModeFlag::quick_only()) {
148+
mode = "mixed mode, emulated-client";
151149
} else {
152-
if (CompilationModeFlag::quick_only()) {
153-
return "mixed mode, emulated-client";
154-
} else {
155-
return "mixed mode";
156-
}
150+
mode = "mixed mode";
157151
}
152+
break;
158153
case Arguments::_comp:
159154
if (CompilationModeFlag::quick_only()) {
160-
return CDSConfig::is_using_archive() ? "compiled mode, emulated-client, sharing" : "compiled mode, emulated-client";
155+
mode = "compiled mode, emulated-client";
156+
} else {
157+
mode = "compiled mode";
161158
}
162-
return CDSConfig::is_using_archive() ? "compiled mode, sharing" : "compiled mode";
159+
break;
160+
default:
161+
ShouldNotReachHere();
163162
}
164-
ShouldNotReachHere();
165-
return "";
163+
164+
const char* static_info = ", static";
165+
const char* sharing_info = ", sharing";
166+
size_t len = strlen(mode) +
167+
(is_vm_statically_linked() ? strlen(static_info) : 0) +
168+
(CDSConfig::is_using_archive() ? strlen(sharing_info) : 0) +
169+
1;
170+
char* vm_info = NEW_C_HEAP_ARRAY(char, len, mtInternal);
171+
// jio_snprintf places null character in the last character.
172+
jio_snprintf(vm_info, len, "%s%s%s", mode,
173+
is_vm_statically_linked() ? static_info : "",
174+
CDSConfig::is_using_archive() ? sharing_info : "");
175+
return vm_info;
166176
}
167177

168178
// NOTE: do *not* use stringStream. this function is called by

test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOptionsUtils.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -61,7 +61,10 @@ public class JVMOptionsUtils {
6161
private static Map<String, JVMOption> optionsAsMap;
6262

6363
static {
64-
if (Platform.isServer()) {
64+
if (Platform.isStatic()) {
65+
// -server|-client|-minimal flags are not supported on static JDK.
66+
VMType = null;
67+
} else if (Platform.isServer()) {
6568
VMType = "-server";
6669
} else if (Platform.isClient()) {
6770
VMType = "-client";

test/lib-test/jdk/test/lib/TestMutuallyExclusivePlatformPredicates.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -51,7 +51,7 @@ private static enum MethodGroup {
5151
VM_TYPE("isClient", "isServer", "isMinimal", "isZero", "isEmbedded"),
5252
MODE("isInt", "isMixed", "isComp"),
5353
IGNORED("isEmulatedClient", "isDebugBuild", "isFastDebugBuild", "isMusl",
54-
"isSlowDebugBuild", "hasSA", "isRoot", "isTieredSupported",
54+
"isStatic", "isSlowDebugBuild", "hasSA", "isRoot", "isTieredSupported",
5555
"areCustomLoadersSupportedForCDS", "isDefaultCDSArchiveSupported",
5656
"isHardenedOSX", "hasOSXPlistEntries", "isOracleLinux7", "isOnWayland");
5757

test/lib/jdk/test/lib/Platform.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -70,6 +70,10 @@ public static boolean isEmbedded() {
7070
return vmName.contains("Embedded");
7171
}
7272

73+
public static boolean isStatic() {
74+
return vmInfo.contains("static");
75+
}
76+
7377
public static boolean isEmulatedClient() {
7478
return vmInfo.contains(" emulated-client");
7579
}

test/lib/jdk/test/lib/cli/CommandLineOptionTest.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -199,7 +199,9 @@ public static void verifySameJVMStartup(String expectedMessages[],
199199
String wrongWarningMessage, ExitCode exitCode, String... options)
200200
throws Throwable {
201201
List<String> finalOptions = new ArrayList<>();
202-
finalOptions.add(CommandLineOptionTest.getVMTypeOption());
202+
if (!Platform.isStatic()) {
203+
finalOptions.add(CommandLineOptionTest.getVMTypeOption());
204+
}
203205
String extraFlagForEmulated = CommandLineOptionTest.getVMTypeOptionForEmulated();
204206
if (extraFlagForEmulated != null) {
205207
finalOptions.add(extraFlagForEmulated);
@@ -394,7 +396,9 @@ public static void verifyOptionValueForSameVM(String optionName,
394396
String expectedValue, String optionErrorString,
395397
String... additionalVMOpts) throws Throwable {
396398
List<String> finalOptions = new ArrayList<>();
397-
finalOptions.add(CommandLineOptionTest.getVMTypeOption());
399+
if (!Platform.isStatic()) {
400+
finalOptions.add(CommandLineOptionTest.getVMTypeOption());
401+
}
398402
String extraFlagForEmulated = CommandLineOptionTest.getVMTypeOptionForEmulated();
399403
if (extraFlagForEmulated != null) {
400404
finalOptions.add(extraFlagForEmulated);

0 commit comments

Comments
 (0)