@@ -69,11 +69,16 @@ private static long getVmRef(J9ObjectPointer continuation) throws CorruptDataExc
69
69
return J9ObjectHelper .getLongField (continuation , vmRefOffset );
70
70
}
71
71
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 );
75
79
}
76
- return J9ObjectHelper .getObjectField (vthread , nameOffset );
80
+
81
+ return (name != null ) ? name : "<N/A>" ;
77
82
}
78
83
79
84
public VirtualThreadsCommand () {
@@ -112,15 +117,15 @@ private static void displayVirtualThreads(J9JavaVMPointer vm, PrintStream out) t
112
117
while (continuation .notNull ()) {
113
118
long vmRef = getVmRef (continuation );
114
119
J9ObjectPointer vthread = getVirtualThread (continuation );
115
- J9ObjectPointer name = getName (vthread );
120
+ String name = getName (vthread );
116
121
117
122
out .format (
118
123
outputFormat ,
119
124
vmRef ,
120
125
vmRef ,
121
126
continuation .getHexAddress (),
122
127
vthread .getHexAddress (),
123
- J9ObjectHelper . stringValue ( name ) );
128
+ name );
124
129
continuation = ObjectReferencePointer .cast (continuation .addOffset (linkOffset )).at (0 );
125
130
}
126
131
continuationObjectList = continuationObjectList ._nextList ();
0 commit comments