Skip to content

feat: Java 21 modernization — util - #10

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

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

Conversation

@devin-ai-integration

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

Copy link
Copy Markdown

Description of the Change

Java 21 modernization of the util package (src/gov/nasa/worldwind/util/). Applies conservative, safe transformations:

  1. SAM → Lambda conversions (22 conversions): Anonymous classes implementing functional interfaces (Runnable, Comparator, ThreadFactory, ActionListener, PropertyChangeListener) converted to lambda expressions.
  2. instanceof pattern matching (18 conversions): Cast-after-check patterns converted to Java 16+ instanceof pattern matching syntax.

Before/After Counts:

Metric Before After
SAM anonymous classes 23 0 (1 commented-out)
instanceof pattern matching used 0 18
Lambda expressions 0 22
Total instanceof statements 231 231

Files modified: 18 files in src/gov/nasa/worldwind/util/ (net -87 lines)

Why Should This Be In Core?

Modernizing the codebase to Java 21 idioms improves readability, reduces boilerplate, and prepares for further language feature adoption. These are safe, mechanical transformations that preserve existing behavior.

Benefits

  • Reduced boilerplate: -87 lines of anonymous class ceremony
  • Improved readability: lambdas and pattern matching are more concise and idiomatic
  • Type safety: pattern matching eliminates redundant casts
  • No behavioral changes: purely syntactic modernization

Potential Drawbacks

  • None identified. All changes are internal implementation details (no public API changes).

Applicable Issues

Part of Java 21 migration initiative.


Build: ✓ JDK 21 ant -f release-build.xml passes (only pre-existing deprecation warning in CachedDataRaster.java)
Public API: ✓ No method signature changes
Tests: Not modified
Verdict: Safe to merge — conservative, compilation-verified modernization
Flagged for review: WWXML.java has a renamed local variable (url2) to avoid pattern variable scope conflict; StatusBar.java combined instanceof+SAM in property listeners.

Session: https://app.devin.ai/sessions/365de6fb459340c997e96354890724ec

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 22 anonymous SAM classes to lambda expressions
  (Runnable, Comparator, ThreadFactory, ActionListener, PropertyChangeListener)
- Apply instanceof pattern matching in 18 locations
  (WWXML, ImageUtil, KMLLayerTreeNode, KMLFeatureTreeNode, etc.)
- No public API changes; all changes are internal implementation
- Builds cleanly with JDK 21 (ant -f release-build.xml)

Co-Authored-By: Jake Cosme <jake@cognition.ai>
@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 util: src/gov/nasa/worldwind/util/. Branch from origin/devin/java21-foundation into devin/java21-util. Target PR base develop. This is large; be conservative and focused. Follow package workflow: pre-count SAM/instanceof, conservative Java 21 modernizations, no public API/test/unrelated changes, JDK21 ant -f release-build.xml, public API diff check, PR title "feat: Java 21 modernization — util", body with before/after counts/rationale/session/verdict/flags. 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