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] Fix #6925: ImmutableField: false positive on picocli @Option/@Parameters fields by arimu1 · Pull Request #6936 · pmd/pmd

Conversation

@arimu1

@arimu1 arimu1 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Describe the PR

Ignore private fields annotated with picocli CommandLine.Option or CommandLine.Parameters in the ImmutableField rule.

picocli injects option/parameter values into those fields at runtime (including when a Java initializer provides a default). Treating them as candidates for final is a false positive, same pattern as the existing lombok.Setter field exclusion.

Related issues

  • Fixes [java] ImmutableField: False positive on picocli annotated fields #6925

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)

Tests

./mvnw -pl pmd-java -am test -Dtest=ImmutableFieldTest -Dsurefire.failIfNoSpecifiedTests=false — 54 tests, 0 failures (Java 21).

Sorry, something went wrong.

Uh oh!

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

All reactions
@arimu1
[java] ImmutableField: ignore picocli @Option/@parameters fields (fixes
3411450
pmd#6925)

picocli injects values into fields annotated with CommandLine.Option
or CommandLine.Parameters at runtime, so those fields should not be
reported as candidates for final. Treat the annotations like the
existing lombok.Setter field exclusion.
@UncleOwen

UncleOwen commented Aug 5, 2026

Copy link
Copy Markdown
Member

Sounds like there could be a lot more libraries with a lot more annotations out there that need to be exempt from this check. What do you think about making this a property, where lombok.Setter, picocli.CommandLine.Option, and picocli.CommandLine.Parameters are the defaults?

All reactions

Sorry, something went wrong.

Uh oh!

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

@pmd-actions-helper

pmd-actions-helper Bot commented Aug 5, 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 4 violations, 16 errors and 9 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-08-13 20:08:47+00:00 for f9cba69)

All reactions

Sorry, something went wrong.

Uh oh!

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

@UncleOwen
Merge branch 'main' into fork/arimu1/fix/6925-immutablefield-picocli
f9cba69
# Conflicts:
#	docs/pages/release_notes.md
UncleOwen
UncleOwen approved these changes Aug 13, 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.

Guess we can make this configurable next time.

Sorry, something went wrong.

Uh oh!

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

All reactions
@UncleOwen UncleOwen added this to the 7.27.0 milestone Aug 13, 2026
@UncleOwen
UncleOwen merged commit cdef01e into pmd:main Aug 13, 2026
13 checks passed

Uh oh!

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

@adangel adangel changed the title [java] ImmutableField: false positive on picocli @Option/@Parameters fields [java] Fix #6925: ImmutableField: false positive on picocli @Option/@Parameters fields Aug 15, 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

No one assigned

Labels

None yet

Projects

None yet

Milestone

7.27.0

Development

Successfully merging this pull request may close these issues.

[java] ImmutableField: False positive on picocli annotated fields

Uh oh!

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

2 participants

@arimu1 @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.