GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [java] Resolve switch patterns before constructor inference by CEXpp · Pull Request #7397 · pmd/pmd

Conversation

@CEXpp

@CEXpp CEXpp commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Describe the PR

When a Java 21 switch pattern variable is passed directly to an anonymous class constructor, PMD can infer the constructor arguments before visiting the pattern and report a processing error on valid Java. Visit the label’s patterns before the guard or branch can trigger inference. The three regression cases cover the anonymous constructor, an ordinary constructor, and an anonymous constructor reached through a local variable.

Related issues

  • Fix [java] PMD 7.29.0 fails to resolve a switch pattern variable passed to an anonymous class constructor #7392

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes locally
  • Added an inline comment explaining the visit order

Validation: ./mvnw clean verify passed on the clean base and this exact change (44/44 modules; patched run: 20,474 tests reported, zero failures or errors, 40 suite-defined skips). With the built distributions, the direct case changed from one processing error (exit 5) to none (exit 0); both controls returned 0 before and after. All three inputs compiled with javac --release 21.

AI disclosure: GPT-6.2 Sol in Codex prepared and tested this change. ChatGPT verified that the submitted files match the tested Git blobs.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@CEXpp
[java] Resolve switch patterns before constructor inference
91bb837
@pmd-actions-helper

pmd-actions-helper Bot commented Nov 26, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Documentation Preview

Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 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-11-27 16:05:53+00:00 for d1bfac5)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

UncleOwen added 2 commits November 27, 2026 16:44
@UncleOwen
Merge branch 'main' into fork/CEXpp/fix/java-switch-pattern-construct…
e2d9ea3
…or-7392
@UncleOwen
[docs] Update release notes
d1bfac5
@UncleOwen UncleOwen added this to the 7.31.0 milestone Nov 27, 2026
UncleOwen
UncleOwen approved these changes Nov 27, 2026
View reviewed changes

@UncleOwen UncleOwen left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@UncleOwen
UncleOwen merged commit 65b9a5f into pmd:main Nov 27, 2026
15 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@pmd-actions-helper pmd-actions-helper Bot assigned UncleOwen Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@UncleOwen UncleOwen UncleOwen approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@UncleOwen UncleOwen

Labels

None yet

Projects

None yet

Milestone

7.31.0

Development

Successfully merging this pull request may close these issues.

[java] PMD 7.29.0 fails to resolve a switch pattern variable passed to an anonymous class constructor

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@CEXpp @UncleOwen
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.