60 likes | 195 Views
Software System Verification and Validation Laboratory Assignment 2. Tools for JML jmlc & jmlrac Assignment date: Lab 2 Delivery date: Lab 3. Software System Verification and Validation. Tools for JML. Extended static checking with ESC/Java.
E N D
Software System Verification and Validation Laboratory Assignment 2 Tools for JML jmlc & jmlrac Assignment date: Lab 2 Delivery date: Lab 3
Software System Verification and Validation Tools for JML Extended static checking with ESC/Java Runtime assertion checking with jmlc/jmlrac Special compiler inserts runtime tests for all JML assertions.Any assertion violation results in a special exception. checks specs at run-time. only tests correctness of specs. Find violations at runtime. • Automatically tries to prove simple JML assertions at compile time. • checks specs at compile-time • proves correctness of specs. • Warn about likely runtime exceptions and violations.
Software System Verification and Validation Runtime assertion checking • Normally • Compile using javac to get A.class • Execute A.class using javac • To do JML runtime assertion checking • Compile using jmlc to get A.class (compiles an instrumented version of the code where JML-assertions are explicitly checked) • Execute A.class using jmlrac (translates JML assertions into runtime checks:during execution, all assertions are tested and any violation of an assertion produces an Error) • Actually, jmlc is a preprocessor for javac, and jmlrac a wrapper for java. • Typically, you use jmlc/jmlrac when testing code. • Benefit (we hope) : More errors detected, with less effort.
Software System Verification and Validation Method specification Specifying Exceptions • normal_behavior keyword notes that method should finish normally. • behavior keyword notes that there can be an exception thrown. • exceptional_behavior states that the method must always terminate with an exception. • signals clause can be used to describe under what condition an exception can be thrown.
jmlc and jmlrac– by example jmlc and jmlrac - Demo 01: Factorial Exception – Demo02: Integer sqrt
Software System Verification and Validation Laboratory Assignment 2 • Tools for JML • jmlc & jmlrac • Assignment date: Lab 2 • Delivery date: Lab 3 • See file AssignmentLab02.pdf