Respect @SuppressWarnings("unused") in editor highlighting of private constructors #9747
Description
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