You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/06/21 13:59:58 UTC
[GitHub] [netbeans] sviperll opened a new issue, #4260: Throwable values used as switch argument are considered unused
sviperll opened a new issue, #4260:
URL: https://github.com/apache/netbeans/issues/4260
### Apache NetBeans version
Apache NetBeans 14
### What happened
Throwable values used as arguments of a switch-statement (with pattern matching) are considered unused.
````java
Throwable cause = ...; // WARNING: unused local variable
switch (cause) {
case IOException ex -> throw ex;
case Throwable ex -> throw new UnexpectedException(ex);
}
````
similar behavior is observed when throwable-returning methods are used:
````java
try {
} catch (InvocationTargetException ex) {
switch (ex.getCause()) { // WARNING: the result of throwable returning method is ignored
case IOException ex -> throw ex;
case Throwable ex -> throw new UnexpectedException(ex);
}
}
````
I expect that no warning are generated in both cases, because the values are actually used.
### How to reproduce
Any code written with JDK 18 that follows the pattern described above forces NetBeans to generate warnings/hints.
### Did this work correctly in an earlier version?
No
### Operating System
Fedora 34
### JDK
JDK 18
### Apache NetBeans packaging
Apache NetBeans binary zip
### Anything else
The problem is stable and occurs all the time.
### Are you willing to submit a pull request?
No
### Code of Conduct
Yes
--
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: notifications-unsubscribe@netbeans.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists