@@ -295,14 +295,12 @@ private static Collection<HeapViewerNode> computeInstancesRoots(Iterator<Instanc
295
295
while (!current .isInterrupted () && instances .hasNext ()) {
296
296
Instance instance = instances .next ();
297
297
Instance gcRoot = getGCRoot (instance , current );
298
- if (gcRoot != null ) {
299
- GCRootNode gcRootNode = (GCRootNode )gcRoots .get (gcRoot );
300
- if (gcRootNode == null ) {
301
- gcRootNode = new GCRootNode (gcRoot );
302
- gcRoots .put (gcRoot , gcRootNode );
303
- }
304
- gcRootNode .addInstance (instance );
298
+ GCRootNode gcRootNode = (GCRootNode )gcRoots .get (gcRoot );
299
+ if (gcRootNode == null ) {
300
+ gcRootNode = new GCRootNode (gcRoot );
301
+ gcRoots .put (gcRoot , gcRootNode );
305
302
}
303
+ gcRootNode .addInstance (instance );
306
304
progress .step ();
307
305
}
308
306
if (current .isInterrupted ()) throw new InterruptedException ();
@@ -336,7 +334,7 @@ private static void storeItem(String itemName, boolean value) {
336
334
"GCRootNode_SamplesContainer=<sample {0} instances>" ,
337
335
"GCRootNode_NodesContainer=<instances {0}-{1}>"
338
336
})
339
- static class GCRootNode extends InstanceNode {
337
+ static class GCRootNode extends InstanceNode . IncludingNull {
340
338
341
339
// private final int maxNodes = UIThresholds.MAX_MERGED_OBJECTS;
342
340
@@ -370,14 +368,17 @@ public int getCount() {
370
368
// }
371
369
372
370
protected HeapViewerNode [] lazilyComputeChildren (Heap heap , String viewID , HeapViewerNodeFilter viewFilter , List <DataType > dataTypes , List <SortOrder > sortOrders , Progress progress ) throws InterruptedException {
373
- final boolean isArray = getInstance ().getJavaClass ().isArray ();
371
+ final Instance gcRoot = getInstance ();
372
+ final boolean isArray = gcRoot != null && gcRoot .getJavaClass ().isArray ();
374
373
NodesComputer <Instance > computer = new NodesComputer <Instance >(instances .size (), UIThresholds .MAX_MERGED_OBJECTS ) {
375
374
protected boolean sorts (DataType dataType ) {
376
375
if (DataType .COUNT .equals (dataType ) || (DataType .OWN_SIZE .equals (dataType ) && !isArray )) return false ;
377
376
return true ;
378
377
}
379
378
protected HeapViewerNode createNode (Instance object ) {
380
- return GCRootNode .this .createNode (object );
379
+ return new GCInstanceNode (object ) {
380
+ public boolean isLeaf () { return gcRoot == null ; }
381
+ };
381
382
}
382
383
protected ProgressIterator <Instance > objectsIterator (int index , Progress progress ) {
383
384
Iterator <Instance > iterator = instances .listIterator (index );
@@ -396,10 +397,6 @@ protected String getNodesContainerString(String firstNodeIdx, String lastNodeIdx
396
397
return computer .computeNodes (GCRootNode .this , heap , viewID , null , dataTypes , sortOrders , progress );
397
398
}
398
399
399
- private HeapViewerNode createNode (Instance instance ) {
400
- return new GCInstanceNode (instance );
401
- }
402
-
403
400
404
401
protected Object getValue (DataType type , Heap heap ) {
405
402
if (type == DataType .COUNT ) return getCount ();
@@ -408,6 +405,11 @@ protected Object getValue(DataType type, Heap heap) {
408
405
}
409
406
410
407
408
+ public boolean isLeaf () {
409
+ return false ;
410
+ }
411
+
412
+
411
413
static class Renderer extends InstanceNodeRenderer {
412
414
413
415
private static final ImageIcon ICON = Icons .getImageIcon (ProfilerIcons .NODE_FORWARD );
@@ -416,6 +418,21 @@ static class Renderer extends InstanceNodeRenderer {
416
418
super (heap );
417
419
}
418
420
421
+ @ Override
422
+ public void setValue (Object value , int row ) {
423
+ if (value != null ) {
424
+ GCRootNode node = (GCRootNode )value ;
425
+ if (node .getInstance () == null ) {
426
+ setNormalValue (Bundle .PathToGCRootPlugin_NoRoot ());
427
+ setBoldValue ("" ); // NOI18N
428
+ setGrayValue ("" ); // NOI18N
429
+ setIcon (ICON );
430
+ return ;
431
+ }
432
+ }
433
+ super .setValue (value , row );
434
+ }
435
+
419
436
@ Override
420
437
protected ImageIcon getIcon (Instance instance , boolean isGCRoot ) {
421
438
return ICON ;
0 commit comments