200 likes | 297 Views
Disscussion: Semantic Issues for JML. Gary T. Leavens University of Central Florida Support from US National Science Foundation Dagstuhl, July 14, 2009. jmlspecs.org. www.eecs.ucf.edu/~leavens. Decisions and Discussions. In email of 11 July: Decisions made and implemented
E N D
Disscussion: Semantic Issues for JML Gary T. LeavensUniversity of Central Florida Support from US National Science FoundationDagstuhl, July 14, 2009 jmlspecs.org www.eecs.ucf.edu/~leavens
Decisions and Discussions In email of 11 July: • Decisions made and implemented • Decisions, documented, but not fully implemented • Decisions made but not documented or implemented • Discussions on open issues • Rejections
Discussions Procedure we’ll follow: • Non-controversial, passed if no one objects, someone documents… • Controversial,we’ll pass along discussion & recommendation • approved --> non-controversial (see above) • rejected --> report that
Discussions, non-controversial (?) • Drop <- from syntax for represents, use = protected represents x =_x/2; • Use <# and <#= for lock ordering • Allow comprehension expressions to use contains(), not just has() • \elemtype(null) is a null pointer exception,\elemtype(nonArray) is illegal arg exception,both technically undefined.
Discussions, non-controversial (?) • New expression \let spec-var-declarators\in spec-expression Examples: \letint fv = \old(theThing(v+y).f) \in fv + fv \letint fv = \old(x.f) \in fv + fv
Discussions, non-controversial (?) • Allow all specification expressions in model methods publicmodel sum2(int[] a) { return 2 * (\sum int j; 0<=j && j<a.length; a[j]); } Hard to implement in RAC?
Discussions, non-controversial (?) • Invariant enforcement for method calls that occur in constructor’s cflow • Object “dented” until construction finished • invariant implicitly !dented ==> inv Against this: you could program it yourself… (Same as “raw”?)
Discussions, non-controversial (?) • Privacy restrictions on specifications for modular reasoning (Leavens & Müller 2007) • For maintenance, don’t expose code details • For soundness, document obligations Specifications visible to module M: • Can only mention members visible to M • For maintenance • For understandability • Must contain all of M’s obligations • For sound modular verification
Discussions, non-controversial (?) • Use relevant semantics for framing, invariants(Müller, et al., various papers) • If you don’t use universes, same as current • Using universes, only object’s universe and owned objects relevant, higher abstraction levels aren’t • Can only refer to rep fields in invariants Alternatives: • Boogie methodology in Spec# • Others?
Discussions What user-visible syntax for JML? • Classic JML with /*@ … @*/ and //@ • Taylor’s annotation syntax (with dollar signs) @SpecCase(header="public normal_behavior", ensures=“$result <==> size == MAX_SIZE;") @Pure public boolean isFull(); • Alagic’s XVP annotations: @JML(“…”) • …
Discussions What user-visible syntax for JML? • … • Java contracts public abstract @Pure boolean isFull(); … public @Pure void isFull$jc(boolean $result) { $specCase(PUBLIC, NORMAL); { $ensures($result == (size() == MAX_SIZE())); } } • Some combination?
Possible Combination Syntax • Start with Classic JML syntax • Replace all modifiers (pure, spec_public, …)with Java annotations (@Pure, @SpecPublic,…) • Replace model fields and represents clauseswith @Pure @Model 0-argument Java methods • Replace model features with @Model Java features • Replace \oper(…) with JML.$oper() • Replace method specification annotations with @JML(“…”) Java 5 annotations. • More? Variations?
Discussions • General method for adding extensions? ext_KeY_... keywords?
Discussions • Simplify the set of suffixes we use for JML specification files?
Discussions • Method caller must satisfy precondition ofreceiver’s static type.
Discussions • Prohibit using instance fields of object being constructed in constructor preconditions?
Discussions • Loosen the rules on the \sum and \product quantifier expressions, to allow other types in the body. • Loosen the rules on the \max and \min quantifier expressions, to allow any Comparable type in the body
Discussions • How should Java's generics be handled? • Should \TYPE still be equal to java.lang.Class
Discussions • Are \TYPE, \bigint, and \real, primitive types? • If so do they autobox and what to?
Rejected Proposals • Generalized applicability of the helper modifier to all methods.