Cascade: A Universal Programmer-assisted Type Qualifier Inference - - PowerPoint PPT Presentation

cascade a universal programmer assisted type qualifier
SMART_READER_LITE
LIVE PREVIEW

Cascade: A Universal Programmer-assisted Type Qualifier Inference - - PowerPoint PPT Presentation

Cascade: A Universal Programmer-assisted Type Qualifier Inference Tool Mohsen Vakilian* Amarin Phaosawasdi* Michael D. Ernst Ralph E. Johnson* *University of Illinois at Urbana-Champaign 1 University of Washington Type qualifiers


slide-1
SLIDE 1

Cascade: A Universal Programmer-assisted Type Qualifier Inference Tool

Mohsen Vakilian*

1

Amarin Phaosawasdi* Michael D. Ernst† Ralph E. Johnson*

*University of Illinois at Urbana-Champaign

†University of Washington

slide-2
SLIDE 2

Type qualifiers allow additional static type checks

static int oldSubindex(@Nullable MathVector ic, int l) { int i = 0; for (int k = 0; k < MathVector.NDIM; k++) { if (((int) ic.value(k) & l) != 0) i += Cell.NSUB >> (k + 1); } return i; }

2

slide-3
SLIDE 3

◼ Locking ◼ Aliasing ◼ Interning ◼ Immutability ◼ Tainting

*checkerframework.org

Java 8 supports custom type systems*

3

slide-4
SLIDE 4

◼ Locking ◼ Aliasing ◼ Interning ◼ Immutability ◼ Tainting

*checkerframework.org

Java 8 supports custom type systems*

4

+ additional static checks

slide-5
SLIDE 5

◼ Locking ◼ Aliasing ◼ Interning ◼ Immutability ◼ Tainting

*checkerframework.org

Java 8 supports custom type systems*

5

+ additional static checks

  • additional code annotation
slide-6
SLIDE 6

The manual annotation process is tedious

6

Run type checker

slide-7
SLIDE 7

The manual annotation process is tedious

7

Add or remove qualifiers Run type checker

slide-8
SLIDE 8

The manual annotation process is tedious

8

Add or remove qualifiers Refactor code Run type checker

slide-9
SLIDE 9

Type qualifier inference tools run in batch mode

9

Infer

Program Annotated program

slide-10
SLIDE 10

Type qualifier inference tools run in batch mode

10

Nullness

Julia, Nit, JastAddJ Nullness, SALSA Nullness, Xylem, Daikon Nullness

Immutability

Javarifier, Pidasai, ReImInfer

Ownership

Universe and Ownership Type Inference System

Infer

Program Annotated program

slide-11
SLIDE 11

Type qualifier inference tools run in batch mode

11

◼ Optimal under certain conditions ◼ Large change without user involvement

Strengths Infer

Program Annotated program

slide-12
SLIDE 12

Type qualifier inference tools run in batch mode

12

Weaknesses

◼ Limited to one set of qualifiers ◼ Unpredictable ◼ Rigid ◼ Inaccurate

Infer

Program Annotated program

slide-13
SLIDE 13

Type qualifier inference tools run in batch mode

13

Run type checker Add or remove qualifiers Refactor code Infer

Program Annotated program

slide-14
SLIDE 14

Type qualifier inference tools run in batch mode

14

Run type checker Add or remove qualifiers Refactor code Infer

Program Annotated program

Automate!

slide-15
SLIDE 15

Type qualifier inference tools run in batch mode

15

Run type checker Add or remove qualifiers Refactor code Infer

Program Annotated program

Human insight needed

slide-16
SLIDE 16

Batch-mode tools make arbitrary decisions

16

slide-17
SLIDE 17

17

slide-18
SLIDE 18

18

BUG

slide-19
SLIDE 19

Batch-mode tools make arbitrary decisions

19

BUG

slide-20
SLIDE 20

Type qualifier inference is a refactoring

◼ Adding type qualifiers preserves the program behavior ◼ Adding maintainable type qualifiers

that match the programmer's intention requires code refactoring

20

slide-21
SLIDE 21

Cascade: A Universal Programmer-assisted Type Qualifier Inference Tool

21

Type Inference Type Checker

Cascade

slide-22
SLIDE 22

Cascade: A Universal Programmer-assisted Type Qualifier Inference Tool

22

Speculative Analysis Compositional Refactoring

Cascade

slide-23
SLIDE 23

Inferring Primitive Changes from Error Messages

23

Type Checker Error Fix

incompatible types in argument. root = root.loadTree(q, xqic); ^ found : @Nullable MathVector required: @NonNull MathVector

Nullness

slide-24
SLIDE 24

Inferring Primitive Changes from Error Messages

24

Type Checker Error Fix

incompatible types in argument. root = root.loadTree(q, xqic); ^ found : @Nullable MathVector required: @NonNull MathVector Change parameter xpic

  • f loadTree() to

@Nullable MathVector

Nullness

slide-25
SLIDE 25

Inferring Primitive Changes from Error Messages

25

Type Checker Error Fix

incompatible types in argument. root = root.loadTree(q, xqic); ^ found : @Nullable MathVector required: @NonNull MathVector Change parameter xpic

  • f loadTree() to

@Nullable MathVector

Nullness

call to value(int) not allowed

  • n the given receiver.

ic.value(k); ^ found : @ReadOnly MathVector required: @Mutable MathVector

Mutability

slide-26
SLIDE 26

Inferring Primitive Changes from Error Messages

26

Type Checker Error Fix

incompatible types in argument. root = root.loadTree(q, xqic); ^ found : @Nullable MathVector required: @NonNull MathVector Change parameter xpic

  • f loadTree() to

@Nullable MathVector

Nullness

call to value(int) not allowed

  • n the given receiver.

ic.value(k); ^ found : @ReadOnly MathVector required: @Mutable MathVector Change receiver parameter

  • f value() to

@ReadOnly MathVector

Mutability

slide-27
SLIDE 27

Speculative analysis suggests a change composition

27

slide-28
SLIDE 28

Speculative analysis suggests a change composition

28

slide-29
SLIDE 29

Speculative analysis suggests a change composition

29

slide-30
SLIDE 30

Speculative analysis suggests a change composition

30

slide-31
SLIDE 31

Cascade Tree

31

slide-32
SLIDE 32

Cascade Tree

32

slide-33
SLIDE 33

Cascade Tree

33

slide-34
SLIDE 34

34

slide-35
SLIDE 35

35

slide-36
SLIDE 36

36

slide-37
SLIDE 37

The speculative analysis computes a tree recursively

37

p e1

Program Error

slide-38
SLIDE 38

The speculative analysis computes a tree recursively

38

p c1 e1

Program Error Fix

slide-39
SLIDE 39

The speculative analysis computes a tree recursively

p c1 e1 c1(p) e2 e3

Program Error

39

Fix

slide-40
SLIDE 40

The speculative analysis computes a tree recursively

40

p c1 e1 c1(p) c2 e2 c3 e3

Program Error Fix

slide-41
SLIDE 41

The speculative analysis computes a tree recursively

41

p c1 e1 c1(p) c2 e2 c3 e3 c3(c1(p)) c2(c1(p))

Program Error

e3 e4

Fix

slide-42
SLIDE 42

A change is represented as an AST path

42

Primitive Change Representation Variable Decl. Fixer Compilation Unit + Variable

  • Decl. + New Type

Method Return Fixer Compilation Unit + Method

  • Decl. + New Type

Method Receiver Fixer Compilation Unit + Method

  • Decl. + New Type
slide-43
SLIDE 43

Research Questions

How does Cascade compare with Julia, a batch qualifier inference tool?

◼ Learnability ◼ Quality of results ◼ Task completion time ◼ Control over process ◼ Willingness to use

43

slide-44
SLIDE 44

User study

Subjects:

◼ 12 computer science graduate students

from 9 different research labs

◼ Familiar with Java and Eclipse ◼ Average of 10 years of programming experience

44

slide-45
SLIDE 45

Training

◼ Nullness Checker ◼ Julia ◼ Cascade

45

github.com/reprogrammer/tqi-study

slide-46
SLIDE 46

Task Design

46

Julia then Cascade Cascade then Julia MST then BH 3 participants 3 participants BH then MST 3 participants 3 participants

BH

Barnes-Hut, a hierarchical force-calculation algorithm

MST

Bentley’s algorithm for finding the minimum spanning tree of a graph

slide-47
SLIDE 47

Users complete tasks faster with Cascade

t test

◼ p = 0.01 ◼ Cohen’s d = 1.13

47

slide-48
SLIDE 48

Users added less inaccurate annotations with Cascade

48

BH + MST Julia Cascade Correct 13.9 9.6 Incorrect 2.8 0.1 Redundant 1.7 0.4 Unnecessary warning suppressions 7.2

slide-49
SLIDE 49

Postquestionnaire Results

49

Questions (T = Julia or Cascade) Cascad e better Equal Rating Julia better I found T easy to learn. 3 6 3 I know why T inserted each annotation. 8 4 Using T, I have control

  • ver the process of

annotating the code. 9 3 I'm willing to use T in the future. 11 1

slide-50
SLIDE 50

Qualitative Interview Results

The participants believe that:

◼ Cascade's speculative analysis is useful (N = 8). ◼ Cascade is more predictable (N = 7). ◼ Cascade's tree computation is slow (N = 5). ◼ The overhead of fixing Julia's annotations is high (N = 7).

50

slide-51
SLIDE 51

Future Work

◼ Improve the performance of Cascade. ◼ Evaluate compositional refactoring and Cascade in the field. ◼ Make Cascade support bidirectional speculative analysis.

51

slide-52
SLIDE 52

Cascade: A Universal Type Qualifier Inference Tool

◼ Cascade is easy to use and helps users complete tasks fast. ◼ Compositional refactoring and speculative analysis. ◼ Less is sometimes more in the automation of software evolution tasks.

◼ More automation is not always better ◼ Some tasks need problem-solving and creativity ◼ Applicable to other fields

52