A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/2348 below:

[java] ConstructorCallsOverridableMethod occurs when unused overloaded method is defined · Issue #2348 · pmd/pmd · GitHub

Affects PMD Version: 6.11.0, 6.21.0

Rule: ConstructorCallsOverridableMethod

Description:
If a constructor calls a non-overridable public method, and this method has an overridable overloaded version (which is not called from the constructor or from the non-overridable version,) then a ConstructorCallsOverridableMethod rule exception is raised.

Code Sample demonstrating the issue:

public class Scratch {
    private Long member = 0L;

    public Scratch(final Long v) {
        setMember(v);
    }

    public final void setMember(final Long v) {
        this.member = v;
    }

    // Renaming this or marking it as final prevents the
    // 'ConstructorCallsOverridableMethod' rule from being broken.
    public void setMember(final String n) {
        setMember(Long.valueOf(n));
    }
}

Running PMD through: Gradle (with version 6.11.0) and CLI (with version 6.21.0)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4