From ee3b39673432bafdff6b82fddcfcc8107ca31ffe Mon Sep 17 00:00:00 2001 From: amosshi Date: Wed, 13 Dec 2023 12:35:14 -0800 Subject: [PATCH 1/2] Backport 84184f947342fd1adbe4e3f2230ce3de4ae6007e --- test/jdk/ProblemList.txt | 2 ++ .../jdk/com/sun/jdi/AfterThreadDeathTest.java | 32 ++++++++++++------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 21e92d97058..6b5aea65b0a 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -782,6 +782,8 @@ com/sun/jdi/NashornPopFrameTest.java 8187143 generic- com/sun/jdi/InvokeHangTest.java 8218463 linux-all +com/sun/jdi/AfterThreadDeathTest.java 8232839 linux-all + ############################################################################ # jdk_time diff --git a/test/jdk/com/sun/jdi/AfterThreadDeathTest.java b/test/jdk/com/sun/jdi/AfterThreadDeathTest.java index 61435a64a61..27904021442 100644 --- a/test/jdk/com/sun/jdi/AfterThreadDeathTest.java +++ b/test/jdk/com/sun/jdi/AfterThreadDeathTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2023, 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 @@ -51,9 +51,9 @@ public static void main(String[] args){ public class AfterThreadDeathTest extends TestScaffold { ReferenceType targetClass; ThreadReference mainThread; - StepRequest stepRequest = null; EventRequestManager erm; - boolean mainIsDead; + volatile boolean mainIsDead = false; + volatile boolean gotExpectedThreadStart = false; AfterThreadDeathTest (String args[]) { super(args); @@ -68,20 +68,23 @@ public static void main(String[] args) throws Exception { public void threadStarted(ThreadStartEvent event) { println("Got ThreadStartEvent: " + event); - if (stepRequest != null) { - erm.deleteEventRequest(stepRequest); - stepRequest = null; - println("Deleted stepRequest"); + // We don't want to attempt the StepRequest.enable() until we recieve + // the ThreadStartEvent for the "DestroyJavaVM" thread. See JDK-8232839. + if (!event.thread().name().equals("DestroyJavaVM")) { + return; } + gotExpectedThreadStart = true; - if (mainIsDead) { + if (!mainIsDead) { + failure("FAILED: Got expected ThreadStartEvent before \"main\" ThreadDeathEvent"); + } else { // Here is the odd thing about this test; whatever thread this event // is for, we do a step on the mainThread. If the mainThread is // already dead, we should get the exception. Note that we don't // come here for the start of the main thread. - stepRequest = erm.createStepRequest(mainThread, - StepRequest.STEP_LINE, - StepRequest.STEP_OVER); + StepRequest stepRequest = erm.createStepRequest(mainThread, + StepRequest.STEP_LINE, + StepRequest.STEP_OVER); stepRequest.addCountFilter(1); stepRequest.setSuspendPolicy (EventRequest.SUSPEND_ALL); try { @@ -146,6 +149,13 @@ protected void runTests() throws Exception { */ listenUntilVMDisconnect(); + if (!gotExpectedThreadStart) { + failure("FAILED: never got expected ThreadStartEvent"); + } + if (!mainIsDead) { + failure("FAILED: never got ThreadDeathEvent for \"main\" thread"); + } + /* * deal with results of test * if anything has called failure("foo") testFailed will be true From 3e968da70345cf72c5b6bb78c74d30da042a3cf9 Mon Sep 17 00:00:00 2001 From: Amos Date: Mon, 18 Dec 2023 01:11:51 -0800 Subject: [PATCH 2/2] Fix ProblemList.txt --- test/jdk/ProblemList.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 6b5aea65b0a..21e92d97058 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -782,8 +782,6 @@ com/sun/jdi/NashornPopFrameTest.java 8187143 generic- com/sun/jdi/InvokeHangTest.java 8218463 linux-all -com/sun/jdi/AfterThreadDeathTest.java 8232839 linux-all - ############################################################################ # jdk_time