Index: src/java/org/apache/lucene/search/cache/DocTermsCreator.java
===================================================================
--- src/java/org/apache/lucene/search/cache/DocTermsCreator.java	(revision 1022730)
+++ src/java/org/apache/lucene/search/cache/DocTermsCreator.java	(working copy)
@@ -34,7 +34,7 @@
 import org.apache.lucene.util.packed.PackedInts;
 
 // TODO: this if DocTermsIndex was already created, we should share it...
-public class DocTermsCreator<T extends DocTerms> extends EntryCreatorWithOptions<T>
+public class DocTermsCreator extends EntryCreatorWithOptions<DocTerms>
 {
   public static final int FASTER_BUT_MORE_RAM = 2;
 
@@ -64,7 +64,7 @@
   }
 
   @Override
-  public T create(IndexReader reader) throws IOException {
+  public DocTerms create(IndexReader reader) throws IOException {
 
     String field = StringHelper.intern(this.field); // TODO?? necessary?
     Terms terms = MultiFields.getTerms(reader, field);
@@ -134,11 +134,11 @@
     }
 
     // maybe an int-only impl?
-    return (T)new DocTermsImpl(bytes.freeze(true), docToOffset.getMutable());
+    return new DocTermsImpl(bytes.freeze(true), docToOffset.getMutable());
   }
 
   @Override
-  public T validate(T entry, IndexReader reader) throws IOException {
+  public DocTerms validate(DocTerms entry, IndexReader reader) throws IOException {
     // TODO? nothing? perhaps subsequent call with FASTER_BUT_MORE_RAM?
     return entry;
   }
Index: src/java/org/apache/lucene/search/cache/DocTermsIndexCreator.java
===================================================================
--- src/java/org/apache/lucene/search/cache/DocTermsIndexCreator.java	(revision 1022730)
+++ src/java/org/apache/lucene/search/cache/DocTermsIndexCreator.java	(working copy)
@@ -36,7 +36,7 @@
 import org.apache.lucene.util.packed.GrowableWriter;
 import org.apache.lucene.util.packed.PackedInts;
 
-public class DocTermsIndexCreator<T extends DocTermsIndex> extends EntryCreatorWithOptions<T>
+public class DocTermsIndexCreator extends EntryCreatorWithOptions<DocTermsIndex>
 {
   public static final int FASTER_BUT_MORE_RAM = 2;
 
@@ -66,7 +66,7 @@
   }
 
   @Override
-  public T create(IndexReader reader) throws IOException
+  public DocTermsIndex create(IndexReader reader) throws IOException
   {
     String field = StringHelper.intern(this.field); // TODO?? necessary?
     Terms terms = MultiFields.getTerms(reader, field);
@@ -166,11 +166,11 @@
     }
 
     // maybe an int-only impl?
-    return (T)new DocTermsIndexImpl(bytes.freeze(true), termOrdToBytesOffset.getMutable(), docToTermOrd.getMutable(), termOrd);
+    return new DocTermsIndexImpl(bytes.freeze(true), termOrdToBytesOffset.getMutable(), docToTermOrd.getMutable(), termOrd);
   }
 
   @Override
-  public T validate(T entry, IndexReader reader) throws IOException {
+  public DocTermsIndex validate(DocTermsIndex entry, IndexReader reader) throws IOException {
     // TODO? nothing? perhaps subsequent call with FASTER_BUT_MORE_RAM?
     return entry;
   }
Index: src/java/org/apache/lucene/search/FieldCacheImpl.java
===================================================================
--- src/java/org/apache/lucene/search/FieldCacheImpl.java	(revision 1022730)
+++ src/java/org/apache/lucene/search/FieldCacheImpl.java	(working copy)
@@ -57,20 +57,30 @@
  */
 public class FieldCacheImpl implements FieldCache {  // Made Public so that 
 	
-  private Map<Class<?>,Cache> caches;
+  private Cache<ByteValues> byteCache;
+  private Cache<ShortValues> shortCache;
+  private Cache<IntValues> intCache;
+  private Cache<FloatValues> floatCache;
+  private Cache<LongValues> longCache;
+  private Cache<DoubleValues> doubleCache;
+  private Cache<DocTermsIndex> docTermsIndexCache;
+  private Cache<DocTerms> docTermsCache;
+  private final List<Cache<?>> caches = new ArrayList<Cache<?>>();
+  
   FieldCacheImpl() {
     init();
   }
+  
   private synchronized void init() {
-    caches = new HashMap<Class<?>,Cache>(7);
-    caches.put(Byte.TYPE, new Cache<ByteValues>(this));
-    caches.put(Short.TYPE, new Cache<ShortValues>(this));
-    caches.put(Integer.TYPE, new Cache<IntValues>(this));
-    caches.put(Float.TYPE, new Cache<FloatValues>(this));
-    caches.put(Long.TYPE, new Cache<LongValues>(this));
-    caches.put(Double.TYPE, new Cache<DoubleValues>(this));
-    caches.put(DocTermsIndex.class, new Cache<DocTermsIndex>(this));
-    caches.put(DocTerms.class, new Cache<DocTerms>(this));
+    caches.clear();
+    caches.add( byteCache = new Cache<ByteValues>( this, ByteValues.class ) );
+    caches.add( shortCache = new Cache<ShortValues>( this, ShortValues.class ) );
+    caches.add( intCache = new Cache<IntValues>( this, IntValues.class ) );
+    caches.add( floatCache = new Cache<FloatValues>( this, FloatValues.class ) );
+    caches.add( longCache = new Cache<LongValues>( this, LongValues.class ) );
+    caches.add( doubleCache = new Cache<DoubleValues>( this, DoubleValues.class ) );
+    caches.add( docTermsIndexCache = new Cache<DocTermsIndex>( this, DocTermsIndex.class ) );
+    caches.add( docTermsCache = new Cache<DocTerms>( this, DocTerms.class ) );
   }
   
   public synchronized void purgeAllCaches() {
@@ -78,23 +88,21 @@
   }
 
   public synchronized void purge(IndexReader r) {
-    for(Cache c : caches.values()) {
+    for(Cache c : caches) {
       c.purge(r);
     }
   }
   
   public synchronized CacheEntry[] getCacheEntries() {
     List<CacheEntry> result = new ArrayList<CacheEntry>(17);
-    for(final Map.Entry<Class<?>,Cache> cacheEntry: caches.entrySet()) {
-      final Cache<?> cache = cacheEntry.getValue();
-      final Class<?> cacheType = cacheEntry.getKey();
+    for(Cache<?> cache: caches) {
       synchronized(cache.readerCache) {
         for( Object readerKey : cache.readerCache.keySet() ) {
           Map<?, Object> innerCache = cache.readerCache.get(readerKey);
           for (final Map.Entry<?, Object> mapEntry : innerCache.entrySet()) {
             Entry entry = (Entry)mapEntry.getKey();
             result.add(new CacheEntryImpl(readerKey, entry.field,
-                                          cacheType, entry.creator,
+                                          cache.clazz, entry.creator,
                                           mapEntry.getValue()));
           }
         }
@@ -139,19 +147,17 @@
 
   /** Expert: Internal cache. */
   final static class Cache<T> {
-    Cache() {
-      this.wrapper = null;
-    }
-
-    Cache(FieldCache wrapper) {
+    Cache(FieldCache wrapper, Class<T> clazz) {
       this.wrapper = wrapper;
+      this.clazz = clazz;
     }
 
+    final Class<T> clazz;
     final FieldCache wrapper;
 
     final Map<Object,Map<Entry<T>,Object>> readerCache = new WeakHashMap<Object,Map<Entry<T>,Object>>();
 
-    protected Object createValue(IndexReader reader, Entry entryKey) throws IOException {
+    protected T createValue(IndexReader reader, Entry<T> entryKey) throws IOException {
       return entryKey.creator.create( reader );
     }
 
@@ -163,8 +169,10 @@
       }
     }
 
+    // We can not use a generic map here since the value is sometimes a 'CreationPlaceholder'
+    // however the value of having the external API see the real type is worth it
     @SuppressWarnings("unchecked")
-    public Object get(IndexReader reader, Entry<T> key) throws IOException {
+    public T get(IndexReader reader, Entry<T> key) throws IOException {
       Map<Entry<T>,Object> innerCache;
       Object value;
       final Object readerKey = reader.getCoreCacheKey();
@@ -201,7 +209,7 @@
               }
             }
           }
-          return progress.value;
+          return (T)progress.value;
         }
       }
       
@@ -209,7 +217,7 @@
       if( key.creator.shouldValidate() ) {
         key.creator.validate( (T)value, reader);
       }
-      return value;
+      return (T)value;
     }
 
     private void printNewInsanity(PrintStream infoStream, Object value) {
@@ -274,10 +282,9 @@
     return getBytes(reader, field, new ByteValuesCreator(field, parser)).values;
   }
 
-  @SuppressWarnings("unchecked")
   public ByteValues getBytes(IndexReader reader, String field, EntryCreator<ByteValues> creator ) throws IOException 
   {
-    return (ByteValues)caches.get(Byte.TYPE).get(reader, new Entry(field, creator));
+    return byteCache.get(reader, new Entry<ByteValues>(field, creator));
   }
   
   // inherit javadocs
@@ -290,10 +297,9 @@
     return getShorts(reader, field, new ShortValuesCreator(field,parser)).values;
   }
 
-  @SuppressWarnings("unchecked")
   public ShortValues getShorts(IndexReader reader, String field, EntryCreator<ShortValues> creator ) throws IOException 
   {
-    return (ShortValues)caches.get(Short.TYPE).get(reader, new Entry(field, creator));
+    return shortCache.get(reader, new Entry<ShortValues>(field, creator));
   }
   
   // inherit javadocs
@@ -306,9 +312,8 @@
     return getInts(reader, field, new IntValuesCreator( field, parser )).values;
   }
 
-  @SuppressWarnings("unchecked")
   public IntValues getInts(IndexReader reader, String field, EntryCreator<IntValues> creator ) throws IOException {
-    return (IntValues)caches.get(Integer.TYPE).get(reader, new Entry(field, creator));
+    return intCache.get(reader, new Entry<IntValues>(field, creator));
   }
   
   // inherit javadocs
@@ -321,9 +326,8 @@
     return getFloats(reader, field, new FloatValuesCreator( field, parser ) ).values;
   }
 
-  @SuppressWarnings("unchecked")
   public FloatValues getFloats(IndexReader reader, String field, EntryCreator<FloatValues> creator ) throws IOException {
-    return (FloatValues)caches.get(Float.TYPE).get(reader, new Entry(field, creator));
+    return floatCache.get(reader, new Entry<FloatValues>(field, creator));
   }
 
   public long[] getLongs(IndexReader reader, String field) throws IOException {
@@ -335,9 +339,8 @@
     return getLongs(reader, field, new LongValuesCreator( field, parser ) ).values;
   }
 
-  @SuppressWarnings("unchecked")
   public LongValues getLongs(IndexReader reader, String field, EntryCreator<LongValues> creator ) throws IOException {
-    return (LongValues)caches.get(Long.TYPE).get(reader, new Entry(field, creator));
+    return longCache.get(reader, new Entry<LongValues>(field, creator));
   }
   
   // inherit javadocs
@@ -350,39 +353,36 @@
     return getDoubles(reader, field, new DoubleValuesCreator( field, parser ) ).values;
   }
 
-  @SuppressWarnings("unchecked")
   public DoubleValues getDoubles(IndexReader reader, String field, EntryCreator<DoubleValues> creator ) throws IOException {
-    return (DoubleValues)caches.get(Double.TYPE).get(reader, new Entry(field, creator));
+    return doubleCache.get(reader, new Entry<DoubleValues>(field, creator));
   }
 
   public DocTermsIndex getTermsIndex(IndexReader reader, String field) throws IOException {    
-    return getTermsIndex(reader, field, new DocTermsIndexCreator<DocTermsIndex>( field ) );
+    return getTermsIndex(reader, field, new DocTermsIndexCreator( field ) );
   }
 
   public DocTermsIndex getTermsIndex(IndexReader reader, String field, boolean fasterButMoreRAM) throws IOException {    
-    return getTermsIndex(reader, field, new DocTermsIndexCreator<DocTermsIndex>( field, 
+    return getTermsIndex(reader, field, new DocTermsIndexCreator( field, 
         fasterButMoreRAM ? DocTermsIndexCreator.FASTER_BUT_MORE_RAM : 0 ) );
   }
 
-  @SuppressWarnings("unchecked")
   public DocTermsIndex getTermsIndex(IndexReader reader, String field, EntryCreator<DocTermsIndex> creator) throws IOException {
-    return (DocTermsIndex)caches.get(DocTermsIndex.class).get(reader, new Entry(field, creator));
+    return docTermsIndexCache.get(reader, new Entry<DocTermsIndex>(field, creator));
   }
 
   // TODO: this if DocTermsIndex was already created, we
   // should share it...
   public DocTerms getTerms(IndexReader reader, String field) throws IOException {
-    return getTerms(reader, field, new DocTermsCreator<DocTerms>( field ) );
+    return getTerms(reader, field, new DocTermsCreator( field ) );
   }
 
   public DocTerms getTerms(IndexReader reader, String field, boolean fasterButMoreRAM) throws IOException {
-    return getTerms(reader, field, new DocTermsCreator<DocTerms>( field,
+    return getTerms(reader, field, new DocTermsCreator( field,
         fasterButMoreRAM ? DocTermsCreator.FASTER_BUT_MORE_RAM : 0 ) );
   }
 
-  @SuppressWarnings("unchecked")
   public DocTerms getTerms(IndexReader reader, String field, EntryCreator<DocTerms> creator) throws IOException {
-    return (DocTerms)caches.get(DocTerms.class).get(reader, new Entry(field, creator));
+    return docTermsCache.get(reader, new Entry<DocTerms>(field, creator));
   }
 
   private volatile PrintStream infoStream;
