diff --git a/test/jdk/com/sun/jdi/AfterThreadDeathTest.java b/test/jdk/com/sun/jdi/AfterThreadDeathTest.java index 27904021442..25987de864c 100644 --- a/test/jdk/com/sun/jdi/AfterThreadDeathTest.java +++ b/test/jdk/com/sun/jdi/AfterThreadDeathTest.java @@ -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 */