Object Usage Models. Andrzej Wasylkowski Saarland University

Size: px
Start display at page:

Download "Object Usage Models. Andrzej Wasylkowski Saarland University"

Transcription

1 Object Usage Models Andrzej Wasylkowski Saarland University

2 A bug in AspectJ 2

3 A bug in AspectJ /** * This method looks through the type hierarchy for some target type - it is attempting to * find an existing parameterization that clashes with the new parent that the user * wants to apply to the type. If it finds an existing parameterization that matches the * new one, it silently completes, if it finds one that clashes (e.g. a type already has * A<String> when the user wants to add A<Number>) then it will produce an error. * * It uses recursion and exits recursion on hitting 'jlobject' * * Related bugzilla entries: pr */ private boolean verifynoinheritedalternateparameterization(resolvedtype typetoverify,resolvedtype newparent,world world) { if (typetoverify.equals(resolvedtype.object)) return true; ResolvedType newparentgenerictype = newparent.getgenerictype(); Iterator iter = typetoverify.getdirectsupertypes(); while (iter.hasnext()) { ResolvedType supertype = (ResolvedType)iter.next(); if ( ((supertype.israwtype() && newparent.isparameterizedtype()) (supertype.isparameterizedtype() && newparent.israwtype())) && newparentgenerictype.equals(supertype.getgenerictype())) { // new parent is a parameterized type, but this is a raw type world.getmessagehandler().handlemessage(new Message( WeaverMessages.format(WeaverMessages.CANT_DECP_MULTIPLE_PARAMETERIZATIONS,newParent.getName(),typeToVerify.getName(),supertype.getName()), getsourcelocation(), true, new ISourceLocation[]{typeToVerify.getSourceLocation())); return false; if (supertype.isparameterizedtype()) { ResolvedType generictype = supertype.getgenerictype(); // If the generic types are compatible but the parameterizations aren't then we have a problem if (generictype.isassignablefrom(newparentgenerictype) &&!supertype.isassignablefrom(newparent)) { world.getmessagehandler().handlemessage(new Message( WeaverMessages.format(WeaverMessages.CANT_DECP_MULTIPLE_PARAMETERIZATIONS,newParent.getName(),typeToVerify.getName(),supertype.getName()), getsourcelocation(), true, new ISourceLocation[]{typeToVerify.getSourceLocation())); return false; return verifynoinheritedalternateparameterization(supertype,newparent,world); return true; 3

4 A bug in AspectJ private boolean verify () { Iterator iter = ; while (iter.hasnext()) { = iter.next(); return verify (); return true; How can we find such a bug automatically? 4

5 The approach a b b Program Smart tool a a!!! c a d e f c d!!! Modeling objects behavior using finite state automata 5

6 How to create models? q = new Queue (); (); while () { e = (); (); Use method calls as transitions How to define states?

7 How to define states? I. Anonymous states via grammar inference q = new Queue (); (); while () { e = (); (); 7

8 How to define states? I. Anonymous states via grammar inference q = new Queue (); (); while () { Execution e = (); (); q = new 7

9 How to define states? I. Anonymous states via grammar inference q = new Queue (); (); while () { Execution e = (); (); q = new Grammar inference q = new 7

10 How to define states? I. Anonymous states via grammar inference q = new Grammar inference q = new 8

11 How to define states? I. Anonymous states via grammar inference q = new Grammar inference q = new Grammar inference q = new 8

12 How to define states? I. Anonymous states via grammar inference q = new Grammar inference q = new Grammar inference q = new Which model represents actual behavior? 8

13 How to define states? I. Anonymous states via grammar inference q = new Grammar inference q = new Can uncover hidden structure! Difficult to assign meaning! NP-hard Grammar inference! Does not handle ambiguity well q = new Which model represents actual behavior? 9

14 How to define states? II. Based on object s state q = new Queue (); (); while () { e = (); (); 10

15 How to define states? II. Based on object s state q = new Queue (); (); while () { e = (); (); Execution q = new size() == 0 size() == 1 10

16 How to define states? II. Based on object s state q = new Queue (); (); while () { e = (); (); q = new Expresses the true meaning of the state Execution size() == 0! Needs abstraction to keep models small size() == 1 11

17 How to define states? III.Based on the way the object is used q = new Queue (); (); while () { e = (); (); 12

18 How to define states? III.Based on the way the object is used q = new Queue (); (); while () { e = (); (); Static analysis q = new Queue (); (...);... (...); e = ();...

19 How to define states? III.Based on the way the object is used q = new Queue (); (); while () { e = (); (); Static analysis q = new!!!!!! 12!!!

20 How to define states? III.Based on the way the object is used q = new Queue (); (); while () { e = (); (); Static analysis q = new 12

21 How to define states? III.Based on the way the object is used q = new Queue (); (); while () { e = (); (); Static analysis q = new User-centered view of the object! May be too specific 13

22 How to define states? I. Anonymous states via grammar inference II. Based on object s state III.Based on the way the object is used 14

23 How to define states? I. Anonymous states via grammar inference II. Based on object s state III.Based on the way the object is used 14

24 External method calls q = new Queue (); (); while () { e = (); refresh (q); 15

25 External method calls q = new Queue (); (); while () { e = (); refresh (q); Static analysis q = new refresh (q) 15

26 Inlining models q = new Queue (); (); while () { e = (); refresh (q); void refresh (Queue q) { if (!q.isempty ()) { e = (); (e); 16

27 Inlining models q = new refresh (q) void refresh (Queue q) { if (!q.isempty ()) { e = (); (e); 16

28 Inlining models q = new q.isempty!!!! refresh (q) 16

29 Inlining models q = new q = new q.isempty refresh (q)!!!! Inlining!!!! q.isempty 17

30 Subject: AspectJ jar file Size (kb) Classes Methods aspectjlib.jar aspectjrt.jar aspectjweaver.jar aspectjtools.jar

31 Time & Models jar file Classes Models Time aspectjlib.jar :01 aspectjrt.jar :04 aspectjweaver.jar :23 aspectjtools.jar :33 19

32 Stack s in ThreadStackImpl11.getThreadStack() s = new s.push s.elements 20

33 StringTokenizer st in AdviceSignatureImpl.toAdviceName() st = new st.hasmoretokens!!!! st.nexttoken!!!!!!!! 21

34 StringTokenizer st in Factory.makeConstructorSig() st = new st.counttokens st.nexttoken 22

35 Method m in AjTypeImpl.asPointcut() m.getdeclaringclass m.getname m.getannotation new PointcutImpl (...,..., m,...,...)!!!!!!!! 23

36 Class c in SignatureImpl.shortTypeName() c.isarray c.getname c.getcomponenttype!!!!!!!!!!!! 24

37 Class c in AjTypeSystem.getAjType() Map.containsKey (c) new AjTypeImpl (c) Map.get (c) new AjTypeImpl (c) Map.put (c,...)!!!! Map.put (c,...) 25

38 Infrequent models (1) Model 1 Model Occurrences of models: SystemColor 26

39 Infrequent models (2) Model 1 Model 2 Model 3 Model Occurrences of models: RuntimeException 27

40 Infrequent models (3) re = new RuntimeException thrown The most frequently occurring RuntimeException model 28

41 Infrequent models (3) re = new re = new RuntimeException thrown Tra ce.e xit (..., re ) List.add (re) RuntimeException thrown Anomalous RuntimeException models 29

42 Infrequent models statistics Total Anomalies jar file Classes Classes Models Time aspectjlib.jar :02 aspectjrt.jar :05 aspectjweaver.jar :16 aspectjtools.jar :06 30

43 Subsequences q = new 31

44 Subsequences q = new Subsequences extraction (new, offer) (new, poll) (offer, offer) (offer, poll) (poll, offer) (poll, poll) 31

45 Frequent subsequences Method Ids of subsequences Dump.println 28, 45, 46, 47, 48, 4386 ClassPathManager.<init> 45, 46, 47, 48 DeclareParents.verify 4, 48, BcelObjectType.get 45, 48,

46 Frequent subsequences Method Ids of subsequences Dump.println 28, 45, 46, 47, 48, 4386 ClassPathManager.<init> 45, 46, 47, 48 DeclareParents.verify 4, 48, BcelObjectType.get 45, 48, Subsequence 48 forms an itemset with support 4 33

47 Frequent subsequences Method Ids of subsequences Dump.println 28, 45, 46, 47, 48, 4386 ClassPathManager.<init> 45, 46, 47, 48 DeclareParents.verify 4, 48, BcelObjectType.get 45, 48,

48 Frequent subsequences Method Ids of subsequences Dump.println 28, 45, 46, 47, 48, 4386 ClassPathManager.<init> 45, 46, 47, 48 DeclareParents.verify 4, 48, BcelObjectType.get 45, 48, Subsequences 45 and 48 form an itemset with support 3 35

49 Missing subsequences Method Ids of subsequences Dump.println 28, 45, 46, 47, 48, 4386 ClassPathManager.<init> 45, 46, 47, 48 DeclareParents.verify 4, 48, BcelObjectType.get 45, 48,

50 Missing subsequences Method Ids of subsequences Dump.println 28, 45, 46, 47, 48, 4386 ClassPathManager.<init> 45, 46, 47, 48 DeclareParents.verify 4, 48, BcelObjectType.get 45, 48, Missing subsequences point to anomalies 36

51 Missing subsequences Method Ids of subsequences Dump.println 28, 45, 46, 47, 48, 4386 ClassPathManager.<init> 45, 46, 47, 48 DeclareParents.verify 4, 48, BcelObjectType.get 45, 48, Subsequence 45: (hasnext, hasnext) Subsequence 48: (hasnext, next) Missing subsequences point to anomalies 36

52 The anomalous method /** * This method looks through the type hierarchy for some target type - it is attempting to * find an existing parameterization that clashes with the new parent that the user * wants to apply to the type. If it finds an existing parameterization that matches the * new one, it silently completes, if it finds one that clashes (e.g. a type already has * A<String> when the user wants to add A<Number>) then it will produce an error. * * It uses recursion and exits recursion on hitting 'jlobject' * * Related bugzilla entries: pr */ private boolean verifynoinheritedalternateparameterization(resolvedtype typetoverify,resolvedtype newparent,world world) { if (typetoverify.equals(resolvedtype.object)) return true; ResolvedType newparentgenerictype = newparent.getgenerictype(); Iterator iter = typetoverify.getdirectsupertypes(); while (iter.hasnext()) { ResolvedType supertype = (ResolvedType)iter.next(); if ( ((supertype.israwtype() && newparent.isparameterizedtype()) (supertype.isparameterizedtype() && newparent.israwtype())) && newparentgenerictype.equals(supertype.getgenerictype())) { // new parent is a parameterized type, but this is a raw type world.getmessagehandler().handlemessage(new Message( WeaverMessages.format(WeaverMessages.CANT_DECP_MULTIPLE_PARAMETERIZATIONS,newParent.getName(),typeToVerify.getName(),supertype.getName()), getsourcelocation(), true, new ISourceLocation[]{typeToVerify.getSourceLocation())); return false; if (supertype.isparameterizedtype()) { ResolvedType generictype = supertype.getgenerictype(); // If the generic types are compatible but the parameterizations aren't then we have a problem if (generictype.isassignablefrom(newparentgenerictype) &&!supertype.isassignablefrom(newparent)) { world.getmessagehandler().handlemessage(new Message( WeaverMessages.format(WeaverMessages.CANT_DECP_MULTIPLE_PARAMETERIZATIONS,newParent.getName(),typeToVerify.getName(),supertype.getName()), getsourcelocation(), true, new ISourceLocation[]{typeToVerify.getSourceLocation())); return false; return verifynoinheritedalternateparameterization(supertype,newparent,world); return true; 37

53 The anomalous method /** * This method looks through the type hierarchy for some target type - it is attempting to * find an existing parameterization that clashes with the new parent that the user * wants to apply to the type. If it finds an existing parameterization that matches the * new one, it silently completes, if it finds one that clashes (e.g. a type already has * A<String> when the user wants to add A<Number>) then it will produce an error. * * It uses recursion and exits recursion on hitting 'jlobject' * * Related bugzilla entries: pr */ private boolean verifynoinheritedalternateparameterization(resolvedtype typetoverify,resolvedtype newparent,world world) { if (typetoverify.equals(resolvedtype.object)) return true; ResolvedType newparentgenerictype = newparent.getgenerictype(); Iterator iter = typetoverify.getdirectsupertypes(); while (iter.hasnext()) { ResolvedType supertype = (ResolvedType)iter.next(); if ( ((supertype.israwtype() && newparent.isparameterizedtype()) (supertype.isparameterizedtype() && newparent.israwtype())) && newparentgenerictype.equals(supertype.getgenerictype())) { // new parent is a parameterized type, but this is a raw type world.getmessagehandler().handlemessage(new Message( WeaverMessages.format(WeaverMessages.CANT_DECP_MULTIPLE_PARAMETERIZATIONS,newParent.getName(),typeToVerify.getName(),supertype.getName()), getsourcelocation(), true, new ISourceLocation[]{typeToVerify.getSourceLocation())); return false; if (supertype.isparameterizedtype()) { ResolvedType generictype = supertype.getgenerictype(); // If the generic types are compatible but the parameterizations aren't then we have a problem if (generictype.isassignablefrom(newparentgenerictype) &&!supertype.isassignablefrom(newparent)) { world.getmessagehandler().handlemessage(new Message( WeaverMessages.format(WeaverMessages.CANT_DECP_MULTIPLE_PARAMETERIZATIONS,newParent.getName(),typeToVerify.getName(),supertype.getName()), getsourcelocation(), true, new ISourceLocation[]{typeToVerify.getSourceLocation())); return false; return verifynoinheritedalternateparameterization(supertype,newparent,world); return true; This method is in fact buggy 37

54 Another anomaly List values = ; for (Iterator it = values.iterator(); it.hasnext();) { return ; The list holds in fact at most one element 38

55 Frequent subsequences statistics jar file Classes Rules Flaws Time aspectjlib.jar :03 aspectjrt.jar :04 aspectjweaver.jar :06 aspectjtools.jar :50 39

56 Frequent subsequences statistics Fast enough to be practically useful jar file Classes Rules Flaws Time aspectjlib.jar :03 Found previously unknown bug in AspectJ aspectjrt.jar :04 Found violations of convention in AspectJ aspectjweaver.jar :06 aspectjtools.jar :50! Many false positives 40

57 Suggesting method calls In Eclipse 44

58 Suggesting method calls st = new st.hasmoretokens!!!! st.nexttoken!!!!!!!! Using models 48

59 Other ideas (1) Use conditions in code to enhance models st = new st = new st.hasmoretokens st.nexttoken!!!!!!!!!!!! st.hasmoretokens st.nexttoken!!!!!!!!!st.hasmoretokens 49

60 Other ideas (2) Suggest changes based on model s evolution Evolution of a model of class A originating from method B 50

61 Other ideas (2) Suggest changes based on model s evolution

62 Other ideas (2) Suggest changes based on model s evolution

63 Other ideas (2) Suggest changes based on model s evolution Suggest the change 52

64 Conclusion 53

Automatic Defect Detection. Andrzej Wasylkowski

Automatic Defect Detection. Andrzej Wasylkowski Automatic Defect Detection Andrzej Wasylkowski Overview Automatic Defect Detection Horizontal Techniques Specification-checking Techniques Mining-based Techniques Mining Repositories Mining Traces Mining

More information

Mining Operational Preconditions. Andrzej Wasylkowski Andreas Zeller Saarland University

Mining Operational Preconditions. Andrzej Wasylkowski Andreas Zeller Saarland University Mining Operational Preconditions Andrzej Wasylkowski Andreas Zeller Saarland University @interface A {} bug.aj aspect Test { declare @field : @A int var* : @A; declare @field : int var* : @A; interface

More information

Detecting Object Usage Anomalies

Detecting Object Usage Anomalies hasnext next next hasnext init push push push Detecting Object Usage Anomalies Andrzej Wasylkowski Dept. of Computer Science Saarland University Saarbrücken, Germany wasylkowski@cs.uni-sb.de Andreas Zeller

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

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

Collections and Iterators. Collections

Collections and Iterators. Collections Collections and Iterators Based on the notes from David Fernandez-Baca and Steve Kautz Based on The Java Tutorial (http://docs.oracle.com/javase/tutorial/java/) Bryn Mawr College CS206 Intro to Data Structures

More information

An Activation Record for Simple Subprograms. Activation Record for a Language with Stack-Dynamic Local Variables

An Activation Record for Simple Subprograms. Activation Record for a Language with Stack-Dynamic Local Variables Activation Records The storage (for formals, local variables, function results etc.) needed for execution of a subprogram is organized as an activation record. An Activation Record for Simple Subprograms.

More information

Mining Temporal Specifications from Object Usage. Andrzej Wasylkowski Andreas Zeller Saarland University

Mining Temporal Specifications from Object Usage. Andrzej Wasylkowski Andreas Zeller Saarland University Mining Temporal Specifications from Object Usage Andrzej Wasylkowski Andreas Zeller Saarland University bug.aj @interface A { aspect Test { declare @field : @A int var* : @A; declare @field : int var*

More information

Take Control with AspectJ

Take Control with AspectJ Hermod Opstvedt Chief Architect DnB NOR ITUD Common components Hermod Opstvedt Slide 1 What is AspectJ? Aspect-oriented programming (AOP) is a technique for improving separation of concerns. Crosscutting

More information

1 Runtime Verification using JavaMOP

1 Runtime Verification using JavaMOP 1 Runtime Verification using JavaMOP Venkatesh Vinayakarao, IIIT Delhi. Monitor Oriented Programming (MOP) 1 is a framework for runtime verification using the concept of monitors. JavaMop 2 is a Java implementation

More information

Refactoring with Eclipse

Refactoring with Eclipse Refactoring with Eclipse Seng 371 Lab 8 By Bassam Sayed Based on IBM article Explore refactoring functions in Eclipse JDT by Prashant Deva Code Refactoring Code refactoring is a disciplined way to restructure

More information

CIS 120 Midterm II November 16, 2012 SOLUTIONS

CIS 120 Midterm II November 16, 2012 SOLUTIONS CIS 120 Midterm II November 16, 2012 SOLUTIONS 1 1. Java vs. OCaml (22 points) a. In OCaml, the proper way to check whether two string values s and t are structurally equal is: s == t s = t s.equals(t)

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Version of February 23, 2013 Abstract Handling errors Declaring, creating and handling exceptions

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Version of February 23, 2013 Abstract Handling errors Declaring, creating and handling exceptions

More information

[TAP:PMUHE] Stack vs Queue

[TAP:PMUHE] Stack vs Queue [TAP:PMUHE] Stack vs Queue A Singly Linked List can be used to implement which of the following A. List B. Stack C. Queue D. B and C E. Whatever 1 Administrative Details Midterm and lab scores (4 and 5)

More information

Question 1: public class BlankKarel extends SuperKarel { public void run() { while (frontisclear()) { walkarow(); move(); } walkarow(); // fencepost }

Question 1: public class BlankKarel extends SuperKarel { public void run() { while (frontisclear()) { walkarow(); move(); } walkarow(); // fencepost } Question 1: public class BlankKarel extends SuperKarel { public void run() { while (frontisclear()) { walkarow(); walkarow(); // fencepost public void walkarow() { turnleft(); while(frontisclear() && leftisblocked()

More information

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this

More information

CS 455: INTRODUCTION TO DISTRIBUTED SYSTEMS [THREADS] Frequently asked questions from the previous class survey

CS 455: INTRODUCTION TO DISTRIBUTED SYSTEMS [THREADS] Frequently asked questions from the previous class survey CS 455: INTRODUCTION TO DISTRIBUTED SYSTEMS [THREADS] Shrideep Pallickara Computer Science Colorado State University L6.1 Frequently asked questions from the previous class survey L6.2 SLIDES CREATED BY:

More information

Active Learning: Streams

Active Learning: Streams Lecture 29 Active Learning: Streams The Logger Application 2 1 Goals Using the framework of the Logger application, we are going to explore three ways to read and write data using Java streams: 1. as text

More information

5 When a program calls a function, in which type of data structure is memory allocated for the variables in that function?

5 When a program calls a function, in which type of data structure is memory allocated for the variables in that function? 1 The finally block of an exception handler is: -executed when an exception is thrown -always executed when the code leaves any part of the Try statement -always executed -always executed when the code

More information

Name CPTR246 Spring '17 (100 total points) Exam 3

Name CPTR246 Spring '17 (100 total points) Exam 3 Name CPTR246 Spring '17 (100 total points) Exam 3 1. Linked Lists Consider the following linked list of integers (sorted from lowest to highest) and the changes described. Make the necessary changes in

More information

CSE 331 Summer 2016 Final Exam. Please wait to turn the page until everyone is told to begin.

CSE 331 Summer 2016 Final Exam. Please wait to turn the page until everyone is told to begin. Name The exam is closed book, closed notes, and closed electronics. Please wait to turn the page until everyone is told to begin. Score / 54 1. / 12 2. / 12 3. / 10 4. / 10 5. / 10 Bonus: 1. / 6 2. / 4

More information

The Collections API. Lecture Objectives. The Collections API. Mark Allen Weiss

The Collections API. Lecture Objectives. The Collections API. Mark Allen Weiss The Collections API Mark Allen Weiss Lecture Objectives To learn how to use the Collections package in Java 1.2. To illustrate features of Java that help (and hurt) the design of the Collections API. Tuesday,

More information

JAVA COLLECTION FRAMEWORK & SETS

JAVA COLLECTION FRAMEWORK & SETS JAVA COLLECTION FRAMEWORK & SETS Ch07.4-5 & Ch10.5 Presentation for use with the textbook 1. Data Structures and Algorithms in Java, 6 th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser,

More information

ADT Stack. Inserting and deleting elements occurs at the top of Stack S. top. bottom. Stack S

ADT Stack. Inserting and deleting elements occurs at the top of Stack S. top. bottom. Stack S Stacks Stacks & Queues A linear sequence, or list, is an ordered collection of elements: S = (s 1, s 2,..., s n ) Stacks and queues are finite linear sequences. A Stack is a LIFO (Last In First Out) list.

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

CS455: Introduction to Distributed Systems [Spring 2019] Dept. Of Computer Science, Colorado State University

CS455: Introduction to Distributed Systems [Spring 2019] Dept. Of Computer Science, Colorado State University CS 455: INTRODUCTION TO DISTRIBUTED SYSTEMS [THREADS] The House of Heap and Stacks Stacks clean up after themselves But over deep recursions they fret The cheerful heap has nary a care Harboring memory

More information

Prelim 2 Solution. CS 2110, November 19, 2015, 5:30 PM Total. Sorting Invariants Max Score Grader

Prelim 2 Solution. CS 2110, November 19, 2015, 5:30 PM Total. Sorting Invariants Max Score Grader Prelim 2 CS 2110, November 19, 2015, 5:30 PM 1 2 3 4 5 6 Total Question True Short Complexity Searching Trees Graphs False Answer Sorting Invariants Max 20 15 13 14 17 21 100 Score Grader The exam is closed

More information

The Java Collections Framework. Chapters 7.5

The Java Collections Framework. Chapters 7.5 The Java s Framework Chapters 7.5 Outline Introduction to the Java s Framework Iterators Interfaces, Classes and Classes of the Java s Framework Outline Introduction to the Java s Framework Iterators Interfaces,

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (IS120) Lecture 30 April 6, 2015 ExcepEons hapter 27 Iterator quiz public static void iteratorexn() { List strs = new LinkedList(); strs.add(""); strs.add("is

More information

Lecture 4. The Java Collections Framework

Lecture 4. The Java Collections Framework Lecture 4. The Java s Framework - 1 - Outline Introduction to the Java s Framework Iterators Interfaces, Classes and Classes of the Java s Framework - 2 - Learning Outcomes From this lecture you should

More information

(Divide and Conquer) Electrical & Computer Engineering University of Waterloo Canada. February 14, Divide And Conquer

(Divide and Conquer) Electrical & Computer Engineering University of Waterloo Canada. February 14, Divide And Conquer ( ) Electrical & Computer Engineering University of Waterloo Canada February 14, 2007 Divide And BinarySearch is an (arguably degenerate) instance of a basic algorithm design pattern: Divide And 1. If

More information

Prelim 2 Solution. CS 2110, November 19, 2015, 7:30 PM Total. Sorting Invariants Max Score Grader

Prelim 2 Solution. CS 2110, November 19, 2015, 7:30 PM Total. Sorting Invariants Max Score Grader Prelim 2 CS 2110, November 19, 2015, 7:30 PM 1 2 3 4 5 6 Total Question True Short Complexity Searching Trees Graphs False Answer Sorting Invariants Max 20 15 13 14 17 21 100 Score Grader The exam is closed

More information

Computational Linguistics (INF2820 TFSs)

Computational Linguistics (INF2820 TFSs) S NP Det N VP V The dog barked LTOP h 1 INDEX e 2 def q rel bark v rel prpstn m rel LBL h 4 dog n rel LBL h RELS LBL h 1 ARG0 x 5 LBL h 9 8 ARG0 e MARG h 3 RSTR h 6 ARG0 x 2 5 ARG1 x BODY h 5 7 HCONS h

More information

The tree data structure. Trees COL 106. Amit Kumar Shweta Agrawal. Acknowledgement :Many slides are courtesy Douglas Harder, UWaterloo

The tree data structure. Trees COL 106. Amit Kumar Shweta Agrawal. Acknowledgement :Many slides are courtesy Douglas Harder, UWaterloo The tree data structure 1 Trees COL 106 Amit Kumar Shweta Agrawal Acknowledgement :Many slides are courtesy Douglas Harder, UWaterloo 1 Trees The tree data structure 3 A rooted tree data structure stores

More information

Lecture 10: Nested Depth First Search, Counter- Example Generation Revisited, Bit-State Hashing, On-The-Fly Model Checking

Lecture 10: Nested Depth First Search, Counter- Example Generation Revisited, Bit-State Hashing, On-The-Fly Model Checking CS 267: Automated Verification Lecture 10: Nested Depth First Search, Counter- Example Generation Revisited, Bit-State Hashing, On-The-Fly Model Checking Instructor: Tevfik Bultan Buchi Automata Language

More information

Tutorial 02: Writing Source Code

Tutorial 02: Writing Source Code Tutorial 02: Writing Source Code Contents: 1. Generating a constructor. 2. Generating getters and setters. 3. Renaming a method. 4. Extracting a superclass. 5. Using other refactor menu items. 6. Using

More information

Lists and Iterators. CSSE 221 Fundamentals of Software Development Honors Rose-Hulman Institute of Technology

Lists and Iterators. CSSE 221 Fundamentals of Software Development Honors Rose-Hulman Institute of Technology Lists and Iterators CSSE 221 Fundamentals of Software Development Honors Rose-Hulman Institute of Technology Announcements Should be making progress on VectorGraphics. Should have turned in CRC cards,

More information

Software Construction

Software Construction Lecture 7: Type Hierarchy, Iteration Abstraction Software Construction in Java for HSE Moscow Tom Verhoeff Eindhoven University of Technology Department of Mathematics & Computer Science Software Engineering

More information

Class 26: Linked Lists

Class 26: Linked Lists Introduction to Computation and Problem Solving Class 26: Linked Lists Prof. Steven R. Lerman and Dr. V. Judson Harward 2 The Java Collection Classes The java.util package contains implementations of many

More information

@ASPECTJ BASED AOP WITH SPRING

@ASPECTJ BASED AOP WITH SPRING @ASPECTJ BASED AOP WITH SPRING http://www.tutorialspoint.com/spring/aspectj_based_aop_appoach.htm Copyright tutorialspoint.com @AspectJ refers to a style of declaring aspects as regular Java classes annotated

More information

C Sc 127B Practice Test 2 Section Leader Your Name 100pts

C Sc 127B Practice Test 2 Section Leader Your Name 100pts C Sc 127B Practice Test 2 Section Leader Your Name 100pts Assume we have two collection class named Stack and Queue that have the appropriate messages: Stack public boolean isempty(); public void push(e

More information

Fall 2017 CISC124 10/1/2017

Fall 2017 CISC124 10/1/2017 CISC124 Today First onq quiz this week write in lab. More details in last Wednesday s lecture. Repeated: The quiz availability times will change to match each lab as the week progresses. Useful Java classes:

More information

CSC 1052 Algorithms & Data Structures II: Lists

CSC 1052 Algorithms & Data Structures II: Lists CSC 1052 Algorithms & Data Structures II: Lists Professor Henry Carter Spring 2018 Recap Collections hold and access elements based on content Order and index no longer considered Comparable elements implement

More information

hw6, BFS, debugging CSE 331 Section 5 10/25/12 Slides by Kellen Donohue

hw6, BFS, debugging CSE 331 Section 5 10/25/12 Slides by Kellen Donohue hw6, BFS, debugging CSE 331 Section 5 10/25/12 Slides by Kellen Donohue Agenda hw4 being graded hw5 may be graded first, for feedback to be used on hw6 hw6 due next week Today hw6 BFS Debugging hashcode()

More information

Implementing a List in Java. CSC 143 Java. List Interface (review) Just an Illusion? Using an Array to Implement a List CSC

Implementing a List in Java. CSC 143 Java. List Interface (review) Just an Illusion? Using an Array to Implement a List CSC Implementing a List in Java CSC 143 Java List Implementation Using Arrays Updated with Java 5.0 Generics Reading: Ch. 13 Two implementation approaches are most commonly used for simple lists: Arrays Linked

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 10 Thomas Wies New York University Review Last class ML Outline Modules Sources: PLP, 3.3.4, 3.3.5, 3.8 McConnell, Steve. Code Complete, Second Edition,

More information

Lecture 8: Iterators and More Mutation

Lecture 8: Iterators and More Mutation Integrated Introduction to Computer Science Fisler, Nelson Contents 1 Traversing Lists 1 2 Motivating Iterators 2 3 Writing an Iterator 3 4 Writing Sum with an Iterator 4 Objectives By the end of this

More information

04/03/03 Lecture 20 1

04/03/03 Lecture 20 1 Figure 14.2 Adjacency list representation of the graph shown in Figure 14.1; the nodes in list i represent vertices adjacent to i and the cost of the connecting edge. 04/03/03 Lecture 20 1 Shortest Paths

More information

Mining Specifications

Mining Specifications Mining Specifications Andreas Zeller Saarland University zeller@acm.org WINNER OF JOLT PRODUCTIVITY AWARD ANDREAS ZELLER WHY PROGRAMS FAIL A GUIDE TO SYSTEMATIC DEBUGGING SECOND EDITION FOSE 10 FSE 10

More information

Basic Array Implementation Exception Safety

Basic Array Implementation Exception Safety Basic Array Implementation Exception Safety CS 311 Data Structures and Algorithms Lecture Slides Monday, October 26, 2009 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks

More information

Mixed projects: Java + Kotlin. Svetlana Isakova

Mixed projects: Java + Kotlin. Svetlana Isakova Mixed projects: Java + Kotlin Svetlana Isakova Compilation of a mixed project *.kt kotlinc *.class *.jar *.java javac *.class Nullability Nullability Type =? Java Kotlin Nullability annotations @Nullable

More information

COP 3530, Course Outcomes

COP 3530, Course Outcomes COP 3530, Course Outcomes be familiar with basic techniques of algorithm analysis master analyzing simple non-recursive algorithms be familiar with analyzing recursive algorithms master the implementation

More information

CIS 120 Midterm II November 16, Name (printed): Pennkey (login id):

CIS 120 Midterm II November 16, Name (printed): Pennkey (login id): CIS 120 Midterm II November 16, 2012 Name (printed): Pennkey (login id): My signature below certifies that I have complied with the University of Pennsylvania s Code of Academic Integrity in completing

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 29 Enums & Iterators Announcements Prof. Benjamin Pierce is lecturing today Will be teaching 120 again next Spring Enumerations Enumerations (a.k.a.

More information

Computational Linguistics (INF2820 TFSs)

Computational Linguistics (INF2820 TFSs) S NP Det N VP V The dog barked LTOP h 1 INDEX e 2 def q rel bark v rel prpstn m rel LBL h 4 dog n rel LBL h RELS LBL h 1 ARG0 x 5 LBL h 9 8 ARG0 e MARG h 3 RSTR h 6 ARG0 x 2 5 ARG1 x BODY h 5 7 HCONS h

More information

CSCI312 Principles of Programming Languages!

CSCI312 Principles of Programming Languages! CSCI312 Principles of Programming Languages!! Chapter 3 Regular Expression and Lexer Xu Liu Recap! Copyright 2006 The McGraw-Hill Companies, Inc. Clite: Lexical Syntax! Input: a stream of characters from

More information

Prelim 2. CS 2110, November 19, 2015, 7:30 PM Total. Sorting Invariants Max Score Grader

Prelim 2. CS 2110, November 19, 2015, 7:30 PM Total. Sorting Invariants Max Score Grader Prelim 2 CS 2110, November 19, 2015, 7:30 PM 1 2 3 4 5 6 Total Question True Short Complexity Searching Trees Graphs False Answer Sorting Invariants Max 20 15 13 14 17 21 100 Score Grader The exam is closed

More information

Lab Exercise Refactoring using Eclipse

Lab Exercise Refactoring using Eclipse Lunds tekniska högskola Datavetenskap, Nov, 2017 Torbjörn Ekman and Görel Hedin (Modified from cvs to git by Ulf Asklund) EDAF45 Programvaruutveckling i grupp projekt Lab Exercise Refactoring using Eclipse

More information

CIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions)

CIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions) By the end of this course, students should CIS 1.5 Course Objectives a. Understand the concept of a program (i.e., a computer following a series of instructions) b. Understand the concept of a variable

More information

CS314 Exam 2 - Spring Suggested Solution and Criteria 1

CS314 Exam 2 - Spring Suggested Solution and Criteria 1 CS314 Spring 2016 Exam 2 Solution and Grading Criteria. Grading acronyms: AIOBE - Array Index out of Bounds Exception may occur BOD - Benefit of the Doubt. Not certain code works, but, can't prove otherwise

More information

CS61BL Summer 2013 Midterm 2

CS61BL Summer 2013 Midterm 2 CS61BL Summer 2013 Midterm 2 Sample Solutions + Common Mistakes Question 0: Each of the following cost you.5 on this problem: you earned some credit on a problem and did not put your five digit on the

More information

CS18000: Programming I

CS18000: Programming I CS18000: Programming I Dynamic Data Structures 12 April 2010 Prof. Chris Clifton More on Dynamic Data Structures Difficulties with Dynamic Data Structures: Removing self Solution 1: Violate Encapsulation

More information

Linked List Nodes (reminder)

Linked List Nodes (reminder) Outline linked lists reminders: nodes, implementation, invariants circular linked list doubly-linked lists iterators the Java foreach statement iterator implementation the ListIterator interface Linked

More information

Course Status Polymorphism Containers Exceptions Midterm Review. CS Java. Introduction to Java. Andy Mroczkowski

Course Status Polymorphism Containers Exceptions Midterm Review. CS Java. Introduction to Java. Andy Mroczkowski CS 190 - Java Introduction to Java Andy Mroczkowski uamroczk@cs.drexel.edu Department of Computer Science Drexel University February 11, 2008 / Lecture 4 Outline Course Status Course Information & Schedule

More information

CS 221 Review. Mason Vail

CS 221 Review. Mason Vail CS 221 Review Mason Vail Inheritance (1) Every class - except the Object class - directly inherits from one parent class. Object is the only class with no parent. If a class does not declare a parent using

More information

2IP15 Programming Methods

2IP15 Programming Methods Lecture 5: Iteration Abstraction 2IP15 Programming Methods From Small to Large Programs Tom Verhoeff Eindhoven University of Technology Department of Mathematics & Computer Science Software Engineering

More information

Graphs - II CS 2110, Spring 2016

Graphs - II CS 2110, Spring 2016 Graphs - II CS, Spring Where did David leave that book? http://www.geahvet.com Where did David leave that book? Where did David leave that book? http://www.geahvet.com Go as far down a path as possible

More information

Compiling expressions

Compiling expressions E H U N I V E R S I T Y T O H F R G Compiling expressions E D I N B U Javier Esparza Computer Science School of Informatics The University of Edinburgh The goal 1 Construct a compiler for arithmetic expressions

More information

Introduction IS

Introduction IS Introduction IS 313 4.1.2003 Outline Goals of the course Course organization Java command line Object-oriented programming File I/O Business Application Development Business process analysis Systems analysis

More information

Dynamic Data Structures and Generics

Dynamic Data Structures and Generics Dynamic Data Structures and Generics Reading: Savitch ch. 12 Objectives Introduce Abstract Data Types (ADTs) and review interfaces Introduce Java's ArrayList class Learn about linked lists and inner classes

More information

Brekeke PBX Version 3 ARS Plug-in Developer s Guide Brekeke Software, Inc.

Brekeke PBX Version 3 ARS Plug-in Developer s Guide Brekeke Software, Inc. Brekeke PBX Version 3 ARS Plug-in Developer s Guide Brekeke Software, Inc. Version Brekeke PBX Version 3 ARS Plug-in Developer s Guide Copyright This document is copyrighted by Brekeke Software, Inc. Copyright

More information

CS 314 Exam 2 Fall 2017

CS 314 Exam 2 Fall 2017 Points off 1 2 3 4 5 Total off CS 314 Exam 2 Fall 2017 Your Name Your UTEID Circle your TAs Name: Gilbert Jacob Jorge Joseph Lucas Rebecca Shelby Instructions: 1. There are 5 questions on this test. 100

More information

1 Lexical Considerations

1 Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler

More information

Introduction to Software Testing Chapter 2, Sec#: 2.5 Graph Coverage for Specifications

Introduction to Software Testing Chapter 2, Sec#: 2.5 Graph Coverage for Specifications Introduction to Software Testing Chapter 2, Sec#: 2.5 Graph Coverage for Specifications Paul Ammann & Jeff Offutt http://www.cs.gmu.edu/~offutt/softwa retest/ Design Specifications A design specification

More information

Brekeke PBX Version 2 ARS Plug-in Developer s Guide Brekeke Software, Inc.

Brekeke PBX Version 2 ARS Plug-in Developer s Guide Brekeke Software, Inc. Brekeke PBX Version 2 ARS Plug-in Developer s Guide Brekeke Software, Inc. Version Brekeke PBX Version 2 ARS Plug-in Developer s Guide Revised February 2010 Copyright This document is copyrighted by Brekeke

More information

Documenting Advanced Programming Techniques

Documenting Advanced Programming Techniques Documenting Advanced Programming Techniques https://no.wikipedia.org/wiki/tastatur#/media/file:computer_keyboard.png Prof. Dr. Bernhard Humm FB Informatik, Hochschule Darmstadt 1 Agenda 1. Documenting

More information

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Lecture 11 Ana Bove April 26th 2018 Recap: Regular Languages Decision properties of RL: Is it empty? Does it contain this word? Contains

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

Computer Science E-119 Fall Problem Set 4. Due prior to lecture on Wednesday, November 28

Computer Science E-119 Fall Problem Set 4. Due prior to lecture on Wednesday, November 28 Computer Science E-119 Fall 2012 Due prior to lecture on Wednesday, November 28 Getting Started To get the files that you will need for this problem set, log into nice.harvard.edu and enter the following

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

Dynamic Inference of Change Contracts

Dynamic Inference of Change Contracts 2014 IEEE International Conference on Software Maintenance and Evolution Dynamic Inference of Change Contracts Tien-Duy B. Le 1, Jooyong Yi 2, David Lo 1, Ferdian Thung 1, and Abhik Roychoudhury 2 1 School

More information

Lex and Yacc. More Details

Lex and Yacc. More Details Lex and Yacc More Details Calculator example From http://byaccj.sourceforge.net/ %{ import java.lang.math; import java.io.*; import java.util.stringtokenizer; %} /* YACC Declarations; mainly op prec &

More information

Collections. James Brucker

Collections. James Brucker Collections James Brucker Collection A Collection is a group of objects. Set an unordered collection no duplicates List ordered collection duplicates are allowed can add or remove elements anywhere in

More information

CSE 143 Java. Exceptions 1/25/

CSE 143 Java. Exceptions 1/25/ CSE 143 Java Exceptions 1/25/17 12-1 Verifying Validity of Input Parameters A non-private method should always perform parameter validation as its caller is out of scope of its implementation http://docs.oracle.com/javase/7/docs/technotes/guides/language/assert.html

More information

The RV System Tutorial

The RV System Tutorial The RV System Tutorial Patrick Meredith and Grigore Rosu joint work with Feng Chen, Dongyun Jin, Dennis Griffith, Michael Ilseman Runtime Verification, Inc. University of Illinois The RV System!"#$%&'(%)!"#*)+,'-(!9&('/+

More information

1. Every program must have at least one class declaration. (*) 2. Every class declared in a program must have a distinct identifier.

1. Every program must have at least one class declaration. (*) 2. Every class declared in a program must have a distinct identifier. The J- Language (Static) Semantics Version 1.3 (4/5/07) We define here the syntactic restrictions and static semantics of the simple language J- used in 2006 for 3516ICT assignments. Most of these restrictions

More information

Programming Assignment Comma Separated Values Reader Page 1

Programming Assignment Comma Separated Values Reader Page 1 Programming Assignment Comma Separated Values Reader Page 1 Assignment What to Submit 1. Write a CSVReader that can read a file or URL that contains data in CSV format. CSVReader provides an Iterator for

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 29 April 3, 2014 Overriding, Enums, Iterators public class Ref { private T contents; public void add(t e) { contents = e; Quiz (on paper) public

More information

A Quick Overview of OBJECT-ORIENTED PROGRAMMING I

A Quick Overview of OBJECT-ORIENTED PROGRAMMING I A Quick Overview of OBJECT-ORIENTED PROGRAMMING I 8 The OO Paradigm Abstract Data Types Encapsulation & Information Hiding Classes and Objects Inheritance and Polymorphism Object Construction & Destruction

More information

Some examples and/or figures were borrowed (with permission) from slides prepared by Prof. H. Roumani. The Collection Framework

Some examples and/or figures were borrowed (with permission) from slides prepared by Prof. H. Roumani. The Collection Framework Some examples and/or figures were borrowed (with permission) from slides prepared by Prof. H. Roumani The Collection Framework Collection: an aggregate that can hold a varying number of elements Interface:

More information

Implementing a List in Java. CSE 143 Java. Just an Illusion? List Interface (review) Using an Array to Implement a List.

Implementing a List in Java. CSE 143 Java. Just an Illusion? List Interface (review) Using an Array to Implement a List. Implementing a List in Java CSE 143 Java List Implementation Using Arrays Reading: Ch. 13 Two implementation approaches are most commonly used for simple lists: Arrays Linked list Java Interface List concrete

More information

Object Oriented Software Design

Object Oriented Software Design Object Oriented Software Design Inner classes, RTTI, Tree implementation Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 29, 2010 G. Lipari (Scuola Superiore Sant

More information

RYERSON POLYTECHNIC UNIVERSITY DEPARTMENT OF MATH, PHYSICS, AND COMPUTER SCIENCE CPS 710 FINAL EXAM FALL 97 INSTRUCTIONS

RYERSON POLYTECHNIC UNIVERSITY DEPARTMENT OF MATH, PHYSICS, AND COMPUTER SCIENCE CPS 710 FINAL EXAM FALL 97 INSTRUCTIONS RYERSON POLYTECHNIC UNIVERSITY DEPARTMENT OF MATH, PHYSICS, AND COMPUTER SCIENCE CPS 710 FINAL EXAM FALL 97 STUDENT ID: INSTRUCTIONS Please write your student ID on this page. Do not write it or your name

More information

Apache Felix Shell. Apache Felix Shell. Overview. How the Shell Service Works. package org.apache.felix.shell;

Apache Felix Shell. Apache Felix Shell. Overview. How the Shell Service Works. package org.apache.felix.shell; Apache Felix Shell Apache Felix Shell Overview How the Shell Service Works How Commands Work Creating a Command Security and the Shell Service Feedback Overview In order to interact with Felix it is necessary

More information

How We Refactor, and How We Know It

How We Refactor, and How We Know It Emerson Murphy-Hill, Chris Parnin, Andrew P. Black How We Refactor, and How We Know It Urs Fässler 30.03.2010 Urs Fässler () How We Refactor, and How We Know It 30.03.2010 1 / 14 Refactoring Definition

More information

COS 126 Written Exam 2, Fall 2009

COS 126 Written Exam 2, Fall 2009 NAME: COS 126 Written Exam 2, Fall 2009 login ID: precept: This test is 11 questions, weighted as indicated. The exam is closed book, except that you are allowed to use a one page cheatsheet. No calculators

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

CS 455 Final Exam Spring 2015 [Bono] May 13, 2015

CS 455 Final Exam Spring 2015 [Bono] May 13, 2015 Name: USC netid (e.g., ttrojan): CS 455 Final Exam Spring 2015 [Bono] May 13, 2015 There are 10 problems on the exam, with 73 points total available. There are 10 pages to the exam, including this one;

More information

Family Name:... Other Names:... ID Number:... Signature... Model Solutions. COMP 103: Test 1. 9th August, 2013

Family Name:... Other Names:... ID Number:... Signature... Model Solutions. COMP 103: Test 1. 9th August, 2013 Family Name:............................. Other Names:............................. ID Number:............................... Signature.................................. Model Solutions COMP 103: Test

More information