feat: Java 21 modernization — symbology - #9
Conversation
Convert 50 instanceof-then-cast patterns to pattern matching instanceof across 26 files in src/gov/nasa/worldwind/symbology/. No SAM anonymous inner classes found in this package. Changes are internal only — no public API, test, or unrelated changes. 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
Java 21 modernization of the
src/gov/nasa/worldwind/symbology/package. Converts all 50instanceof-then-cast patterns to pattern matchinginstanceof(JEP 394, finalized in Java 16).Before / After Counts
instanceofwith cast (old style)instanceof26 files touched across the symbology package hierarchy — no public API signatures changed, no test files modified, no unrelated packages touched.
Why Should This Be In Core?
Part of the systematic Java 21 migration effort. Pattern matching
instanceofeliminates redundant casts, reducing boilerplate and the risk ofClassCastExceptionfrom mismatched type checks and casts.Benefits
if (o instanceof Color color)is clearer thanif (o instanceof Color) { Color c = (Color) o; ... }Potential Drawbacks
None. Pattern matching
instanceofhas been stable since Java 16 and is a drop-in replacement for the traditional check-then-cast idiom.Applicable Issues
Java 21 migration initiative. Branched from
devin/java21-foundation.Build verification:
ant -f release-build.xmlpasses cleanly on JDK 21 (only pre-existing deprecation warning forSystem.runFinalization()).Public API diff check:
git diff --staton public method signatures shows zero changes.Verdict: Safe to merge — mechanical refactor only, no semantic changes.
Session: https://app.devin.ai/sessions/3d8ea42a306c4bba95b3eacb06af22f2
Requested by: @jakexcosme
Devin Review