jsr107/jsr107spec — Issue #36: Allow deeper enforcement of types
Author: gregrluck
Created: 2011-11-10 01:45:02+00:00
State: open

(From a Terracotta internal review)

Both CacheManager.createCacheBuilder(…) and CacheManager.getCache(…) should include Class parameters matching the supplied generic types - this will allow implementations that so choose to validate the supplied generic types against any pre-existing cache (disk persistent or distributed) and also against any future configuration settings. The method signatures would then become:

CacheBuilder createCacheBuilder(String cacheName, Class keyType, Class valueType)
Cache getCache(String cacheName, Class keyType, Class valueType)

Implementations that wish to ignore the classes could be free to do so, but those that wish to validate the generic type of what they are returning can do so. For example an implementation that supports disk-persistent caches could save the class-name (or even a more full featured descriptor) to the disk that could be validated against the supplied key and value types when that cache is retrieved in a subsequent JVM execution.