Apache NetBeans version
Apache NetBeans 30
What happened
Editing java file, get the assigned value is never used. This is not accurate, should be no warning.
Language / Project Type / NetBeans Component
No response
How to reproduce
- Edit the following
class Warn
Observe the warning on the indicated line: data = switch(o) {
Note: it looks like the analysis is getting confused by the throw. Replace the throw, like with "j", and the warning goes away.
package com.raelity.play.warn;
public class Warn {
public void f()
{
String data = null;
Object o = g(null);
if (o != null) {
data = switch(o) { // warn: the assigned value is never used
case Integer _ -> "i";
default -> throw new IllegalArgumentException();
};
}
g(data);
}
Object g(Object o) {
return 1;
}
}
Did this work correctly in an earlier version?
No / Don't know
Operating System
Linux harmony 6.17.9-76061709-generic #202511241048176470475122.04~b24b425 SMP PREEMPT_DYNAMIC Tue D x86_64 x86_64 x86_64 GNU/Linux
JDK
openjdk version "26" 2026-03-17 OpenJDK Runtime Environment (build 26+35-2893) OpenJDK 64-Bit Server VM (build 26+35-2893, mixed mode, sharing)
Apache NetBeans packaging
Apache NetBeans binary zip
Anything else
No response
Are you willing to submit a pull request?
No
Apache NetBeans version
Apache NetBeans 30
What happened
Editing java file, get
the assigned value is never used. This is not accurate, should be no warning.Language / Project Type / NetBeans Component
No response
How to reproduce
class WarnObserve the warning on the indicated line:
data = switch(o) {Note: it looks like the analysis is getting confused by the
throw. Replace the throw, like with"j", and the warning goes away.Did this work correctly in an earlier version?
No / Don't know
Operating System
Linux harmony 6.17.9-76061709-generic #202511241048
176470475122.04~b24b425 SMP PREEMPT_DYNAMIC Tue D x86_64 x86_64 x86_64 GNU/LinuxJDK
openjdk version "26" 2026-03-17 OpenJDK Runtime Environment (build 26+35-2893) OpenJDK 64-Bit Server VM (build 26+35-2893, mixed mode, sharing)
Apache NetBeans packaging
Apache NetBeans binary zip
Anything else
No response
Are you willing to submit a pull request?
No