@@ -36,7 +36,7 @@ class Decoder {
3636
3737 private final ByteBuffer buffer ;
3838
39- private final ConcurrentHashMap <Class , CachedConstructor > constructors ;
39+ private final ConcurrentHashMap <Class <?> , CachedConstructor <?> > constructors ;
4040
4141 Decoder (NodeCache cache , ByteBuffer buffer , long pointerBase ) {
4242 this (
@@ -51,7 +51,7 @@ class Decoder {
5151 NodeCache cache ,
5252 ByteBuffer buffer ,
5353 long pointerBase ,
54- ConcurrentHashMap <Class , CachedConstructor > constructors
54+ ConcurrentHashMap <Class <?> , CachedConstructor <?> > constructors
5555 ) {
5656 this .cache = cache ;
5757 this .pointerBase = pointerBase ;
@@ -135,7 +135,7 @@ DecodedValue decodePointer(long pointer, Class<?> cls, java.lang.reflect.Type ge
135135 int targetOffset = (int ) pointer ;
136136 int position = buffer .position ();
137137
138- CacheKey key = new CacheKey (targetOffset , cls , genericType );
138+ CacheKey <?> key = new CacheKey <> (targetOffset , cls , genericType );
139139 DecodedValue o = cache .get (key , cacheLoader );
140140
141141 buffer .position (position );
@@ -371,7 +371,7 @@ private <T, V> Map<String, V> decodeMapIntoMap(
371371
372372 private <T > Object decodeMapIntoObject (int size , Class <T > cls )
373373 throws IOException {
374- CachedConstructor <T > cachedConstructor = this . constructors . get (cls );
374+ CachedConstructor <T > cachedConstructor = getCachedConstructor (cls );
375375 Constructor <T > constructor ;
376376 Class <?>[] parameterTypes ;
377377 java .lang .reflect .Type [] parameterGenericTypes ;
@@ -392,7 +392,7 @@ private <T> Object decodeMapIntoObject(int size, Class<T> cls)
392392
393393 this .constructors .put (
394394 cls ,
395- new CachedConstructor (
395+ new CachedConstructor <> (
396396 constructor ,
397397 parameterTypes ,
398398 parameterGenericTypes ,
@@ -445,6 +445,13 @@ private <T> Object decodeMapIntoObject(int size, Class<T> cls)
445445 }
446446 }
447447
448+ private <T > CachedConstructor <T > getCachedConstructor (Class <T > cls ) {
449+ // This cast is safe because we only put CachedConstructor<T> for Class<T> as the key
450+ @ SuppressWarnings ("unchecked" )
451+ CachedConstructor <T > result = (CachedConstructor <T >) this .constructors .get (cls );
452+ return result ;
453+ }
454+
448455 private static <T > Constructor <T > findConstructor (Class <T > cls )
449456 throws ConstructorNotFoundException {
450457 Constructor <?>[] constructors = cls .getConstructors ();
0 commit comments