views:

107

answers:

3

I have a relatively complex object which among other things has a ConcurrentHashMap inside it. Within the debugger i'd like to see the results of calling the .size() method but I dont actually want this in my code nor do I want to put it in.

Debugger image.

Above you can see what I have avail but id love to be able to somehow call/see the results of the .size() method

I can however see lots of references to Maps and segments etc but they are just values.

Just wondering if its possible ?

A: 

I would use log4j and do some debug output:

if (log.isDebugEnabled()) {
  log.debug("size: " + myConcurrentHashMap.size());
}

This way .size() is only called when you are in debug log level...

+6  A: 

In the debugger, open the Display view. This will allow you to evaluate an expression that you enter.

See http://www.ibm.com/developerworks/library/os-ecbug/ under "Scrapbooking your live code".

Here is a more detailed article: http://larsho.blogspot.com/2008/07/my-favorite-eclipse-view.html

danben
+1 for Eclipse voodoo...
Thorbjørn Ravn Andersen
+1. The Display view is priceless.
Eli Acherkan
+1. Thanks this is exactly what I want
wmitchell
+3  A: 

As an alternative to running the size() method in the Display view, you can simply press the "Show Logical Structure" button on your Variables window and the display of your Map will change to view like an array of entries. The size of the array is the size of your Map.

Robin
this is actually even better thanks Robin, thanks Danben my eclipse ++ now.
wmitchell