views:

28

answers:

2

(Specifically, org.codehaus.groovy.util.AbstractConcurrentMap)

While doing some profiling of our application thats mixed Java/Groovy, I'm seeing a lot of references to the AbstractConcurrentMap class, none of which are explicit in the code base. Does groovy use this class when maps are instantiated in the groovy dynamic def myMap = [:] style? Are there rules somewhere about when groovy chooses to use this as opposed to, say, java.util.HashMap?

And does anyone have any performance information comparing the two? My rough "eyeball check" says that AbstractConcurrentMap seems to be much slower - anyone know if I'm right?

A: 

Casual rant: The API javadoc for Groovy seems to suck badly (no description on what and/or for what this abstract class is).

But from what I can see there are at least 2 classes which extend this abstract class.

org.codehaus.groovy.reflection.MixinInMetaClass

org.codehaus.groovy.reflection.ClassInfo$ClassInfoSet

Both (as you can guess from the package name) have to do something with the reflection code in Groovy. So I imagine Groovy instantiates implementations of this abstract class for some internal stuff (e.g. as your usage of java/groovy maps)

Btw. the javadoc on the ClassInfo class (which encloses the ClassInfoSet) laconically states

Handle for all information we want to keep about the class

Which I guess only makes sense for the author "Alex.Tkachman -"

jitter
A: 

In Groovy version 1.6.3, the following:

println [:].getClass()

prints

class java.util.LinkedHashMap

which indicates that a LinkedHashMap is the Map implementation used for literal maps.

Don