Static field used before initialization
Reports static
variables that are read before initialization.
The inspection ignores equality checks with null
.
Example:
class Foo {
public static int bar;
public static void main(String[] args) {
System.out.println(bar);
}
}
Note that this inspection uses a very conservative dataflow algorithm and may incorrectly report static
variables as uninitialized. Variables reported as initialized will always be initialized.
Use the Ignore primitive fields option to ignore uninitialized primitive fields.
Inspection options
Option | Type | Default |
---|---|---|
Ignore primitive fields | Checkbox | false |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |
Last modified: 13 July 2023