Inference of Field Initialization
Fausto Spoto and Michael D. Ernst
University of Verona, Italy & University of Washington, USA
Honolulu, May 25, 2011, ICSE
1 / 8
Inference of Field Initialization Fausto Spoto and Michael D. Ernst - - PowerPoint PPT Presentation
Inference of Field Initialization Fausto Spoto and Michael D. Ernst University of Verona, Italy & University of Washington, USA Honolulu, May 25, 2011, ICSE 1 / 8 Clever tracking of windows by name (from a real story) public class MyWindow
1 / 8
2 / 8
3 / 8
4 / 8
5 / 8
6 / 8
7 / 8
8 / 8
9 / 8
10 / 8
11 / 8
12 / 8
13 / 8
1 define a concrete operational semantics of a Java-like language 2 define a constraint-based abstract interpretation of that
3 prove them related by a correctness relation 4 use our abstract interpretation as an inference engine for
5 measure its precision by using nullness analysis
14 / 8
load 0 of type MyWindow call javax.swing.JWindow.<init>():void catch throw java.lang.Throwable load 0 of type MyWindow load 1 of type java.lang.String putfield MyWindow.name:java.lang.String load 0 of type MyWindow const 1 call MyWindow.setVisible(boolean):void return void
15 / 8
uninit
name
value count
12 µ
locals stack
< [this,name], , > this
16 / 8
uninit
name
value count
12 µ
locals stack
< [this,name], this , > ::name
17 / 8
value count
12
name
ε µ
locals stack
< [this,name], , >
18 / 8
19 / 8
20 / 8
21 / 8
name
value count
locals stack
name
value count
locals stack
value count
name
locals stack
load 0 of type MyWindow call javax.swing.JWindow.<init>():void catch throw java.lang.Throwable load 0 of type MyWindow load 1 of type java.lang.String putfield MyWindow.name:java.lang.String load 0 of type MyWindow const 1 call MyWindow.setVisible(boolean):void return void
25 / 8
load 0 of type MyWindow call javax.swing.JWindow.<init>():void catch throw java.lang.Throwable load 0 of type MyWindow load 1 of type java.lang.String putfield MyWindow.name:java.lang.String load 0 of type MyWindow const 1 call MyWindow.setVisible(boolean):void return void
26 / 8
load 0 of type MyWindow call javax.swing.JWindow.<init>():void catch throw java.lang.Throwable load 0 of type MyWindow load 1 of type java.lang.String putfield MyWindow.name:java.lang.String load 0 of type MyWindow const 1 call MyWindow.setVisible(boolean):void return void
27 / 8
constant node containing all sj sj s(j+1) s0 s0 li li l0 l0
program point p program point q fields of C and of its superclasses 28 / 8
sj s0 li l0 l0 li s0 sj program point p program point q s(j+1) 29 / 8
sj s0 li lk l0 l0 lk li s0 sj s(j+1)
program point p program point q 30 / 8
sj s(j−1) s0 s0 s(j−1) li li lk lk l0 l0
program point p program point q
31 / 8
program point q program point p
sj sj s0 s0 li li l0 l0 f
stored in f in the objects fields uninitialized
32 / 8
sj f s(j−1) s(j−2) s(j−2) s0 s0 li li lk lk l0 l0
program point p program point q
stack locals
stored in f in the objects fields uninitialized
33 / 8
ret@m sj sj s0 s0 li li l0 l0
program point p program point q
in the returned values of m fields uninitialized 34 / 8
returned value
ret@m
sj s(j−k+1) s(j−k) s0 li l0 l0 li s0 s(j−k) s(j−k+1) l0 l(k−1)
program point p program point q fields uninitialized in the returned values of m
35 / 8
load 0 of type MyWindow call javax.swing.JWindow.<init>():void [public javax.swing.JWindow.<init>():void] catch throw java.lang.Throwable load 0 of type MyWindow load 1 of type java.lang.String putfield MyWindow.name:java.lang.String [private final MyWindow.name:java.lang.String] load 0 of type MyWindow const 1 call MyWindow.setVisible(boolean):void [public java.awt.Window.setVisible(boolean):void] return void
36 / 8
load 0 of type MyWindow call javax.swing.JWindow.<init>():void [public javax.swing.JWindow.<init>():void] catch throw java.lang.Throwable load 0 of type MyWindow load 1 of type java.lang.String putfield MyWindow.name:java.lang.String [private final MyWindow.name:java.lang.String] load 0 of type MyWindow const 1 call MyWindow.setVisible(boolean):void [public java.awt.Window.setVisible(boolean):void] return void
37 / 8
load 0 of type MyWindow call javax.swing.JWindow.<init>():void [public javax.swing.JWindow.<init>():void] catch throw java.lang.Throwable load 0 of type MyWindow load 1 of type java.lang.String putfield MyWindow.name:java.lang.String [private final MyWindow.name:java.lang.String] load 0 of type MyWindow const 1 call MyWindow.setVisible(boolean):void [public java.awt.Window.setVisible(boolean):void] return void
38 / 8
39 / 8
40 / 8
41 / 8
42 / 8
43 / 8
44 / 8
45 / 8
46 / 8
47 / 8
48 / 8