Run-Time Assertion Checking and Monitoring Java Programs



Similar documents
Rigorous Software Development CSCI-GA

VDM vs. Programming Language Extensions or their Integration

Verifying Semantic of System Composition for an Aspect-Oriented Approach

A Framework for the Semantics of Behavioral Contracts

Rigorous Software Engineering Hoare Logic and Design by Contracts

Rigorous Software Development CSCI-GA

Programming by Contract vs. Defensive Programming: A Comparison of Run-time Performance and Complexity

Software Engineering Techniques

Design by Contract beyond class modelling

Thomas Jefferson High School for Science and Technology Program of Studies Foundations of Computer Science. Unit of Study / Textbook Correlation

Specification and Analysis of Contracts Lecture 1 Introduction

DIRECT PH.D. (POST B.S.) IN COMPUTER SCIENCE PROGRAM

An Eclipse Plug-In for Visualizing Java Code Dependencies on Relational Databases

Monitors, Java, Threads and Processes

Glossary of Object Oriented Terms

Constructing Contracts: Making Discrete Mathematics Relevant to Beginning Programmers

StaRVOOrS: A Tool for Combined Static and Runtime Verification of Java

Computer Science. General Education Students must complete the requirements shown in the General Education Requirements section of this catalog.

Java Application Developer Certificate Program Competencies

02-201: Programming for Scientists

How To Write A Test Engine For A Microsoft Microsoft Web Browser (Php) For A Web Browser For A Non-Procedural Reason)

Structure of Presentation. Stages in Teaching Formal Methods. Motivation (1) Motivation (2) The Scope of Formal Methods (1)

Safe Locking for Multi-threaded Java

Software Component Specification Using Design by Contract

Challenges and Opportunities for formal specifications in Service Oriented Architectures

Lecture 1: Introduction

1.1 WHAT IS A PROGRAMMING LANGUAGE?

Unified Static and Runtime Verification of Object-Oriented Software

Systems Integration: Co C mp m onent- t bas a e s d s o s ftw ft a w r a e r e ngin i eeri r n i g

SOFT 437. Software Performance Analysis. Ch 5:Web Applications and Other Distributed Systems

Formal Engineering for Industrial Software Development

Advances in Programming Languages

A Hoare Logic for Monitors in Java

Fundamentals of Java Programming

Resource-Aware Applications for the Cloud

Overview Motivating Examples Interleaving Model Semantics of Correctness Testing, Debugging, and Verification

Java SE 7 Programming

BCS Higher Education Qualifications. Professional Graduate Diploma in IT. Programming Paradigms Syllabus

CS Standards Crosswalk: CSTA K-12 Computer Science Standards and Oracle Java Programming (2014)

Programming Without a Call Stack: Event-driven Architectures

Assessment for Master s Degree Program Fall Spring 2011 Computer Science Dept. Texas A&M University - Commerce

C#5.0 IN A NUTSHELL. Joseph O'REILLY. Albahari and Ben Albahari. Fifth Edition. Tokyo. Sebastopol. Beijing. Cambridge. Koln.

A Structured Methodology For Spreadsheet Modelling

Construct by Contract: Construct by Contract: An Approach for Developing Reliable Software

Meta Model Based Integration of Role-Based and Discretionary Access Control Using Path Expressions

Quotes from Object-Oriented Software Construction

Useful Patterns for BPEL Developers

Lecture 9. Semantic Analysis Scoping and Symbol Table

MSc Information Technology - E521

LIACS Fundamentals. Jetty Kleijn Informatica Bachelorklas

Adapting C++ Exception Handling to an Extended COM Exception Model

Fully Abstract Operation Contracts

Language Evaluation Criteria. Evaluation Criteria: Readability. Evaluation Criteria: Writability. ICOM 4036 Programming Languages

Component visualization methods for large legacy software in C/C++

Business Rule Standards -- Interoperability and Portability

Applications of formal verification for secure Cloud environments at CEA LIST

Analysis of the Specifics for a Business Rules Engine Based Projects

Static vs. Dynamic. Lecture 10: Static Semantics Overview 1. Typical Semantic Errors: Java, C++ Typical Tasks of the Semantic Analyzer

Chapter 6: Programming Languages

Programming Language Pragmatics

On the Relation between Design Contracts and Errors: A Software Development Strategy

PROPERTECHNIQUEOFSOFTWARE INSPECTIONUSING GUARDED COMMANDLANGUAGE

Composing Concerns with a Framework Approach

Real Time Programming: Concepts

Software Specification and Testing

Automated Program Behavior Analysis

Monitoring Method Call Sequences using Annotations

Eastern Washington University Department of Computer Science. Questionnaire for Prospective Masters in Computer Science Students

Integration of Application Business Logic and Business Rules with DSL and AOP

Software Verification and Testing. Lecture Notes: Temporal Logics

Hoare-Style Monitors for Java

A Case Study on Model-Driven and Conventional Software Development: The Palladio Editor

What is a programming language?

Deployment Pattern. Youngsu Son 1,JiwonKim 2, DongukKim 3, Jinho Jang 4

CONSTRAINT-BASED DATA QUALITY MANAGEMENT FRAMEWORK FOR OBJECT DATABASES

Chapter 1: Introduction

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

Information Systems. Administered by the Department of Mathematical and Computing Sciences within the College of Arts and Sciences.

3 Extending the Refinement Calculus

Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy

Hochschule Esslingen University of Applied Sciences

University of Dayton Department of Computer Science Undergraduate Programs Assessment Plan DRAFT September 14, 2011

AndroLIFT: A Tool for Android Application Life Cycles

Scoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6)

Agile Specification-Driven Development

Transcription:

Run-Time Assertion Checking and Monitoring Java Programs Envisage Bertinoro Summer School June 2014 June 19, 2014

Your Lecturers Today Frank en Stijn

What This Talk Is All About Formal Methods in Practice: Theorie ist, wenn man alles weiss und nichts klappt. Praxis ist, wenn alles klappt und keiner weiss warum.

What Fails In Practice: Run-Time Assertion Checking Take for example JML (citing Peter Wong) Stability of tooling IDE support e.g. on-the-fly parsing and type checking, navigability between specifcations and source codes Maintainability of specification due to constant code change Error reporting and analysis See also Run-time checking of data- and protocol-oriented properties of Java programs: an industrial case study. Stijn de Gouw, Frank S. de Boer, Peter Y. H. Wong and Einar Broch Johnsen. SAC 2013.

Outline Formal Specification: Assertions Behavioral Abstraction Run-time checking of data- and protocol-oriented properties Tooling

What? Formal Specfification? Assertions?

Industrial Relevance National Institute of Standards and Technology (NIST): Software errors cost us approximately $60 billion per year in lost productivity, increased time to market costs, higher market transaction costs, etc. If allowed to continue unchecked this problem s costs may get much worse. Managerial Misconceptions: Software development is not an art, and programmers are not artists, despite any claims to the contrary. Management has come to believe the first and most important misconception: that it is impossible to ship software devoid of errors in a cost-effective way.

What Makes Software Buggy? An imperative program describes how a problem can be solved by a computer.

The Von Neumann Architecture of Imperative Programming

What The Hack Are You Doing? What does the following program compute, assuming that the initial value of x is greater than or equal to 0? y := 0; u := 0; v := 1; while u + v x do y := y + 1; u := u + v; v := v + 2 od

Debugging: Let it Flow x y u v 13 0 0 1 13 1 1 3 13 2 4 5 13 3 9 7.. What s the relation between the values of x, y, u and v?..

Robert Floyd Introduced Assertions For Program Specification in the Seventies y 2 x < (y + 1) 2

Edsger Dijkstra Introduced Structured Programming Debugging only shows that a program is incorrect.

Sir. Tony Hoare Developed a First Programming Logic {P}S{Q}

Design by Contract Caller = Client and Callee = Supplier in Method calls in object-oriented programs Designer must formally specify for each method: What does it expect? (precondition) What does it guarantee?(postcondition) What does it maintain? (invariant) Main idea: Formal specification of contracts by assertions, i.e. logical formulas

Design by Contract in Practice Object-oriented programming language Eiffel introduced by the company Eiffel Software. The Java Modelling Language JML supports run-time assertion checking. Spec# is a formal language for API contracts developed and used by Microsoft. Object Constraint Language (OCL) for the specification of UML diagrams

Behavioral Abstraction (Information Hiding) State of the Art (= state-based) Getters: Get X Model variables (JML): public model instance JMLObjectBag elementsinqueue

Formal Semantics: Full Abstraction That is, Minimal information required for compositionality smallest congruence containing operational equivalence: for every context C[ ] S S if and only if O(C[S]) = O(C[S ]),

Compositionality Java Programs Two perspectives: Threads (stack: shared-variable concurrency) Classes (Objects) (monitor: message passing)

Compositionality Shared Variable Concurrency (Multi-threading) Initial/final state semantics is not compositional: O(x := x + 1; x := x + 1) = O(x := x + 2) but O(x := x + 1; x := x + 1 x := 0) O(x := x + 2 x := 0) We need reactive sequences: and R(x := x + 1) = { σ, σ[x := σ(x) + 1] σ Σ} R(S 1 S 2 ) = R(S 1 ) R(S 2 ) where denotes interleaving. See Reasoning about Recursive Processes in Shared-Variable Concurrency. F.S. de Boer. LNCS 5930, 2010.

Compositional Proof Theory for Communicating Sequential Processes (CSP) From non-compositional: Communication Assumptions {p}c?x{q} and {p}c!e{q} Cooperation Test {p} c!e {q} {p } c?x {q } to compositional by means of histories (or traces) Communication Axioms Example: See } {p p }x := e{q q } { x.p[h (c, x)/h]}c?x{q} and {p[h (c, e)/h]}c!e{q} {[h] c = ɛ}c?x{[h] c = (c, x)} {[h] c = ɛ}c!0{[h] c = (c, 0)} {[h] c = ɛ}c?x c!0{[h] c = (c, x) [h] c = (c, 0)} An assertion-based proof system for multithreaded Java by Abraham, de Boer, de Roever and Steffen, in TCS, Vol. 331, 2005.

A Short History of Histories Proofs of networks of processes by Misra and Chandy, in IEEE Transactions on Sofware Engineering, 1981. Formal justification of a proof system for CSP by K.R. Apt in J.ACM, Vol 30, 1983. A theory of communicating sequential processes, by Brookes, Hoare and Roscoe, in J. ACM, Vol. 31, 1984. Compositionality and concurrent networks: soundness and completeness of a proof system by Zwiers, de Roever and van Emde Boas, in LNCS, Vol. 194, 1985. Fully abstract trace semantics for a core Java language by Jeffrey and Rathke, in LNCS, Vol. 344, 2005. Object Connectivity and Full Abstraction for a Concurrent Calculus of Classes. Erika Ábrahám, Marcello M. Bonsangue, Frank S. de Boer, Martin Steffen: ICTAC 2004: 37-51

The Very Nature of Object-Orientation Inherently Parallel (even If Sequential)

Run-Time Assertion Checking Requires Executable assertions But what we want (need badly) is combining data- and protocol-oriented properties

Main Idea Grammars to specify protocols (= formal languages) Main problem/challenge: Integration grammars in assertion checking that works in practice

Specifying Interfaces in Java: A Running Example interface Stack { void push(object item); Object pop(); }

The Modelling Framework: Messages call-push Attributes public Object item return-push Attributes public Object item call-pop Attributes public Object item return-pop Attributes public Object result

The Modelling Framework: Communication Views Partial mappings from call and return events to tokens

Communication Views: An Example view StackHistory { return void push(object item) push, return Object pop() pop }

General Properties of Communication Views Multiple views for interfaces Multiple views for classes/components (provided/required methods) User-defined event names Abstraction of irrelevant events Identifying different events Distinguishing different events using method signatures (method overloading)

The Modelling Framework: Attribute Grammars class EList extends List { public EList append(object element) public EList append(elist list) } Elist stack S ::= push S 1 stack = S 1.stack.append(push.item) S 1 S 2 stack = S 2.stack.append(S 1.Stack) B stack = new EList() B ::= push B pop ɛ

Example Parse tree of sequence of tokens push(5) push(7) pop(7) S S.stack=5 push 5 S S.stack=<> push B pop 7 7

The Modelling Framework: Interface Specifications interface Stack { //@ public model instance StackHistory history; //@ ensures history.stack() == \old(history.stack()).append(item); void push(object item); //@ requires history.stack().size! = 0; //@ ensures history.stack() = \old(history.stack()).tail(); //@ ensures \result == \old(history.stack()).head(); Object pop()

The Modelling Framework: Summary ATTRIBUTE GRAMMAR ATTRIBUTES HISTORY TERMINALS VIEW MODEL FIELDS MESSAGE TYPES INTERFACE SPECIFICATION JML

Run-Time Assertion Checking: Method Invocation Program JML API History (instance) Parser Check Precondition Incoming Method Call Get Attributes Attribute values Triggers New Attribute values Program JML API History (instance) Parser

Run-Time Assertion Checking: Method Return Program History (instance) Parser JML API stdout Method Return Triggers Attribute values Check Postcondition Get Attributes Attribute values Assertion Failure Program History (instance) Parser JML API stdout

Attribute Grammars as Behavioral Types Another Example: Specifying the BufferedReader class Class BufferedReader { BufferedReader(Reader in); void close(); String readline();... } Communication View: view BufferedReaderHistory { new(reader in) open, call String readline() read, call void close() close }

Extended Attribute Grammar modeling the behavior of a BufferedReader BufferedReader can only be read when opened and before closed. BufferedReader can only be closed by the object that opened it: S ::= open C assert open.caller!= null ==> open.caller == C.caller; ɛ C ::= read C 1 C.caller = C 1.caller; close S C.caller = close.caller; ɛ C.caller = null;

Summarizing Attribute grammars provide a systematic approach for specifying histories which allows a declarative expression of complex properties of histories and seamlessly combines specification of protocol oriented properties (grammar) data-oriented properties (attributes) into a single formalism.