feat: Java 21 modernization — cache - #8
Conversation
- Convert 3 traditional instanceof checks to pattern matching instanceof (AbstractFileStore: getFile(), isInstall(); BasicGpuResourceCache: onEntryRemoved()) - Apply diamond operator to 11 generic instantiations across 7 files - Fix raw type Reference -> Reference<?> in BasicRasterServerCache No public API changes. Builds cleanly with JDK 21. Co-Authored-By: Jake Cosme <[email protected]>
Original prompt from Jake
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Description of the Change
Modernizes
src/gov/nasa/worldwind/cache/for Java 21, applying conservative, behavior-preserving transformations.Before → After counts:
instanceof+ castinstanceof<>Reference→Reference<?>)Files changed (8):
AbstractFileStore.java— 2 pattern-matching instanceof, 2 diamond operatorsBasicGpuResourceCache.java— 1 pattern-matching instanceof (with cast elimination)BasicMemoryCache.java— 2 diamond operatorsBasicMemoryCacheSet.java— 2 diamond operatorsBasicDataFileStore.java— 1 diamond operatorBasicRasterServerCache.java— 1 diamond operator, 1 raw type fixBasicSessionCache.java— 1 diamond operatorShapeDataCache.java— 1 diamond operatorWhy Should This Be In Core?
Part of the Java 21 migration effort. These changes bring the
cachepackage up to modern Java idioms while maintaining exact behavioral parity. Pattern matching instanceof eliminates redundant casts and null-checks; diamond operators reduce visual noise; fixing raw types eliminates compiler warnings.Benefits
o instanceof Type tis false whenois null), eliminating the manualo != null &&guardBasicRasterServerCachePotential Drawbacks
None. All changes are internal implementation details — no public API signatures modified. Built and verified with JDK 21 (
ant -f release-build.xml).Applicable Issues
Java 21 migration tracking.
Flagged non-converted cases:
MemoryCache.CacheListenerhas 2 abstract methods (entryRemoved,removalException), so the anonymous class inBasicGpuResourceCacheconstructor cannot be converted to a lambda. Would require@FunctionalInterfaceredesign — out of scope for conservative modernization.Devin session: https://app.devin.ai/sessions/32eacaa7ed7e44e1ae9851995bef1bc7
Requested by: @jakexcosme
Devin Review