Static Detection of Brittle Parameter Typing

Similar documents
Static Detection of Brittle Parameter Typing

Chapter 12 GUI Basics

Tool Kits, Swing. Overview. SMD158 Interactive Systems Spring Tool Kits in the Abstract. An overview of Swing/AWT

Handout 14 Graphical User Interface (GUI) with Swing, Event Handling

Automatic Testing of Sequential and Concurrent Substitutability

Swing UI. Powered by Pentalog. by Vlad Costel Ungureanu for Learn Stuff

CS111: PROGRAMMING LANGUAGE II

Fully Automatic and Precise Detection of Thread Safety Violations

Overview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008

Object-Oriented Programming Design. Topic : User Interface Components with Swing GUI Part III

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

Graphical User Interface (GUI) components in Java Applets. With Abstract Window Toolkit (AWT) we can build an applet that has the basic GUI

Graphical User Interfaces. Swing. Jose Jesus García Rueda

Swing. By Iqtidar Ali

Summary Chapter 25 GUI Components: Part 2

Java Swing. Lists Trees Tables Styled Text Components Progress Indicators Component Organizers

Chapter 13 GUI Basics. Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved.

Basics of programming 3. Java GUI and SWING

CSE 1325 Project Description

Outline. Composite Pattern. Model-View-Controller Pattern Callback Pattern

CS410G: GUI Programming. The Model/View/Controller Pattern. Model. Controller. View. MVC is a popular architecture for building GUIs

Goals. Lecture 7 More GUI programming. The application. The application D&D 12. CompSci 230: Semester JFrame subclass: ListOWords

Graphics. Lecture 18 COP 3252 Summer June 6, 2017

Event Driven Programming

Chapter 12 GUI Basics. Motivations. The design of the API for Java GUI programming

Graphical User Interface (Part-3) Supplementary Material for CPSC 233

Sketchpad. Plan for Today. Class 22: Graphical User Interfaces IBM 705 (1954) Computer as Clerk : Augmenting Human Intellect

Large-Scale API Protocol Mining for Automated Bug Detection

Java 11 Swing with Eclipse Index

Java Swing. based on slides by: Walter Milner. Java Swing Walter Milner 2005: Slide 1

Swing. Component overview. Java UI, summer semester 2017/2018 1

Java 11 Swing Index. Section Title Page

Part 3: Graphical User Interface (GUI) & Java Applets

Packages: Putting Classes Together

Learn Java Programming, Dr.Hashamdar. Getting Started with GUI Programming

Java 1.9 Swing Index

Graphics programming. COM6516 Object Oriented Programming and Design Adam Funk (originally Kirill Bogdanov & Mark Stevenson)

Java 1.8 Swing with Eclipse Oxygen Index

Java 1.8 Swing with Eclipse Mars Index

Java 1.8 Swing with Eclipse Neon Index

Chapter 17 Creating User Interfaces

Advanced Java Programming. Swing. Introduction to Swing. Swing libraries. Eran Werner, Tel-Aviv University Summer, 2005

Java IDE Programming-I

Nomen est Omen: Exploring and Exploiting Name Similarities between Arguments and Parameters

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp

A Simple Text Editor Application

JLayeredPane. Depth Constants in JLayeredPane

SD Module-1 Advanced JAVA

Outline. Observer Pattern: Pitfalls. Observer Applications

SD Module-1 Advanced JAVA. Assignment No. 4

SilkTest Classic. Migrating from the SilkTest Classic Agent to the Open Agent

Object Oriented Programming

TypeDevil: Dynamic Type Inconsistency Analysis for JavaScript

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7

Contents Introduction 1

Implementing Graphical User Interfaces

1.1 GUI. JFrame. import java.awt.*; import javax.swing.*; public class XXX extends JFrame { public XXX() { // XXX. init() main() public static

Systems Programming Graphical User Interfaces

// Class used to hold a list of Strings interpreted as web site addresses. public class URLList {

user-friendly and easy to use.

2110: GUIS: Graphical User Interfaces

Programming graphics

Chapter 14. More Swing

More Swing. Chapter 14. Chapter 14 1

Window Interfaces Using Swing Objects

Jonathan Aldrich Charlie Garrod

More Swing. CS180 Recitation 12/(04,05)/08

Contents Chapter 1 Introduction to Programming and the Java Language

MEMORY MANAGEMENT TEST-CASE GENERATION OF C PROGRAMS USING BOUNDED MODEL CHECKING

Window Interfaces Using Swing Objects

2010 가을학기부산대학교정보컴퓨터공학부 OVERVIEW OF GUI PROGRAMMING

JBuilder 8.0 JFC and Swing Programming

GUI Applications. Let s start with a simple Swing application in Java, and then we will look at the same application in Jython. See Listing 16-1.

JList. Displays a series of items The user can select one or more items Class JList extends directly class Jcomponent Class Jlist supports

Silk Test Migrating from the Classic Agent to the Open Agent

Swing Programming Example Number 2

Widgets. Widgets Widget Toolkits. 2.3 Widgets 1

RELIABLE SOFTWARE SYSTEMS

Chapter 13 Lab Advanced GUI Applications

Graphic User Interfaces. - GUI concepts - Swing - AWT

Chapter 13 Lab Advanced GUI Applications Lab Objectives. Introduction. Task #1 Creating a Menu with Submenus

C Praktikum. Advanced Pointers. Eugen Betke, Nathanael Hübbe, Michael Kuhn, Jakob Lüttgau, Jannek Squar

Certified Eclipse Bundle

CONTENTS. Chapter 1 Getting Started with Java SE 6 1. Chapter 2 Exploring Variables, Data Types, Operators and Arrays 13

Certified Eclipse Bundle

Rizvi College of Arts, Science & Commerce Bandra (W), Mumbai Teaching Plan Academic Year

FULLY AUTOMATIC AND PRECISE DETECTION OF THREAD SAFETY VIOLATIONS

Unit 6 - Software Design and Development LESSON 4 DATA TYPES

Widgets. Widgets Widget Toolkits. User Interface Widget

Lesson 36: for() Loops (W11D1)

Module 5 The Applet Class, Swings. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

First Name: AITI 2004: Exam 2 July 19, 2004

Week 2: Quick and Dirty Jython Refresher

Graphical User Interface (GUI)

Graphical User Interfaces. Comp 152

JTcl and Swank. Bruce A. Johnson, Tom Poindexter, & Dan Bodoh. What s new with Tcl and Tk on the JVM. Wednesday, October 26, 11

Outline. More on the Swing API Graphics: double buffering and timers Model - View - Controller paradigm Applets

Chris9an Kästner Charlie Garrod

GUI Components Continued EECS 448

Outline CSE 3461 F10. What is a Widget? Properties of Widgets. A self-contained screen object Also called a control Examples of widgets:

Transcription:

Static Detection of Brittle Parameter Typing Michael Pradel, Severin Heiniger, and Thomas R. Gross Department of Computer Science ETH Zurich 1

Motivation void m(a a) {... } Object A.. B C D E F 2

Motivation void m(a a) {... } Object Compatible types A.. B C D E F 2

Motivation void m(a a) {... } Object A.. Expected by method B C D E F 2

Motivation void m(a a) {... } Object A.. Expected by method Unexpected by method B C D E F 2

Example: Swing API (1) JMenu.add(Component) Component JComponent CheckBox AbstractButton JTextField JCheckBox JSeparator JMenuItem JCheckBoxMenuItem JMenu JRadioButtonMenuItem 3

Example: Swing API (1) JMenu.add(Component) Expected Component JComponent CheckBox AbstractButton JTextField JCheckBox JSeparator JMenuItem JCheckBoxMenuItem JMenu JRadioButtonMenuItem 3

Example: Swing API (1) JMenu.add(Component) Expected Unexpected Component JComponent CheckBox AbstractButton JTextField JCheckBox JSeparator JMenuItem JCheckBoxMenuItem JMenu JRadioButtonMenuItem 3

Example: Swing API (1) JMenu.add(Component) Expected Unexpected Component Mismatch between declared JComponent CheckBox type and expected types AbstractButton JTextField JCheckBox JSeparator JMenuItem JCheckBoxMenuItem JMenu JRadioButtonMenuItem 3

Example: Swing API (2) Expected argument type: JCheckBoxMenuItem Unexpected argument type: JCheckBox Confirmed as bug: See ntorrent issue #136 4

The Problem Brittle parameter type: Has subtypes that are not expected by callee Compatible but unexpected arguments: Subtle errors hidden from the type system 5

This Talk Infer from API clients which parameters are brittle and search for unusual argument types 6

Overview API clients Static analysis Argument type observations Anomaly detection Warnings about unexpected types 7

Overview API clients Static analysis Argument type observations Anomaly detection Warnings about unexpected types 7

Static Analysis Goal Find types of arguments given to API methods Two variants Simple: Statically declared type Points-to analysis: Use points-to set of arguments 8

Argument Type Observations (1) Client: Foo foo = new Foo(); JLabel label = new JLabel(); api(foo, label); API: void api(object, Component) 9

Argument Type Observations (1) Client: Foo foo = new Foo(); JLabel label = new JLabel(); api(foo, label); Simple analysis: Foo JLabel API: void api(object, Component) 9

Argument Type Observations (2) Client: Component Button JLabel Foo foo = new Foo(); Component comp; if (...) comp = new JLabel(); else comp = new Button(); api(foo, comp); API: void api(object, Component) 10

Argument Type Observations (2) Client: Component Button JLabel Foo foo = new Foo(); Component comp; if (...) comp = new JLabel(); else comp = new Button(); api(foo, comp); Simple analysis: Foo Component API: void api(object, Component) 10

Argument Type Observations (2) Client: Component Button JLabel Foo foo = new Foo(); Component comp; if (...) comp = new JLabel(); else comp = new Button(); api(foo, comp); Simple analysis: Foo Imprecision Component API: void api(object, Component) 10

Argument Type Observations (2) Client: Component Button JLabel Foo foo = new Foo(); Component comp; if (...) comp = new JLabel(); else comp = new Button(); api(foo, comp); Points-to analysis: Foo JLabel, Button API: void api(object, Component) 10

Argument Type Observations (2) Client: Component Button JLabel Foo foo = new Foo(); Component comp; if (...) comp = new JLabel(); else comp = new Button(); api(foo, comp); Points-to analysis: (with confidence) Foo (1.0) JLabel (0.5), Button (0.5) API: void api(object, Component) 10

Argument Type Observations (3) Result: Parameter Observations api(object,...) Foo (1.0) api(..., Component) Button (0.5) JLabel (0.5) 11

Focus on API Types 1. Generalize client types to API types: Button Foo API type Client-specific type Foo (1.0) Button (1.0) 2. Remove all non-api types 12

Merging Observations Merge observations from Different clients of same API Different call sites of same API method Example: Parameter Observations api(object,...) Button (1.0) JList (1.0) Button (0.25)... api(..., Component)... 13

Overview API clients Static analysis Argument type observations Anomaly detection Warnings about unexpected types 14

Overview API clients Static analysis Argument type observations Anomaly detection Warnings about unexpected types 14

Anomaly Detection Goal: Find unexpected arguments given to likely brittle parameters For each parameter: 1. Build type histogram 2. Search anomalies 15

Type Histograms JComponent.add(Component, Object) 16

Type Histograms JComponent.add(Component, Object) Not a brittle parameter 16

Type Histograms (2) Container.add(Component, Object) 17

Type Histograms (2) Container.add(Component, Object) Brittle parameter 17

Type Histograms (3) JMenu.add(Component) 18

Type Histograms (3) JMenu.add(Component) Brittle parameter, two unexpected arguments 18

Type Histograms (4) JScrollPane.<init>(Component, int, int) 19

Type Histograms (4) JScrollPane.<init>(Component, int, int) Little information 19

Finding Anomalies All observations Initial assumption: Each observation = potential anomaly Filters to remove false warnings Warnings If all filters passed: Warning about unexpected argument 20

Filtering 21

Filtering Initial assumption: All observations are anomalies 21

Filtering 21

Filtering Whole-histogram filter: Minimum number of observations 21

Filtering 21

Filtering Whole-histogram filter: Maximum number of types 21

Filtering 21

Filtering Per-type filter: Minimum Confidence Drop (Does the argument type deviate from an otherwise accepted rule?) 21

Filtering 21

Filtering Whole-histogram filter: Maximum percentage of anomalies 21

Filtering 21

Filtering Result: Two anomalies (both are bugs) 21

Summary API clients Static analysis Argument type observations Anomaly detection Warnings about unexpected types 22

Evaluation 21 programs (650 kloc) AWT/Swing API Bugs - code smells - false positives 23

Example: Bug in jedit class FilteredListModel extends AbstractListModel { void setfilter(string filter) { Runnable runner = new Runnable() { public void run() { firecontentschanged(this, 0, getsize()-1); } }; } } Confirmed as a bug and fixed within a day. See bug #3477759. 24

Example: Bug in jedit class FilteredListModel extends AbstractListModel { void setfilter(string filter) { Runnable runner = new Runnable() { public void run() { firecontentschanged(this, 0, getsize()-1); } }; } } Confirmed as a bug and fixed within a day. See bug #3477759. 24

Example: Bug in jedit class FilteredListModel extends AbstractListModel { void setfilter(string filter) { Runnable runner = new Runnable() { public void run() { firecontentschanged(this, 0, getsize()-1); } }; } } Confirmed as a bug and fixed within a day. See bug #3477759. 24

Example: Bug in jedit class FilteredListModel extends AbstractListModel { void setfilter(string filter) { Runnable runner = new Runnable() { public void run() { firecontentschanged(this, 0, getsize()-1); } }; } } Declared: Object Expected: *ListModel Here: Runnable Confirmed as a bug and fixed within a day. See bug #3477759. 24

Example: Bug in JFtp... JScrollPane scrollpane = new JScrollPane(list); container.add(new JScrollPane(scrollPane));... Confirmed as a bug and fixed. See bug #3484625. 25

Example: Bug in JFtp... JScrollPane scrollpane = new JScrollPane(list); container.add(new JScrollPane(scrollPane));... Declared: Component Expected: JList, JTextArea,... Here: JScrollPane Confirmed as a bug and fixed. See bug #3484625. 25

Characteristics of Issues Common to all issues found: Subtle problems (no exception etc.) Visual glitches GUI misbehavior Hard to find with traditional testing 26

Precision Default filtering: 47% 5 bugs 4 code smells 10 false positives 27

Precision Default filtering: 47% 5 bugs 4 code smells 10 false positives Recall-focused filtering: 11%.. 11 bugs 4 code smells 140 false positives 27

Recall Randomly seeded bugs (for known brittle parameters) Default filtering: 83% Recall-focused filtering: 94% 28

Influence of Points-to Analysis Benefits of using points-to analysis Find two more bugs (recall-focused configuration, original programs) Increased precision: 76% 83% (default configuration, seeded bugs) 29

Influence of Points-to Analysis Benefits of using points-to analysis Find two more bugs (recall-focused configuration, original programs) Increased precision: 76% 83% (default configuration, seeded bugs) Beneficial but not crucial 29

Performance Good performance for automatic analysis All 21 programs: 23 minutes 99.9% of time: Static analysis Intel Core 2 Duo with 3.16 GHz, 2.5 GB memory 30

Conclusion Powerful analysis that finds subtle errors where traditional testing fails Lessons learned: Brittle parameters: Real problem that deserves attention Simple analysis: Effective in practice Many-client analysis: Key to success 31

Thank you! Implementation and experimental data: http://mp.binaervarianz.de/issta2012/ Static Detection of Brittle Parameter Typing Michael Pradel, Severin Heiniger, and Thomas R. Gross 32