8000 [java] MissingOverride false positive when extending JDK classes · Issue #4291 · pmd/pmd · GitHub
[go: up one dir, main page]

Skip to content
[java] MissingOverride false positive when extending JDK classes #4291
@adangel

Description

@adangel

Affects PMD Version: 6.53.0

Rule: MissingOverride

Description:

When an application is extending standard JDK classes, then this rule might produce a false positive. Eg. in PMD 7, we extend java.lang.CharSequence and add a method isEmpty without @Override, because this method doesn't exist in Java 8. But it has been added in Java 15.

The rule uses reflection to get the methods of the super class. This depends on the runtime JVM that is used when executing PMD.

In PMD 6, the rule directly uses reflection, so there is no way we could provide a different auxclasspath.

In PMD 7, the rule uses the new symbol API, which uses ASM to load the info from the class files. So we could potentially run PMD with an auxclasspath containing a different JDK classpath than the runtime JVM.

Code Sample demonstrating the issue:

I found this problem when build PMD 7 with Java 17.

Expected outcome:

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

Running PMD through: Maven

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0