Skip to content

[java] ImmutableField: Do not flag fields annotated with @Inject #4011

@maikelsteneker

Description

@maikelsteneker

Affects PMD Version: 6.46.0

Rule: ImmutableField

Description: Fields that are annotated using the javax.inject.Inject annotation should not be final. However, a violation suggesting as much is still triggered.

Code Sample demonstrating the issue:

public abstract class AbstractDapiProcess implements Process {
   @Inject private AuthenticationService authService;

Expected outcome: No violation

PMD reports a violation at line 2 but that's wrong. That's a false positive.

Running PMD through: CLI

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:false-positivePMD flags a piece of code that is not problematic

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions