nmatt opened a new issue, #9168:
URL: https://github.com/apache/netbeans/issues/9168
### Apache NetBeans version
Apache NetBeans 28
### What happened
Example:
```java
class Example
{
public void testA() { doIt(this::methodA); }
private void methodA(String unusedA) { System.out.println("A"); }
// warning here: ^^^^^^^
interface Interface { void method(String param); }
static void doIt(Interface impl) { impl.method("test"); }
public void testB() { doIt(this::methodB); }
void methodB(String unusedB) { System.out.println("B"); }
public void testC() { doIt(unusedC -> { System.out.println("C"); }); }
public void testD() { doIt(implD); }
private final Interface implD = unusedD -> { System.out.println("D"); };
public void testE() { doIt(implE); }
private final Interface implE = new Interface() { @Override public void
method(String unusedE) { System.out.println("E"); } };
public void testF() { doIt(new Interface() { @Override public void
method(String unusedF) { System.out.println("F"); } }); }
}
```
Parameter `unusedA` incorrectly shows a warning "Variable unusedA is never
read".
For comparison, parameter `unusedB` correctly does _not_ show the warning,
even though `methodB` isn't otherwise used in the packacke. Cases C to F
illustrate further variations of providing an interface implementations where
correctly also no warning is shown for the unused parameters.
A method reference effectively turns the referenced method definition into
the implementation of an abstract method. Unused parameters in implementations
of abstract methods generally do not cause a warning, because it is normal that
not all implementations need all parameters. Therefore one would expect there
to be no warning here either, in presence of a method reference.
### Language / Project Type / NetBeans Component
Java, Hints
### How to reproduce
See example above.
### Did this work correctly in an earlier version?
No / Don't know
### Operating System
Windows
### JDK
JDK 21
### Apache NetBeans packaging
Apache NetBeans binary zip
### Anything else
_No response_
### Are you willing to submit a pull request?
No
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists