English 中文(简体)
Under what circumstances does Groovy use AbstractConcurrentMap?
原标题:

(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?

问题回答

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 -"

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.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签