Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions jcstress-core/src/main/java/org/openjdk/jcstress/JCStress.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.io.*;
import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

/**
* JCStress main entry point.
Expand Down Expand Up @@ -237,15 +238,46 @@ private void forkedUnified(List<TestConfig> testConfigs, VMSupport.Config config
public SortedSet<String> getTests() {
String filter = opts.getTestFilter();
SortedSet<String> s = new TreeSet<>();

Pattern byteArrayAndBufferExclusion = null;
if (VMSupport.getJdkVersionMajor() > 22) {
String regexPrefix = "org.openjdk.jcstress.tests".replace(".", "\\.");
String[] members = new String[]{
"accessAtomic.varHandles.byteArray",
"accessAtomic.varHandles.byteBuffer",
"acqrel.varHandles.byteArray",
"acqrel.vHandles.byteBuffer",
"atomicity.varHandles.byteArray",
"atomicity.varHandles.byteBuffer",
"coherence.varHandles.byteArray",
"coherence.varHandles.byteBuffer"};
String regexBody = "(" + Arrays.stream(members).map(ss -> ss.replace(".", "\\.")).collect(Collectors.joining("|")) + ")";
String regexSuffix = "(big|heap|little).*";
byteArrayAndBufferExclusion = Pattern.compile(regexPrefix + "\\." + regexBody + "\\." + regexSuffix);
}
Pattern pattern = Pattern.compile(filter);
int excludedBuffersAndArrays = 0;
for (String testName : TestList.tests()) {
if (pattern.matcher(testName).find()) {
s.add(testName);
if (byteArrayAndBufferExclusion != null && byteArrayAndBufferExclusion.matcher(testName).find()) {
excludedBuffersAndArrays++;
} else {
s.add(testName);
}
}
}
if (excludedBuffersAndArrays > 0) {
out.println();
out.println("Warning! JDK 23 or newer detected and " + excludedBuffersAndArrays + " of selected " + (s.size() + excludedBuffersAndArrays) + " (from total " + TestList.tests().size() + ") tests were excluded by:");
out.println(byteArrayAndBufferExclusion.toString().replaceAll("\\\\", ""));
out.println("This is known bug: https://bugs.openjdk.org/browse/CODETOOLS-7903671");
out.println("This is temporarily workaround and issue should be fixed soon.");
if (s.isEmpty()) {
out.println("Warning! Nothing remained!");
}
out.println();
}
return s;
}
}

public int listTests(Options opts) {
JCStress.ConfigsWithScheduler configsWithScheduler = getConfigs();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2014, 2015, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
package org.openjdk.jcstress.vm;

public class TargetJvmVersion {

/**
* The "return" message is parsed ond colon and brackets.
*
* @param args
*/
public static void main(String... args) {
try {
Runtime.Version version = Runtime.version();
System.out.println("Detected: " + version.feature() + " (" + version + ")");
} catch (Throwable ex) {
System.out.println("Runtime.Version not found, fallback to: 8 (" + System.getProperty("java.version", "unknown)") + ")");
System.exit(0);
}
}

}
49 changes: 46 additions & 3 deletions jcstress-core/src/main/java/org/openjdk/jcstress/vm/VMSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@

public class VMSupport {

private static class ResultWithMessage {
private final boolean result;
private final String message;

public ResultWithMessage(boolean result, String message) {
this.result = result;
this.message = message;
}
}

private static final List<String> GLOBAL_JVM_FLAGS = new ArrayList<>();
private static final List<String> C2_STRESS_JVM_FLAGS = new ArrayList<>();
private static final List<String> C2_ONLY_STRESS_JVM_FLAGS = new ArrayList<>();
Expand All @@ -50,6 +60,8 @@ public class VMSupport {
private static volatile boolean COMPILER_DIRECTIVES_AVAILABLE;
private static volatile boolean PRINT_ASSEMBLY_AVAILABLE;
private static volatile boolean STRESS_SEED_AVAILABLE;
private static volatile int JDK_VERSION_MAJOR;
private static volatile String JDK_VERSION_MAJOR_FULL = "undetected";

private static volatile boolean C1_AVAILABLE;
private static volatile boolean C2_AVAILABLE;
Expand Down Expand Up @@ -80,6 +92,10 @@ public static boolean c2Available() {
return C2_AVAILABLE;
}

public static int getJdkVersionMajor() {
return JDK_VERSION_MAJOR;
}

public static boolean enableNativeAccessAvailable() {
return ENABLE_NATIVE_ACCESS_AVAILABLE;
}
Expand All @@ -93,6 +109,14 @@ public static void initFlags(Options opts) {
System.out.println(" (all failures are non-fatal, but may affect testing accuracy)");
System.out.println();

ResultWithMessage futureJdkVersionMajor =
detectWithMessage("Checking JVM feature version",
true,
TargetJvmVersion.class,
null
);
setDetectedJdkVersion(futureJdkVersionMajor);

detect("Unlocking diagnostic VM options",
true,
SimpleTestMain.class,
Expand Down Expand Up @@ -383,21 +407,40 @@ public static void initFlags(Options opts) {
System.out.println();
}

private static void setDetectedJdkVersion(ResultWithMessage futureJdkVersionMajor) {
if (futureJdkVersionMajor.result && futureJdkVersionMajor.message!=null){
try {
JDK_VERSION_MAJOR = Integer.parseInt(futureJdkVersionMajor.message.replaceAll(".*: ", "").replaceAll(" .*", "").trim());
JDK_VERSION_MAJOR_FULL=futureJdkVersionMajor.message.replaceAll(".*\\(", "").replaceAll("\\).*", "").trim();
}catch(Exception ex){
JDK_VERSION_MAJOR = 8;
JDK_VERSION_MAJOR_FULL=futureJdkVersionMajor.message;
}
} else {
JDK_VERSION_MAJOR = 8;
}
}

private static boolean detect(String label, boolean expectPass, Class<?> mainClass, List<String> list, String... opts) {
return detectWithMessage(label, expectPass, mainClass, list, opts).result;
}

private static ResultWithMessage detectWithMessage(String label, boolean expectPass, Class<?> mainClass, List<String> list, String... opts) {
String msg = "Message not received";
try {
String[] arguments = ArrayUtils.concat(opts, mainClass.getName());
tryWith(arguments);
msg = tryWith(arguments);
if (list != null) {
list.addAll(Arrays.asList(opts));
}
System.out.printf("----- %s %s%n", "[OK]", label);
return true;
return new ResultWithMessage(true, msg);
} catch (VMSupportException ex) {
System.out.printf("----- %s %s%n", "[N/A]", label);
if (expectPass) {
System.out.println(ex.getMessage());
}
return false;
return new ResultWithMessage(false, msg);
}
}

Expand Down