Skip to content

feat: Java 21 modernization — formats - #15

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

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

Conversation

@devin-ai-integration

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

Copy link
Copy Markdown

Note: Filling out this template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the
maintainer's discretion.

Description of the Change

Modernizes clear-cut Java 21 pattern-matching opportunities in src/gov/nasa/worldwind/formats/ only:

  • Converted 15 instanceof-then-cast sites to Java 21 pattern matching.
  • Updated 5 files: WorldFile.java, GeoSymSupport.java, VPFBasicPrimitiveDataFactory.java, VPFBasicSymbolFactory.java, and VPFLayer.java.
  • Introduced 0 records, 0 sealed hierarchies, 0 text blocks, and 0 deprecated API removals.
  • Made no public/protected API signature changes and no test changes.

Verification:

  • Before counts: new Runnable(): 1, new ActionListener(): 1, new Callable(): 0, new MouseListener(): 0, new KeyListener(): 0, new ChangeListener(): 0, new PropertyChangeListener(): 1, new WindowListener(): 0, instanceof: 68.
  • After counts: same aggregate instanceof count, with 15 local cast-after-check sites converted to pattern variables.
  • git diff origin/devin/java21-foundation -- src/gov/nasa/worldwind/formats | grep -E "^\+.*public |^\+.*protected " returned no public/protected API additions.
  • ant -f release-build.xml under JDK 21: BUILD SUCCESSFUL; JUnit: 435 tests, 0 failures, 0 errors, 7 skipped.

Flagged for human review:

  • Remaining new Runnable(), new ActionListener(), and new PropertyChangeListener() anonymous classes are retained due to listener/threading semantics or multi-method/anonymous-class shape.
  • Remaining instanceof checks are retained when they are pure boolean guards, negative guards, or readability-neutral cases without nearby casts.

Devin session: https://app.devin.ai/sessions/36287b7c637242dba0a6a659737d5402
Devin Review verdict: ready for review; no API/test-surface changes detected locally.

Why Should This Be In Core?

This is one atomic package step in the Java 11 to Java 21 LTS migration. It keeps file/format parsing behavior stable while reducing legacy cast boilerplate.

Benefits

  • Uses Java 21 pattern variables for clearer local type narrowing.
  • Preserves existing behavior and package boundaries.
  • Keeps the migration reviewable as a package-scoped PR.

Potential Drawbacks

  • This PR depends on the foundation JDK 21 build-retargeting work for compilation under Java 21.
  • Listener/threading anonymous classes remain intentionally unchanged for compatibility.

Applicable Issues

N/A

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

Copy link
Copy Markdown
Author
Original prompt from Jake

#``# Overview

Migrate COG-GTM/WorldWindJava from Java 11 to Java 21 LTS. This is a federal-grade, zero-breakage migration with atomic per-package PRs, full test verification before and after, and a rollup audit document. Use parallel child sessions to accelerate. All PRs target the fork's develop branch.

#``# PHASE 0: Pre-Migration Baseline (Sequential — MUST complete before anything else)

#``#``# Step 0.1: Capture Pre-Migration Baseline Metrics
Before ANY changes, on the develop branch with JDK 11:

`#` File count
find src -name "*.java" | wc -l
`#` Anonymous inner class counts
grep -rn "new Runnable()" --include="*.java" src/ | wc -l
grep -rn "new ActionListener()" --include="*.java" src/ | wc -l
grep -rn "new Callable()" --include="*.java" src/ | wc -l
grep -rn "new MouseListener()" --include="*.java" src/ | wc -l
grep -rn "new KeyListener()" --include="*.java" src/ | wc -l  
grep -rn "new ChangeListener()" --include="*.java" src/ | wc -l
grep -rn "new PropertyChangeListener()" --include="*.java" src/ | wc -l
grep -rn "new WindowListener()" --include="*.java" src/ | wc -l
`#` instanceof pattern-match candidates
grep -rn "instanceof " --include="*.java" src/ | wc -l
`#` Deprecated usage
grep -rn "`@`Deprecated" --include="*.java" src/ | wc -l
grep -rn "new Integer(" --include="*.java" src/ | wc -l
grep -rn "new Double(" --include="*.java" src/ | wc -l
grep -rn "new Float(" --include="*.java" src/ | wc -l
grep -rn "new Long(" --include="*.java" src/ | wc -l
grep -rn "new Boolean(" --include="*.java" src/ | wc -l

Save all counts to a file BASELINE-METRICS.txt at the repo root. This is your "before" snapshot.

#``#``# Step 0.2: Run the existing test suite under JDK 11

ant -f release-build.xml

Record pass/fail counts. This establishes that the test suite is green BEFORE migration.

#``# PHASE 1: Foundational JDK 21 Retarget PR (Sequential — Wave 0)

#``#``# Step 1.1: Create branch devin/java21-foundation
Make these changes ONLY (no code changes):

  1. **`release-... (12653 chars truncated...)

@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