A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J...

87
A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter Müller Microsoft Research Redmond

Transcript of A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J...

Page 1: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

A Universe-Type-Based Verification Technique for Mutable

Static Fields and Methods

Alexander J Summers Sophia Drossopoulou

Imperial College London

Peter Müller

Microsoft ResearchRedmond

Page 2: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

What is it all about?

►A new verification technique►Extend Visibility Technique

– handle static fields, methods and invariants

►Visible state semantics – safely handle/restrict call-backs

►Multiple-object invariants►Global data structures

– mutable static fields and static methods

►Expressive invariants: quantification over instances►Minimal code annotations using Universe Types

Page 3: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

Page 4: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

Page 5: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

Page 6: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

Page 7: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

Page 8: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

Page 9: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

Page 10: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

Page 11: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Universe types

►Describe relative location of objects

►Universe modifiersrep : an object I own, part of

my representation

Page 12: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Universe types

►Describe relative location of objects

►Universe modifiersrep : an object I own, part of

my representation

Page 13: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Universe types

►Describe relative location of objects

►Universe modifiersrep : an object I own, part of

my representation

Page 14: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Universe types

►Describe relative location of objects

►Universe modifiersrep : an object I own, part of

my representation

peer : an object with the same owner as me

Page 15: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Universe types

►Describe relative location of objects

►Universe modifiersrep : an object I own, part of

my representation

peer : an object with the same owner as me

Page 16: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Universe types

►Describe relative location of objects

►Universe modifiersrep : an object I own, part of

my representation

peer : an object with the same owner as me

any, readonly, lost, etc. : not in this paper

Page 17: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Universe types

►Describe relative location of objects

►Universe modifiersrep : an object I own, part of

my representation

peer : an object with the same owner as me

any, readonly, lost, etc. : not in this paper

Page 18: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Universe types

►Describe relative location of objects

►Universe modifiersrep : an object I own, part of

my representation

peer : an object with the same owner as me

any, readonly, lost, etc. : not in this paper

►All object references must respect ownership

Page 19: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Universe types

►Describe relative location of objects

►Universe modifiersrep : an object I own, part of

my representation

peer : an object with the same owner as me

any, readonly, lost, etc. : not in this paper

►All object references must respect ownership

Page 20: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Framework Paper (ECOOP 2008)

►Identifies 7 parameters to describe a techniqueX invariants expected at visible states of a method

V invariants vulnerable to execution of a method

D invariants which may depend on a particular field

B invariants which must be proven before a method call

E invariants which must be proven at end of a method call

U permitted receivers for field updates (who updates fields)

C permitted receivers for method calls (who calls who)

►Identifies 5 sufficient conditions, in terms of these– e.g., before a permitted method call, all invariants

expected by the new method which are not currently known to hold, must be proven

Page 21: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Visible State Semantics

►Invariants need only hold at ‘visible states’– beginning of a method call– end of a method call– may be temporarily broken in between

►Flexible, but must handle call-backs with care– avoid control returning to an object temporarily broken

►This problem can be avoided by:– avoiding ‘loops’ in sequences of calls, or,– requiring invariants to be proven before such calls

►Ensure expected invariants hold for a new receiver

Page 22: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Visibility Technique (Müller et al.)

Page 23: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Visibility Technique (Müller et al.)

►Calls are restricted

Page 24: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Visibility Technique (Müller et al.)

►Calls are restricted– calls ‘down’ to reps

Page 25: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Visibility Technique (Müller et al.)

►Calls are restricted– calls ‘down’ to reps

Page 26: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Visibility Technique (Müller et al.)

►Calls are restricted– calls ‘down’ to reps– calls ‘across’ to peers

Page 27: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Visibility Technique (Müller et al.)

►Calls are restricted– calls ‘down’ to reps– calls ‘across’ to peers

►Expect invariants of peers & transitive reps

Page 28: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Visibility Technique (Müller et al.)

►Calls are restricted– calls ‘down’ to reps– calls ‘across’ to peers

►Expect invariants of peers & transitive reps

Page 29: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Visibility Technique (Müller et al.)

►Calls are restricted– calls ‘down’ to reps– calls ‘across’ to peers

►Expect invariants of peers & transitive reps

Page 30: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Visibility Technique (Müller et al.)

►Calls are restricted– calls ‘down’ to reps– calls ‘across’ to peers

►Expect invariants of peers & transitive reps

Page 31: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Visibility Technique (Müller et al.)

►Calls are restricted– calls ‘down’ to reps– calls ‘across’ to peers

►Expect invariants of peers & transitive reps

Page 32: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Visibility Technique (Müller et al.)

►Calls are restricted– calls ‘down’ to reps– calls ‘across’ to peers

►Expect invariants of peers & transitive reps

►Calls down may leave invariants broken

Page 33: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Visibility Technique (Müller et al.)

►Calls are restricted– calls ‘down’ to reps– calls ‘across’ to peers

►Expect invariants of peers & transitive reps

►Calls down may leave invariants broken

Page 34: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Visibility Technique (Müller et al.)

►Calls are restricted– calls ‘down’ to reps– calls ‘across’ to peers

►Expect invariants of peers & transitive reps

►Calls down may leave invariants broken

Page 35: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Visibility Technique (Müller et al.)

►Calls are restricted– calls ‘down’ to reps– calls ‘across’ to peers

►Expect invariants of peers & transitive reps

►Calls down may leave invariants broken– temporarily

Page 36: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Visibility Technique (Müller et al.)

►Calls are restricted– calls ‘down’ to reps– calls ‘across’ to peers

►Expect invariants of peers & transitive reps

►Calls down may leave invariants broken– temporarily

Page 37: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Visibility Technique (Müller et al.)

►Calls are restricted– calls ‘down’ to reps– calls ‘across’ to peers

►Expect invariants of peers & transitive reps

►Calls down may leave invariants broken– temporarily– no calls ‘up’ are legal

Page 38: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Visibility Technique (Müller et al.)

►Calls are restricted– calls ‘down’ to reps– calls ‘across’ to peers

►Expect invariants of peers & transitive reps

►Calls down may leave invariants broken– temporarily– no calls ‘up’ are legal

►peer call-backs exist

Page 39: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Visibility Technique (Müller et al.)

►Calls are restricted– calls ‘down’ to reps– calls ‘across’ to peers

►Expect invariants of peers & transitive reps

►Calls down may leave invariants broken– temporarily– no calls ‘up’ are legal

►peer call-backs exist

Page 40: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Visibility Technique (Müller et al.)

►Calls are restricted– calls ‘down’ to reps– calls ‘across’ to peers

►Expect invariants of peers & transitive reps

►Calls down may leave invariants broken– temporarily– no calls ‘up’ are legal

►peer call-backs exist

Page 41: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Visibility Technique (Müller et al.)

►Calls are restricted– calls ‘down’ to reps– calls ‘across’ to peers

►Expect invariants of peers & transitive reps

►Calls down may leave invariants broken– temporarily– no calls ‘up’ are legal

►peer call-backs exist– extra proof obligations

Page 42: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Static fields and methods

►Static fields can control/refine instantiation of class– Restricting/counting number of instances (Singleton)– Maintaining invariants across all instances

• Instances of Thread are assigned unique identifiers– Sharing data across all instances

• String can maintain a ‘pool’ of shared instances for use

►Static fields are internal ‘representation’ of the class– Motivates static rep fields– Objects owned by classes (or objects)– Classes do not have owners themselves

►Static methods are methods of the class– Treat classes as potential receivers, like objects

Page 43: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

Page 44: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Classes in the topology

Page 45: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Classes in the topology

Page 46: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Classes in the topology – Classes may be owners

Page 47: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Classes in the topology – Classes may be owners

• Multiple trees

Page 48: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Classes in the topology – Classes may be owners

• Multiple trees• Static rep fields

Page 49: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Classes in the topology – Classes may be owners

• Multiple trees• Static rep fields

Page 50: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Classes in the topology – Classes may be owners

• Multiple trees• Static rep fields

Page 51: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Classes in the topology – Classes may be owners

• Multiple trees• Static rep fields

– Classes may be receivers • static methods

Page 52: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Classes in the topology – Classes may be owners

• Multiple trees• Static rep fields

– Classes may be receivers• static methods

– Same rules apply for instance method calls

Page 53: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Classes in the topology – Classes may be owners

• Multiple trees• Static rep fields

– Classes may be receivers• static methods

– Same rules apply for instance method calls

Page 54: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Classes in the topology – Classes may be owners

• Multiple trees• Static rep fields

– Classes may be receivers• static methods

– Same rules apply for instance method calls

Page 55: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Classes in the topology – Classes may be owners

• Multiple trees• Static rep fields

– Classes may be receivers• static methods

– Same rules apply for instance method calls

Page 56: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Classes in the topology – Classes may be owners

• Multiple trees• Static rep fields

– Classes may be receivers• static methods

– Same rules apply for instance method calls

– Expected invariants

Page 57: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Classes in the topology – Classes may be owners

• Multiple trees• Static rep fields

– Classes may be receivers• static methods

– Same rules apply for instance method calls

– Expected invariants• Current tree: as before

Page 58: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Classes in the topology – Classes may be owners

• Multiple trees• Static rep fields

– Classes may be receivers• static methods

– Same rules apply for instance method calls

– Expected invariants• Current tree: as before• Other unvisited trees

Page 59: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Classes in the topology – Classes may be owners

• Multiple trees• Static rep fields

– Classes may be receivers• static methods

– Same rules apply for instance method calls

– Expected invariants• Current tree: as before• Other unvisited trees

– Who calls static methods?

Page 60: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Classes in the topology – Classes may be owners

• Multiple trees• Static rep fields

– Classes may be receivers• static methods

– Same rules apply for instance method calls

– Expected invariants• Current tree: as before• Other unvisited trees

– Who calls static methods?

?

Page 61: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Classes in the topology – Classes may be owners

• Multiple trees• Static rep fields

– Classes may be receivers• static methods

– Same rules apply for instance method calls

– Expected invariants• Current tree: as before• Other unvisited trees

– Who calls static methods?

Page 62: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Classes in the topology – Classes may be owners

• Multiple trees• Static rep fields

– Classes may be receivers• static methods

– Same rules apply for instance method calls

– Expected invariants• Current tree: as before• Other unvisited trees

– Who calls static methods?

?

Page 63: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Who calls static methods?– class has no owner/peers– VT implies only self-calls– Unrestricted static calls?

• flexible, useful• source of call-backs

Page 64: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Who calls static methods?– class has no owner/peers– VT implies only self-calls– Unrestricted static calls?

• flexible, useful• source of call-backs

Page 65: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Who calls static methods?– class has no owner/peers– VT implies only self-calls– Unrestricted static calls?

• flexible, useful• source of call-backs

Page 66: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Who calls static methods?– class has no owner/peers– VT implies only self-calls– Unrestricted static calls?

• flexible, useful• source of call-backs

Page 67: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Who calls static methods?– class has no owner/peers– VT implies only self-calls– Unrestricted static calls?

• flexible, useful• source of call-backs

Page 68: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

►Who calls static methods?– class has no owner/peers– VT implies only self-calls– Unrestricted static calls?

• flexible, useful• source of call-backs

Page 69: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Heap topology

► Who calls static methods?– class has no owner/peers– VT implies only self-calls– Unrestricted static calls?

• flexible, useful• source of call-backs

► Idea to avoid call-backs:– A static method can only

be called if the class is not a prior receiver

– depends on call-stack– approximate with effects

Page 70: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Effect annotations

►Ensure that a class cannot receive a call-back►Annotate methods with a set effects(c,m)

– Our effects sets are sets of class-names– Which classes might have static methods called on them,

as a result of executing method m of class c?– Predict this set of classes (conservatively)

►Static method of c is legal only if c is not in effects►Effects sets can be computed iteratively►Further restriction necessary:

– An overridden method may not have any extra effects– Ensures effects conservatively predict runtime calls

Page 71: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Soundness (outline)

►If the invariants of an object (or class) do not hold, then either it or one of its peers must be a receiver somewhere on the call-stack.

►If an object o is a receiver on the call-stack, the most recently-preceding class receiver to o is the ‘root’ of the tree in which o resides.

►Effects are conservative: if a static method of c is called, c was in effects of all methods on the stack

►Call-backs to classes are restricted to self-calls.►Call-backs to objects are restricted to peer calls.►Proof obligations imposed are sufficient

Page 72: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Problematic example

Class MyClass extends Object { boolean equals(Object o) { System.out.println(new String(“equals”)); return (o == this); }}

Page 73: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Problematic example

Class MyClass extends Object { boolean equals(Object o) { System.out.println(new String(“equals”)); return (o == this); }}

►String must be in the effects of MyClass::equals()►String must be in the effects of Object::equals()►Annotation overhead problem►Information-hiding problem►Practicality problem

Page 74: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Levels

Page 75: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Levels

►Divide forest into (totally ordered) levels

Page 76: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Levels

►Divide forest into (totally ordered) levels

►Restriction: lower-level classes do not mention higher-level classes.

Page 77: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Levels

►Divide forest into (totally ordered) levels

►Restriction: lower-level classes do not mention higher-level classes.– Static method calls can

be made ‘down’ but not ‘up’

Page 78: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Levels

►Divide forest into (totally ordered) levels

►Restriction: lower-level classes do not mention higher-level classes.– Static method calls can

be made ‘down’ but not ‘up’

Page 79: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Levels

►Divide forest into (totally ordered) levels

►Restriction: lower-level classes do not mention higher-level classes.– Static method calls can

be made ‘down’ but not ‘up’

Page 80: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Levels

►Divide forest into (totally ordered) levels

►Restriction: lower-level classes do not mention higher-level classes.– Static method calls can

be made ‘down’ but not ‘up’

– Calls to lower levels can never result in call-backs

Page 81: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Levels

►Divide forest into (totally ordered) levels

►Restriction: lower-level classes do not mention higher-level classes.– Static method calls can

be made ‘down’ but not ‘up’

– Calls to lower levels can never result in call-backs

– Effects only computed for one level at a time

Page 82: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Levels

►Divide forest into (totally ordered) levels

►Restriction: lower-level classes do not mention higher-level classes.– Static method calls can be

made ‘down’ but not ‘up’– Calls to lower levels can

never result in call-backs– Effects only computed for

one level at a time

►MyClass is now legal

Page 83: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Soundness (outline)

►If c ≥ c’ then level(c) ≥ level(c’)►If an object o is transitively owned by c, and c’ is the

dynamic class of o, then level(c)≥level(c’)►If a sequence of legal calls can be made starting

from receiver r and ending with receiver r’, then level(r) ≥ level(r’)

►If a sequence of legal calls starts and ends with receiver r, then for all intermediate receivers r’, level(r’) = level(r)

►Effects sets for one level are enough to guarantee no call-backs to that level

Page 84: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Finally..

►We refine static invariants to allow quantification over instances– e.g., all Thread instances have distinct identifiers

►Use ECOOP paper to calculate necessary changes– Satisfy the 5 soundness conditions presented there– These imply sufficient changes to the 7 parameters

►Note: we allow static invariants to quantify over instances, whereas JML allows instance invariants to mention static fields– Similar expressiveness in logical terms– Different visible state semantics (future work)

Page 85: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Related work

►JML supports some statics and Universe Types– Limited support for both in combination– No static rep or peer fields: only readonly

►Leino and Müller extend Boogie technique to statics– supports static rep fields– refine work with a class ordering– restrictions on static initialisation

►Jacobs et. al. present modular verification for multithreaded programs in the context of Spec#– partially order locks, to avoid deadlock– similar to our levels, but without flexibility of effects

Page 86: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Possible future work

►Practicality: examples, case studies►Static initialisation

– Trees ‘appear’ in the topology– Rules for verifying static initialisers

►Formal definitions and proofs►Extend framework (ECOOP) to cover our technique

– formal proofs ‘for free’

►Cover static factory methods– Ownership Transfer

►Considering ‘levels’ for other problems►Path types to allow further flexibility

Page 87: A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.

Any questions?

Thank you for listening!