Shin Hwei Tan Darko Marinov Lin Tan Gary T. Leavens University of Illinois. University of Illinois

Size: px
Start display at page:

Download "Shin Hwei Tan Darko Marinov Lin Tan Gary T. Leavens University of Illinois. University of Illinois"

Transcription

1 Shin Hwei Tan Darko Marinov Lin Tan Gary T. Leavens University of Illinois University of Illinois University of Waterloo University of Central Florida 1

2 /* * Returns a synchronized map backed by the given map. map the map to synchronize, must not be null a synchronized map backed by the given map IllegalArgument if the map is null */ static <K,V> Map<K,V> synchronizedmap(map<k,v> map) Overall Description Block - Parameter name, - - name, Condition under which the exception is thrown 2

3 Writing Javadoc comments is a common practice Lots of Javadoc comments exist in Java libraries. Number of Number of Javadoc Ratio Project methods comments for methods (%) Collections 3,874 2, GlazedLists 2,753 1, JFreeChart 6,205 6, JodaTime 3,887 2, Log4j 2, Lucene 5,222 2, Xalan 5,404 3,

4 /* map the map to synchronize, must not be null a synchronized map backed by the given map IllegalArgument if the map is null */ static <K,V> Map<K,V> synchronizedmap(map<k,v> map) Javadoc comments can be inconsistent with code Expected behavior for synchronizedmap (null): Throws IllegalArgument Actual behavior: Throws NullPointer 4

5 Important to find bugs in comments Comments are not executed Comments are read by developers to understand code Incorrect comments could cause developers to write wrong code [SOSP 07] Challenging to automatically analyze comments Ambiguities in understanding general text NLP made progress but struggles with general text 5

6 Build domain-specific analyses icomment (locking protocols & function calls) [SOSP 07] acomment (interrupts) [ICSE 11] System code (C/C++) Extract machine-checkable rules from comments Use static analysis to check consistency between code and comments/rules 6

7 Javadoc Comments Java Tests with Inconsistency New Domain Method properties for null values and related exceptions Dynamic Analysis (Random Testing) Fewer false alarms compared to static analysis Improved Testing Reduce false alarms in test generation tool Evaluation on 7 Libraries Found 28 inconsistencies, 12 were fixed 7

8 /* map the map to synchronize, must not be null a synchronized map backed by the given map IllegalArgument if the map is null */ static <K,V> Map<K,V> synchronizedmap(map<k,v> map) 8

9 /* map the map to synchronize, must not be null a synchronized map backed by the given map IllegalArgument if the map is null */ static <K,V> Map<K,V> synchronizedmap(map<k,v> map) 9

10 /* map the map to synchronize, must not be null a synchronized map backed by the given map IllegalArgument if the map is null */ static <K,V> Map<K,V> synchronizedmap(map<k,v> map) public void test1() throws Throwable { java.util.map var0 = null; try { java.util.map var1=...synchronizedmap(var0); } catch (IllegalArgument expected) {return;} fail("expected exception of type IllegalArgument but got NullPointer ); } 10

11 /* map the map to synchronize, must not be null a synchronized map backed by the given map IllegalArgument if the map is null */ static <K,V> Map<K,V> synchronizedmap(map<k,v> map) Confirmed & fixed by Collections developers public void test1() throws Throwable { java.util.map var0 = null; try { java.util.map var1=...synchronizedmap(var0); } catch (IllegalArgument expected) {return;} fail("expected exception of type IllegalArgument but got NullPointer ); } 11

12 /* anchor the anchor (<code>null</code> not permitted). */ void setrotationanchor(textanchor anchor) 12

13 /* anchor the anchor (<code>null</code> not permitted). */ void setrotationanchor(textanchor anchor) 13

14 /* anchor the anchor (<code>null</code> not permitted). */ void setrotationanchor(textanchor anchor) public void test2() throws Throwable {...CategoryPointerAnnotation var0 = new CategoryPointerAnnotation( $0.00, (java.lang.comparable)'#', 10.0d, 10.0d); org.jfree.ui.textanchor var1 = null; try { var0.setrotationanchor(var1); fail("expected exception but got Normal Execution"); } catch ( expected) {} } 14

15 /* anchor the anchor (<code>null</code> not permitted). */ void setrotationanchor(textanchor anchor) Confirmed & fixed by JFreeChart developers public void test2() throws Throwable {...CategoryPointerAnnotation var0 = new CategoryPointerAnnotation( $0.00, (java.lang.comparable)'#', 10.0d, 10.0d); org.jfree.ui.textanchor var1 = null; try { var0.setrotationanchor(var1); fail("expected exception but got Normal Execution"); } catch ( expected) {} } 15

16 @tcomment Javadoc Comments Infer properties Properties Java Methods Modified Randoop Tests with Inconsistency 16

17 @tcomment Javadoc Comments 2 Infer properties 1 Properties Java Methods Modified Randoop 3 4 Tests with Inconsistency 17

18 Null Normal, the method should execute normally (no exception) predicate the predicate to use, may be null Null Any, the method should throw some exception collection the collection to add to, must not be null Null Specific (id==null => IllegalArgumentExc), the method should throw a specific type of exception IllegalArgument if the id is null Null Unknown, the method behavior is unknown array the array over which to iterate 1 18

19 Null Normal, the method should execute normally (no exception) predicate the predicate to use, may be null Null Any, the method should throw some exception collection the collection to add to, must not be null Null Specific (id==null => IllegalArgumentExc), the method should throw a specific type of exception IllegalArgument if the id is null Null Unknown, the method behavior is unknown array the array over which to iterate 1 19

20 Null Normal, the method should execute normally (no exception) predicate the predicate to use, may be null Null Any, the method should throw some exception collection the collection to add to, must not be null Null Specific (id==null => IllegalArgumentExc), the method should throw a specific type of exception IllegalArgument if the id is null Null Unknown, the method behavior is unknown array the array over which to iterate 1 20

21 Null Normal, the method should execute normally (no exception) predicate the predicate to use, may be null Null Any, the method should throw some exception collection the collection to add to, must not be null Null Specific (id==null => IllegalArgumentExc), the method should throw a specific type of exception IllegalArgument if the id is null Null Unknown, the method behavior is unknown array the array over which to iterate 1 21

22 2 Parse Javadoc (Standard Doclet) Analyze text 22

23 2 Parse Javadoc (Standard Doclet) Analyze text Negation words (±3 distance within null) Null Any No negation words Null Normal null tag, then searches the list of parameter names. If found Null Specific param == null =>Specific Generates multiple properties for or and either in tag 23

24 while timelimit not reached: a. Create a new sequence 1. Randomly pick a method call m(t 1...T k ) 2. For each parameter, randomly pick a sequence S i that can construct the object for that parameter Select null with some probability (nullratio) 3. Create new sequence S new S 1;...S k ; m(var 1...var k ) b. Classify the new sequence S new Execute & check contract violations? - Output as failure-revealing test case No - Add to sequences if not redundant, else discard 24

25 3 while timelimit not reached: a. Create a new sequence 1. Randomly pick a method call m(t 1...T k ) 2. For each parameter, randomly pick a sequence S i that can construct the object for that parameter Select null with some probability (nullratio) 3. Create new sequence S new S 1;...S k ; m(var 1...var k ) b. Classify the new sequence S new Execute & check contract violations properties? Violate contract - Output as failure-revealing tests Violate properties - Output as comment-code inconsistency No - Add to sequences if not redundant, else discard 25

26 4 /** logger logger, may not be null. sourceclass source class, may be null. sourcemethod method, may be null. */ void exiting(logger logger, String sourceclass, String sourcemethod) 26

27 4 /** Null Any logger logger, may not be null. sourceclass source class, may be null. sourcemethod method, may be null. */ void exiting(logger logger, String sourceclass, String sourcemethod) 27

28 4 /** Null Any logger logger, may not be null. sourceclass source class, may be null. sourcemethod method, may be null. */ void exiting(logger logger, String sourceclass, String sourcemethod) 28

29 4 /** Null Any logger logger, may not be null. sourceclass source class, may be null. sourcemethod method, may be null. */ void exiting(logger logger, String sourceclass, String sourcemethod) Execute 29

30 4 /** Null Any logger logger, may not be null. sourceclass source class, may be null. sourcemethod method, may be null. */ void exiting(logger logger, String sourceclass, String sourcemethod) Execute Actual Thrown 30

31 4 /** Null Any logger logger, may not be null. sourceclass source class, may be null. sourcemethod method, may be null. */ void exiting(logger logger, String sourceclass, String sourcemethod) Execute Actual Thrown Matches 31

32 4 /** Null Any logger logger, may not be null. sourceclass source class, may be null. sourcemethod method, may be null. */ void exiting(logger logger, String sourceclass, String sourcemethod) Execute Actual Thrown Null Any Matches 32

33 4 /** Null Any logger logger, may not be null. sourceclass source class, may be null. sourcemethod method, may be null. */ void exiting(logger logger, String sourceclass, String sourcemethod) Execute Actual Thrown Null Any Matches iscommentcodeinconsistency? 33

34 4 Throws? Execute 34

35 4 Throws? Execute No Null Any / Null Specific? 35

36 4 Execute Throws? No Null Any / Null Specific? Missing 36

37 4 Execute Throws? No Null Any / Null Specific? Missing 1 Null Specific? 37

38 4 Execute Throws? No Null Any / Null Specific? Missing 1 Null Specific? No 1 Null Normal? 38

39 4 Execute Throws? No Null Any / Null Specific? Missing 1 Null Specific? No 1 Null Normal? Unexpected 39

40 4 Execute Throws? No Null Any / Null Specific? Missing 1 Null Specific? No 1 Null Normal? Unexpected Unknown Status 40

41 4 Execute Throws? No Null Any / Null Specific? Missing 1 Null Specific? No 1 Null Normal? Unexpected in the set of expected? Unknown Status 41

42 4 Execute Throws? No Null Any / Null Specific? Missing 1 Null Specific? No 1 Null Normal? Unexpected in the set of expected? No Different Unknown Status 42

43 4 Execute Throws? No Null Any / Null Specific? Missing 1 Null Specific? No 1 Null Normal? Unexpected in the set of expected? No Different Unknown Status Expected 43

44 4 Execute Throws? No Null Any / Null Specific? Missing 1 Null Specific? No 1 Null Normal? Unexpected in the set of expected? No Different Unknown Status Expected Missing Different Unexpected Unknown Status Expected Is Comment-code Inconsistency? 44

45 7 open source projects to infer properties Ran Modified Randoop to check properties Varying 2 options on Modified Randoop nullratio ( How often null is chosen as input for a method?) timelimit ( How long should Modified Randoop take for generating tests before stopping?) Best configuration for all projects nullratio = 0.6 timelimit = 3600s (reached plateau effect after that) 45

46 Project Description # LOC # Classes # Methods Collections Collection library and utilities 19, ,874 GlazedLists List transformations in Java 19, ,753 JFreeChart Chart creator 51, ,205 JodaTime Date and time library 18, ,887 Log4j Logging service 14, ,115 Lucene Text search engine 38, ,222 Xalan XML transformations 53, ,404 46

47 Project Missing Different Unexpected Unknown Status Expected Tested Properties Collections GlazedLists JFreeChart JodaTime Log4j Lucene Xalan Total

48 Project Missing Different Unexpected Unknown Status Expected Tested Properties Collections GlazedLists JFreeChart JodaTime Log4j Lucene Xalan Total Tested only a fraction of properties inferred 48

49 Project Missing = TI + FA Different = TI + FA Unexpected = TI + FA Collections GlazedLists JFreeChart JodaTime Log4j Lucene Xalan Total True Inconsistencies (TI) Total False Alarms (FA)

50 45% 27% 28% Incorrectly inferred properties Missing properties Incorrect/missing properties for another method Incorrect inference Wrong type of inferred properties Missing properties Missing property (Null Unknown) causes unexpected exception Incorrect/missing properties for another method Method under test depend on other method, other method causes unexpected exception 50

51 Project Precision [%] Recall [%] Accuracy Norm Any Spec Norm Any Spec [%] Collections GlazedLists JFreeChart JodaTime Log4j Lucene Xalan Total/Overall properties are inferred, 1 incorrect High accuracy (97-100%) 51

52 Comment-Code Inconsistency Detection Detected 28 comment-code inconsistencies 40 false alarms Comment Analysis Result High accuracy of % without using NLP techniques Javadoc comments are well-structured Not much variance in paraphrases 52

53 An inconsistency between comment and code is highly indicative of program checks consistency of Java method bodies and Javadoc comments properties related to null values and exceptions Evaluated on 7 open-source projects Discovered 28 inconsistencies and 12 were already fixed Acknowledgement: Travel expenses sponsored by NSF CCF grants and ACM-W Scholarships for Attendance at Research Conferences. 53

c 2012 Shin Hwei Tan

c 2012 Shin Hwei Tan c 2012 Shin Hwei Tan @TCOMMENT: TESTING JAVADOC COMMENTS TO DETECT COMMENT-CODE INCONSISTENCIES BY SHIN HWEI TAN THESIS Submitted in partial fulfillment of the requirements for the degree of Master of

More information

@tcomment: Testing Javadoc Comments to Detect Comment-Code Inconsistencies

@tcomment: Testing Javadoc Comments to Detect Comment-Code Inconsistencies @tcomment: Testing Javadoc Comments to Detect Comment-Code Inconsistencies Shin Hwei Tan University of Illinois Urbana, IL 61801, USA stan6@illinois.edu Darko Marinov University of Illinois Urbana, IL

More information

@tcomment: Testing Javadoc Comments to Detect Comment-Code Inconsistencies

@tcomment: Testing Javadoc Comments to Detect Comment-Code Inconsistencies @tcomment: Testing Javadoc Comments to Detect Comment-Code Inconsistencies Shin Hwei Tan University of Illinois Urbana, IL 61801, USA stan6@illinois.edu Darko Marinov University of Illinois Urbana, IL

More information

Automatic Generation of Oracles for Exceptional Behaviors

Automatic Generation of Oracles for Exceptional Behaviors Automatic Generation of Oracles for Exceptional Behaviors ISSTA * * Artifact Consistent * Complete * Well Documented * Easy to Reuse * Evaluated * AEC * Alberto Goffi alberto.goffi@usi.ch USI Università

More information

Feedback-directed Random Test Generation

Feedback-directed Random Test Generation Feedback-directed Random Test Generation (ICSE 07 with minor edits) Carlos Pacheco Shuvendu Lahiri Michael Ernst Thomas Ball MIT Microsoft Research Random testing Select inputs at random from a program

More information

Translating Code Comments to Procedure Specifications

Translating Code Comments to Procedure Specifications Translating Code Comments to Procedure Specifications Arianna Blasi Alberto Goffi Konstantin Kuznetsov Alessandra Gorla Michael D. Ernst Mauro Pezzè Sergio Delgado USI Università della Svizzera italiana,

More information

Identifying Patch Correctness in Test-Based Program Repair

Identifying Patch Correctness in Test-Based Program Repair Key Laboratory of High Confidence Software Technologies (Peking University), MoE Institute of Software, EECS, Peking University, Beijing, 100871, China {xiongyf,liuxinyuan,mhzeng,zhanglucs,hg}@pku.edu.cn

More information

CalFuzzer: An Extensible Active Testing Framework for Concurrent Programs Pallavi Joshi 1, Mayur Naik 2, Chang-Seo Park 1, and Koushik Sen 1

CalFuzzer: An Extensible Active Testing Framework for Concurrent Programs Pallavi Joshi 1, Mayur Naik 2, Chang-Seo Park 1, and Koushik Sen 1 CalFuzzer: An Extensible Active Testing Framework for Concurrent Programs Pallavi Joshi 1, Mayur Naik 2, Chang-Seo Park 1, and Koushik Sen 1 1 University of California, Berkeley, USA {pallavi,parkcs,ksen}@eecs.berkeley.edu

More information

Errors and Exceptions

Errors and Exceptions Exceptions Errors and Exceptions An error is a bug in your program dividing by zero going outside the bounds of an array trying to use a null reference An exception isn t necessarily your fault trying

More information

How Good Are the Specs?

How Good Are the Specs? How Good Are the Specs? A Study of the Bug-Finding Effectiveness of Existing Java API Specifications Owolabi Legunsen, Wajih Ul Hassan, Xinyue Xu Grigore Rosu and Darko Marinov ASE 2016 Singapore, Singapore

More information

Exceptions. Errors and Exceptions. Dealing with exceptions. What to do about errors and exceptions

Exceptions. Errors and Exceptions. Dealing with exceptions. What to do about errors and exceptions Errors and Exceptions Exceptions An error is a bug in your program dividing by zero going outside the bounds of an array trying to use a null reference An exception is a problem whose cause is outside

More information

Object Oriented Programming. Week 7 Part 1 Exceptions

Object Oriented Programming. Week 7 Part 1 Exceptions Object Oriented Programming Week 7 Part 1 Exceptions Lecture Overview of Exception How exceptions solve unexpected occurrences Catching exceptions Week 7 2 Exceptions Overview Week 7 3 Unexpected Occurances

More information

Which Configuration Option Should I Change?

Which Configuration Option Should I Change? Which Configuration Option Should I Change? Sai Zhang, Michael D. Ernst University of Washington Presented by: Kıvanç Muşlu I have released a new software version Developers I cannot get used to the UI

More information

Java Loose Ends. 11 December 2017 OSU CSE 1

Java Loose Ends. 11 December 2017 OSU CSE 1 Java Loose Ends 11 December 2017 OSU CSE 1 What Else? A few Java issues introduced earlier deserve a more in-depth treatment: Try-Catch and Exceptions Members (static vs. instance) Nested interfaces and

More information

Log System Based on Software Testing System Design And Implementation

Log System Based on Software Testing System Design And Implementation 4th International Conference on Mechatronics, Materials, Chemistry and Computer Engineering (ICMMCCE 2015) Log System Based on Software Testing System Design And Implementation Yan Liu1, a, Dahai Jin1,

More information

Write for your audience

Write for your audience Comments Write for your audience Program documentation is for programmers, not end users There are two groups of programmers, and they need different kinds of documentation Some programmers need to use

More information

Alfresco repo under concurrent write load. Alexey Vasyukov, ITD Systems

Alfresco repo under concurrent write load. Alexey Vasyukov, ITD Systems Alfresco repo under concurrent write load Alexey Vasyukov, ITD Systems The System Alfresco repo under reasonable write load In our experience we have the following: Alfresco 5.2 20 000 users 10-100 write

More information

Regression testing. Whenever you find a bug. Why is this a good idea?

Regression testing. Whenever you find a bug. Why is this a good idea? Regression testing Whenever you find a bug Reproduce it (before you fix it!) Store input that elicited that bug Store correct output Put into test suite Then, fix it and verify the fix Why is this a good

More information

Javadoc. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 7

Javadoc. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 7 Javadoc Computer Science and Engineering College of Engineering The Ohio State University Lecture 7 Motivation Over the lifetime of a project, it is easy for documentation and implementation to diverge

More information

Leveraging Test Generation and Specification Mining for Automated Bug Detection without False Positives

Leveraging Test Generation and Specification Mining for Automated Bug Detection without False Positives Leveraging Test Generation and Specification Mining for Automated Bug Detection without False Positives Michael Pradel and Thomas R. Gross Department of Computer Science ETH Zurich 1 Motivation API usage

More information

CUTE: A Concolic Unit Testing Engine for C

CUTE: A Concolic Unit Testing Engine for C CUTE: A Concolic Unit Testing Engine for C Koushik Sen Darko Marinov Gul Agha University of Illinois Urbana-Champaign Goal Automated Scalable Unit Testing of real-world C Programs Generate test inputs

More information

Program Correctness and Efficiency. Chapter 2

Program Correctness and Efficiency. Chapter 2 Program Correctness and Efficiency Chapter 2 Chapter Objectives To understand the differences between the three categories of program errors To understand the effect of an uncaught exception and why you

More information

Fault, Error, and Failure

Fault, Error, and Failure Fault, Error, and Failure Testing, Quality Assurance, and Maintenance Winter 2018 Prof. Arie Gurfinkel based on slides by Prof. Lin Tan and others Terminology, IEEE 610.12-1990 Fault -- often referred

More information

Static Analysis of C++ Projects with CodeSonar

Static Analysis of C++ Projects with CodeSonar Static Analysis of C++ Projects with CodeSonar John Plaice, Senior Scientist, GrammaTech jplaice@grammatech.com 25 July 2017, Meetup C++ de Montréal Abstract Static program analysis consists of the analysis

More information

Statically Checking API Protocol Conformance with Mined Multi-Object Specifications

Statically Checking API Protocol Conformance with Mined Multi-Object Specifications Statically Checking API Protocol Conformance with Mined Multi-Object Specifications Michael Pradel Department of Computer Science ETH Zurich, Switzerland Ciera Jaspan Jonathan Aldrich Institute for Software

More information

FULLY AUTOMATIC AND PRECISE DETECTION OF THREAD SAFETY VIOLATIONS

FULLY AUTOMATIC AND PRECISE DETECTION OF THREAD SAFETY VIOLATIONS FULLY AUTOMATIC AND PRECISE DETECTION OF THREAD SAFETY VIOLATIONS PLDI 2012 by Michael Pradel and Thomas R. Gross ETH Zurich presented by Martin Aigner University of Salzburg May 2, 2013 OVERVIEW The problem

More information

16-Dec-10. Consider the following method:

16-Dec-10. Consider the following method: Boaz Kantor Introduction to Computer Science IDC Herzliya Exception is a class. Java comes with many, we can write our own. The Exception objects, along with some Java-specific structures, allow us to

More information

Synchronization SPL/2010 SPL/20 1

Synchronization SPL/2010 SPL/20 1 Synchronization 1 Overview synchronization mechanisms in modern RTEs concurrency issues places where synchronization is needed structural ways (design patterns) for exclusive access 2 Overview synchronization

More information

Viola: A Verifier For Interoperating Components

Viola: A Verifier For Interoperating Components Viola: A Verifier For Interoperating Components Mark Grechanik The University of Texas at Austin, Austin TX 78729, USA, gmark@cs.utexas.edu Abstract. Two or more components (e.g., objects, modules, or

More information

Large-Scale API Protocol Mining for Automated Bug Detection

Large-Scale API Protocol Mining for Automated Bug Detection Large-Scale API Protocol Mining for Automated Bug Detection Michael Pradel Department of Computer Science ETH Zurich 1 Motivation LinkedList pinconnections =...; Iterator i = pinconnections.iterator();

More information

Natural language is a programming language

Natural language is a programming language Natural language is a programming language Michael D. Ernst UW CSE Joint work with Arianna Blasi, Juan Caballero, Sergio Delgado Castellanos, Alberto Goffi, Alessandra Gorla, Victoria Lin, Deric Pang,

More information

9/19/2018 Programming Data Structures. Polymorphism And Abstract

9/19/2018 Programming Data Structures. Polymorphism And Abstract 9/19/2018 Programming Data Structures Polymorphism And Abstract 1 In-class assignment: deadline noon!! 2 Overview: 4 main concepts in Object-Oriented Encapsulation in Java is a mechanism of wrapping the

More information

Comparing Non-adequate Test Suites using Coverage Criteria

Comparing Non-adequate Test Suites using Coverage Criteria Comparing Non-adequate Test Suites using Coverage Criteria Milos Gligoric 1, Alex Groce 2, Chaoqiang Zhang 2 Rohan Sharma 1, Amin Alipour 2, Darko Marinov 1 ISSTA 2013 Lugano, Switzerland July 18, 2013

More information

acomment: Mining Annotations from Comments and Code to Detect Interrupt Related Concurrency Bugs

acomment: Mining Annotations from Comments and Code to Detect Interrupt Related Concurrency Bugs acomment: Mining Annotations from Comments and Code to Detect Interrupt Related Concurrency Bugs Lin Tan University of Waterloo 200 University Avenue West Waterloo, ON N2L3G1, Canada lintan@uwaterloo.ca

More information

Automatic Test Generation. Galeotti/Gorla/Rau Saarland University

Automatic Test Generation. Galeotti/Gorla/Rau Saarland University Automatic Test Generation Galeotti/Gorla/Rau Saarland University Testing : Find inputs that make the program fail Debugging : The process of finding the cause of a failure. Test Case Values/Test Input/Test

More information

Automatically Generating Precise Oracles from Structured Natural Language Specifications

Automatically Generating Precise Oracles from Structured Natural Language Specifications Automatically Generating Precise Oracles from Structured Natural Language Specifications Manish Motwani and Yuriy Brun College of Information and Computer Sciences University of Massachusetts Amherst Amherst,

More information

Exceptions, Case Study-Exception handling in C++.

Exceptions, Case Study-Exception handling in C++. PART III: Structuring of Computations- Structuring the computation, Expressions and statements, Conditional execution and iteration, Routines, Style issues: side effects and aliasing, Exceptions, Case

More information

Checked and Unchecked Exceptions in Java

Checked and Unchecked Exceptions in Java Checked and Unchecked Exceptions in Java Introduction In this article from my free Java 8 course, I will introduce you to Checked and Unchecked Exceptions in Java. Handling exceptions is the process by

More information

Static program checking and verification

Static program checking and verification Chair of Software Engineering Software Engineering Prof. Dr. Bertrand Meyer March 2007 June 2007 Slides: Based on KSE06 With kind permission of Peter Müller Static program checking and verification Correctness

More information

CSE wi Midterm Exam 2/8/18. Name UW ID #

CSE wi Midterm Exam 2/8/18. Name UW ID # Name UW ID # There are 11 questions worth a total of 120 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes,

More information

Combined Static and Dynamic Automated Test Generation

Combined Static and Dynamic Automated Test Generation Combined Static and Dynamic Automated Test Generation Sai Zhang University of Washington Joint work with: David Saff, Yingyi Bu, Michael D. Ernst 1 Unit Testing for Object-oriented Programs Unit test =

More information

Defensive Programming

Defensive Programming Defensive Programming Software Engineering CITS1220 Based on the Java1200 Lecture notes by Gordon Royle Lecture Outline Why program defensively? Encapsulation Access Restrictions Documentation Unchecked

More information

Formal Methods for Java

Formal Methods for Java Formal Methods for Java Lecture 17: Advanced Key Jochen Hoenicke Software Engineering Albert-Ludwigs-University Freiburg December 21, 2011 Jochen Hoenicke (Software Engineering) Formal Methods for Java

More information

Steps for project success. git status. Milestones. Deliverables. Homework 1 submitted Homework 2 will be posted October 26.

Steps for project success. git status. Milestones. Deliverables. Homework 1 submitted Homework 2 will be posted October 26. git status Steps for project success Homework 1 submitted Homework 2 will be posted October 26 due November 16, 9AM Projects underway project status check-in meetings November 9 System-building project

More information

The Java Memory Model

The Java Memory Model Jeremy Manson 1, William Pugh 1, and Sarita Adve 2 1 University of Maryland 2 University of Illinois at Urbana-Champaign Presented by John Fisher-Ogden November 22, 2005 Outline Introduction Sequential

More information

Context-Based Detection of Clone-Related Bugs. Lingxiao Jiang, Zhendong Su, Edwin Chiu University of California at Davis

Context-Based Detection of Clone-Related Bugs. Lingxiao Jiang, Zhendong Su, Edwin Chiu University of California at Davis Context-Based Detection of Clone-Related Bugs Lingxiao Jiang, Zhendong Su, Edwin Chiu University of California at Davis 1 Outline Introduction and samples of cloning errors Definitions of inconsistencies

More information

Object Oriented Design. Object-Oriented Design. Inheritance & Polymorphism. Class Hierarchy. Goals Robustness Adaptability Flexible code reuse

Object Oriented Design. Object-Oriented Design. Inheritance & Polymorphism. Class Hierarchy. Goals Robustness Adaptability Flexible code reuse Object-Oriented Design Object Oriented Design Goals Robustness Adaptability Flexible code reuse Principles Abstraction Encapsulation Modularity March 2005 Object Oriented Design 1 March 2005 Object Oriented

More information

Why Design by Contract! CS 619 Introduction to OO Design and Development. Design by Contract. Fall 2012

Why Design by Contract! CS 619 Introduction to OO Design and Development. Design by Contract. Fall 2012 Why Design by Contract What s the difference with Testing? CS 619 Introduction to OO Design and Development Design by Contract Fall 2012 Testing tries to diagnose (and cure) defects after the facts. Design

More information

Binghamton University. CS-140 Fall Problem Solving. Creating a class from scratch

Binghamton University. CS-140 Fall Problem Solving. Creating a class from scratch Problem Solving Creating a class from scratch 1 Recipe for Writing a Class 1. Write the class boilerplate stuff 2. Declare Fields 3. Write Creator(s) 4. Write accessor methods 5. Write mutator methods

More information

CS 3 Introduction to Software Engineering. 3: Exceptions

CS 3 Introduction to Software Engineering. 3: Exceptions CS 3 Introduction to Software Engineering 3: Exceptions Questions? 2 Objectives Last Time: Procedural Abstraction This Time: Procedural Abstraction II Focus on Exceptions. Starting Next Time: Data Abstraction

More information

public static void negate2(list<integer> t)

public static void negate2(list<integer> t) See the 2 APIs attached at the end of this worksheet. 1. Methods: Javadoc Complete the Javadoc comments for the following two methods from the API: (a) / @param @param @param @return @pre. / public static

More information

Object-Oriented Design. March 2005 Object Oriented Design 1

Object-Oriented Design. March 2005 Object Oriented Design 1 Object-Oriented Design March 2005 Object Oriented Design 1 Object Oriented Design Goals Robustness Adaptability Flexible code reuse Principles Abstraction Encapsulation Modularity March 2005 Object Oriented

More information

Automated Documentation Inference to Explain Failed Tests

Automated Documentation Inference to Explain Failed Tests Automated Documentation Inference to Explain Failed Tests Sai Zhang University of Washington Joint work with: Cheng Zhang, Michael D. Ernst A failed test reveals a potential bug Before bug-fixing, programmers

More information

Lecture 4 Specifications

Lecture 4 Specifications CSE 331 Software Design and Implementation Administrivia Next assignments posted tonight HW2: Written problems on loops Lecture 4 Specifications Readings posted as well! Quizzes coming soon J Zach Tatlock

More information

public static boolean isoutside(int min, int max, int value)

public static boolean isoutside(int min, int max, int value) See the 2 APIs attached at the end of this worksheet. 1. Methods: Javadoc Complete the Javadoc comments for the following two methods from the API: (a) / @param @param @param @return @pre. / public static

More information

Finding Concurrency Bugs in Java

Finding Concurrency Bugs in Java July 25, 2004 Background Our Work Recommendations Background Our Work Programmers are Not Scared Enough Java makes threaded programming too easy Language often hides consequences of incorrect synchronization

More information

CSE wi Midterm Exam 2/8/18 Sample Solution

CSE wi Midterm Exam 2/8/18 Sample Solution Remember: For all of the questions involving proofs, assertions, invariants, and so forth, you should assume that all numeric quantities are unbounded integers (i.e., overflow can not happen) and that

More information

JML tool-supported specification for Java Erik Poll Radboud University Nijmegen

JML tool-supported specification for Java Erik Poll Radboud University Nijmegen JML tool-supported specification for Java Erik Poll Radboud University Nijmegen Erik Poll - JML p.1/41 Overview The specification language JML Tools for JML, in particular runtime assertion checking using

More information

CS 520 Theory and Practice of Software Engineering Fall 2018

CS 520 Theory and Practice of Software Engineering Fall 2018 CS 520 Theory and Practice of Software Engineering Fall 2018 Nediyana Daskalova Monday, 4PM CS 151 Debugging October 30, 2018 Personalized Behavior-Powered Systems for Guiding Self-Experiments Help me

More information

Test automation / JUnit. Building automatically repeatable test suites

Test automation / JUnit. Building automatically repeatable test suites Test automation / JUnit Building automatically repeatable test suites Test automation n Test automation is software that automates any aspect of testing n Generating test inputs and expected results n

More information

Test automation Test automation / JUnit

Test automation Test automation / JUnit Test automation Test automation / JUnit Building automatically repeatable test suites Test automation is software that automates any aspect of testing Generating test inputs and expected results Running

More information

Implementing Rules. Java rules ok

Implementing Rules. Java rules ok Implementing Rules Java rules ok This is a design discussion lecture for Sprint 2 of the game What types of Rule:s exist in the Game? After analysing the old specification, it seems that there are two

More information

In this lab we will practice creating, throwing and handling exceptions.

In this lab we will practice creating, throwing and handling exceptions. Lab 5 Exceptions Exceptions indicate that a program has encountered an unforeseen problem. While some problems place programmers at fault (for example, using an index that is outside the boundaries of

More information

School of Informatics, University of Edinburgh

School of Informatics, University of Edinburgh CS1Ah Lecture Note 29 Streams and Exceptions We saw back in Lecture Note 9 how to design and implement our own Java classes. An object such as a Student4 object contains related fields such as surname,

More information

CS159. Nathan Sprague

CS159. Nathan Sprague CS159 Nathan Sprague What s wrong with the following code? 1 /* ************************************************** 2 * Return the mean, or -1 if the array has length 0. 3 ***************************************************

More information

SOftware defect prediction techniques [22], [29], [31], [41],

SOftware defect prediction techniques [22], [29], [31], [41], Deep Semantic Feature Learning for Software Defect Prediction Song Wang, Taiyue Liu, Jaechang Nam, and Lin Tan Abstract Software defect prediction, which predicts defective code regions, can assist developers

More information

Automatic Generation of Program Specifications

Automatic Generation of Program Specifications Automatic Generation of Program Specifications Jeremy Nimmer MIT Lab for Computer Science http://pag.lcs.mit.edu/ Joint work with Michael Ernst Jeremy Nimmer, page 1 Synopsis Specifications are useful

More information

JML. Java Modeling Language

JML. Java Modeling Language JML Java Modeling Language Overview About the JML Project DBC Design By Contract JML concepts, examples, syntax and capabilities Basics Exceptions Invariants Assertions Quantifiers Other keywords JML hiding

More information

Exception-Handling Overview

Exception-Handling Overview م.عبد الغني أبوجبل Exception Handling No matter how good a programmer you are, you cannot control everything. Things can go wrong. Very wrong. When you write a risky method, you need code to handle the

More information

Main concepts to be covered. Handling errors. Some causes of error situations. Not always programmer error. Defensive programming.

Main concepts to be covered. Handling errors. Some causes of error situations. Not always programmer error. Defensive programming. Main concepts to be covered Handling errors Or, When Bad Things Happen to Good Programs Defensive programming. Anticipating that things could go wrong. Exception handling and throwing. Error reporting.

More information

CSE 331 Midterm Exam Sample Solution 2/18/15

CSE 331 Midterm Exam Sample Solution 2/18/15 Question 1. (10 points) (Forward reasoning) Using forward reasoning, write an assertion in each blank space indicating what is known about the program state at that point, given the precondition and the

More information

ASSERTIONS AND LOGGING

ASSERTIONS AND LOGGING SUMMARY Exception handling, ASSERTIONS AND LOGGING PROGRAMMAZIONE CONCORRENTE E DISTR. Università degli Studi di Padova Dipartimento di Matematica Corso di Laurea in Informatica, A.A. 2015 2016 rcardin@math.unipd.it

More information

COE318 Lecture Notes Week 10 (Nov 7, 2011)

COE318 Lecture Notes Week 10 (Nov 7, 2011) COE318 Software Systems Lecture Notes: Week 10 1 of 5 COE318 Lecture Notes Week 10 (Nov 7, 2011) Topics More about exceptions References Head First Java: Chapter 11 (Risky Behavior) The Java Tutorial:

More information

ekey Error Codes Error Code Short Name Cause Message Resolution

ekey Error Codes Error Code Short Name Cause Message Resolution ekey s Short Name Cause Message Resolution Keybox Operating s 9026 Bad Cookie Keybox failed to decrypt a cookie. 9027 Key Expired Keybox determines that a cookie is expired. 9028 Not Enough Data 9029 Command

More information

CSE 331. Programming by contract: pre/post conditions; Javadoc

CSE 331. Programming by contract: pre/post conditions; Javadoc CSE 331 Programming by contract: pre/post conditions; Javadoc slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia http://www.cs.washington.edu/331/ 1

More information

Chapter 16 Heuristic Search

Chapter 16 Heuristic Search Chapter 16 Heuristic Search Part I. Preliminaries Part II. Tightly Coupled Multicore Chapter 6. Parallel Loops Chapter 7. Parallel Loop Schedules Chapter 8. Parallel Reduction Chapter 9. Reduction Variables

More information

Debugging and Testing Optimizers through Comparison Checking

Debugging and Testing Optimizers through Comparison Checking Electronic Notes in Theoretical Computer Science 65 No. 2 (2002) URL: http://www.elsevier.nl/locate/entcs/volume65.html 17 pages Debugging and Testing Optimizers through Comparison Checking Clara Jaramillo

More information

Software Specifications. CMSC 433 Programming Language Technologies and Paradigms Spring Specifications Help You Write Code

Software Specifications. CMSC 433 Programming Language Technologies and Paradigms Spring Specifications Help You Write Code Software Specifications CMSC 433 Programming Language Technologies and Paradigms Spring 2007 Documentation Feb. 20, 2007 A specification defines the behavior of an abstraction This is the contract between

More information

CSE 331 Software Design & Implementation

CSE 331 Software Design & Implementation CSE 331 Software Design & Implementation Hal Perkins Spring 2017 Exceptions and Assertions 1 Outline General concepts about dealing with errors and failures Assertions: what, why, how For things you believe

More information

Using Type Annotations to Improve Your Code

Using Type Annotations to Improve Your Code Using Type Annotations to Improve Your Code Birds-of-a-Feather Session Werner Dietl, University of Waterloo Michael Ernst, University of Washington Open for questions Survey: Did you attend the tutorial?

More information

Classes, interfaces, & documentation. Review of basic building blocks

Classes, interfaces, & documentation. Review of basic building blocks Classes, interfaces, & documentation Review of basic building blocks Objects Data structures literally, storage containers for data constitute object knowledge or state Operations an object can perform

More information

A Practical Approach to Programming With Assertions

A Practical Approach to Programming With Assertions A Practical Approach to Programming With Assertions Ken Bell Christian-Albrechts Universität Kiel Department of Computer Science and Applied Mathematics Real-Time Systems and Embedded Systems Group July

More information

A NOVEL APPROACH TO ERROR DETECTION AND CORRECTION OF C PROGRAMS USING MACHINE LEARNING AND DATA MINING

A NOVEL APPROACH TO ERROR DETECTION AND CORRECTION OF C PROGRAMS USING MACHINE LEARNING AND DATA MINING A NOVEL APPROACH TO ERROR DETECTION AND CORRECTION OF C PROGRAMS USING MACHINE LEARNING AND DATA MINING Prof. KhushaliDeulkar 1, Jai Kapoor 2, Priya Gaud 3, Harshal Gala 4 Department Of Computer Engineering

More information

Symbolic Inference of Partial Specifications to Augment Regression Testing

Symbolic Inference of Partial Specifications to Augment Regression Testing Symbolic Inference of Partial Specifications to Augment Regression Testing Koen Wermer Utrecht University Student number: 3705951 April 21, 2017 1 1 Introduction A large part of the costs (50-80% [17])

More information

Introduction to JML David Cok, Joe Kiniry, and Erik Poll Eastman Kodak Company, University College Dublin, and Radboud University Nijmegen

Introduction to JML David Cok, Joe Kiniry, and Erik Poll Eastman Kodak Company, University College Dublin, and Radboud University Nijmegen Introduction to JML David Cok, Joe Kiniry, and Erik Poll Eastman Kodak Company, University College Dublin, and Radboud University Nijmegen David Cok, Joe Kiniry & Erik Poll - ESC/Java2 & JML Tutorial p.1/30

More information

On Exceptions, Events and Observer Chains

On Exceptions, Events and Observer Chains Computer Science Technical Reports Computer Science 1-15-2013 On Exceptions, Events and Observer Chains Mehdi Bagherzadeh Iowa State University, mbagherz@iastate.edu Hridesh Rajan Iowa State University

More information

Early detection of configuration errors to reduce failure damage

Early detection of configuration errors to reduce failure damage Early detection of configuration errors to reduce failure damage Tianyin Xu, Xinxin Jin, Peng Huang, Yuanyuan Zhou, Shan Lu, Long Jin, Shankar Pasupathy UC San Diego University of Chicago NetApp This paper

More information

Automated SQL Ownage Techniques. OWASP October 30 th, The OWASP Foundation

Automated SQL Ownage Techniques. OWASP October 30 th, The OWASP Foundation Automated SQL Ownage Techniques October 30 th, 2009 Sebastian Cufre Developer Core Security Technologies sebastian.cufre@coresecurity.com Copyright The Foundation Permission is granted to copy, distribute

More information

Verification & Validation of Open Source

Verification & Validation of Open Source Verification & Validation of Open Source 2011 WORKSHOP ON SPACECRAFT FLIGHT SOFTWARE Gordon Uchenick Coverity, Inc Open Source is Ubiquitous Most commercial and proprietary software systems have some open

More information

COMP 213. Advanced Object-oriented Programming. Lecture 17. Exceptions

COMP 213. Advanced Object-oriented Programming. Lecture 17. Exceptions COMP 213 Advanced Object-oriented Programming Lecture 17 Exceptions Errors Writing programs is not trivial. Most (large) programs that are written contain errors: in some way, the program doesn t do what

More information

An Industrial Evaluation of Unit Test Generation: Finding Real Faults in a Financial Application

An Industrial Evaluation of Unit Test Generation: Finding Real Faults in a Financial Application An Industrial Evaluation of Unit Test Generation: Finding Real Faults in a Financial Application M. Moein Almasi, Hadi Hemmati, Gordon Fraser, Andrea Arcuri, Jānis Benefelds Department of Computer Science,

More information

Video 2.1. Arvind Bhusnurmath. Property of Penn Engineering, Arvind Bhusnurmath. SD1x-2 1

Video 2.1. Arvind Bhusnurmath. Property of Penn Engineering, Arvind Bhusnurmath. SD1x-2 1 Video 2.1 Arvind Bhusnurmath SD1x-2 1 Topics Why is testing important? Different types of testing Unit testing SD1x-2 2 Software testing Integral part of development. If you ship a software with bugs,

More information

Projeto de Software / Programação 3 Tratamento de Exceções. Baldoino Fonseca/Márcio Ribeiro

Projeto de Software / Programação 3 Tratamento de Exceções. Baldoino Fonseca/Márcio Ribeiro Projeto de Software / Programação 3 Tratamento de Exceções Baldoino Fonseca/Márcio Ribeiro baldoino@ic.ufal.br What can go wrong?! result = n1 / n2; In the following slides: 1) Analyze the code; 2) read

More information

CSE 331 Final Exam 6/5/17. Name UW ID#

CSE 331 Final Exam 6/5/17. Name UW ID# Name UW ID# There are 10 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes,

More information

NDSeq: Runtime Checking for Nondeterministic Sequential Specs of Parallel Correctness

NDSeq: Runtime Checking for Nondeterministic Sequential Specs of Parallel Correctness EECS Electrical Engineering and Computer Sciences P A R A L L E L C O M P U T I N G L A B O R A T O R Y NDSeq: Runtime Checking for Nondeterministic Sequential Specs of Parallel Correctness Jacob Burnim,

More information

Documentation (and midterm review)

Documentation (and midterm review) Documentation (and midterm review) Comp-303 : Programming Techniques Lecture 13 Alexandre Denault Computer Science McGill University Winter 2004 February 16, 2004 Lecture 13 Comp 303 : Programming Techniques

More information

CSE331 Winter 2014, Midterm Examination February 12, 2014

CSE331 Winter 2014, Midterm Examination February 12, 2014 CSE331 Winter 2014, Midterm Examination February 12, 2014 Please do not turn the page until 10:30. Rules: The exam is closed-book, closed-note, etc. Please stop promptly at 11:20. There are 100 points

More information

11 Using JUnit with jgrasp

11 Using JUnit with jgrasp 11 Using JUnit with jgrasp jgrasp includes an easy to use plug-in for the JUnit testing framework. JUnit provides automated support for unit testing of Java source code, and its utility has made it a de

More information

Error Management in Compilers and Run-time Systems

Error Management in Compilers and Run-time Systems TDDB29 Compilers and Interpreters Error Management in Compilers and Run-time Systems Program errors major part of the total cost of software projects is due to testing and debugging. US-Study 2002: Software

More information

Name: Class: Date: 2. Today, a bug refers to any sort of problem in the design and operation of a program.

Name: Class: Date: 2. Today, a bug refers to any sort of problem in the design and operation of a program. Name: Class: Date: Chapter 6 Test Bank True/False Indicate whether the statement is true or false. 1. You might be able to write statements using the correct syntax, but be unable to construct an entire,

More information