8373297: Test com/sun/jdi/AfterThreadDeathTest.java failed with unexpected ObjectCollectedException

Reviewed-by: kevinw, sspitsyn, amenkov, lmesnik
This commit is contained in:
Chris Plummer 2025-12-15 19:50:46 +00:00
parent ad29642d8f
commit 45ee89c4c8

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 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
@ -93,6 +93,7 @@ public class AfterThreadDeathTest extends TestScaffold {
println("Ok; got expected IllegalThreadStateException");
return;
} catch (Exception ee) {
ee.printStackTrace(System.err);
failure("FAILED: Did not get expected"
+ " IllegalThreadStateException"
+ " on a StepRequest.enable(). \n"
@ -133,6 +134,13 @@ public class AfterThreadDeathTest extends TestScaffold {
mainThread = bpe.thread();
erm = vm().eventRequestManager();
/*
* The "main" thread will be referenced during the ThreadDeathEvent, which
* uses SUSPEND_NONE, so the thread might get gc'd and cause an unexpected
* ObjectCollectedException. Disable it from collection to prevent problems.
*/
mainThread.disableCollection();
/*
* Set event requests
*/