Debian Codegraph @

framework/tests/all-systems/InstanceOf.java

raw
1 /* This example causes an error when computing the GLB of two types
2 * because the GLB is empty. */
3
4 class FieldInstruction {}
5
6 class GETFIELD extends FieldInstruction {}
7
8 class PUTFIELD extends FieldInstruction {}
9
10 class InstanceOf {
11 public void emptyGLB(FieldInstruction f) {
12 if (f instanceof GETFIELD || f instanceof PUTFIELD) {
13 if (f instanceof PUTFIELD) {
14 // During org.checkerframework.dataflow analysis, we can believe that f is both a
15 // GETFIELD and a PUTFIELD, which yields an empty GLB. Once
16 // org.checkerframework.dataflow converges, it will know that f is a PUTFIELD.
17 return;
18 }
19 return;
20 }
21 }
22
23 public boolean assignInstanceOf(Object obj) {
24 // We fixed a bug where the type in an instanceof expression
25 // like Class<?> was stored as the abstract value result of
26 // the expression.
27 boolean is_class = obj instanceof Class<?>;
28 return is_class;
29 }
30 }