Test Patterns in Java

Size: px
Start display at page:

Download "Test Patterns in Java"

Transcription

1 Test Patterns in Java Jaroslav Tulach, Jesse Glick, Miloš Kleint Sun Microsystems JavaOne SM Conference Session BOF 0220

2 Automated Testing Test is a Kind of Documentation Learn why to invest in automated testing and let us give you overview of the wildest test patterns that NetBeans project found useful JavaOne SM Conference Session BOF

3 Agenda What is the problem? Why do automated tests help? How to write tests? Questions and Answers 2006 JavaOne SM Conference Session BOF

4 The Quality of an Application quality = implementation specification quality may not be the right term maybe term confidence is better regressions cost too much the "amoeba" model 2006 JavaOne SM Conference Session BOF

5 The Amoeba Model 2006 JavaOne SM Conference Session BOF

6 The Amoeba Model 2006 JavaOne SM Conference Session BOF

7 Why write automated tests? Make sure the code works Things do not get wrong concurrent access garbage collection and finalizers Algorithms and data structures are sane fast and small Mistakes do not reappear race conditions deadlocks 2006 JavaOne SM Conference Session BOF

8 Do tests influence code? methods to verify state ways to prevent asynchronous behavior separation to units using lookup and discovery code against interfaces not implementation Java is not single threaded tests may need cooperation with code openide util/org/openide/util/lookup.html 2006 JavaOne SM Conference Session BOF

9 Test Patterns in Java Testing exception states Hard to invent Easy to copy and use Premise: Test everything 2006 JavaOne SM Conference Session BOF

10 Demo Application Extraordinary Complex and Useless Calculator 2006 JavaOne SM Conference Session BOF

11 Code Against Interfaces define abstract interfaces and lookup implementation: public abstract class DialogDisplayer { public abstract Object notify(javax.swing.joptionpane what); public static DialogDisplayer getdefault() { return Lookup.getDefault().lookup(DialogDisplayer.class); // or in Mustang return java.util.serviceloader.load(dialogdisplayer.class).iterator.next(); real implementation in the application mock object in the test 2006 JavaOne SM Conference Session BOF

12 Setup Testing Environment fill lookup with own mock implementation replace UI with headless displayer public class MyTest extends org.netbeans.nbjunit.nbtestcase { protected void setup() { org.netbeans.nbjunit.mockservices.setservices(mockdialogdisplayer.class); public class MockDialogDisplayer extends DialogDisplayer { public static JOptionPane lastpane; public static Object toreturn; public Object notify(joptionpane p) { lastpane = p; return toreturn; 2006 JavaOne SM Conference Session BOF

13 Memory Leak Tests Memory management is important aspect of amoeba easy to regress hard to describe and verify NbTestCase.assertGC(String, Reference); Cooperates with Insane library class SetupAndGCTest extends NbTestCase { public void testtheycandisappear() { Calculator same = Calculator.create("powerful"); WeakReference ref = new WeakReference(same); same = null; assertgc("caches can be GCed", ref); NetBeans JUnit Extensions JavaOne SM Conference Session BOF

14 Memory Leak Tests II Controlling size of data structures hard to describe and verify NbTestCase.assertSize(String, int, Object); virtual size of data structure trees 8/16/16/24 bytes Based on Insane library How big is an empty string? NetBeans JUnit Extensions Object datastructure = ; assertsize( "Less than 16bytes?", 16, datastructure ); class SizeRegisterFailingTest extends NbTestCase: Calculator calc = Calculator.create("powerful"); Calculator.Register reg = calc.getregisters().get(0); assertsize("register contains one integer field => 16 bytes. Will it fit?", Collections.singleton(reg), 16, new Object[] { calc ); // last array allows to exclude some objects 2006 JavaOne SM Conference Session BOF

15 Speed Test NbTestSuite.speedSuite and linearspeedsuite Size of the test Comparing speed of various algorithms Need to eliminate influence of GC and hotspot protected void setup () { calc.ensureregisterssize(gettestnumber()); list = calc.getregisters(); public void test10() { dotest (); public void test100() { dotest (); public void test1000() { dotest (); public void test10000 () { dotest (); private void dotest () { for (int i = 0; i < 10000; i++) { list.get(size / 2); 2006 JavaOne SM Conference Session BOF

16 Randomized Tests Test for the unknown Hard to test where amoeba does more than expected Use random sequence of operations: int op = random.nextint(); switch (op) { case 0: list.add(new Integer(random.nextInt()); break; case 1: list.removeat(random.nextint(list.size())); break; case... Record the seed for case of failure seed = System.currentTimeMillis(); random = new Random(seed); 2006 JavaOne SM Conference Session BOF

17 Deadlock Test I Deadlocks are biggest contributors of amoeba's shaking no reasonable theory hard to simulate from outside 2006 JavaOne SM Conference Session BOF

18 Foreign Code In Critical Section Deadlock prone code Calling foreign code under lock leads to deadlocks Sometimes hard to prevent private HashSet allcreated = new HashSet(); public synchronized JLabel createlabel() { JLabel l = new JLabel(); allcreated.add(l); return l; java.awt.component grabs AWT tree lock HashSet.add calls Object.equals design.html 2006 JavaOne SM Conference Session BOF

19 Deadlock Test II Regression test Reading thread dumps Reproducing thread locks Need more threads Using time out for the test Block them in the right moment overriding virtual methods introducing artificial hooks 2006 JavaOne SM Conference Session BOF

20 Race Condition Test Similar to deadlock tests Missing thread dump information Need more threads Block them in the right moment overriding virtual methods introducing artificial hooks if (System.getProperty( simulate.race.condition.2 )!= null) { Thread.sleep(500); 2006 JavaOne SM Conference Session BOF

21 The Beauty of Logging Analyze random failures protected Level loglevel() { return Level.FINE; CharSequence msgs = Log.enable( logname, Level.ALL); Natural in source code Logger LOG = Logger.getLogger( logname ); LOG.finest( simulate.race.condition.2 ); Tests can plug their own Handlers class TestHandler extends Handler { public void publish(logrecord r) { if (r.getmessage().equals(( simulate.race.condition.2 )) Thread.sleep(500); 2006 JavaOne SM Conference Session BOF

22 Flow Control using Logging Automatic breakpoints Allows replay of captured log files plugs in own handler blocks and wake the threads up Complexity hidden behind simple NetBeans JUnit API: Log.controlFlow( THREAD: main MSG: simulate.race.* THREAD: second MSG: cause problems ); 2006 JavaOne SM Conference Session BOF

23 Summary Prevent Amoeba from shaking from one side e.g. what is not working Automate testing, its cheaper Treat tests as a complement to documentation Use our test patterns Invent new test patterns 2006 JavaOne SM Conference Session BOF

24 References BOF 2559 Thu 19:30 Gateway 105 Discovery and Dependency Injection Patterns in Modular Architectures TS 6218 Fri 14:30 Gateway 102/103 How to Write APIs That Will Stand the Test of Time download from download from JavaOne SM Conference Session BOF

25 Q&A Jesse Glick Miloš Kleint Jaroslav Tulach 2006 JavaOne SM Conference Session BOF

NetBeans Rich Client Platform Simpletests. Anton Epple Eppleton IT Consulting

NetBeans Rich Client Platform Simpletests. Anton Epple Eppleton IT Consulting Simpletests NetBeans Rich Client Platform Simpletests Anton Epple Eppleton IT Consulting Unit tests for RCP Applications Introduced in 6.5 Before: Xtest infrastructure Unit & Functional Tests hard to set

More information

MemoryLint. Petr Nejedlý, Radim Kubacki SUN Microsystems, BOF-9066

MemoryLint. Petr Nejedlý, Radim Kubacki SUN Microsystems,   BOF-9066 MemoryLint Petr Nejedlý, Radim Kubacki SUN Microsystems, http://www.sun.com/, http://www.netbeans.org BOF-9066 2007 JavaOne SM Conference Session BOF-9066 Goal Get ideas how to analyze content of Java

More information

AUTOMATED HEAPDUMP ANALYSIS FOR DEVELOPERS, TESTERS, AND SUPPORT EMPLOYEES

AUTOMATED HEAPDUMP ANALYSIS FOR DEVELOPERS, TESTERS, AND SUPPORT EMPLOYEES AUTOMATED HEAPDUMP ANALYSIS FOR DEVELOPERS, TESTERS, AND SUPPORT EMPLOYEES Krum Tsvetkov Andreas Buchen TS-5729 Find memory leaks WITHOUT working with Memory Analyzer 2008 JavaOne SM Conference java.sun.com/javaone

More information

Real Time: Understanding the Trade-offs Between Determinism and Throughput

Real Time: Understanding the Trade-offs Between Determinism and Throughput Real Time: Understanding the Trade-offs Between Determinism and Throughput Roland Westrelin, Java Real-Time Engineering, Brian Doherty, Java Performance Engineering, Sun Microsystems, Inc TS-5609 Learn

More information

Building a Java ME Test Suite in 15 Minutes

Building a Java ME Test Suite in 15 Minutes Building a Java ME Test Suite in 15 Minutes Mikhail Gorshenev, Senior Staff Engineer Roman Zelov, Member of Technical Staff Alexander Glasman, Member of Technical Staff Sun Microsystems, Inc. http://www.sun.com/

More information

Designing API: 20 API Paradoxes. Jaroslav Tulach NetBeans Platform Architect

Designing API: 20 API Paradoxes. Jaroslav Tulach NetBeans Platform Architect Designing API: 20 API Paradoxes Jaroslav Tulach NetBeans Platform Architect Motto Just like there is a difference between describing a house and describing a Universe, there is a difference between writing

More information

Writing a Sony PlayStation Emulator Using Java Technology

Writing a Sony PlayStation Emulator Using Java Technology Writing a Sony PlayStation Emulator Using Java Technology Graham Sanderson Matt Howitt Lombardi Software www.lombardisoftware.com TS-5547 2006 JavaOne SM Conference Session TS-5547 High Performance Java

More information

New Compiler Optimizations in the Java HotSpot Virtual Machine

New Compiler Optimizations in the Java HotSpot Virtual Machine New Compiler Optimizations in the Java HotSpot Virtual Machine Steve Dever Steve Goldman Kenneth Russell Sun Microsystems, Inc. TS-3412 Copyright 2006, Sun Microsystems Inc., All rights reserved. 2006

More information

Paradoxes of API Design. Jaroslav Tulach NetBeans Platform Architect

Paradoxes of API Design. Jaroslav Tulach NetBeans Platform Architect Paradoxes of API Design Jaroslav Tulach NetBeans Platform Architect Motto Just like there is a difference between describing a house and describing a Universe, there is a difference between writing a code

More information

How NikeiD Hurdled the Java Technology and Flash Barrier

How NikeiD Hurdled the Java Technology and Flash Barrier How NikeiD Hurdled the Java Technology and Flash Barrier Jonathan Hager, Kirk Jones and Travis Davidson Nike, Inc. nikeid.nike.com TS-9123 2006 JavaOne SM Conference Session TS-9123 Goal What You Will

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

Processes and Threads. Industrial Programming. Processes and Threads (cont'd) Processes and Threads (cont'd)

Processes and Threads. Industrial Programming. Processes and Threads (cont'd) Processes and Threads (cont'd) Processes and Threads Industrial Programming Lecture 5: C# Threading Introduction, Accessing Shared Resources Based on: An Introduction to programming with C# Threads By Andrew Birrell, Microsoft, 2005

More information

Systems Programming & Scripting

Systems Programming & Scripting Systems Programming & Scripting Lecture 10: C# Threading Introduction, Accessing Shared Resources Based on: An Introduction to programming with C# Threads By Andrew Birrell, Microsoft, 2005 Examples from

More information

Swinging from the Outside

Swinging from the Outside Swinging from the Outside A guide to navigating Swing from the outside of Sun Brian Mason, Dir Software of Engineering, Teseda S295599 Space is big, really big. You might think it is a long way down to

More information

Testing Concurrent Software

Testing Concurrent Software Testing Concurrent Software Bill Pugh Professor of Computer Science, University of Maryland Brian Goetz Senior Staff Engineer, Sun Microsystems Cliff Click Distinguished Engineer, Azul Systems TS-2220

More information

Testing Concurrent Software

Testing Concurrent Software Testing Concurrent Software Bill Pugh Professor of Computer Science, University of Maryland Brian Goetz Senior Staff Engineer, Sun Microsystems Cliff Click Distinguished Engineer, Azul Systems TS-2220

More information

LAB-6340: Advanced Java ME Programming - Streaming Video From Server to Your Device

LAB-6340: Advanced Java ME Programming - Streaming Video From Server to Your Device LAB-6340: Advanced Java ME Programming - Streaming Video From Server to Your Device Lukas Hasik, Fabiola Galleros Rios Software Engineer, Mobility Pack QE Sun Microsystems Inc. http://www.sun.com 2007

More information

TestingofScout Application. Ludwigsburg,

TestingofScout Application. Ludwigsburg, TestingofScout Application Ludwigsburg, 27.10.2014 The Tools approach The Testing Theory approach Unit testing White box testing Black box testing Integration testing Functional testing System testing

More information

High Performance Computing Course Notes Shared Memory Parallel Programming

High Performance Computing Course Notes Shared Memory Parallel Programming High Performance Computing Course Notes 2009-2010 2010 Shared Memory Parallel Programming Techniques Multiprocessing User space multithreading Operating system-supported (or kernel) multithreading Distributed

More information

ENTERPRISE JAVABEANS TM (EJB TM ) 3.1 TECHNOLOGY

ENTERPRISE JAVABEANS TM (EJB TM ) 3.1 TECHNOLOGY ENTERPRISE JAVABEANS TM (EJB TM ) 3.1 TECHNOLOGY Kenneth Saks Senior Staff Engineer SUN Microsystems TS-5343 Learn what is planned for the next version of Enterprise JavaBeans (EJB ) technology 2008 JavaOne

More information

INF 212 ANALYSIS OF PROG. LANGS CONCURRENCY. Instructors: Crista Lopes Copyright Instructors.

INF 212 ANALYSIS OF PROG. LANGS CONCURRENCY. Instructors: Crista Lopes Copyright Instructors. INF 212 ANALYSIS OF PROG. LANGS CONCURRENCY Instructors: Crista Lopes Copyright Instructors. Basics Concurrent Programming More than one thing at a time Examples: Network server handling hundreds of clients

More information

Introduction to Concurrent Software Systems. CSCI 5828: Foundations of Software Engineering Lecture 08 09/17/2015

Introduction to Concurrent Software Systems. CSCI 5828: Foundations of Software Engineering Lecture 08 09/17/2015 Introduction to Concurrent Software Systems CSCI 5828: Foundations of Software Engineering Lecture 08 09/17/2015 1 Goals Present an overview of concurrency in software systems Review the benefits and challenges

More information

Introduction to Java

Introduction to Java Introduction to Java Module 1: Getting started, Java Basics 22/01/2010 Prepared by Chris Panayiotou for EPL 233 1 Lab Objectives o Objective: Learn how to write, compile and execute HelloWorld.java Learn

More information

Scala Actors. Scalable Multithreading on the JVM. Philipp Haller. Ph.D. candidate Programming Methods Lab EPFL, Lausanne, Switzerland

Scala Actors. Scalable Multithreading on the JVM. Philipp Haller. Ph.D. candidate Programming Methods Lab EPFL, Lausanne, Switzerland Scala Actors Scalable Multithreading on the JVM Philipp Haller Ph.D. candidate Programming Methods Lab EPFL, Lausanne, Switzerland The free lunch is over! Software is concurrent Interactive applications

More information

Creating Professional Swing UIs Using the NetBeans GUI Builder

Creating Professional Swing UIs Using the NetBeans GUI Builder Creating Professional Swing UIs Using the NetBeans GUI Builder Tomas Pavek, Jan Stola, Scott Violet Sun Microsystems http://www.netbeans.org http://swinglabs.dev.java.net TS-4916 Copyright 2006, Sun Microsystems,

More information

Introduction to Concurrent Software Systems. CSCI 5828: Foundations of Software Engineering Lecture 12 09/29/2016

Introduction to Concurrent Software Systems. CSCI 5828: Foundations of Software Engineering Lecture 12 09/29/2016 Introduction to Concurrent Software Systems CSCI 5828: Foundations of Software Engineering Lecture 12 09/29/2016 1 Goals Present an overview of concurrency in software systems Review the benefits and challenges

More information

Concurrency in Java Prof. Stephen A. Edwards

Concurrency in Java Prof. Stephen A. Edwards Concurrency in Java Prof. Stephen A. Edwards The Java Language Developed by James Gosling et al. at Sun Microsystems in the early 1990s Originally called Oak, first intended application was as an OS for

More information

User Space Multithreading. Computer Science, University of Warwick

User Space Multithreading. Computer Science, University of Warwick User Space Multithreading 1 Threads Thread short for thread of execution/control B efore create Global During create Global Data Data Executing Code Code Stack Stack Stack A fter create Global Data Executing

More information

JavaServer Faces Technology, AJAX, and Portlets: It s Easy if You Know How!

JavaServer Faces Technology, AJAX, and Portlets: It s Easy if You Know How! TS-6824 JavaServer Faces Technology, AJAX, and Portlets: It s Easy if You Know How! Brendan Murray Software Architect IBM http://www.ibm.com 2007 JavaOne SM Conference Session TS-6824 Goal Why am I here?

More information

Concurrency, Mutual Exclusion and Synchronization C H A P T E R 5

Concurrency, Mutual Exclusion and Synchronization C H A P T E R 5 Concurrency, Mutual Exclusion and Synchronization C H A P T E R 5 Multiple Processes OS design is concerned with the management of processes and threads: Multiprogramming Multiprocessing Distributed processing

More information

Java Language Modularity With Superpackages

Java Language Modularity With Superpackages Java Language Modularity With Superpackages Alex Buckley JSR 294 Co-spec lead Sun Microsystems Andreas Sterbenz JSR 294 Co-spec lead Sun Microsystems TS-2401 2007 JavaOne SM Conference Session 2401 Goal

More information

Threads and Java Memory Model

Threads and Java Memory Model Threads and Java Memory Model Oleg Šelajev @shelajev oleg@zeroturnaround.com October 6, 2014 Agenda Threads Basic synchronization Java Memory Model Concurrency Concurrency - several computations are executing

More information

Compaq Interview Questions And Answers

Compaq Interview Questions And Answers Part A: Q1. What are the difference between java and C++? Java adopts byte code whereas C++ does not C++ supports destructor whereas java does not support. Multiple inheritance possible in C++ but not

More information

Configuring the Heap and Garbage Collector for Real- Time Programming.

Configuring the Heap and Garbage Collector for Real- Time Programming. Configuring the Heap and Garbage Collector for Real- Time Programming.... A user s perspective to garbage collection Fridtjof Siebert, IPD, University of Karlsruhe 1 Jamaica Systems Structure What is the

More information

Using Aspect-Oriented Programming to Streamline Mobile Application Development

Using Aspect-Oriented Programming to Streamline Mobile Application Development Allen Lau TS-5363 Using Aspect-Oriented Programming to Streamline Mobile Application Development CTO and Co-Founder Tira Wireless tirawireless.com 2007 JavaOne SM Conference Session TS-5363 Goal of This

More information

Profilers and Debuggers. Introductory Material. One-Slide Summary

Profilers and Debuggers. Introductory Material. One-Slide Summary Profilers and Debuggers #1 Introductory Material First, who doesn t know assembly language? You ll get to answer all the assembly questions. Yes, really. Lecture Style: Sit on the table and pose questions.

More information

Grand Central Dispatch and NSOperation. CSCI 5828: Foundations of Software Engineering Lecture 28 12/03/2015

Grand Central Dispatch and NSOperation. CSCI 5828: Foundations of Software Engineering Lecture 28 12/03/2015 Grand Central Dispatch and NSOperation CSCI 5828: Foundations of Software Engineering Lecture 28 12/03/2015 1 Credit Where Credit Is Due Most of the examples in this lecture were inspired by example code

More information

Keep Learning with Oracle University

Keep Learning with Oracle University Keep Learning with Oracle University Classroom Training Learning Subscription Live Virtual Class Training On Demand Cloud Technology Applications Industries education.oracle.com 3 Session Surveys Help

More information

Emulating the Java ME Platform on Java SE

Emulating the Java ME Platform on Java SE Emulating the Java ME Platform on Java SE Kenneth Russell Tony Wyant Sun Microsystems, Inc. Session TS-2515 2007 JavaOne SM Conference Session TS-2515 Goal of This Talk Learn advanced uses of Java bytecode

More information

NASA World Wind Java SDK

NASA World Wind Java SDK NASA World Wind Java SDK Tom Gaskins NWW Technical Director http://worldwind.arc.nasa.gov TS-3489 2007 JavaOne SM Conference Session TS-3489 Today s Agenda Build an Application Deploy with Java Web Start

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

i219 Software Design Methodology 11. Software model checking Kazuhiro Ogata (JAIST) Outline of lecture

i219 Software Design Methodology 11. Software model checking Kazuhiro Ogata (JAIST) Outline of lecture i219 Software Design Methodology 11. Software model checking Kazuhiro Ogata (JAIST) Outline of lecture 2 Concurrency Model checking Java Pathfinder (JPF) Detecting race condition Bounded buffer problem

More information

Simplifying Development and Testing of GUIs with SAF (JSR 296) and FEST. Michael Hüttermann Training & Consulting Alex Ruiz Oracle Corporation

Simplifying Development and Testing of GUIs with SAF (JSR 296) and FEST. Michael Hüttermann Training & Consulting Alex Ruiz Oracle Corporation Simplifying Development and Testing of GUIs with SAF (JSR 296) and FEST Michael Hüttermann Training & Consulting Alex Ruiz Oracle Corporation Agenda Why do we need a Swing framework? Introducing the Swing

More information

C#.Net. Course Contents. Course contents VT BizTalk. No exam, but laborations

C#.Net. Course Contents. Course contents VT BizTalk. No exam, but laborations , 1 C#.Net VT 2009 Course Contents C# 6 hp approx. BizTalk 1,5 hp approx. No exam, but laborations Course contents Architecture Visual Studio Syntax Classes Forms Class Libraries Inheritance Other C# essentials

More information

CSCD 330 Network Programming

CSCD 330 Network Programming CSCD 330 Network Programming Lecture 12 More Client-Server Programming Winter 2016 Reading: References at end of Lecture 1 Introduction So far, Looked at client-server programs with Java Sockets TCP and

More information

How to Build, Run, and Develop Code With the phoneme Open Source Project Stuart Marks Hinkmond Wong Sun Microsystems, Inc.

How to Build, Run, and Develop Code With the phoneme Open Source Project Stuart Marks Hinkmond Wong Sun Microsystems, Inc. How to Build, Run, and Develop Code With the phoneme Open Source Project Stuart Marks Hinkmond Wong Sun Microsystems, Inc. http://phoneme.dev.java.net TS-5712 2007 JavaOne SM Conference Session TS-5712

More information

Outline of lecture. i219 Software Design Methodology 10. Multithreaded programming. Kazuhiro Ogata (JAIST)

Outline of lecture. i219 Software Design Methodology 10. Multithreaded programming. Kazuhiro Ogata (JAIST) i219 Software Design Methodology 10. Multithreaded programming Kazuhiro Ogata (JAIST) Outline of lecture 2 Thread Race condition Synchronization Deadlock Bounded buffer problem Thread (1) 3 Units of execution.

More information

Adding Telephony to Java Technology-Based Enterprise Applications

Adding Telephony to Java Technology-Based Enterprise Applications Adding Telephony to Java Technology-Based Enterprise Applications Jonathan Kaplan & Sreeram Duvur Researcher/Architect Sun Microsystems, Inc. http://glassfish.dev.java.net/ TS-4919 2007 JavaOne SM Conference

More information

Bringing Life to Swing Desktop Applications

Bringing Life to Swing Desktop Applications Bringing Life to Swing Desktop Applications Alexander Potochkin Sun Microsystems Kirill Grouchnikov Amdocs Inc. TS-3414 2007 JavaOne SM Conference Session TS-3414 Presentation Goal Learn advanced painting

More information

Multithreading and Interactive Programs

Multithreading and Interactive Programs Multithreading and Interactive Programs CS160: User Interfaces John Canny. This time Multithreading for interactivity need and risks Some design patterns for multithreaded programs Debugging multithreaded

More information

Problems with Concurrency. February 19, 2014

Problems with Concurrency. February 19, 2014 with Concurrency February 19, 2014 s with concurrency interleavings race conditions dead GUI source of s non-determinism deterministic execution model 2 / 30 General ideas Shared variable Access interleavings

More information

Introduction to Programming (Java) 2/12

Introduction to Programming (Java) 2/12 Introduction to Programming (Java) 2/12 Michal Krátký Department of Computer Science Technical University of Ostrava Introduction to Programming (Java) 2008/2009 c 2006 2008 Michal Krátký Introduction

More information

Overview. CMSC 330: Organization of Programming Languages. Concurrency. Multiprocessors. Processes vs. Threads. Computation Abstractions

Overview. CMSC 330: Organization of Programming Languages. Concurrency. Multiprocessors. Processes vs. Threads. Computation Abstractions CMSC 330: Organization of Programming Languages Multithreaded Programming Patterns in Java CMSC 330 2 Multiprocessors Description Multiple processing units (multiprocessor) From single microprocessor to

More information

Homework # 7 Distributed Computing due Saturday, December 13th, 2:00 PM

Homework # 7 Distributed Computing due Saturday, December 13th, 2:00 PM Homework # 7 Distributed Computing due Saturday, December 13th, 2:00 PM In this homework you will add code to permit a calendar to be served to clients, and to open a calendar on a remote server. You will

More information

Deploying Java Platform, Standard Edition (Java SE Platform) in Today s Embedded Devices

Deploying Java Platform, Standard Edition (Java SE Platform) in Today s Embedded Devices Deploying Java Platform, Standard Edition (Java SE Platform) in Today s Embedded Devices Bob Vandette Senior Staff Engineer Sun Microsystems, Inc. http://www.sun.com TS-2602 2007 JavaOne SM Conference

More information

Testing Eclipse plug-ins: Tips & Tricks

Testing Eclipse plug-ins: Tips & Tricks Testing Eclipse plug-ins: Tips & Tricks Lorenzo Bettini DISIA University Firenze, Italy Vincenzo Caselli Francesco Guidieri RCP-Vision, Firenze, Italy EclipseCon Europe 2017 Project Quality Day Motivations

More information

Principles of Software Construction: Objects, Design, and Concurrency (Part 2: Designing (Sub )Systems)

Principles of Software Construction: Objects, Design, and Concurrency (Part 2: Designing (Sub )Systems) Principles of Software Construction: Objects, Design, and Concurrency (Part 2: Designing (Sub )Systems) More Analysis for Functional Correctness Jonathan Aldrich Charlie Garrod School of Computer Science

More information

Deterministic Parallel Programming

Deterministic Parallel Programming Deterministic Parallel Programming Concepts and Practices 04/2011 1 How hard is parallel programming What s the result of this program? What is data race? Should data races be allowed? Initially x = 0

More information

Thread Safety. Review. Today o Confinement o Threadsafe datatypes Required reading. Concurrency Wrapper Collections

Thread Safety. Review. Today o Confinement o Threadsafe datatypes Required reading. Concurrency Wrapper Collections Thread Safety Today o Confinement o Threadsafe datatypes Required reading Concurrency Wrapper Collections Optional reading The material in this lecture and the next lecture is inspired by an excellent

More information

CSCD 330 Network Programming

CSCD 330 Network Programming CSCD 330 Network Programming Lecture 12 More Client-Server Programming Winter 2019 Reading: References at end of Lecture 1 Introduction So far, Looked at client-server programs with Java Sockets TCP and

More information

Modular Applications and the Lookup API. Tim Boudreau Senior Staff Engineer Sun Microsystems

Modular Applications and the Lookup API. Tim Boudreau Senior Staff Engineer Sun Microsystems Modular Applications and the Lookup API Tim Boudreau Senior Staff Engineer Sun Microsystems The Need for Modular Applications Applications get more complex Assembled from pieces Developed by distributed

More information

JSR 311: JAX-RS: The Java API for RESTful Web Services

JSR 311: JAX-RS: The Java API for RESTful Web Services JSR 311: JAX-RS: The Java API for RESTful Web Services Marc Hadley, Paul Sandoz, Roderico Cruz Sun Microsystems, Inc. http://jsr311.dev.java.net/ TS-6411 2007 JavaOne SM Conference Session TS-6411 Agenda

More information

Bytecode Manipulation Techniques for Dynamic Applications for the Java Virtual Machine

Bytecode Manipulation Techniques for Dynamic Applications for the Java Virtual Machine Bytecode Manipulation Techniques for Dynamic Applications for the Java Virtual Machine Eugene Kuleshov, Terracotta Tim Eck, Terracotta Tom Ware, Oracle Corporation Charles Nutter, Sun Microsystems, Inc.

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

CS61B, Spring 2003 Discussion #17 Amir Kamil UC Berkeley 5/12/03

CS61B, Spring 2003 Discussion #17 Amir Kamil UC Berkeley 5/12/03 CS61B, Spring 2003 Discussion #17 Amir Kamil UC Berkeley 5/12/03 Topics: Threading, Synchronization 1 Threading Suppose we want to create an automated program that hacks into a server. Many encryption

More information

Copyright 2014 Oracle and/or its affiliates. All rights reserved.

Copyright 2014 Oracle and/or its affiliates. All rights reserved. Copyright 2014 Oracle and/or its affiliates. All rights reserved. On the Quest Towards Fastest (Java) Virtual Machine on the Planet! @JaroslavTulach Oracle Labs Copyright 2015 Oracle and/or its affiliates.

More information

Defective Java Code: Turning WTF code into a learning experience

Defective Java Code: Turning WTF code into a learning experience Defective Java Code: Turning WTF code into a learning experience William Pugh, Professor, Univ. of Maryland TS-6589 Examine some defective Java code to become a better developer, and discuss how to turn

More information

Dynamic data race detection in concurrent Java programs

Dynamic data race detection in concurrent Java programs 8th Central and Eastern European Software Engineering Conference in Russia - CEE-SECR 2012 November 1-2, Moscow Dynamic data race detection in concurrent Java programs Vitaly Trifanov, Dmitry Tsitelov

More information

Symbolic PathFinder, Pex, RoadRunner

Symbolic PathFinder, Pex, RoadRunner Symbolic PathFinder, Pex, RoadRunner http://d3s.mff.cuni.cz Pavel Parízek CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics Pavel Parízek Symbolic Execution, Dynamic Analysis 2 JPF extensions

More information

CS 351 Design of Large Programs Threads and Concurrency

CS 351 Design of Large Programs Threads and Concurrency CS 351 Design of Large Programs Threads and Concurrency Brooke Chenoweth University of New Mexico Spring 2018 Concurrency in Java Java has basic concurrency support built into the language. Also has high-level

More information

CS180 Review. Recitation Week 15

CS180 Review. Recitation Week 15 CS180 Review Recitation Week 15 Announcement Final exam will be held on Thursday(12/17) 8:00~10:00 AM The coverage is comprehensive Project 5 is graded. Check your score in Blackboard. Classes and Methods

More information

CSE332: Data Abstractions Lecture 22: Shared-Memory Concurrency and Mutual Exclusion. Tyler Robison Summer 2010

CSE332: Data Abstractions Lecture 22: Shared-Memory Concurrency and Mutual Exclusion. Tyler Robison Summer 2010 CSE332: Data Abstractions Lecture 22: Shared-Memory Concurrency and Mutual Exclusion Tyler Robison Summer 2010 1 Toward sharing resources (memory) So far we ve looked at parallel algorithms using fork-join

More information

Defective Java Code: Turning WTF code into a learning experience

Defective Java Code: Turning WTF code into a learning experience Defective Java Code: Turning WTF code into a learning experience William Pugh, Professor, Univ. of Maryland TS-6589 Examine some defective Java code to become a better developer, and discuss how to turn

More information

JUnit 4 and Java EE 5 Better Testing by Design

JUnit 4 and Java EE 5 Better Testing by Design JUnit 4 and Java EE 5 Better Testing by Design Kent Beck Alberto Savoia Agitar Software Inc. www.agitar.com TS-1580 2006 JavaOne SM Conference Session TS-1580 Simplifying Developer Testing JUnit 4 further

More information

Project. Threads. Plan for today. Before we begin. Thread. Thread. Minimum submission. Synchronization TSP. Thread synchronization. Any questions?

Project. Threads. Plan for today. Before we begin. Thread. Thread. Minimum submission. Synchronization TSP. Thread synchronization. Any questions? Project Threads Synchronization Minimum submission Deadline extended to tonight at midnight Early submitters 10 point bonus TSP Still due on Tuesday! Before we begin Plan for today Thread synchronization

More information

Concurrency in Object Oriented Programs 1. Object-Oriented Software Development COMP4001 CSE UNSW Sydney Lecturer: John Potter

Concurrency in Object Oriented Programs 1. Object-Oriented Software Development COMP4001 CSE UNSW Sydney Lecturer: John Potter Concurrency in Object Oriented Programs 1 Object-Oriented Software Development COMP4001 CSE UNSW Sydney Lecturer: John Potter Outline Concurrency: the Future of Computing Java Concurrency Thread Safety

More information

Welcome to the session...

Welcome to the session... Welcome to the session... Copyright 2013, Oracle and/or its affiliates. All rights reserved. 02/22/2013 1 The following is intended to outline our general product direction. It is intended for information

More information

Principles of Software Construction: Testing: One, Two, Three

Principles of Software Construction: Testing: One, Two, Three Principles of Software Construction: Testing: One, Two, Three Josh Bloch Charlie Garrod School of Computer Science 1 Administrivia Homework 4a due today, 11:59 p.m. Design review meeting is mandatory But

More information

Modular Applications and the Lookup API. David Štrupl Sun Microsystems

Modular Applications and the Lookup API. David Štrupl Sun Microsystems Modular Applications and the Lookup API David Štrupl Sun Microsystems The Need for Modular Applications Applications get more complex Assembled from pieces Developed by distributed teams Components have

More information

2IP15 Programming Methods

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

More information

The Sun s Java Certification and its Possible Role in the Joint Teaching Material

The Sun s Java Certification and its Possible Role in the Joint Teaching Material The Sun s Java Certification and its Possible Role in the Joint Teaching Material Nataša Ibrajter Faculty of Science Department of Mathematics and Informatics Novi Sad 1 Contents Kinds of Sun Certified

More information

Mock Objects and Distributed Testing

Mock Objects and Distributed Testing Mock Objects and Distributed Testing Making a Mockery of your Software Brian Gilstrap Once, said the Mock Turtle at last, with a deep sigh, I was a real Turtle. (Alice In Wonderland, Lewis Carroll) The

More information

CMSC 433 Section 0101 Fall 2012 Midterm Exam #1

CMSC 433 Section 0101 Fall 2012 Midterm Exam #1 Name: CMSC 433 Section 0101 Fall 2012 Midterm Exam #1 Directions: Test is closed book, closed notes. Answer every question; write solutions in spaces provided. Use backs of pages for scratch work. Good

More information

mvn package -Dmaven.test.skip=false //builds DSpace and runs tests

mvn package -Dmaven.test.skip=false //builds DSpace and runs tests DSpace Testing 1 Introduction 2 Quick Start 2.1 Maven 2.2 JUnit 2.3 JMockit 2.4 ContiPerf 2.5 H2 3 Unit Tests Implementation 3.1 Structure 3.2 Limitations 3.3 How to build new tests 3.4 How to run the

More information

Course 834 EC-Council Certified Secure Programmer Java (ECSP)

Course 834 EC-Council Certified Secure Programmer Java (ECSP) Course 834 EC-Council Certified Secure Programmer Java (ECSP) Duration: 3 days You Will Learn How To Apply Java security principles and secure coding practices Java Security Platform, Sandbox, JVM, Class

More information

An overview of (a)sync & (non-) blocking

An overview of (a)sync & (non-) blocking An overview of (a)sync & (non-) blocking or why is my web-server not responding? with funny fonts! Experiment & reproduce https://github.com/antonfagerberg/play-performance sync & blocking code sync &

More information

Chapter 2: Using Data

Chapter 2: Using Data Chapter 2: Using Data TRUE/FALSE 1. A variable can hold more than one value at a time. F PTS: 1 REF: 52 2. The legal integer values are -2 31 through 2 31-1. These are the highest and lowest values that

More information

Parallelizing Ocean plug-in computations using the Background Worker + PFX pattern

Parallelizing Ocean plug-in computations using the Background Worker + PFX pattern Parallelizing Ocean plug-in computations using the Background Worker + PFX pattern Dmitriy Repin Program Architect, Schlumberger PTS Ocean Development Framework User Meeting Houston, October 24, 2014 2014

More information

CS 140 Project 4 File Systems Review Session

CS 140 Project 4 File Systems Review Session CS 140 Project 4 File Systems Review Session Prachetaa Due Friday March, 14 Administrivia Course withdrawal deadline today (Feb 28 th ) 5 pm Project 3 due today (Feb 28 th ) Review section for Finals on

More information

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc.

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc. Chapter 1 GETTING STARTED SYS-ED/ Computer Education Techniques, Inc. Objectives You will learn: Java platform. Applets and applications. Java programming language: facilities and foundation. Memory management

More information

Attila Szegedi, Software

Attila Szegedi, Software Attila Szegedi, Software Engineer @asz Everything I ever learned about JVM performance tuning @twitter Everything More than I ever wanted to learned about JVM performance tuning @twitter Memory tuning

More information

JSR 377 Desktop Application Framework September Andres Almiray

JSR 377 Desktop Application Framework September Andres Almiray JSR 377 Desktop Application Framework September 29 2017 Andres Almiray Agenda Goals Information to be gathered Implementation notes Issues Questions, discussion, next steps 2 Goals 3 Goals Define APIs

More information

generate-jvm-report shows the threads, classes, memory, and loggers for a given target instance. Name Synopsis

generate-jvm-report shows the threads, classes, memory, and loggers for a given target instance. Name Synopsis Name Synopsis Description Options generate-jvm-report shows the threads, classes, memory, and loggers for a given target instance. generate-jvm-report [--help] [ --type =summary memory class thread log]

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Multithreading Multiprocessors Description Multiple processing units (multiprocessor) From single microprocessor to large compute clusters Can perform multiple

More information

THE MINION SEARCH ENGINE: INDEXING, SEARCH, TEXT SIMILARITY AND TAG GARDENING

THE MINION SEARCH ENGINE: INDEXING, SEARCH, TEXT SIMILARITY AND TAG GARDENING THE MINION SEARCH ENGINE: INDEXING, SEARCH, TEXT SIMILARITY AND TAG GARDENING Jeff Alexander, Member of Technical Staff, Sun Microsystems Stephen Green, Senior Staff Engineer, Sun Microsystems TS-5027

More information

Java 2 Platform, Micro Edition

Java 2 Platform, Micro Edition Java 2 Platform, Micro Edition ArchitectureOverview Jon Courtney Senior Staff Engineer Sun Microsystems JavaOne203 Sesion316 Overall Presentation Goal Learnaboutthearchitectural features ofthejava 2Platform,MicroEdition(J2ME

More information

Improve and Expand JavaServer Faces Technology with JBoss Seam

Improve and Expand JavaServer Faces Technology with JBoss Seam Improve and Expand JavaServer Faces Technology with JBoss Seam Michael Yuan Kito D. Mann Product Manager, Red Hat Author, JSF in Action http://www.michaelyuan.com/seam/ Principal Consultant Virtua, Inc.

More information

Concurrency, Thread. Dongkun Shin, SKKU

Concurrency, Thread. Dongkun Shin, SKKU Concurrency, Thread 1 Thread Classic view a single point of execution within a program a single PC where instructions are being fetched from and executed), Multi-threaded program Has more than one point

More information

Programming Web Apps for Tiny Devices with Java Card 3.0 Connected Edition

Programming Web Apps for Tiny Devices with Java Card 3.0 Connected Edition Programming Web Apps for Tiny Devices with Java Card 3.0 Connected Edition Laurent LAGOSANTO Jean-Jacques VANDEWALLE Patrick VAN HAVER TS-5910 Discover the features of Java Card platform 3.0 Connected

More information

Learning from Bad Examples. CSCI 5828: Foundations of Software Engineering Lecture 25 11/18/2014

Learning from Bad Examples. CSCI 5828: Foundations of Software Engineering Lecture 25 11/18/2014 Learning from Bad Examples CSCI 5828: Foundations of Software Engineering Lecture 25 11/18/2014 1 Goals Demonstrate techniques to design for shared mutability Build on an example where multiple threads

More information