From ac81ce51fa4ed04b6dbcc28cb2dd8eabcfe52ad7 Mon Sep 17 00:00:00 2001 From: Chris Plummer Date: Mon, 8 Dec 2025 15:38:35 +0000 Subject: [PATCH] 8372555: Test com/sun/jdi/ExceptionEvents.java failed: ObjectCollectedException Reviewed-by: amenkov, dholmes --- test/jdk/com/sun/jdi/ExceptionEvents.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/jdk/com/sun/jdi/ExceptionEvents.java b/test/jdk/com/sun/jdi/ExceptionEvents.java index de5f51c4aa2..ee9e91b4dd9 100644 --- a/test/jdk/com/sun/jdi/ExceptionEvents.java +++ b/test/jdk/com/sun/jdi/ExceptionEvents.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 @@ -355,7 +355,16 @@ public class ExceptionEvents extends TestScaffold { if (event.request() == request) { try { System.out.print("ExceptionEvent: "); - System.out.print("" + event.exception().referenceType().name()); + try { + System.out.print("" + event.exception().referenceType().name()); + } catch (ObjectCollectedException e) { + if (event.request().suspendPolicy() == EventRequest.SUSPEND_NONE) { + // Since the thread was not suspended, the exception object can be collected. + System.out.print(""); + } else { + throw e; + } + } Location loc = event.location(); System.out.print(" @ " + loc.method().name()); System.out.print(":" + loc.lineNumber());