8372555: Test com/sun/jdi/ExceptionEvents.java failed: ObjectCollectedException

Reviewed-by: amenkov, dholmes
This commit is contained in:
Chris Plummer 2025-12-08 15:38:35 +00:00
parent ed5fc9ad2d
commit ac81ce51fa

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
@ -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("<exception object collected>");
} else {
throw e;
}
}
Location loc = event.location();
System.out.print(" @ " + loc.method().name());
System.out.print(":" + loc.lineNumber());