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] MissingStaticMethodInNonInstantiatableClass: False negative when method in nested class returns null · Issue #6343 · pmd/pmd

[java] MissingStaticMethodInNonInstantiatableClass: False negative when method in nested class returns null #6343

New issue
Copy link
New issue
Copy link
Closed
#6292
Closed
[java] MissingStaticMethodInNonInstantiatableClass: False negative when method in nested class returns null#6343
#6292
Copy link
Labels
a:false-negativePMD doesn't flag a problematic piece of code
Milestone
7.20.0

Description

@adangel
adangel
opened on Dec 19, 2025
Issue body actions

Affects PMD Version: 7.19.0

Rule: MissingStaticMethodInNonInstantiatableClass

Description:
When there is a nested class that has a method that returns null, then the rule considers this wrongly as a builder method which returns an instance of the outer class.

This is due to currently that null is considered to be compatible with any type, which is not correct. With the changes in #6292 this will be corrected.

Code Sample demonstrating the issue:

public class MyClass {

    private MyClass() {
    }

    public static class NotABuilder {

        private NotABuilder() {}

        public NotABuilder notABuilder() {
            return null;
        }
    }
}

Expected outcome:

PMD should report a violation at line 1, but doesn't. This is a false-negative.

Activity

  1. adangel
    added
    a:false-negativePMD doesn't flag a problematic piece of code
    on Dec 19, 2025
  2. adangel
    added this to the 7.20.0 milestone on Dec 19, 2025
  3. adangel
    added a commit that references this issue on Dec 19, 2025

    [java] MissingStaticMethodInNonInstantiatableClass: Test for pmd#6343

    5b61ebd
  4. adangel
    closed this as completedin #6292on Dec 19, 2025
  5. adangel
    added a commit that references this issue on Dec 19, 2025

    [doc] Update release notes (#6291, #6343, #6292)

    d348ab7
  6. wener-tiobe
    added a commit that references this issue on Feb 10, 2026

    RM-37163: CPD 7.21.0 upgrade (#8)

    6a1959a
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-negativePMD doesn't flag a problematic piece of code

    Type

    No type

    Projects

    No projects

      Milestone

      • 7.20.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.