-
Notifications
You must be signed in to change notification settings - Fork 905
Open
Labels
Java[ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)[ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)hintskind:bugBug report or fixBug report or fix
Description
Apache NetBeans version
Apache NetBeans 14
What happened
Throwable values used as arguments of a switch-statement (with pattern matching) are considered unused.
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:
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
Metadata
Metadata
Assignees
Labels
Java[ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)[ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)hintskind:bugBug report or fixBug report or fix