From 2596608ba1bb1b271dfa062bf732a5095e22fffd Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Fri, 5 Dec 2025 21:20:20 +0000 Subject: [PATCH] 8370846: Support execution of mlvm testing with test thread factory Reviewed-by: cjplummer --- .../vm/mlvm/share/jdi/JDIBreakpointTest.java | 17 +++++++++++-- .../test/lib/thread/TestThreadFactory.java | 25 ++++++++++++++++--- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/vm/mlvm/share/jdi/JDIBreakpointTest.java b/test/hotspot/jtreg/vmTestbase/vm/mlvm/share/jdi/JDIBreakpointTest.java index 29980ac2117..2b3f5a479b6 100644 --- a/test/hotspot/jtreg/vmTestbase/vm/mlvm/share/jdi/JDIBreakpointTest.java +++ b/test/hotspot/jtreg/vmTestbase/vm/mlvm/share/jdi/JDIBreakpointTest.java @@ -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=") diff --git a/test/lib/jdk/test/lib/thread/TestThreadFactory.java b/test/lib/jdk/test/lib/thread/TestThreadFactory.java index ac5a6b74909..043c96cf284 100644 --- a/test/lib/jdk/test/lib/thread/TestThreadFactory.java +++ b/test/lib/jdk/test/lib/thread/TestThreadFactory.java @@ -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);