Files
openide/java/java-tests/testData/inspection/dataFlow/fixture/StaticFieldInAnonymous.java
Tagir Valeev a813ef19b5 [java-dfa] FieldChecker: correctly find parent method if we are inside static analyzer
DfaPsiUtil.getBlockNotNullFields may run DFA for static initializer block. If it happens to be a local/anonymous class inside a method, that outer method was incorrectly used as a context. This caused wrong state of FieldChecker and might eventually lead to StackOverflowError.

GitOrigin-RevId: a96b4527cb03d77160be3579935e47d79bfca48c
2021-10-13 11:24:45 +00:00

16 lines
324 B
Java

public class StaticFieldInAnonymous {
void test() {
Runnable r = new Runnable() {
private static final String s;
static {
s = "foo";
}
@Override
public void run() {
if (<warning descr="Condition 's == null' is always 'false'">s == null</warning>) {}
}
};
}
}