Skip to content

[java] Fix #5670, #5514: ExhaustiveSwitchHasDefault when default is necessary - #6822

Merged
UncleOwen merged 10 commits into
pmd:mainfrom
UncleOwen:issue-5670-5514-ExhaustiveSwitchHasDefault
Jul 15, 2026
Merged

UncleOwen merged 10 commits into
pmd:mainfrom
UncleOwen:issue-5670-5514-ExhaustiveSwitchHasDefault

Conversation

@UncleOwen

Copy link
Copy Markdown
Member

Describe the PR

What this PR doesn't do

  • This PR doesn't address any of the concerns in this comment.

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

@pmd-actions-helper

pmd-actions-helper Bot commented Jun 27, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Preview

Compared to main:
This changeset changes 1 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 2 violations, 0 errors and 0 configuration errors.
There are 0 changed duplications, 0 new duplications and 0 removed duplications.
There are 0 changed CPD errors, 0 new CPD errors and 0 removed CPD errors.

Regression Tester Report

(comment created at 2026-07-15 09:22:43+00:00 for 1169e5f)

@UncleOwen
UncleOwen force-pushed the issue-5670-5514-ExhaustiveSwitchHasDefault branch 3 times, most recently from f4bd397 to a5c0c8c Compare July 6, 2026 10:10
@UncleOwen
UncleOwen force-pushed the issue-5670-5514-ExhaustiveSwitchHasDefault branch from a5c0c8c to fc2aa88 Compare July 6, 2026 15:08

@adangel adangel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good. Just some minor suggestions (not sure if they work).

This PR doesn't address any of the concerns in #5514 (comment).

Should we create a new issue for that? IIRC, the java compiler adds in sometimes a default case, to exactly prevent the issue described in the comment (compiling against a different enum version than running at runtime...).
Hm.. it seems, this happens only for exhaustive switch expressions (see https://openjdk.org/jeps/361 - section "Exhaustiveness").
So, maybe it indeed makes sense have a separate issue for this.

@UncleOwen
UncleOwen force-pushed the issue-5670-5514-ExhaustiveSwitchHasDefault branch from a3bb19c to 1169e5f Compare July 15, 2026 09:05
@UncleOwen

Copy link
Copy Markdown
Member Author

Thanks for the review. I've added #6879 to track the other issue.

@UncleOwen
UncleOwen merged commit df58615 into pmd:main Jul 15, 2026
13 checks passed
@UncleOwen UncleOwen added this to the 7.27.0 milestone Jul 15, 2026
@UncleOwen
UncleOwen deleted the issue-5670-5514-ExhaustiveSwitchHasDefault branch July 15, 2026 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants