mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 01:19:28 +01:00
8370846: Support execution of mlvm testing with test thread factory
Reviewed-by: cjplummer
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 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
|
||||
@@ -28,6 +28,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import jdk.test.lib.thread.TestThreadFactory;
|
||||
import nsk.share.jdi.Binder;
|
||||
import nsk.share.jdi.Debugee;
|
||||
import vm.mlvm.share.Env;
|
||||
@@ -437,10 +438,22 @@ public abstract class JDIBreakpointTest extends MlvmTest {
|
||||
for (StackFrame f : frames) {
|
||||
Location l = f.location();
|
||||
|
||||
String sourcePath;
|
||||
try {
|
||||
sourcePath = l.sourcePath();
|
||||
} catch (AbsentInformationException aie) {
|
||||
// Test Thread Factory support has generated methods in MainWrapper class.
|
||||
if (TestThreadFactory.isTestThreadFactorySet()) {
|
||||
sourcePath = "unknown";
|
||||
} else {
|
||||
throw aie;
|
||||
}
|
||||
}
|
||||
|
||||
buf.append(String.format("#%-4d", frameNum))
|
||||
.append(l.method())
|
||||
.append("\n source: ")
|
||||
.append(l.sourcePath())
|
||||
.append(sourcePath)
|
||||
.append(":")
|
||||
.append(l.lineNumber())
|
||||
.append("; bci=")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 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
|
||||
@@ -32,8 +32,27 @@ import java.util.concurrent.ThreadFactory;
|
||||
|
||||
public class TestThreadFactory {
|
||||
|
||||
private static ThreadFactory threadFactory = "Virtual".equals(System.getProperty("test.thread.factory"))
|
||||
? virtualThreadFactory() : platformThreadFactory();
|
||||
public enum TestThreadFactoryType {
|
||||
NONE, VIRTUAL
|
||||
}
|
||||
|
||||
private final static TestThreadFactoryType testThreadFactoryType =
|
||||
"Virtual".equals(System.getProperty("test.thread.factory"))
|
||||
? TestThreadFactoryType.VIRTUAL
|
||||
: TestThreadFactoryType.NONE;
|
||||
|
||||
private final static ThreadFactory threadFactory =
|
||||
testThreadFactoryType == TestThreadFactoryType.VIRTUAL
|
||||
? virtualThreadFactory()
|
||||
: platformThreadFactory();
|
||||
|
||||
public static TestThreadFactoryType testThreadFactoryType() {
|
||||
return testThreadFactoryType;
|
||||
}
|
||||
|
||||
public static boolean isTestThreadFactorySet() {
|
||||
return !testThreadFactoryType.equals(TestThreadFactoryType.NONE);
|
||||
}
|
||||
|
||||
public static Thread newThread(Runnable task) {
|
||||
return threadFactory.newThread(task);
|
||||
|
||||
Reference in New Issue
Block a user