Skip to content

feat: Java 21 modernization — SAM threshold reduction - #22

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

feat: Java 21 modernization — SAM threshold reduction#22
devin-ai-integration[bot] wants to merge 3 commits into
developfrom
devin/java21-sam-reduction

Conversation

@devin-ai-integration

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

Copy link
Copy Markdown

Description of the Change

Follow-up Java 21 modernization pass that converts safe remaining anonymous Runnable and ActionListener single-method adapters to lambdas across the combined package set. This is focused on satisfying the Phase 3 completeness gate after the per-package modernization PRs, especially the high-density examples/application Swing handlers.

Verification on this branch:

find src -name "*.java" | wc -l
# 1727

grep -rn "new Runnable()" --include="*.java" src/ | wc -l
# 3

grep -rn "new ActionListener()" --include="*.java" src/ | wc -l
# 7

ant -f release-build.xml
# BUILD SUCCESSFUL; 435 tests, 0 failures, 0 errors, 7 skipped

The remaining grep matches include commented-out examples and a small set of deliberately retained anonymous classes where this binding or review clarity is safer than automated conversion.

Why Should This Be In Core?

The Java 21 migration gate requires the combined modernization state to reduce anonymous Runnable instances to ≤15 and anonymous ActionListener instances to ≤18. This PR brings the counts to Runnable=3 and ActionListener=7 while preserving public API signatures and keeping the change limited to implementation syntax.

Benefits

  • Completes the Phase 3 SAM threshold gate for Java 21 migration readiness.
  • Reduces boilerplate in Swing/threading call sites without changing behavior.
  • Keeps public APIs unchanged; only implementation bodies are modernized.
  • Full release build and unit tests pass locally under JDK 21.

Potential Drawbacks

  • The diff is broad because the threshold gate is repository-wide, though each edit is a mechanical single-method adapter conversion.
  • Some remaining matches are intentionally left for human review or are commented-out code.

Applicable Issues

N/A

Link to Devin session: https://app.devin.ai/sessions/36287b7c637242dba0a6a659737d5402
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