1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
import javax.swing.JMenuBar;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.checker.nullness.qual.RequiresNonNull;
public abstract class FlowExpressionParsingBug {
//// Check that flow expressions with explicit and implicit 'this' work
protected @Nullable JMenuBar menuBar = null;
@RequiresNonNull("menuBar")
public void addFavorite() {}
@RequiresNonNull("this.menuBar")
public void addFavorite1() {}
//// Check flow expressions for static fields with different ways to access the field
static @Nullable String i = null;
@RequiresNonNull("FlowExpressionParsingBug.i")
public void a() {}
@RequiresNonNull("i")
public void b() {}
@RequiresNonNull("this.i")
public void c() {}
void test1() {
// :: error: (contracts.precondition.not.satisfied)
a();
FlowExpressionParsingBug.i = "";
a();
}
void test1b() {
// :: error: (contracts.precondition.not.satisfied)
a();
i = "";
a();
}
void test1c() {
// :: error: (contracts.precondition.not.satisfied)
a();
this.i = "";
a();
}
void test2() {
// :: error: (contracts.precondition.not.satisfied)
b();
FlowExpressionParsingBug.i = "";
b();
}
void test2b() {
// :: error: (contracts.precondition.not.satisfied)
b();
i = "";
b();
}
void test2c() {
// :: error: (contracts.precondition.not.satisfied)
b();
this.i = "";
b();
}
void test3() {
// :: error: (contracts.precondition.not.satisfied)
c();
FlowExpressionParsingBug.i = "";
c();
}
void test3b() {
// :: error: (contracts.precondition.not.satisfied)
c();
i = "";
c();
}
void test3c() {
// :: error: (contracts.precondition.not.satisfied)
c();
this.i = "";
c();
}
}
|