Skip to content

[java] CompareObjectsWithEquals: FP with array.length #2976

@djh82

Description

@djh82

Since: 6.30.0

Rule: CompareObjectsWithEquals

Codebase passes with previous PMD version, just upgraded to 6.30.0 and are now seeing assumed false positives with CompareObjectsWithEquals.

Code is as follows:

public static byte[] myArrayFunc(byte[] a1, byte[] a2) {
    if (a1.length != a2.length) {
        throw new IllegalArgumentException();
    }

    ....
}

PMD now fails on the if (a1.length != a2.length) line; they are both primitive ints, and therefore do not have an equals method.

Possibly introduced by #2934

Metadata

Metadata

Assignees

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