Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/jdk.jdi/share/classes/com/sun/tools/jdi/EventSetImpl.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
Expand Down Expand Up @@ -37,6 +37,7 @@
import com.sun.jdi.Locatable;
import com.sun.jdi.Location;
import com.sun.jdi.Method;
import com.sun.jdi.ObjectCollectedException;
import com.sun.jdi.ObjectReference;
import com.sun.jdi.ReferenceType;
import com.sun.jdi.ThreadReference;
Expand Down Expand Up @@ -206,6 +207,19 @@ public String toString() {

}

/* Safely fetch the thread name in case there is an ObjectCollectedException.
* This can happen when dealing with SUSPEND_NONE events.
*/
private static String getThreadName(ThreadReference thread) {
String name;
try {
name = thread.name();
} catch (ObjectCollectedException oce) {
name = "<thread collected>";
}
return name;
}

abstract class ThreadedEventImpl extends EventImpl {
private ThreadReference thread;

Expand All @@ -220,7 +234,7 @@ public ThreadReference thread() {
}

public String toString() {
return eventName() + " in thread " + thread.name();
return eventName() + " in thread " + getThreadName(thread);
}
}

Expand Down Expand Up @@ -249,7 +263,7 @@ public Method method() {
public String toString() {
return eventName() + "@" +
((location() == null) ? " null" : location().toString()) +
" in thread " + thread().name();
" in thread " + getThreadName(thread());
}
}

Expand Down
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,6 @@ javax/swing/plaf/synth/7158712/bug7158712.java 8324782 macosx-all
# jdk_jdi

com/sun/jdi/InvokeHangTest.java 8218463 linux-all
com/sun/jdi/MethodInvokeWithTraceOnTest.java 8373022 generic-all

############################################################################

Expand Down