netbeans
netbeans copied to clipboard
False positive for "Unused Element" hint on overriding package-private method
Apache NetBeans version
Apache NetBeans 15
What happened
Example Java source code:
public abstract class AbstractBase
{
abstract void method();
static
{
AbstractBase base = new Derived();
base.method();
}
}
final class Derived extends AbstractBase
{
@Override
void method() { return; } // (*)
}
NetBeans shows a warning and hint 'Remove unused "method"' on the overriding method() (*) in the Derived class, This is incorrect, because clearly the method is being used, via the AbstractBase type. The usage analysis apparently doesn't take overridden methods into account.
NetBeans 12.2 (which I used previously) does not show that warning, although it does support the same hint ("Unused Element"). So this appears to be a regression.
How to reproduce
See example source code above.
Did this work correctly in an earlier version?
Apache NetBeans 12.3 or earlier
Operating System
Windows 10 Enterprise 22H1
JDK
Oracle JDK 8u271
Apache NetBeans packaging
Apache NetBeans provided installer
Anything else
No response
Are you willing to submit a pull request?
No
Code of Conduct
Yes