You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The nullness checker appears to be unable to determine that mutators do not modify a given variable. A minimal example that can be used to prove this:
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.ArrayList;
class Foo {
static class Bar {
Object a = new Object();
void mutate() { a = new Object(); }
}
Bar b = new Bar();
@Nullable Object o = null;
void foo() {
if (o == null) return;
b.mutate();
o.hashCode();
}
}
The real-world example where this came up was something like:
List<Node> nodes = new ArrayList<>();
InterestingType a = null;
void loop() {
...
if (a == null) {
a = nonNullThing;
nodes.add(buildNode());
a.doThing();
}
...
}
The text was updated successfully, but these errors were encountered:
The nullness checker appears to be unable to determine that mutators do not modify a given variable.
While checking one method, the Nullness Checker does not do inference of side effects for other methods.
Rather, the Nullness Checker verifies programmer-written annotations.
I remember that it took me a long time to track this down. Is there any way to perhaps propagate this information up to the resulting error, so that users at least know where to look?
The nullness checker appears to be unable to determine that mutators do not modify a given variable. A minimal example that can be used to prove this:
The real-world example where this came up was something like:
The text was updated successfully, but these errors were encountered: