Skip to content

Commit eba0289

Browse files
committed
Update Docs
1 parent 9fb2510 commit eba0289

2 files changed

Lines changed: 3 additions & 7 deletions

File tree

pages/annotations/ghosts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ s.pop();
3939
s.pop(); // State Refinement Error
4040
```
4141

42-
In the "constructor" method, the ghost variable `size` is initialized to `0`. An equality in a method postcondition is how ghost variables are updated. In this case, the explicit postcondition is optional, because if no postcondition is declared the ghost variable is initialized to its default value, similarly to how Java initializes fields with no explicit initializer (`int -> 0`, `boolean -> false`, and so on).
42+
In the "constructor" method, the ghost variable `size` is initialized to `0`. An equality in a method postcondition is how ghost variables are updated. If no initial value is declared, the ghost variable is initialized to its default value, similarly to how Java initializes fields with no explicit initializer (`int -> 0`, `boolean -> false`, and so on).
4343

4444
In the `push` method, we specify no precondition, since we can always push an element to the stack, but we specify a postcondition that increments the `size` by one. In this case, we tell the typechecker that the new value of `size` after calling `push` is equal to the old value of `size` plus one. This is possible using the `old` function, which takes an object instance and returns its value before the method call.
4545

pages/annotations/state-refinements.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,8 @@ public class Buffer {
5656
}
5757
```
5858

59-
If no `to` transition is declared, LiquidJava defaults the constructor to the first state listed in the corresponding `@StateSet`.
60-
61-
Constructors must always be present for typestate checking to work correctly, because they are the point where the initial state values are assigned. Otherwise, the initial values are not set and the verifier won't be able to track the state of the object across method calls.
62-
63-
When refining interfaces, which cannot have a constructor, LiquidJava still needs an initialization point. In those cases, the refinement interface must declare a method whose name matches the class we are refining. For example, an interface named `ArrayListRefinements` that is refining `java.util.ArrayList` should declare the method `public void ArrayList()`. This method plays the role of a constructor for the typestate system and ensures the initial values are set correctly.
64-
59+
If no `to` transition is declared, LiquidJava defaults the constructor to the first state of each state set.
60+
When refining interfaces, which cannot have constructors, a method whose name matches the target class or interface can be used to play the role of a constructor. For example, an interface named `ArrayListRefinements` that is refining the class `java.util.ArrayList` can declare the method `public void ArrayList()` for setting the initial state.
6561

6662
## Multiple State Sets
6763

0 commit comments

Comments
 (0)