Skip to content

Commit 851a4eb

Browse files
authored
Merge pull request #19343 from fengxue-IS/18859
Fix !vthreads command error with uninitialized Continuations
2 parents d9a1f14 + 8a599a2 commit 851a4eb

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/tools/ddrinteractive/VirtualThreadsCommand.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,16 @@ private static long getVmRef(J9ObjectPointer continuation) throws CorruptDataExc
6969
return J9ObjectHelper.getLongField(continuation, vmRefOffset);
7070
}
7171

72-
private static J9ObjectPointer getName(J9ObjectPointer vthread) throws CorruptDataException {
73-
if (nameOffset == null) {
74-
nameOffset = J9ObjectHelper.getFieldOffset(vthread, "name", "Ljava/lang/String;");
72+
private static String getName(J9ObjectPointer vthread) throws CorruptDataException {
73+
String name = null;
74+
if (vthread.notNull()) {
75+
if (nameOffset == null) {
76+
nameOffset = J9ObjectHelper.getFieldOffset(vthread, "name", "Ljava/lang/String;");
77+
}
78+
name = J9ObjectHelper.getStringField(vthread, nameOffset);
7579
}
76-
return J9ObjectHelper.getObjectField(vthread, nameOffset);
80+
81+
return (name != null) ? name : "<N/A>";
7782
}
7883

7984
public VirtualThreadsCommand() {
@@ -112,15 +117,15 @@ private static void displayVirtualThreads(J9JavaVMPointer vm, PrintStream out) t
112117
while (continuation.notNull()) {
113118
long vmRef = getVmRef(continuation);
114119
J9ObjectPointer vthread = getVirtualThread(continuation);
115-
J9ObjectPointer name = getName(vthread);
120+
String name = getName(vthread);
116121

117122
out.format(
118123
outputFormat,
119124
vmRef,
120125
vmRef,
121126
continuation.getHexAddress(),
122127
vthread.getHexAddress(),
123-
J9ObjectHelper.stringValue(name));
128+
name);
124129
continuation = ObjectReferencePointer.cast(continuation.addOffset(linkOffset)).at(0);
125130
}
126131
continuationObjectList = continuationObjectList._nextList();

0 commit comments

Comments
 (0)