It is incredibly dangerous to cache data with a type reference as a key.
1. A type is not unique in the sense you might expect, the same fully qualified type name can appear multiple times, once for each class-loader. Beware.
2. Holding on to a reference of a type prevents its corresponding class-loader from garbage collecting, which can lead to memory leaks.
Be very cautious with this type of code.
If you are running with JRE 7 or later, leverage ClassValue, which is the solution to these problems in the same way that caching data per thread requires ThreadLocal because manually caching by thread is dangerous.
http://docs.oracle.com/javase/7/docs/api/java/lang/ClassValue.htmlIf you are stuck on JRE 6, the best you can do is use a WeakReference[Class[T]] key, so that the map does not cause the static class data or classloader to leak when no longer needed.