Skip to content

Commit ac81ce5

Browse files
committed
8372555: Test com/sun/jdi/ExceptionEvents.java failed: ObjectCollectedException
Reviewed-by: amenkov, dholmes
1 parent ed5fc9a commit ac81ce5

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

test/jdk/com/sun/jdi/ExceptionEvents.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -355,7 +355,16 @@ public void exceptionThrown(ExceptionEvent event) {
355355
if (event.request() == request) {
356356
try {
357357
System.out.print("ExceptionEvent: ");
358-
System.out.print("" + event.exception().referenceType().name());
358+
try {
359+
System.out.print("" + event.exception().referenceType().name());
360+
} catch (ObjectCollectedException e) {
361+
if (event.request().suspendPolicy() == EventRequest.SUSPEND_NONE) {
362+
// Since the thread was not suspended, the exception object can be collected.
363+
System.out.print("<exception object collected>");
364+
} else {
365+
throw e;
366+
}
367+
}
359368
Location loc = event.location();
360369
System.out.print(" @ " + loc.method().name());
361370
System.out.print(":" + loc.lineNumber());

0 commit comments

Comments
 (0)