2016-04-07 13:43:35 +00:00
|
|
|
/*
|
2024-02-16 09:23:42 +00:00
|
|
|
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
|
2016-04-07 13:43:35 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
|
|
|
*/
|
2021-03-18 15:34:58 +00:00
|
|
|
|
2016-04-07 13:43:35 +00:00
|
|
|
package requires;
|
|
|
|
|
2018-06-15 16:53:28 +00:00
|
|
|
import java.io.BufferedInputStream;
|
|
|
|
import java.io.FileInputStream;
|
2016-04-07 13:43:35 +00:00
|
|
|
import java.io.IOException;
|
2018-06-15 16:53:28 +00:00
|
|
|
import java.io.InputStream;
|
2023-02-17 19:37:02 +00:00
|
|
|
import java.io.File;
|
|
|
|
import java.nio.charset.Charset;
|
2016-04-07 13:43:35 +00:00
|
|
|
import java.nio.file.Files;
|
2017-08-02 15:52:14 +00:00
|
|
|
import java.nio.file.Path;
|
2016-04-07 13:43:35 +00:00
|
|
|
import java.nio.file.Paths;
|
2016-11-23 09:25:21 +00:00
|
|
|
import java.nio.file.StandardOpenOption;
|
2023-02-17 19:37:02 +00:00
|
|
|
import java.time.Instant;
|
2016-04-07 13:43:35 +00:00
|
|
|
import java.util.ArrayList;
|
2021-03-18 15:34:58 +00:00
|
|
|
import java.util.Collections;
|
2016-04-07 13:43:35 +00:00
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
2018-06-15 16:53:28 +00:00
|
|
|
import java.util.Properties;
|
2021-03-18 15:34:58 +00:00
|
|
|
import java.util.Set;
|
2016-04-07 13:43:35 +00:00
|
|
|
import java.util.concurrent.Callable;
|
2017-10-11 02:18:36 +00:00
|
|
|
import java.util.concurrent.TimeUnit;
|
2023-06-20 10:08:13 +00:00
|
|
|
import java.util.function.Predicate;
|
2019-02-22 22:39:57 +00:00
|
|
|
import java.util.function.Supplier;
|
2016-04-07 13:43:35 +00:00
|
|
|
import java.util.regex.Matcher;
|
|
|
|
import java.util.regex.Pattern;
|
2023-10-17 09:22:03 +00:00
|
|
|
import java.util.stream.Stream;
|
2016-12-21 11:41:48 +00:00
|
|
|
|
2023-05-02 13:56:32 +00:00
|
|
|
import jdk.internal.foreign.CABI;
|
2021-08-02 20:44:18 +00:00
|
|
|
import jdk.test.whitebox.code.Compiler;
|
|
|
|
import jdk.test.whitebox.cpuinfo.CPUInfo;
|
|
|
|
import jdk.test.whitebox.gc.GC;
|
|
|
|
import jdk.test.whitebox.WhiteBox;
|
2017-06-02 00:34:34 +00:00
|
|
|
import jdk.test.lib.Platform;
|
2019-07-22 08:48:14 +00:00
|
|
|
import jdk.test.lib.Container;
|
2016-04-07 13:43:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The Class to be invoked by jtreg prior Test Suite execution to
|
|
|
|
* collect information about VM.
|
2019-02-22 22:39:57 +00:00
|
|
|
* Do not use any APIs that may not be available in all target VMs.
|
2016-04-07 13:43:35 +00:00
|
|
|
* Properties set by this Class will be available in the @requires expressions.
|
|
|
|
*/
|
|
|
|
public class VMProps implements Callable<Map<String, String>> {
|
2019-02-22 22:39:57 +00:00
|
|
|
// value known to jtreg as an indicator of error state
|
|
|
|
private static final String ERROR_STATE = "__ERROR__";
|
2016-04-07 13:43:35 +00:00
|
|
|
|
2024-05-24 16:07:36 +00:00
|
|
|
private static final String GC_PREFIX = "-XX:+Use";
|
|
|
|
private static final String GC_SUFFIX = "GC";
|
|
|
|
|
2016-07-21 13:07:41 +00:00
|
|
|
private static final WhiteBox WB = WhiteBox.getWhiteBox();
|
|
|
|
|
2019-02-22 22:39:57 +00:00
|
|
|
private static class SafeMap {
|
|
|
|
private final Map<String, String> map = new HashMap<>();
|
|
|
|
|
|
|
|
public void put(String key, Supplier<String> s) {
|
|
|
|
String value;
|
|
|
|
try {
|
|
|
|
value = s.get();
|
|
|
|
} catch (Throwable t) {
|
|
|
|
System.err.println("failed to get value for " + key);
|
|
|
|
t.printStackTrace(System.err);
|
|
|
|
value = ERROR_STATE + t;
|
|
|
|
}
|
|
|
|
map.put(key, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-07 13:43:35 +00:00
|
|
|
/**
|
|
|
|
* Collects information about VM properties.
|
|
|
|
* This method will be invoked by jtreg.
|
|
|
|
*
|
|
|
|
* @return Map of property-value pairs.
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public Map<String, String> call() {
|
2023-02-17 19:37:02 +00:00
|
|
|
log("Entering call()");
|
2019-02-22 22:39:57 +00:00
|
|
|
SafeMap map = new SafeMap();
|
|
|
|
map.put("vm.flavor", this::vmFlavor);
|
|
|
|
map.put("vm.compMode", this::vmCompMode);
|
|
|
|
map.put("vm.bits", this::vmBits);
|
|
|
|
map.put("vm.flightRecorder", this::vmFlightRecorder);
|
|
|
|
map.put("vm.simpleArch", this::vmArch);
|
|
|
|
map.put("vm.debug", this::vmDebug);
|
|
|
|
map.put("vm.jvmci", this::vmJvmci);
|
2023-07-13 07:20:18 +00:00
|
|
|
map.put("vm.jvmci.enabled", this::vmJvmciEnabled);
|
2019-02-22 22:39:57 +00:00
|
|
|
map.put("vm.emulatedClient", this::vmEmulatedClient);
|
2018-06-25 21:04:21 +00:00
|
|
|
// vm.hasSA is "true" if the VM contains the serviceability agent
|
|
|
|
// and jhsdb.
|
2019-02-22 22:39:57 +00:00
|
|
|
map.put("vm.hasSA", this::vmHasSA);
|
2018-07-20 07:46:57 +00:00
|
|
|
// vm.hasJFR is "true" if JFR is included in the build of the VM and
|
|
|
|
// so tests can be executed.
|
2019-02-22 22:39:57 +00:00
|
|
|
map.put("vm.hasJFR", this::vmHasJFR);
|
2022-02-16 20:08:27 +00:00
|
|
|
map.put("vm.hasDTrace", this::vmHasDTrace);
|
2020-08-21 22:49:09 +00:00
|
|
|
map.put("vm.jvmti", this::vmHasJVMTI);
|
2019-02-22 22:39:57 +00:00
|
|
|
map.put("vm.cpu.features", this::cpuFeatures);
|
2020-08-26 03:28:10 +00:00
|
|
|
map.put("vm.pageSize", this::vmPageSize);
|
2019-02-22 22:39:57 +00:00
|
|
|
map.put("vm.rtm.cpu", this::vmRTMCPU);
|
|
|
|
map.put("vm.rtm.compiler", this::vmRTMCompiler);
|
2017-08-01 14:03:06 +00:00
|
|
|
// vm.cds is true if the VM is compiled with cds support.
|
2019-02-22 22:39:57 +00:00
|
|
|
map.put("vm.cds", this::vmCDS);
|
|
|
|
map.put("vm.cds.custom.loaders", this::vmCDSForCustomLoaders);
|
2024-11-15 22:28:54 +00:00
|
|
|
map.put("vm.cds.supports.aot.class.linking", this::vmCDSSupportsAOTClassLinking);
|
2021-09-10 22:45:26 +00:00
|
|
|
map.put("vm.cds.write.archived.java.heap", this::vmCDSCanWriteArchivedJavaHeap);
|
2022-06-02 09:02:37 +00:00
|
|
|
map.put("vm.continuations", this::vmContinuations);
|
2017-10-02 21:31:34 +00:00
|
|
|
// vm.graal.enabled is true if Graal is used as JIT
|
2019-02-22 22:39:57 +00:00
|
|
|
map.put("vm.graal.enabled", this::isGraalEnabled);
|
2023-07-14 14:10:10 +00:00
|
|
|
// jdk.hasLibgraal is true if the libgraal shared library file is present
|
|
|
|
map.put("jdk.hasLibgraal", this::hasLibgraal);
|
2024-09-26 21:38:08 +00:00
|
|
|
map.put("vm.libgraal.jit", this::isLibgraalJIT);
|
2019-02-22 22:39:57 +00:00
|
|
|
map.put("vm.compiler1.enabled", this::isCompiler1Enabled);
|
|
|
|
map.put("vm.compiler2.enabled", this::isCompiler2Enabled);
|
2024-10-12 03:25:42 +00:00
|
|
|
map.put("container.support", this::containerSupport);
|
2024-09-11 16:57:13 +00:00
|
|
|
map.put("systemd.support", this::systemdSupport);
|
2020-10-13 09:35:58 +00:00
|
|
|
map.put("vm.musl", this::isMusl);
|
2019-02-22 22:39:57 +00:00
|
|
|
map.put("release.implementor", this::implementor);
|
2020-10-26 20:30:37 +00:00
|
|
|
map.put("jdk.containerized", this::jdkContainerized);
|
2021-03-18 15:34:58 +00:00
|
|
|
map.put("vm.flagless", this::isFlagless);
|
2023-05-02 13:56:32 +00:00
|
|
|
map.put("jdk.foreign.linker", this::jdkForeignLinker);
|
2024-11-11 13:35:25 +00:00
|
|
|
map.put("jlink.packagedModules", this::packagedModules);
|
2016-06-21 14:36:37 +00:00
|
|
|
vmGC(map); // vm.gc.X = true/false
|
2021-09-01 16:50:11 +00:00
|
|
|
vmGCforCDS(map); // may set vm.gc
|
2018-05-31 08:41:36 +00:00
|
|
|
vmOptFinalFlags(map);
|
2016-06-21 14:36:37 +00:00
|
|
|
|
2019-02-22 22:39:57 +00:00
|
|
|
dump(map.map);
|
2023-02-17 19:37:02 +00:00
|
|
|
log("Leaving call()");
|
2019-02-22 22:39:57 +00:00
|
|
|
return map.map;
|
2016-04-07 13:43:35 +00:00
|
|
|
}
|
|
|
|
|
2017-07-06 14:03:54 +00:00
|
|
|
/**
|
2019-02-22 22:39:57 +00:00
|
|
|
* Print a stack trace before returning error state;
|
2017-07-06 14:03:54 +00:00
|
|
|
* Used by the various helper functions which parse information from
|
|
|
|
* VM properties in the case where they don't find an expected property
|
2019-02-22 22:39:57 +00:00
|
|
|
* or a property doesn't conform to an expected format.
|
2017-07-06 14:03:54 +00:00
|
|
|
*
|
2019-02-22 22:39:57 +00:00
|
|
|
* @return {@link #ERROR_STATE}
|
2017-07-06 14:03:54 +00:00
|
|
|
*/
|
2019-02-22 22:39:57 +00:00
|
|
|
private String errorWithMessage(String message) {
|
2017-07-06 14:03:54 +00:00
|
|
|
new Exception(message).printStackTrace();
|
2019-02-22 22:39:57 +00:00
|
|
|
return ERROR_STATE + message;
|
2017-07-06 14:03:54 +00:00
|
|
|
}
|
|
|
|
|
2016-06-17 10:05:53 +00:00
|
|
|
/**
|
|
|
|
* @return vm.simpleArch value of "os.simpleArch" property of tested JDK.
|
|
|
|
*/
|
|
|
|
protected String vmArch() {
|
|
|
|
String arch = System.getProperty("os.arch");
|
|
|
|
if (arch.equals("x86_64") || arch.equals("amd64")) {
|
|
|
|
return "x64";
|
2019-02-22 22:39:57 +00:00
|
|
|
} else if (arch.contains("86")) {
|
2016-06-17 10:05:53 +00:00
|
|
|
return "x86";
|
|
|
|
} else {
|
|
|
|
return arch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-07 13:43:35 +00:00
|
|
|
/**
|
|
|
|
* @return VM type value extracted from the "java.vm.name" property.
|
|
|
|
*/
|
|
|
|
protected String vmFlavor() {
|
|
|
|
// E.g. "Java HotSpot(TM) 64-Bit Server VM"
|
|
|
|
String vmName = System.getProperty("java.vm.name");
|
|
|
|
if (vmName == null) {
|
2019-02-22 22:39:57 +00:00
|
|
|
return errorWithMessage("Can't get 'java.vm.name' property");
|
2016-04-07 13:43:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Pattern startP = Pattern.compile(".* (\\S+) VM");
|
|
|
|
Matcher m = startP.matcher(vmName);
|
|
|
|
if (m.matches()) {
|
|
|
|
return m.group(1).toLowerCase();
|
|
|
|
}
|
2019-02-22 22:39:57 +00:00
|
|
|
return errorWithMessage("Can't get VM flavor from 'java.vm.name'");
|
2016-04-07 13:43:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return VM compilation mode extracted from the "java.vm.info" property.
|
|
|
|
*/
|
|
|
|
protected String vmCompMode() {
|
|
|
|
// E.g. "mixed mode"
|
|
|
|
String vmInfo = System.getProperty("java.vm.info");
|
|
|
|
if (vmInfo == null) {
|
2019-02-22 22:39:57 +00:00
|
|
|
return errorWithMessage("Can't get 'java.vm.info' property");
|
2016-04-07 13:43:35 +00:00
|
|
|
}
|
2019-02-22 22:39:57 +00:00
|
|
|
vmInfo = vmInfo.toLowerCase();
|
|
|
|
if (vmInfo.contains("mixed mode")) {
|
2017-07-06 14:03:54 +00:00
|
|
|
return "Xmixed";
|
2019-02-22 22:39:57 +00:00
|
|
|
} else if (vmInfo.contains("compiled mode")) {
|
2017-07-06 14:03:54 +00:00
|
|
|
return "Xcomp";
|
2019-02-22 22:39:57 +00:00
|
|
|
} else if (vmInfo.contains("interpreted mode")) {
|
2017-07-06 14:03:54 +00:00
|
|
|
return "Xint";
|
|
|
|
} else {
|
2019-02-22 22:39:57 +00:00
|
|
|
return errorWithMessage("Can't get compilation mode from 'java.vm.info'");
|
2016-04-07 13:43:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return VM bitness, the value of the "sun.arch.data.model" property.
|
|
|
|
*/
|
|
|
|
protected String vmBits() {
|
2017-07-06 14:03:54 +00:00
|
|
|
String dataModel = System.getProperty("sun.arch.data.model");
|
|
|
|
if (dataModel != null) {
|
|
|
|
return dataModel;
|
|
|
|
} else {
|
2019-02-22 22:39:57 +00:00
|
|
|
return errorWithMessage("Can't get 'sun.arch.data.model' property");
|
2017-07-06 14:03:54 +00:00
|
|
|
}
|
2016-04-07 13:43:35 +00:00
|
|
|
}
|
|
|
|
|
2016-06-17 15:45:24 +00:00
|
|
|
/**
|
|
|
|
* @return "true" if Flight Recorder is enabled, "false" if is disabled.
|
|
|
|
*/
|
|
|
|
protected String vmFlightRecorder() {
|
2016-07-21 13:07:41 +00:00
|
|
|
Boolean isFlightRecorder = WB.getBooleanVMFlag("FlightRecorder");
|
|
|
|
String startFROptions = WB.getStringVMFlag("StartFlightRecording");
|
2018-06-22 04:37:28 +00:00
|
|
|
if (isFlightRecorder != null && isFlightRecorder) {
|
|
|
|
return "true";
|
|
|
|
}
|
|
|
|
if (startFROptions != null && !startFROptions.isEmpty()) {
|
|
|
|
return "true";
|
2016-06-17 15:45:24 +00:00
|
|
|
}
|
|
|
|
return "false";
|
|
|
|
}
|
|
|
|
|
2016-10-20 13:53:35 +00:00
|
|
|
/**
|
|
|
|
* @return debug level value extracted from the "jdk.debug" property.
|
|
|
|
*/
|
|
|
|
protected String vmDebug() {
|
2017-07-06 14:03:54 +00:00
|
|
|
String debug = System.getProperty("jdk.debug");
|
|
|
|
if (debug != null) {
|
|
|
|
return "" + debug.contains("debug");
|
|
|
|
} else {
|
2019-02-22 22:39:57 +00:00
|
|
|
return errorWithMessage("Can't get 'jdk.debug' property");
|
2017-07-06 14:03:54 +00:00
|
|
|
}
|
2016-10-20 13:53:35 +00:00
|
|
|
}
|
|
|
|
|
2016-11-25 08:55:33 +00:00
|
|
|
/**
|
|
|
|
* @return true if VM supports JVMCI and false otherwise
|
|
|
|
*/
|
|
|
|
protected String vmJvmci() {
|
|
|
|
// builds with jvmci have this flag
|
2019-10-01 13:38:26 +00:00
|
|
|
if (WB.getBooleanVMFlag("EnableJVMCI") == null) {
|
|
|
|
return "false";
|
|
|
|
}
|
|
|
|
|
2020-12-03 13:42:50 +00:00
|
|
|
// Not all GCs have full JVMCI support
|
|
|
|
if (!WB.isJVMCISupportedByGC()) {
|
|
|
|
return "false";
|
2019-10-01 13:38:26 +00:00
|
|
|
}
|
|
|
|
|
2021-01-22 07:05:30 +00:00
|
|
|
// Interpreted mode cannot enable JVMCI
|
|
|
|
if (vmCompMode().equals("Xint")) {
|
|
|
|
return "false";
|
|
|
|
}
|
|
|
|
|
2020-12-03 13:42:50 +00:00
|
|
|
return "true";
|
2016-11-25 08:55:33 +00:00
|
|
|
}
|
|
|
|
|
2023-07-13 07:20:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if JVMCI is enabled
|
|
|
|
*/
|
|
|
|
protected String vmJvmciEnabled() {
|
|
|
|
// builds with jvmci have this flag
|
|
|
|
if ("false".equals(vmJvmci())) {
|
|
|
|
return "false";
|
|
|
|
}
|
|
|
|
|
|
|
|
return "" + Compiler.isJVMCIEnabled();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-18 05:39:22 +00:00
|
|
|
/**
|
|
|
|
* @return true if VM runs in emulated-client mode and false otherwise.
|
|
|
|
*/
|
|
|
|
protected String vmEmulatedClient() {
|
|
|
|
String vmInfo = System.getProperty("java.vm.info");
|
|
|
|
if (vmInfo == null) {
|
2019-02-22 22:39:57 +00:00
|
|
|
return errorWithMessage("Can't get 'java.vm.info' property");
|
2017-01-18 05:39:22 +00:00
|
|
|
}
|
|
|
|
return "" + vmInfo.contains(" emulated-client");
|
|
|
|
}
|
|
|
|
|
2016-12-21 11:41:48 +00:00
|
|
|
/**
|
|
|
|
* @return supported CPU features
|
|
|
|
*/
|
|
|
|
protected String cpuFeatures() {
|
|
|
|
return CPUInfo.getFeatures().toString();
|
|
|
|
}
|
|
|
|
|
2016-06-21 14:36:37 +00:00
|
|
|
/**
|
|
|
|
* For all existing GC sets vm.gc.X property.
|
|
|
|
* Example vm.gc.G1=true means:
|
|
|
|
* VM supports G1
|
|
|
|
* User either set G1 explicitely (-XX:+UseG1GC) or did not set any GC
|
2020-07-10 18:52:35 +00:00
|
|
|
* G1 can be selected, i.e. it doesn't conflict with other VM flags
|
2019-02-22 22:39:57 +00:00
|
|
|
*
|
2016-06-21 14:36:37 +00:00
|
|
|
* @param map - property-value pairs
|
|
|
|
*/
|
2019-02-22 22:39:57 +00:00
|
|
|
protected void vmGC(SafeMap map) {
|
2020-12-03 13:42:50 +00:00
|
|
|
var isJVMCIEnabled = Compiler.isJVMCIEnabled();
|
2023-06-20 10:08:13 +00:00
|
|
|
Predicate<GC> vmGCProperty = (GC gc) -> (gc.isSupported()
|
|
|
|
&& (!isJVMCIEnabled || gc.isSupportedByJVMCICompiler())
|
|
|
|
&& (gc.isSelected() || GC.isSelectedErgonomically()));
|
2016-06-21 14:36:37 +00:00
|
|
|
for (GC gc: GC.values()) {
|
2023-06-20 10:08:13 +00:00
|
|
|
map.put("vm.gc." + gc.name(), () -> "" + vmGCProperty.test(gc));
|
2016-06-21 14:36:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-01 16:50:11 +00:00
|
|
|
/**
|
|
|
|
* "jtreg -vmoptions:-Dtest.cds.runtime.options=..." can be used to specify
|
|
|
|
* the GC type to be used when running with a CDS archive. Set "vm.gc" accordingly,
|
|
|
|
* so that tests that need to explicitly choose the GC type can be excluded
|
|
|
|
* with "@requires vm.gc == null".
|
|
|
|
*
|
|
|
|
* @param map - property-value pairs
|
|
|
|
*/
|
|
|
|
protected void vmGCforCDS(SafeMap map) {
|
|
|
|
if (!GC.isSelectedErgonomically()) {
|
|
|
|
// The GC has been explicitly specified on the command line, so
|
|
|
|
// jtreg will set the "vm.gc" property. Let's not interfere with it.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
String jtropts = System.getProperty("test.cds.runtime.options");
|
|
|
|
if (jtropts != null) {
|
|
|
|
for (String opt : jtropts.split(",")) {
|
|
|
|
if (opt.startsWith(GC_PREFIX) && opt.endsWith(GC_SUFFIX)) {
|
|
|
|
String gc = opt.substring(GC_PREFIX.length(), opt.length() - GC_SUFFIX.length());
|
|
|
|
map.put("vm.gc", () -> gc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-31 08:41:36 +00:00
|
|
|
/**
|
|
|
|
* Selected final flag.
|
2019-02-22 22:39:57 +00:00
|
|
|
*
|
2018-05-31 08:41:36 +00:00
|
|
|
* @param map - property-value pairs
|
|
|
|
* @param flagName - flag name
|
|
|
|
*/
|
2019-02-22 22:39:57 +00:00
|
|
|
private void vmOptFinalFlag(SafeMap map, String flagName) {
|
|
|
|
map.put("vm.opt.final." + flagName,
|
|
|
|
() -> String.valueOf(WB.getBooleanVMFlag(flagName)));
|
2018-05-31 08:41:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Selected sets of final flags.
|
2019-02-22 22:39:57 +00:00
|
|
|
*
|
2018-06-29 00:07:34 +00:00
|
|
|
* @param map - property-value pairs
|
2018-05-31 08:41:36 +00:00
|
|
|
*/
|
2019-02-22 22:39:57 +00:00
|
|
|
protected void vmOptFinalFlags(SafeMap map) {
|
2018-05-31 08:41:36 +00:00
|
|
|
vmOptFinalFlag(map, "ClassUnloading");
|
2019-10-09 06:09:12 +00:00
|
|
|
vmOptFinalFlag(map, "ClassUnloadingWithConcurrentMark");
|
2023-05-11 13:59:37 +00:00
|
|
|
vmOptFinalFlag(map, "CriticalJNINatives");
|
2018-06-29 00:07:34 +00:00
|
|
|
vmOptFinalFlag(map, "EnableJVMCI");
|
2018-01-31 00:48:53 +00:00
|
|
|
vmOptFinalFlag(map, "EliminateAllocations");
|
2024-10-04 09:01:41 +00:00
|
|
|
vmOptFinalFlag(map, "UnlockExperimentalVMOptions");
|
2023-05-11 13:59:37 +00:00
|
|
|
vmOptFinalFlag(map, "UseCompressedOops");
|
2024-09-24 05:35:12 +00:00
|
|
|
vmOptFinalFlag(map, "UseLargePages");
|
2024-11-21 09:54:25 +00:00
|
|
|
vmOptFinalFlag(map, "UseTransparentHugePages");
|
2023-05-11 13:59:37 +00:00
|
|
|
vmOptFinalFlag(map, "UseVectorizedMismatchIntrinsic");
|
2018-05-31 08:41:36 +00:00
|
|
|
}
|
|
|
|
|
2018-06-25 21:04:21 +00:00
|
|
|
/**
|
|
|
|
* @return "true" if VM has a serviceability agent.
|
|
|
|
*/
|
|
|
|
protected String vmHasSA() {
|
|
|
|
return "" + Platform.hasSA();
|
|
|
|
}
|
|
|
|
|
2018-07-20 07:46:57 +00:00
|
|
|
/**
|
|
|
|
* @return "true" if the VM is compiled with Java Flight Recorder (JFR)
|
|
|
|
* support.
|
|
|
|
*/
|
|
|
|
protected String vmHasJFR() {
|
2021-05-12 23:14:30 +00:00
|
|
|
return "" + WB.isJFRIncluded();
|
2018-07-20 07:46:57 +00:00
|
|
|
}
|
|
|
|
|
2020-08-21 22:49:09 +00:00
|
|
|
/**
|
|
|
|
* @return "true" if the VM is compiled with JVMTI
|
|
|
|
*/
|
|
|
|
protected String vmHasJVMTI() {
|
|
|
|
return "" + WB.isJVMTIIncluded();
|
2022-02-16 20:08:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return "true" if the VM is compiled with DTrace
|
|
|
|
*/
|
|
|
|
protected String vmHasDTrace() {
|
|
|
|
return "" + WB.isDTraceIncluded();
|
2020-08-21 22:49:09 +00:00
|
|
|
}
|
|
|
|
|
2017-06-02 00:34:34 +00:00
|
|
|
/**
|
2024-03-20 19:59:13 +00:00
|
|
|
* @return "true" if compiler in use supports RTM and "false" otherwise.
|
|
|
|
* Note: Lightweight locking does not support RTM (for now).
|
2017-06-02 00:34:34 +00:00
|
|
|
*/
|
2018-09-14 19:32:22 +00:00
|
|
|
protected String vmRTMCompiler() {
|
|
|
|
boolean isRTMCompiler = false;
|
2017-06-02 00:34:34 +00:00
|
|
|
|
2018-09-14 19:32:22 +00:00
|
|
|
if (Compiler.isC2Enabled() &&
|
2024-03-20 19:59:13 +00:00
|
|
|
(Platform.isX86() || Platform.isX64() || Platform.isPPC()) &&
|
|
|
|
is_LM_LIGHTWEIGHT().equals("false")) {
|
2018-09-14 19:32:22 +00:00
|
|
|
isRTMCompiler = true;
|
2017-06-02 00:34:34 +00:00
|
|
|
}
|
2018-09-14 19:32:22 +00:00
|
|
|
return "" + isRTMCompiler;
|
2017-06-02 00:34:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if VM runs RTM supported CPU and false otherwise.
|
|
|
|
*/
|
|
|
|
protected String vmRTMCPU() {
|
2018-05-21 17:23:55 +00:00
|
|
|
return "" + CPUInfo.hasFeature("rtm");
|
2017-06-02 00:34:34 +00:00
|
|
|
}
|
|
|
|
|
2017-08-01 14:03:06 +00:00
|
|
|
/**
|
|
|
|
* Check for CDS support.
|
|
|
|
*
|
|
|
|
* @return true if CDS is supported by the VM to be tested.
|
|
|
|
*/
|
|
|
|
protected String vmCDS() {
|
2021-05-12 23:14:30 +00:00
|
|
|
return "" + WB.isCDSIncluded();
|
2017-08-01 14:03:06 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 17:47:04 +00:00
|
|
|
/**
|
|
|
|
* Check for CDS support for custom loaders.
|
|
|
|
*
|
2018-02-15 19:39:42 +00:00
|
|
|
* @return true if CDS provides support for customer loader in the VM to be tested.
|
2017-11-28 17:47:04 +00:00
|
|
|
*/
|
|
|
|
protected String vmCDSForCustomLoaders() {
|
2019-02-22 22:39:57 +00:00
|
|
|
return "" + ("true".equals(vmCDS()) && Platform.areCustomLoadersSupportedForCDS());
|
2017-11-28 17:47:04 +00:00
|
|
|
}
|
|
|
|
|
2018-02-15 19:39:42 +00:00
|
|
|
/**
|
2021-09-10 22:45:26 +00:00
|
|
|
* @return true if this VM can write Java heap objects into the CDS archive
|
2018-02-15 19:39:42 +00:00
|
|
|
*/
|
2021-09-10 22:45:26 +00:00
|
|
|
protected String vmCDSCanWriteArchivedJavaHeap() {
|
2024-05-24 16:07:36 +00:00
|
|
|
return "" + ("true".equals(vmCDS()) && WB.canWriteJavaHeapArchive()
|
|
|
|
&& isCDSRuntimeOptionsCompatible());
|
|
|
|
}
|
|
|
|
|
2024-11-15 22:28:54 +00:00
|
|
|
/**
|
|
|
|
* @return true if this VM can support the -XX:AOTClassLinking option
|
|
|
|
*/
|
|
|
|
protected String vmCDSSupportsAOTClassLinking() {
|
|
|
|
// Currently, the VM supports AOTClassLinking as long as it's able to write archived java heap.
|
|
|
|
return vmCDSCanWriteArchivedJavaHeap();
|
|
|
|
}
|
|
|
|
|
2024-05-24 16:07:36 +00:00
|
|
|
/**
|
|
|
|
* @return true if the VM options specified via the "test.cds.runtime.options"
|
|
|
|
* property is compatible with writing Java heap objects into the CDS archive
|
|
|
|
*/
|
|
|
|
protected boolean isCDSRuntimeOptionsCompatible() {
|
|
|
|
String jtropts = System.getProperty("test.cds.runtime.options");
|
|
|
|
if (jtropts == null) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
String CCP_DISABLED = "-XX:-UseCompressedClassPointers";
|
|
|
|
String G1GC_ENABLED = "-XX:+UseG1GC";
|
2024-10-04 16:20:01 +00:00
|
|
|
String PARALLELGC_ENABLED = "-XX:+UseParallelGC";
|
|
|
|
String SERIALGC_ENABLED = "-XX:+UseSerialGC";
|
2024-05-24 16:07:36 +00:00
|
|
|
for (String opt : jtropts.split(",")) {
|
|
|
|
if (opt.equals(CCP_DISABLED)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (opt.startsWith(GC_PREFIX) && opt.endsWith(GC_SUFFIX) &&
|
2024-10-04 16:20:01 +00:00
|
|
|
!opt.equals(G1GC_ENABLED) && !opt.equals(PARALLELGC_ENABLED) && !opt.equals(SERIALGC_ENABLED)) {
|
2024-05-24 16:07:36 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
2018-02-15 19:39:42 +00:00
|
|
|
}
|
|
|
|
|
2022-06-02 09:02:37 +00:00
|
|
|
/**
|
|
|
|
* @return "true" if this VM supports continuations.
|
|
|
|
*/
|
|
|
|
protected String vmContinuations() {
|
|
|
|
if (WB.getBooleanVMFlag("VMContinuations")) {
|
|
|
|
return "true";
|
|
|
|
} else {
|
|
|
|
return "false";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-26 03:28:10 +00:00
|
|
|
/**
|
|
|
|
* @return System page size in bytes.
|
|
|
|
*/
|
|
|
|
protected String vmPageSize() {
|
|
|
|
return "" + WB.getVMPageSize();
|
|
|
|
}
|
|
|
|
|
2024-03-20 19:59:13 +00:00
|
|
|
/**
|
|
|
|
* @return LockingMode.
|
|
|
|
*/
|
|
|
|
protected String vmLockingMode() {
|
|
|
|
return "" + WB.getIntVMFlag("LockingMode");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return "true" if LockingMode == 0 (LM_MONITOR)
|
|
|
|
*/
|
|
|
|
protected String is_LM_MONITOR() {
|
|
|
|
return "" + vmLockingMode().equals("0");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return "true" if LockingMode == 1 (LM_LEGACY)
|
|
|
|
*/
|
|
|
|
protected String is_LM_LEGACY() {
|
|
|
|
return "" + vmLockingMode().equals("1");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return "true" if LockingMode == 2 (LM_LIGHTWEIGHT)
|
|
|
|
*/
|
|
|
|
protected String is_LM_LIGHTWEIGHT() {
|
|
|
|
return "" + vmLockingMode().equals("2");
|
|
|
|
}
|
|
|
|
|
2017-10-02 21:31:34 +00:00
|
|
|
/**
|
|
|
|
* Check if Graal is used as JIT compiler.
|
|
|
|
*
|
|
|
|
* @return true if Graal is used as JIT compiler.
|
|
|
|
*/
|
|
|
|
protected String isGraalEnabled() {
|
2019-02-22 22:39:57 +00:00
|
|
|
return "" + Compiler.isGraalEnabled();
|
2017-10-02 21:31:34 +00:00
|
|
|
}
|
|
|
|
|
2023-07-14 14:10:10 +00:00
|
|
|
/**
|
|
|
|
* Check if the libgraal shared library file is present.
|
|
|
|
*
|
|
|
|
* @return true if the libgraal shared library file is present.
|
|
|
|
*/
|
|
|
|
protected String hasLibgraal() {
|
|
|
|
return "" + WB.hasLibgraal();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if libgraal is used as JIT compiler.
|
|
|
|
*
|
|
|
|
* @return true if libgraal is used as JIT compiler.
|
|
|
|
*/
|
2024-09-26 21:38:08 +00:00
|
|
|
protected String isLibgraalJIT() {
|
|
|
|
return "" + Compiler.isLibgraalJIT();
|
2023-07-14 14:10:10 +00:00
|
|
|
}
|
|
|
|
|
2018-08-09 01:38:34 +00:00
|
|
|
/**
|
|
|
|
* Check if Compiler1 is present.
|
|
|
|
*
|
|
|
|
* @return true if Compiler1 is used as JIT compiler, either alone or as part of the tiered system.
|
|
|
|
*/
|
|
|
|
protected String isCompiler1Enabled() {
|
2019-02-22 22:39:57 +00:00
|
|
|
return "" + Compiler.isC1Enabled();
|
2018-08-09 01:38:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if Compiler2 is present.
|
|
|
|
*
|
|
|
|
* @return true if Compiler2 is used as JIT compiler, either alone or as part of the tiered system.
|
|
|
|
*/
|
|
|
|
protected String isCompiler2Enabled() {
|
2019-02-22 22:39:57 +00:00
|
|
|
return "" + Compiler.isC2Enabled();
|
2018-08-09 01:38:34 +00:00
|
|
|
}
|
2017-10-11 02:18:36 +00:00
|
|
|
|
2023-05-02 13:56:32 +00:00
|
|
|
/**
|
2024-10-12 03:25:42 +00:00
|
|
|
* A simple check for container support
|
2017-10-11 02:18:36 +00:00
|
|
|
*
|
2024-10-12 03:25:42 +00:00
|
|
|
* @return true if container is supported in a given environment
|
2017-10-11 02:18:36 +00:00
|
|
|
*/
|
2024-10-12 03:25:42 +00:00
|
|
|
protected String containerSupport() {
|
|
|
|
log("Entering containerSupport()");
|
2023-02-17 19:37:02 +00:00
|
|
|
|
2018-03-03 10:15:23 +00:00
|
|
|
boolean isSupported = false;
|
|
|
|
if (Platform.isLinux()) {
|
2024-10-12 03:25:42 +00:00
|
|
|
// currently container testing is only supported for Linux,
|
2018-03-03 10:15:23 +00:00
|
|
|
// on certain platforms
|
|
|
|
|
|
|
|
String arch = System.getProperty("os.arch");
|
|
|
|
|
|
|
|
if (Platform.isX64()) {
|
|
|
|
isSupported = true;
|
2019-02-22 22:39:57 +00:00
|
|
|
} else if (Platform.isAArch64()) {
|
2018-03-03 10:15:23 +00:00
|
|
|
isSupported = true;
|
2019-02-22 22:39:57 +00:00
|
|
|
} else if (Platform.isS390x()) {
|
2018-03-03 10:15:23 +00:00
|
|
|
isSupported = true;
|
2019-02-22 22:39:57 +00:00
|
|
|
} else if (arch.equals("ppc64le")) {
|
2018-03-03 10:15:23 +00:00
|
|
|
isSupported = true;
|
|
|
|
}
|
2018-02-07 15:16:50 +00:00
|
|
|
}
|
2017-10-11 02:18:36 +00:00
|
|
|
|
2024-10-12 03:25:42 +00:00
|
|
|
log("containerSupport(): platform check: isSupported = " + isSupported);
|
2023-02-17 19:37:02 +00:00
|
|
|
|
2018-03-03 10:15:23 +00:00
|
|
|
if (isSupported) {
|
|
|
|
try {
|
2024-10-12 03:25:42 +00:00
|
|
|
isSupported = checkProgramSupport("checkContainerSupport()", Container.ENGINE_COMMAND);
|
2018-03-03 10:15:23 +00:00
|
|
|
} catch (Exception e) {
|
|
|
|
isSupported = false;
|
|
|
|
}
|
|
|
|
}
|
2017-10-11 02:18:36 +00:00
|
|
|
|
2024-10-12 03:25:42 +00:00
|
|
|
log("containerSupport(): returning isSupported = " + isSupported);
|
2019-02-22 22:39:57 +00:00
|
|
|
return "" + isSupported;
|
2017-10-11 02:18:36 +00:00
|
|
|
}
|
|
|
|
|
2024-09-11 16:57:13 +00:00
|
|
|
/**
|
|
|
|
* A simple check for systemd support
|
|
|
|
*
|
|
|
|
* @return true if systemd is supported in a given environment
|
|
|
|
*/
|
|
|
|
protected String systemdSupport() {
|
|
|
|
log("Entering systemdSupport()");
|
|
|
|
|
|
|
|
boolean isSupported = Platform.isLinux();
|
|
|
|
if (isSupported) {
|
|
|
|
try {
|
|
|
|
isSupported = checkProgramSupport("checkSystemdSupport()", "systemd-run");
|
|
|
|
} catch (Exception e) {
|
|
|
|
isSupported = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
log("systemdSupport(): returning isSupported = " + isSupported);
|
|
|
|
return "" + isSupported;
|
|
|
|
}
|
|
|
|
|
2023-02-17 19:37:02 +00:00
|
|
|
// Configures process builder to redirect process stdout and stderr to a file.
|
|
|
|
// Returns file names for stdout and stderr.
|
|
|
|
private Map<String, String> redirectOutputToLogFile(String msg, ProcessBuilder pb, String fileNameBase) {
|
|
|
|
Map<String, String> result = new HashMap<>();
|
|
|
|
String timeStamp = Instant.now().toString().replace(":", "-").replace(".", "-");
|
|
|
|
|
|
|
|
String stdoutFileName = String.format("./%s-stdout--%s.log", fileNameBase, timeStamp);
|
|
|
|
pb.redirectOutput(new File(stdoutFileName));
|
|
|
|
log(msg + ": child process stdout redirected to " + stdoutFileName);
|
|
|
|
result.put("stdout", stdoutFileName);
|
|
|
|
|
|
|
|
String stderrFileName = String.format("./%s-stderr--%s.log", fileNameBase, timeStamp);
|
|
|
|
pb.redirectError(new File(stderrFileName));
|
|
|
|
log(msg + ": child process stderr redirected to " + stderrFileName);
|
|
|
|
result.put("stderr", stderrFileName);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void printLogfileContent(Map<String, String> logFileNames) {
|
|
|
|
logFileNames.entrySet().stream()
|
|
|
|
.forEach(entry ->
|
|
|
|
{
|
|
|
|
log("------------- " + entry.getKey());
|
|
|
|
try {
|
|
|
|
Files.lines(Path.of(entry.getValue()))
|
|
|
|
.forEach(line -> log(line));
|
|
|
|
} catch (IOException ie) {
|
|
|
|
log("Exception while reading file: " + ie);
|
|
|
|
}
|
|
|
|
log("-------------");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-09-11 16:57:13 +00:00
|
|
|
private boolean checkProgramSupport(String logString, String cmd) throws IOException, InterruptedException {
|
|
|
|
log(logString + ": entering");
|
|
|
|
ProcessBuilder pb = new ProcessBuilder("which", cmd);
|
2023-10-12 16:29:14 +00:00
|
|
|
Map<String, String> logFileNames =
|
2024-09-11 16:57:13 +00:00
|
|
|
redirectOutputToLogFile(logString + ": which " + cmd,
|
|
|
|
pb, "which-cmd");
|
2017-10-11 02:18:36 +00:00
|
|
|
Process p = pb.start();
|
|
|
|
p.waitFor(10, TimeUnit.SECONDS);
|
2023-02-17 19:37:02 +00:00
|
|
|
int exitValue = p.exitValue();
|
|
|
|
|
2024-09-11 16:57:13 +00:00
|
|
|
log(String.format("%s: exitValue = %s, pid = %s", logString, exitValue, p.pid()));
|
2023-02-17 19:37:02 +00:00
|
|
|
if (exitValue != 0) {
|
|
|
|
printLogfileContent(logFileNames);
|
|
|
|
}
|
2017-10-11 02:18:36 +00:00
|
|
|
|
2023-02-17 19:37:02 +00:00
|
|
|
return (exitValue == 0);
|
2017-10-11 02:18:36 +00:00
|
|
|
}
|
|
|
|
|
2020-10-13 09:35:58 +00:00
|
|
|
/**
|
|
|
|
* Checks musl libc.
|
|
|
|
*
|
|
|
|
* @return true if musl libc is used.
|
|
|
|
*/
|
|
|
|
protected String isMusl() {
|
|
|
|
return Boolean.toString(WB.getLibcName().contains("musl"));
|
|
|
|
}
|
|
|
|
|
2018-06-15 16:53:28 +00:00
|
|
|
private String implementor() {
|
|
|
|
try (InputStream in = new BufferedInputStream(new FileInputStream(
|
|
|
|
System.getProperty("java.home") + "/release"))) {
|
|
|
|
Properties properties = new Properties();
|
|
|
|
properties.load(in);
|
2018-07-24 15:58:32 +00:00
|
|
|
String implementorProperty = properties.getProperty("IMPLEMENTOR");
|
2019-02-22 22:39:57 +00:00
|
|
|
if (implementorProperty != null) {
|
|
|
|
return implementorProperty.replace("\"", "");
|
|
|
|
}
|
|
|
|
return errorWithMessage("Can't get 'IMPLEMENTOR' property from 'release' file");
|
2018-06-15 16:53:28 +00:00
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
2019-02-22 22:39:57 +00:00
|
|
|
return errorWithMessage("Failed to read 'release' file " + e);
|
2018-06-15 16:53:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-26 20:30:37 +00:00
|
|
|
private String jdkContainerized() {
|
|
|
|
String isEnabled = System.getenv("TEST_JDK_CONTAINERIZED");
|
|
|
|
return "" + "true".equalsIgnoreCase(isEnabled);
|
|
|
|
}
|
|
|
|
|
2024-11-11 13:35:25 +00:00
|
|
|
private String packagedModules() {
|
|
|
|
// Some jlink tests require packaged modules being present (jmods).
|
|
|
|
// For a runtime linkable image build packaged modules aren't present
|
|
|
|
try {
|
|
|
|
Path jmodsDir = Path.of(System.getProperty("java.home"), "jmods");
|
|
|
|
if (jmodsDir.toFile().exists()) {
|
|
|
|
return Boolean.TRUE.toString();
|
|
|
|
} else {
|
|
|
|
return Boolean.FALSE.toString();
|
|
|
|
}
|
|
|
|
} catch (Throwable t) {
|
|
|
|
return Boolean.FALSE.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-18 15:34:58 +00:00
|
|
|
/**
|
|
|
|
* Checks if we are in <i>almost</i> out-of-box configuration, i.e. the flags
|
|
|
|
* which JVM is started with don't affect its behavior "significantly".
|
|
|
|
* {@code TEST_VM_FLAGLESS} enviroment variable can be used to force this
|
2024-02-23 19:58:38 +00:00
|
|
|
* method to return true or false and allow or reject any flags.
|
2021-03-18 15:34:58 +00:00
|
|
|
*
|
|
|
|
* @return true if there are no JVM flags
|
|
|
|
*/
|
|
|
|
private String isFlagless() {
|
|
|
|
boolean result = true;
|
2024-02-23 19:58:38 +00:00
|
|
|
String flagless = System.getenv("TEST_VM_FLAGLESS");
|
|
|
|
if (flagless != null) {
|
|
|
|
return "" + "true".equalsIgnoreCase(flagless);
|
2021-03-18 15:34:58 +00:00
|
|
|
}
|
|
|
|
|
2023-10-17 09:22:03 +00:00
|
|
|
List<String> allFlags = allFlags().toList();
|
2021-03-18 15:34:58 +00:00
|
|
|
|
|
|
|
// check -XX flags
|
|
|
|
var ignoredXXFlags = Set.of(
|
|
|
|
// added by run-test framework
|
|
|
|
"MaxRAMPercentage",
|
|
|
|
// added by test environment
|
|
|
|
"CreateCoredumpOnCrash"
|
|
|
|
);
|
|
|
|
result &= allFlags.stream()
|
|
|
|
.filter(s -> s.startsWith("-XX:"))
|
|
|
|
// map to names:
|
|
|
|
// remove -XX:
|
|
|
|
.map(s -> s.substring(4))
|
|
|
|
// remove +/- from bool flags
|
|
|
|
.map(s -> s.charAt(0) == '+' || s.charAt(0) == '-' ? s.substring(1) : s)
|
|
|
|
// remove =.* from others
|
|
|
|
.map(s -> s.contains("=") ? s.substring(0, s.indexOf('=')) : s)
|
|
|
|
// skip known-to-be-there flags
|
|
|
|
.filter(s -> !ignoredXXFlags.contains(s))
|
|
|
|
.findAny()
|
|
|
|
.isEmpty();
|
|
|
|
|
|
|
|
// check -X flags
|
|
|
|
var ignoredXFlags = Set.of(
|
|
|
|
// default, yet still seen to be explicitly set
|
2023-09-28 17:15:40 +00:00
|
|
|
"mixed",
|
|
|
|
// -XmxmNNNm added by run-test framework for non-hotspot tests
|
|
|
|
"mx"
|
2021-03-18 15:34:58 +00:00
|
|
|
);
|
|
|
|
result &= allFlags.stream()
|
|
|
|
.filter(s -> s.startsWith("-X") && !s.startsWith("-XX:"))
|
|
|
|
// map to names:
|
2023-09-28 17:15:40 +00:00
|
|
|
// remove -X
|
|
|
|
.map(s -> s.substring(2))
|
|
|
|
// remove :.* from flags with values
|
|
|
|
.map(s -> s.contains(":") ? s.substring(0, s.indexOf(':')) : s)
|
|
|
|
// remove size like 4G, 768m which might be set for non-hotspot tests
|
|
|
|
.map(s -> s.replaceAll("(\\d+)[mMgGkK]", ""))
|
2021-03-18 15:34:58 +00:00
|
|
|
// skip known-to-be-there flags
|
|
|
|
.filter(s -> !ignoredXFlags.contains(s))
|
|
|
|
.findAny()
|
|
|
|
.isEmpty();
|
|
|
|
|
|
|
|
return "" + result;
|
|
|
|
}
|
|
|
|
|
2023-10-17 09:22:03 +00:00
|
|
|
private Stream<String> allFlags() {
|
|
|
|
return Stream.of((System.getProperty("test.vm.opts", "") + " " + System.getProperty("test.java.opts", "")).trim().split("\\s+"));
|
|
|
|
}
|
|
|
|
|
2023-05-02 13:56:32 +00:00
|
|
|
/*
|
|
|
|
* A string indicating the foreign linker that is currently being used. See jdk.internal.foreign.CABI
|
|
|
|
* for valid values.
|
|
|
|
*
|
|
|
|
* "FALLBACK" and "UNSUPPORTED" are special values. The former indicates the fallback linker is
|
|
|
|
* being used. The latter indicates an unsupported platform.
|
|
|
|
*/
|
|
|
|
private String jdkForeignLinker() {
|
|
|
|
return String.valueOf(CABI.current());
|
|
|
|
}
|
|
|
|
|
2016-04-07 13:43:35 +00:00
|
|
|
/**
|
|
|
|
* Dumps the map to the file if the file name is given as the property.
|
|
|
|
* This functionality could be helpful to know context in the real
|
|
|
|
* execution.
|
|
|
|
*
|
|
|
|
* @param map
|
|
|
|
*/
|
2016-11-23 09:25:21 +00:00
|
|
|
protected static void dump(Map<String, String> map) {
|
2016-04-07 13:43:35 +00:00
|
|
|
String dumpFileName = System.getProperty("vmprops.dump");
|
|
|
|
if (dumpFileName == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
List<String> lines = new ArrayList<>();
|
2016-06-17 15:45:24 +00:00
|
|
|
map.forEach((k, v) -> lines.add(k + ":" + v));
|
2023-07-14 14:10:10 +00:00
|
|
|
Collections.sort(lines);
|
2016-04-07 13:43:35 +00:00
|
|
|
try {
|
2019-02-22 22:39:57 +00:00
|
|
|
Files.write(Paths.get(dumpFileName), lines,
|
|
|
|
StandardOpenOption.APPEND, StandardOpenOption.CREATE);
|
2016-04-07 13:43:35 +00:00
|
|
|
} catch (IOException e) {
|
|
|
|
throw new RuntimeException("Failed to dump properties into '"
|
|
|
|
+ dumpFileName + "'", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-17 19:37:02 +00:00
|
|
|
/**
|
|
|
|
* Log diagnostic message.
|
|
|
|
*
|
|
|
|
* @param msg
|
|
|
|
*/
|
|
|
|
protected static void log(String msg) {
|
|
|
|
// Always log to a file.
|
|
|
|
logToFile(msg);
|
|
|
|
|
|
|
|
// Also log to stderr; guarded by property to avoid excessive verbosity.
|
|
|
|
// By jtreg design stderr produced here will be visible
|
|
|
|
// in the output of a parent process. Note: stdout should not be used
|
|
|
|
// for logging as jtreg parses that output directly and only echoes it
|
|
|
|
// in the event of a failure.
|
|
|
|
if (Boolean.getBoolean("jtreg.log.vmprops")) {
|
|
|
|
System.err.println("VMProps: " + msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Log diagnostic message to a file.
|
|
|
|
*
|
|
|
|
* @param msg
|
|
|
|
*/
|
|
|
|
protected static void logToFile(String msg) {
|
|
|
|
String fileName = "./vmprops.log";
|
|
|
|
try {
|
|
|
|
Files.writeString(Paths.get(fileName), msg + "\n", Charset.forName("ISO-8859-1"),
|
|
|
|
StandardOpenOption.APPEND, StandardOpenOption.CREATE);
|
|
|
|
} catch (IOException e) {
|
|
|
|
throw new RuntimeException("Failed to log into '" + fileName + "'", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-07 13:43:35 +00:00
|
|
|
/**
|
|
|
|
* This method is for the testing purpose only.
|
2019-02-22 22:39:57 +00:00
|
|
|
*
|
2016-04-07 13:43:35 +00:00
|
|
|
* @param args
|
|
|
|
*/
|
|
|
|
public static void main(String args[]) {
|
|
|
|
Map<String, String> map = new VMProps().call();
|
2016-06-17 15:45:24 +00:00
|
|
|
map.forEach((k, v) -> System.out.println(k + ": '" + v + "'"));
|
2016-04-07 13:43:35 +00:00
|
|
|
}
|
|
|
|
}
|