Skip to content

feat: Java 21 modernization — cache - #8

Open
devin-ai-integration[bot] wants to merge 3 commits into
developfrom
devin/java21-cache
Open

feat: Java 21 modernization — cache#8
devin-ai-integration[bot] wants to merge 3 commits into
developfrom
devin/java21-cache

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented May 26, 2026

Copy link
Copy Markdown

Description of the Change

Modernizes src/gov/nasa/worldwind/cache/ for Java 21, applying conservative, behavior-preserving transformations.

Before → After counts:

Pattern Before After Converted
Traditional instanceof + cast 3 0 3 → pattern matching instanceof
SAM anonymous classes → lambda 0 0 0 (CacheListener has 2 methods, not a SAM)
Explicit diamond operator 11 0 11 → <>
Raw types 1 0 1 (ReferenceReference<?>)

Files changed (8):

  • AbstractFileStore.java — 2 pattern-matching instanceof, 2 diamond operators
  • BasicGpuResourceCache.java — 1 pattern-matching instanceof (with cast elimination)
  • BasicMemoryCache.java — 2 diamond operators
  • BasicMemoryCacheSet.java — 2 diamond operators
  • BasicDataFileStore.java — 1 diamond operator
  • BasicRasterServerCache.java — 1 diamond operator, 1 raw type fix
  • BasicSessionCache.java — 1 diamond operator
  • ShapeDataCache.java — 1 diamond operator

Why Should This Be In Core?

Part of the Java 21 migration effort. These changes bring the cache package 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

  • Type safety: Pattern matching instanceof is null-safe by spec (o instanceof Type t is false when o is null), eliminating the manual o != null && guard
  • Readability: Removes 3 redundant cast expressions, 11 redundant type arguments
  • Compiler cleanliness: Eliminates raw-type warning in BasicRasterServerCache
  • Zero behavioral change: All transformations are mechanical and semantics-preserving

Potential 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.CacheListener has 2 abstract methods (entryRemoved, removalException), so the anonymous class in BasicGpuResourceCache constructor cannot be converted to a lambda. Would require @FunctionalInterface redesign — out of scope for conservative modernization.

Devin session: https://app.devin.ai/sessions/32eacaa7ed7e44e1ae9851995bef1bc7

Requested by: @jakexcosme


Devin Review

Status Commit
⚪ Not started

Run Devin Review

💡 Connect your GitHub account to enable automatic code reviews.

Open in Devin Review (Staging)

devin-ai-integration Bot and others added 3 commits May 26, 2026 15:45
- 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]>
@devin-ai-integration

Copy link
Copy Markdown
Author
Original prompt from Jake

You are a child Devin session for COG-GTM/WorldWindJava Java 21 migration. Authorized to start. Work ONLY on package cache: src/gov/nasa/worldwind/cache/. Branch from origin/devin/java21-foundation into devin/java21-cache. Target PR base develop. Follow package workflow: pre-count SAM/instanceof, conservative modernizations, no public API/test/unrelated changes, JDK21 ant -f release-build.xml, public API diff check, PR title "feat: Java 21 modernization — cache", PR body with before/after counts, rationale, Devin session URL, Devin Review verdict if available, and flagged non-converted cases. Return structured output.

@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant