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] ConstructorCallsOverridableMethod occurs when unused overloaded method is defined · Issue #2348 · pmd/pmd

[java] ConstructorCallsOverridableMethod occurs when unused overloaded method is defined #2348

New issue
Copy link
New issue
Copy link
Closed
#4101
Closed
[java] ConstructorCallsOverridableMethod occurs when unused overloaded method is defined#2348
#4101
Copy link
Labels
a:false-positivePMD flags a piece of code that is not problematic
Milestone
6.50.0

Description

@mistercam
mistercam
opened on Mar 11, 2020
Issue body actions

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)

Activity

  1. jsotuyod
    added
    a:false-negativePMD doesn't flag a problematic piece of code
    in:symbol-tableAffects the symbol table code
    on Mar 11, 2020
  2. mistercam
    changed the title [-][java] ConstructorCallsOverridableMethod occurs when unused overloaded method is used[/-] [+][java] ConstructorCallsOverridableMethod occurs when unused overloaded method is defined[/+] on Mar 11, 2020
  3. adangel commented on Mar 12, 2020

    @adangel
    adangel
    on Mar 12, 2020
    Member
    More actions

    Another example:

    import java.util.Date;
    
    public class MyTimestamp {
        private final long t;
        public MyTimestamp() {
            t = new Date().getTime(); // <-- false-positive violation here
        }
        public long getTime() {
            return t;
        }
    }
  4. adangel
    added
    a:false-positivePMD flags a piece of code that is not problematic
    and removed
    in:symbol-tableAffects the symbol table code
    a:false-negativePMD doesn't flag a problematic piece of code
    on Sep 29, 2022
  5. adangel
    added this to the 6.50.0 milestone on Sep 29, 2022
  6. adangel
    added a commit that references this issue on Sep 29, 2022

    [doc] Update release notes (pmd#1718, pmd#2348)

    defb0cd
  7. adangel
    closed this as completedin #4101on Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      • 6.50.0

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      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.