Skip to content

Respect @SuppressWarnings("unused") in editor highlighting of private constructors #9747

Open

Description

@stefike69

Apache NetBeans version

Apache NetBeans 31

What happened

In Apache NetBeans 29, an intentionally empty private constructor is marked as unused:

public class Connect {
  @SuppressWarnings("unused")
  private Connect() {
  }

  public static void open() {
  }
}

The private constructor deliberately prevents instantiation of a class used through static methods.

Adding @SuppressWarnings("unused") removes the yellow hint indicator, but the constructor remains underlined as unused.

Expected behavior: the annotation should suppress the unused-element underline as well. An empty private constructor together with explicit suppression clearly indicates intentional non-use.

Disabling unused-element highlighting globally is unsuitable because it hides useful feedback elsewhere.

Environment: Apache NetBeans 29, JDK 25, Windows.

Language / Project Type / NetBeans Component

No response

How to reproduce

In Apache NetBeans 29, an intentionally empty private constructor is marked as unused:

public class Connect {
  @SuppressWarnings("unused")
  private Connect() {
  }

  public static void open() {
  }
}

The private constructor deliberately prevents instantiation of a class used through static methods.

Adding @SuppressWarnings("unused") removes the yellow hint indicator, but the constructor remains underlined as unused.

Expected behavior: the annotation should suppress the unused-element underline as well. An empty private constructor together with explicit suppression clearly indicates intentional non-use.

Disabling unused-element highlighting globally is unsuitable because it hides useful feedback elsewhere.

Environment: Apache NetBeans 29, JDK 25, Windows.

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows 10

JDK

jdk-21.0.11

Apache NetBeans packaging

Apache NetBeans binary zip

Anything else

Every times

Are you willing to submit a pull request?

No

Activity

  1. added
    Java[ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)
    on Oct 25, 2026
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

    Java[ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)kind:bugBug report or fixneeds:triageRequires attention from one of the committers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions