Generic Programming Constructs and Applications in Object-Oriented Languages

Size: px
Start display at page:

Download "Generic Programming Constructs and Applications in Object-Oriented Languages"

Transcription

1 Generic Programming Constructs and Applications in Object-Oriented Languages Maurizio Cimadamore sun.com] alice research group Alma Mater Studiorum Università di Bologna Sun Microsystems Ireland Ltd. tutors: Antonio Natali, Andrea Omicini, Mirko Viroli Ph.D final seminar - XXII cycle 13, January 2010

2 Outline 1 Overview Generic Programming in Java 2 Reification 3 Usability Diamond Operator Error Messages 4 P@J 5 References

3 Outline 1 Overview Generic Programming in Java 2 Reification 3 Usability 4 P@J 5 References

4 Overview Goal Evaluation of advanced constructs and application of generic programming w.r.t. mainstream Object-Oriented programming languages Areas Foundations design of new features for improving generic programming Usability making generic programming available to the mainstream Applications design of a framework exploiting advanced generic programming concepts

5 Overview Case study: Java developers download/update per month 6 bln of Java-enabled devices available on 91% PC (> Windows!) open-source Generic Programming in Java Generics programming support since JDK 5.0 (2004) List<String>, HashMap<String, Integer>

6 Java Generics History Java 1.0 announced in 1995 Generics considered, but omitted from final language Proposals for adding generics (JSR14) starting in 1997 Generics included in Java 5 in 2004 Generic Idiom (JDK 1.4) Java collection classes defined to hold Object: List, Stack, Queue, Set, SortedSet,... No restrictions on what can be added Casts required when retrieving elements

7 Java Generics Generic Types (JDK 5.0) Java collection classes have been generified: List<E>, Stack<E>, Queue<E>, Set<E>, SortedSet<E>,... Only element of type E can be added No casts required when retrieving elements Type-erasure Generic types are turned into non-generic types during compilation near 100% backward compatibility no performance hit

8 Outline 1 Overview 2 Reification 3 Usability 4 P@J 5 References

9 Reification of generic types Problem Generic types disallowed in type-dependent operations Goal Develop a JVM with builtin support for generic types Low performance overahed No new bytecode instructions Completeness (generic classes, methods, wildcards...) Case study CVM (J2ME CDC) JVM Hotspot (OpenJDK)

10 Compile-time Reification: Overview The compiler stores additional generic type-info in custom classfile attributes Run-time The generic JVM leverages such information when performing type-dependent operations

11 Reification Conclusions Benchmarks Execution-time overhead: < 2% Memory footprint: < 3% Classfile size: < 4% Open Issues Backward-compatibility w.r.t. raw cast semantics Indecidable type-system problematic when performing runtime type-tests

12 Outline 1 Overview 2 Reification 3 Usability Diamond Operator Error Messages 4 P@J 5 References

13 Usability of Java Generics Goals Simplify and improve generic programming experience in the Java Programming Language New syntax for less verbose creation of generic instances Provide better support for error messages involving generics/wildcards Widespread distribution The results of this work will be included in the next official release of the Java Development Kit (JDK 7)

14 Usability Diamond Operator Problem Generics can easily lead to verbose declarations: List<String> l = new ArrayLisy<String>(); Goal Minimize the amount of explicit types in generic declarations in the most frequent use-cases Case study javac/openjdk (JDK 7)

15 Usability Diamond Operator Problem Generics can easily lead to verbose declarations: List<String> l = new ArrayLisy<String>(); Map<String, Integer> m = new HashMap<String, Integer>(); Goal Minimize the amount of explicit types in generic declarations in the most frequent use-cases Case study javac/openjdk (JDK 7)

16 Usability Diamond Operator Problem Generics can easily lead to verbose declarations: List<String> l = new ArrayLisy<String>(); Map<String, Integer> m = new HashMap<String, Integer>(); Map<List<String>, List<Integer>> m = new HashMap<List<String>, List<Integer>>(); Goal Minimize the amount of explicit types in generic declarations in the most frequent use-cases Case study javac/openjdk (JDK 7)

17 Usability Diamond Operator Problem Generics can easily lead to verbose declarations: List<String> l = new ArrayLisy<String>(); Map<String, Integer> m = new HashMap<String, Integer>(); Map<List<String>, List<Integer>> m = new HashMap<List<String>, List<Integer>>(); Goal Minimize the amount of explicit types in generic declarations in the most frequent use-cases Case study javac/openjdk (JDK 7)

18 At a glance Diamond Operator: Overview Map<String, Integer> m = new HashMap<String, Integer>(); Idea Types in the RHS are inferred from types in the LHS Less verbose Interface/abstract classes allowed in the LHS Non ambiguous syntax (w.r.t. raw types) Two variants Simple: only types in LHS are used Complex: uses both LHS and constructor argument types

19 At a glance Diamond Operator: Overview Map<String, Integer> m = new HashMap<String, Integer>(); Map<String, Integer> m = new HashMap<>(); Idea Types in the RHS are inferred from types in the LHS Less verbose Interface/abstract classes allowed in the LHS Non ambiguous syntax (w.r.t. raw types) Two variants Simple: only types in LHS are used Complex: uses both LHS and constructor argument types

20 At a glance Diamond Operator: Overview Map<String, Integer> m = new HashMap<String, Integer>(); Map<String, Integer> m = new HashMap<>(); Idea Types in the RHS are inferred from types in the LHS Less verbose Interface/abstract classes allowed in the LHS Non ambiguous syntax (w.r.t. raw types) Two variants Simple: only types in LHS are used Complex: uses both LHS and constructor argument types

21 Diamond Operator: Conclusions Benchmarks Simple: 89% sites inferred Complex: 93% sites inferred Complex is better Allows for language evolution (esp. w.r.t. method inference in type-argument position) Part of JDK 7 Open Issues LHS diamond

22 Usability Error Messages Problem Error messages involving generics are often obscure Goal The ultimate cause of the error could be buried in the JLS More information often required in order to understand a given message Error message should be easy to understand even for programmers with no generic skills Case study javac (JDK 7)

23 Solution Brand new diagnostic subsystem Error Messages: Overview Highly configurable (generates text, XML,...) Tightly integrated with Java type-system Before incompatible types found : Object&I1&I2 required: A After incompatible types required: A found: INT#1 where INT#1 is an intersection type: INT#1 extends Object,I1,I2

24 Solution Brand new diagnostic subsystem Error Messages: Overview Highly configurable (generates text, XML,...) Tightly integrated with Java type-system Before incompatible types found : Object&I1&I2 required: A After incompatible types required: A found: INT#1 where INT#1 is an intersection type: INT#1 extends Object,I1,I2

25 Solution Brand new diagnostic subsystem Error Messages: Overview Highly configurable (generates text, XML,...) Tightly integrated with Java type-system Before incompatible types found : Object&I1&I2 required: A After incompatible types required: A found: INT#1 where INT#1 is an intersection type: INT#1 extends Object,I1,I2

26 Hyperlinks! Error Messages: J Demo

27 Error Messages: Conclusions Integrated in JDK 7 Very positive feedback during J1 Demo 2009 Open Issues DTD for standardized XML error messages Integration with mainstream Java IDE (NetBeans, Eclipse, IntelliJ,...)

28 Outline 1 Overview 2 Reification 3 Usability 4 P@J 5 References

29 Problem Java-Prolog Integration Existing approaches for using Prolog from Java (and vice-versa) are only half-baked solutions Goal lack of true integration between host and target language usually lead to lot of boilerplate code Develop a framework that allows true Java/Prolog interoperability Language integration achieved through existing constructs in the Java programming language (esp. generics) Automatic marshalling from Java to Prolog (and back) Case study tuprolog engine

30 : Key Ideas Idea #1 : Bidirectionality through generics/wildcards X in Term<X> denotes the kind of a (concrete) Prolog term Term<Int> is a placeholder for both: Int as Int extends Term<Int> Var<Int> as Var<X> extends Term<X> Idea #2 : Java/Prolog mapping through annotations Prolog code attached to abstract Java methods via annotation method s type variables correspond to predicate logic variables predicate yielding multiple results Iterable

31 A parser in : abstract class ExprParserVal (clauses={"parse_expr(e,l):-phrase(expr(e),l).", "expr(e) --> term(t), expr2(t,e).", "expr2(t,e) --> [ + ],term(t2),expr2(plus(t,t2),e).", "expr2(t,e) --> [ - ],term(t2),expr2(minus(t,t2),e).", "expr2(t,t) --> [].", "term(t) --> fact(f), term2(f,t).", "term2(f,t) --> [ * ],fact(f2),term2(times(f,f2),t).", "term2(f,t) --> [ / ],fact(f2),term2(div(f,f2),t).", "term2(f,f) --> [].", "fact(e) --> [ ( ],expr(e),[ ) ].", "fact(x) --> [X],{number(X)}."}) abstract <$L extends Term<?>, $E extends List<?>> $L parse($e expr); public static void main(string[] args) throws Exception { ExprParserVal ep = PJ.newInstance(ExprParserVal.class); List<Object> tokenied_expr = new List(Arrays.asList(new Object[] {1,"+",2, "*", 3}); Term<?> parsed_expr = ep.parse_expr(tokenized_expr); } }

32 Advanced Features : Conclusions Custom annotation processor for easy cross-language checking Stateful representation through instance theory Full backtracking support when calling methods from Prolog code Custom Object values automatically turned into Prolog terms s call-by-value) Prototype available - Open Issues Performance tuning (goal: one tuprolog engine per P@J framework!)

33 Outline 1 Overview 2 Reification 3 Usability 4 P@J 5 References

34 Riferimenti I M. Cimadamore and M. Viroli. A Prolog-oriented extension of Java programming based on generics and annotations. In PPPJ 07: Proceedings of the 5th international symposium on Principles and practice of programming in Java, pages , New York, NY, USA, ACM. M. Cimadamore and M. Viroli. Integrating Java and Prolog using Java 5.0 generics and annotations. In MPOOL 07: Proceedings of 6th International Workshop on Multiparadigm Programming with 6th workshop on Multiparadigm Programming with Object-Oriented Languages, 2007.

35 Riferimenti II M. Cimadamore and M. Viroli. Reifying wildcards in Java using the EGO approach. In SAC 07: Proceedings of the 2007 ACM symposium on Applied computing, pages , New York, NY, USA, ACM. M. Cimadamore and M. Viroli. Integrating Java and Prolog through generic methods and type inference. In SAC 08: Proceedings of the 2008 ACM symposium on Applied computing, pages , New York, NY, USA, ACM. M. Cimadamore and M. Viroli. On Reification of Java Wildcards. Science of Computer Programming, 2008.

36 Riferimenti III A. Ricci, M. Viroli, and M. Cimadamore. Prototyping Concurrent Systems with Agents and Artifacts: Framework and Core Calculus. In FOCLASA 07: Proceedings of the 6th International Workshop on the Foundations of Coordination Languages and Software Architectures, A. Ricci, M. Viroli, and M. Cimadamore. Prototyping Concurrent Systems with Agents and Artifacts: Framework and Core Calculus. Electron. Notes Theor. Comput. Sci., 194(4): , 2008.

37 Generic Programming Constructs and Applications in Object-Oriented Languages Maurizio Cimadamore sun.com] alice research group Alma Mater Studiorum Università di Bologna Sun Microsystems Ireland Ltd. tutors: Antonio Natali, Andrea Omicini, Mirko Viroli Ph.D final seminar - XXII cycle 13, January 2010

38 Sun Microsystems Timeline 2003 internship Mountain View, California, USA joint project DEIS - Sun Microsystems Dicembre now dipendente Sun Microsystem Ricerca & Lavoro Ricerca su nuovi costrutti linguaggio Java (e.g. function types) Generici e wildcards (bug & specifiche) Nuovi linguaggi (JavaFX)

Science of Computer Programming

Science of Computer Programming Science of Computer Programming 73 (2008) 59 75 Contents lists available at ScienceDirect Science of Computer Programming journal homepage: www.elsevier.com/locate/scico On the reification of Java wildcards

More information

Java Generics -- an introduction. Based on https://docs.oracle.com/javase/tutorial/java/generics/why.html

Java Generics -- an introduction. Based on https://docs.oracle.com/javase/tutorial/java/generics/why.html Java Generics -- an introduction Based on https://docs.oracle.com/javase/tutorial/java/generics/why.html Generics vs. Templates Templates in C++ are compiled into unique code based on the types passed

More information

simpa An Agent-Oriented Approach for Prototyping Concurrent Applications on Top of Java

simpa An Agent-Oriented Approach for Prototyping Concurrent Applications on Top of Java SISMA 2008/2009 - Seminar simpa An Agent-Oriented Approach for Prototyping Concurrent Applications on Top of Java Alessandro Ricci alice group at DEIS, Università di Bologna, Cesena a.ricci@unibo.it joint

More information

Eclipse and Java 8. Daniel Megert Platform and JDT Lead Eclipse PMC Member IBM Rational Zurich Research Lab

Eclipse and Java 8. Daniel Megert Platform and JDT Lead Eclipse PMC Member IBM Rational Zurich Research Lab Eclipse and Java 8 Daniel Megert Platform and JDT Lead Eclipse PMC Member IBM Rational Zurich Research Lab Eclipse and Java 8 New Java language features Eclipse features for Java 8 (demo) Behind the scenes

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

On the Algorithm for Specializing Java Programs with Generic Types

On the Algorithm for Specializing Java Programs with Generic Types On the Algorithm for Specializing Java Programs with Generic Types Daniel Selifonov, Nathan Dahlberg, Elena Machkasova Computer Science Discipline University of Minnesota Morris Morris MN, 56267 selif004,dahlb061,elenam@umn.edu

More information

Designing a Development Environment for Logic and Multi-Paradigm Programming

Designing a Development Environment for Logic and Multi-Paradigm Programming Designing a Development Environment for Logic and Multi-Paradigm Programming Giulio Piancastelli 1 and Enrico Denti 2 1 DEIS Alma Mater Studiorum Università di Bologna via Venezia 52, I-47023 Cesena, FC,

More information

Programming Kotlin. Familiarize yourself with all of Kotlin s features with this in-depth guide. Stephen Samuel Stefan Bocutiu BIRMINGHAM - MUMBAI

Programming Kotlin. Familiarize yourself with all of Kotlin s features with this in-depth guide. Stephen Samuel Stefan Bocutiu BIRMINGHAM - MUMBAI Programming Kotlin Familiarize yourself with all of Kotlin s features with this in-depth guide Stephen Samuel Stefan Bocutiu BIRMINGHAM - MUMBAI Programming Kotlin Copyright 2017 Packt Publishing First

More information

CSE 331 Software Design and Implementation. Lecture 14 Generics 2

CSE 331 Software Design and Implementation. Lecture 14 Generics 2 CSE 331 Software Design and Implementation Lecture 14 Generics 2 James Wilcox / Winter 2016 Hi, I m James! Big picture Last time: Generics intro Subtyping and Generics Using bounds for more flexible subtyping

More information

Introduction to Java. Lecture 1 COP 3252 Summer May 16, 2017

Introduction to Java. Lecture 1 COP 3252 Summer May 16, 2017 Introduction to Java Lecture 1 COP 3252 Summer 2017 May 16, 2017 The Java Language Java is a programming language that evolved from C++ Both are object-oriented They both have much of the same syntax Began

More information

JDB - QUICK GUIDE JDB - INTRODUCTION

JDB - QUICK GUIDE JDB - INTRODUCTION http://www.tutorialspoint.com/jdb/jdb_quick_guide.htm JDB - QUICK GUIDE Copyright tutorialspoint.com JDB - INTRODUCTION Debugging is a technical procedure to find and remove bugs or defects in a program

More information

INDEX. A SIMPLE JAVA PROGRAM Class Declaration The Main Line. The Line Contains Three Keywords The Output Line

INDEX. A SIMPLE JAVA PROGRAM Class Declaration The Main Line. The Line Contains Three Keywords The Output Line A SIMPLE JAVA PROGRAM Class Declaration The Main Line INDEX The Line Contains Three Keywords The Output Line COMMENTS Single Line Comment Multiline Comment Documentation Comment TYPE CASTING Implicit Type

More information

Object-Oriented Middleware for Distributed Systems

Object-Oriented Middleware for Distributed Systems Object-Oriented Middleware for Distributed Systems Distributed Systems Sistemi Distribuiti Andrea Omicini andrea.omicini@unibo.it Ingegneria Due Alma Mater Studiorum Università di Bologna a Cesena Academic

More information

CS108, Stanford Handout #8. Java Generics

CS108, Stanford Handout #8. Java Generics CS108, Stanford Handout #8 Fall, 2007-08 Nick Parlante Java Generics Java generics (added in version 5) are a mixed bag. Some uses of generics are simple to understand and make the code cleaner. They are

More information

CSE 331 Software Design and Implementation. Lecture 14 Generics 2

CSE 331 Software Design and Implementation. Lecture 14 Generics 2 CSE 331 Software Design and Implementation Lecture 14 Generics 2 Zach Tatlock / Spring 2018 Big picture Last time: Generics intro Subtyping and Generics Using bounds for more flexible subtyping Using wildcards

More information

Parametric polymorphism and Generics

Parametric polymorphism and Generics Parametric polymorphism and Generics Today s Lecture Outline Parametric polymorphism Java generics Declaring and instantiating generics Bounded types: restricting instantiations Generics and subtyping.

More information

Advanced programming for Java platform. Introduction

Advanced programming for Java platform. Introduction Advanced programming for Java platform Introduction About course Petr Hnětynka hnetynka@d3s.mff.cuni.cz http://d3s.mff.cuni.cz/teaching/vsjava/ continuation of "Java (NPRG013)" basic knowledge of Java

More information

A Type-Passing Approach for the Implementation of Parametric Methods in Java

A Type-Passing Approach for the Implementation of Parametric Methods in Java A Type-Passing Approach for the Implementation of Parametric Methods in Java MIRKO VIROLI c British Computer Society 2003 DEIS, Università di Bologna, via Rasi e Spinelli 176, 47023 Cesena (FC), Italy

More information

OOPSLA 2004, Vancouver

OOPSLA 2004, Vancouver Alan Donovan, Adam Kieżun Matthew Tschantz, Michael Ernst MIT Computer Science & AI Lab OOPSLA 2004, Vancouver Introduction: generic types in Java.5 The problem: inferring type arguments Our approach Allocation

More information

Before you start with this tutorial, you need to know basic Java programming.

Before you start with this tutorial, you need to know basic Java programming. JDB Tutorial 1 About the Tutorial The Java Debugger, commonly known as jdb, is a useful tool to detect bugs in Java programs. This is a brief tutorial that provides a basic overview of how to use this

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

Extending Programming Languages: the case of Java. Mirko Viroli DEIS, Alma Mater Studiorum Università di Bologna

Extending Programming Languages: the case of Java. Mirko Viroli DEIS, Alma Mater Studiorum Università di Bologna Extending Programming Languages: the case of Java Mirko Viroli DEIS, Alma Mater Studiorum Università di Bologna mirko.viroli@unibo.it The Research on Mainstream Languages in alice Mirko Viroli DEIS, Alma

More information

COMP6700/2140 Generic Methods

COMP6700/2140 Generic Methods COMP6700/2140 Generic Methods Alexei B Khorev and Josh Milthorpe Research School of Computer Science, ANU March 2017 Alexei B Khorev and Josh Milthorpe (RSCS, ANU) COMP6700/2140 Generic Methods March 2017

More information

IQTIDAR ALI Lecturer IBMS Agriculture University Peshawar

IQTIDAR ALI Lecturer IBMS Agriculture University Peshawar IQTIDAR ALI Lecturer IBMS Agriculture University Peshawar Upon completing the course, you will understand Create, compile, and run Java programs Primitive data types Java control flow Operator Methods

More information

Oracle Corporation

Oracle Corporation 1 2011 Oracle Corporation Making heads and tails of Project Coin, Small language changes in JDK 7 Joseph D. Darcy Presenting with LOGO 2 2011 Oracle Corporation Project Coin is a suite of language and

More information

<Insert Picture Here> Project Coin: Small Language Changes for JDK 7 & JSR 334: Small Language Changes for Java SE 7

<Insert Picture Here> Project Coin: Small Language Changes for JDK 7 & JSR 334: Small Language Changes for Java SE 7 1 Project Coin: Small Language Changes for JDK 7 & JSR 334: Small Language Changes for Java SE 7 Joseph D. Darcy Java Platform Group The following is intended to outline our general

More information

Programming. Syntax and Semantics

Programming. Syntax and Semantics Programming For the next ten weeks you will learn basic programming principles There is much more to programming than knowing a programming language When programming you need to use a tool, in this case

More information

The Heads and Tails of Project Coin

The Heads and Tails of Project Coin The Heads and Tails of Project Coin Alex Buckley Specification Lead, Java Language & VM 1 Copyright 2012, Oracle and/or its affiliates. All rights reserved. The following is intended to outline our general

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

Safe Instantiation in Generic Java

Safe Instantiation in Generic Java Safe Instantiation in Generic Java January 31, 2003 Abstract This paper presents the safe-instantiation principle a new design principle for evaluating extensions of Java with support for generic types.

More information

JQueryScapes: customizable Java code perspectives

JQueryScapes: customizable Java code perspectives JQueryScapes: customizable Java code perspectives [Forum Demonstration Proposal] Lloyd Markle, Kris De Volder Department of Computer Science University of British Columbia Vancouver, BC, Canada 604-822-1290

More information

Labelled Variables in Logic Programming: A First Prototype in tuprolog

Labelled Variables in Logic Programming: A First Prototype in tuprolog Labelled Variables in Logic Programming: A First Prototype in tuprolog Roberta Calegari, Enrico Denti, and Andrea Omicini Dipartimento di Informatica, Scienza e Ingegneria (DISI) Alma Mater Studiorum Università

More information

Notes of the course - Advanced Programming. Barbara Russo

Notes of the course - Advanced Programming. Barbara Russo Notes of the course - Advanced Programming Barbara Russo a.y. 2014-2015 Contents 1 Lecture 2 Lecture 2 - Compilation, Interpreting, and debugging........ 2 1.1 Compiling and interpreting...................

More information

Code verification. CSE 331 University of Washington. Michael Ernst

Code verification. CSE 331 University of Washington. Michael Ernst Code verification CSE 331 University of Washington Michael Ernst Specification and verification To find an error, compare two things Mental model Verification Specification Program Example input & output

More information

Announcements. Lecture 15 Generics 2. Announcements. Big picture. CSE 331 Software Design and Implementation

Announcements. Lecture 15 Generics 2. Announcements. Big picture. CSE 331 Software Design and Implementation CSE 331 Software Design and Implementation Lecture 15 Generics 2 Announcements Leah Perlmutter / Summer 2018 Announcements Quiz 5 is due tomorrow Homework 6 due tomorrow Section tomorrow! Subtyping now

More information

CSE 331 Software Design and Implementation. Lecture 15 Generics 2

CSE 331 Software Design and Implementation. Lecture 15 Generics 2 CSE 331 Software Design and Implementation Lecture 15 Generics 2 Leah Perlmutter / Summer 2018 Announcements Announcements Quiz 5 is due tomorrow Homework 6 due tomorrow Section tomorrow! Subtyping now

More information

Course Description. Learn To: : Intro to JAVA SE7 and Programming using JAVA SE7. Course Outline ::

Course Description. Learn To: : Intro to JAVA SE7 and Programming using JAVA SE7. Course Outline :: Module Title Duration : Intro to JAVA SE7 and Programming using JAVA SE7 : 9 days Course Description The Java SE 7 Fundamentals course was designed to enable students with little or no programming experience

More information

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview Introduction to Visual Basic and Visual C++ Introduction to Java Lesson 13 Overview I154-1-A A @ Peter Lo 2010 1 I154-1-A A @ Peter Lo 2010 2 Overview JDK Editions Before you can write and run the simple

More information

Software Engineering. Prof. Agostino Poggi

Software Engineering. Prof. Agostino Poggi Agent and Object Technology Lab Dipartimento di Ingegneria dell Informazione Università degli Studi di Parma Software Engineering Generics Prof. Agostino Poggi public class ListOfIntegers { //... fields...

More information

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 2. true / false ML can be compiled. 3. true / false FORTRAN can reasonably be considered

More information

II. Compiling and launching from Command-Line, IDE A simple JAVA program

II. Compiling and launching from Command-Line, IDE A simple JAVA program Contents Topic 01 - Java Fundamentals I. Introducing JAVA II. Compiling and launching from Command-Line, IDE A simple JAVA program III. How does JAVA work IV. Review - Programming Style, Documentation,

More information

Grouping Objects (I)

Grouping Objects (I) KTH ROYAL INSTITUTE OF TECHNOLOGY Stockholm Sweden Grouping Objects (I) Managing collections of objects Ric Glassey glassey@kth.se Main concepts to be covered Grouping Objects Using ArrayLists Looping

More information

Lecture Outline. Parametric Polymorphism and Java Generics. Polymorphism. Polymorphism

Lecture Outline. Parametric Polymorphism and Java Generics. Polymorphism. Polymorphism Lecture Outline Parametric Polymorphism and Java Generics Parametric polymorphism Java generics Declaring and instantiating generics Bounded types: restricting instantiations Generics and subtyping. Wildcards

More information

Syntax and Grammars 1 / 21

Syntax and Grammars 1 / 21 Syntax and Grammars 1 / 21 Outline What is a language? Abstract syntax and grammars Abstract syntax vs. concrete syntax Encoding grammars as Haskell data types What is a language? 2 / 21 What is a language?

More information

Programming Language Concepts: Lecture 2

Programming Language Concepts: Lecture 2 Programming Language Concepts: Lecture 2 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2011 PLC 2011, Lecture 2, 6 January 2011 Classes and

More information

Type Checking and Type Inference

Type Checking and Type Inference Type Checking and Type Inference Principles of Programming Languages CSE 307 1 Types in Programming Languages 2 Static Type Checking 3 Polymorphic Type Inference Version: 1.8 17:20:56 2014/08/25 Compiled

More information

From Objects to Agents: The Java Agent Middleware (JAM)

From Objects to Agents: The Java Agent Middleware (JAM) From Objects to Agents: The Java Agent Middleware (JAM) Laboratory of Multiagent Systems LM Laboratorio di Sistemi Multiagente LM Elena Nardini elena.nardini@unibo.it Ingegneria Due Alma Mater Studiorum

More information

JDK 7 (2011.7) knight76.tistory.com Knight76 at gmail.com

JDK 7 (2011.7) knight76.tistory.com Knight76 at gmail.com JDK 7 (2011.7) JDK 7 #2 Project Coin knight76.tistory.com Knight76 at gmail.com 1 Project Coin 2 Project Leader Joseph D. Darcy( ) IDEA 2 27, 2009 3 30, 2009 (open call) 70 jdk 7, Language, The Java programming-language

More information

1. Introduction. Java. Fall 2009 Instructor: Dr. Masoud Yaghini

1. Introduction. Java. Fall 2009 Instructor: Dr. Masoud Yaghini 1. Introduction Java Fall 2009 Instructor: Dr. Masoud Yaghini Outline Introduction Introduction The Java Programming Language The Java Platform References Java technology Java is A high-level programming

More information

7. Introduction to Denotational Semantics. Oscar Nierstrasz

7. Introduction to Denotational Semantics. Oscar Nierstrasz 7. Introduction to Denotational Semantics Oscar Nierstrasz Roadmap > Syntax and Semantics > Semantics of Expressions > Semantics of Assignment > Other Issues References > D. A. Schmidt, Denotational Semantics,

More information

Administration CS 412/413. Why build a compiler? Compilers. Architectural independence. Source-to-source translator

Administration CS 412/413. Why build a compiler? Compilers. Architectural independence. Source-to-source translator CS 412/413 Introduction to Compilers and Translators Andrew Myers Cornell University Administration Design reports due Friday Current demo schedule on web page send mail with preferred times if you haven

More information

Semantic Analysis. CSE 307 Principles of Programming Languages Stony Brook University

Semantic Analysis. CSE 307 Principles of Programming Languages Stony Brook University Semantic Analysis CSE 307 Principles of Programming Languages Stony Brook University http://www.cs.stonybrook.edu/~cse307 1 Role of Semantic Analysis Syntax vs. Semantics: syntax concerns the form of a

More information

CSE Lecture 7: Polymorphism and generics 16 September Nate Nystrom UTA

CSE Lecture 7: Polymorphism and generics 16 September Nate Nystrom UTA CSE 3302 Lecture 7: Polymorphism and generics 16 September 2010 Nate Nystrom UTA 2 Polymorphism poly = many morph = shape Allow a variable to contain values with different types 3 Subtype polymorphism

More information

Review what constitutes a thread Creating threads general Creating threads Java What happens if synchronization is not used? Assignment.

Review what constitutes a thread Creating threads general Creating threads Java What happens if synchronization is not used? Assignment. Review what constitutes a thread Creating threads general Creating threads Java What happens if synchronization is not used? Assignment Overview What constitutes a thread? Instruction pointer Stack space

More information

Java Programming. Manuel Oriol, March 22nd, 2007

Java Programming. Manuel Oriol, March 22nd, 2007 Java Programming Manuel Oriol, March 22nd, 2007 Goal Teach Java to proficient programmers 2 Roadmap Java Basics Eclipse Java GUI Threads and synchronization Class loading and reflection Java Virtual Machines

More information

JPred-P 2. Josh Choi, Michael Welch {joshchoi,

JPred-P 2. Josh Choi, Michael Welch {joshchoi, JPred-P 2 Josh Choi, Michael Welch {joshchoi, mjwelch}@cs.ucla.edu 1. Introduction Precondition and postcondition checking on methods aids the development process by explicitly notifying the programmer

More information

New Features Overview

New Features Overview Features pf JDK 7 New Features Overview Full List: http://docs.oracle.com/javase/7/docs/webnotes/adoptionguide/index.html JSR 334: Small language enhancements (Project Coin) Concurrency and collections

More information

CHAPTER 1. Introduction to JAVA Programming

CHAPTER 1. Introduction to JAVA Programming CHAPTER 1 Introduction to JAVA Programming What java is Java is high level You can use java to write computer applications that computes number,process words,play games,store data, etc. History of Java.

More information

CS 321 Homework 4 due 1:30pm, Thursday, March 15, 2012 This homework specification is copyright by Andrew Tolmach. All rights reserved.

CS 321 Homework 4 due 1:30pm, Thursday, March 15, 2012 This homework specification is copyright by Andrew Tolmach. All rights reserved. CS 321 Homework 4 due 1:30pm, Thursday, March 15, 2012 This homework specification is copyright 2002-2012 by Andrew Tolmach. All rights reserved. Typechecking In this assignment, you will build a type-checker

More information

Outline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring

Outline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring Java Outline Java Models for variables Types and type checking, type safety Interpretation vs. compilation Reasoning about code CSCI 2600 Spring 2017 2 Java Java is a successor to a number of languages,

More information

Lambdas and Generics (Intro)

Lambdas and Generics (Intro) Lambdas and Generics (Intro) Dan S. Wallach and Mack Joiner, Rice University Copyright 2016 Dan S. Wallach, All Rights Reserved New this week in Subversion! week02-lists (check it out!) edu/rice/week2lists/glist.java

More information

The collections interfaces

The collections interfaces Generics in Java Advanced Programming 4/18/16 1 The collections interfaces Contains unique elements Maps unique keys to values 4/18/16 2 Collections in Java Array has a special language support Iterators

More information

THE CONCEPT OF OBJECT

THE CONCEPT OF OBJECT THE CONCEPT OF OBJECT An object may be defined as a service center equipped with a visible part (interface) and an hidden part Operation A Operation B Operation C Service center Hidden part Visible part

More information

CSC 172 Data Structures and Algorithms. Lecture 3 Spring 2018 TuTh 3:25 pm 4:40 pm

CSC 172 Data Structures and Algorithms. Lecture 3 Spring 2018 TuTh 3:25 pm 4:40 pm CSC 172 Data Structures and Algorithms Lecture 3 Spring 2018 TuTh 3:25 pm 4:40 pm Agenda Administrative aspects Java Generics Chapter 1 ADMINISTRATIVE ASPECTS Workshops Workshops Workshops begin on this

More information

Java Leaders Summit Java SE

Java Leaders Summit Java SE Java Leaders Summit Java SE Staffan Friberg Product Manager Java Platform Group 1 Copyright 2011-2013 Oracle and/or its affiliates. The following is intended to outline our general product direction. It

More information

Chapter 1 Introduction to Computers, Programs, and Java

Chapter 1 Introduction to Computers, Programs, and Java Chapter 1 Introduction to Computers, Programs, and Java 1.1 What are hardware and software? 1. A computer is an electronic device that stores and processes data. A computer includes both hardware and software.

More information

Lambda expressions in Java: a compiler writer's perspective. Maurizio Cimadamore Type-system engineer, Oracle Corporation

Lambda expressions in Java: a compiler writer's perspective. Maurizio Cimadamore Type-system engineer, Oracle Corporation Lambda expressions in Java: a compiler writer's perspective Maurizio Cimadamore Type-system engineer, Oracle Corporation The following is intended to outline our general product direction. It is intended

More information

CSE 421 Course Overview and Introduction to Java

CSE 421 Course Overview and Introduction to Java CSE 421 Course Overview and Introduction to Java Computer Science and Engineering College of Engineering The Ohio State University Lecture 1 Learning Objectives Knowledgeable in how sound software engineering

More information

Java Bytecode (binary file)

Java Bytecode (binary file) Java is Compiled Unlike Python, which is an interpreted langauge, Java code is compiled. In Java, a compiler reads in a Java source file (the code that we write), and it translates that code into bytecode.

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

CS 11 java track: lecture 1

CS 11 java track: lecture 1 CS 11 java track: lecture 1 Administrivia need a CS cluster account http://www.cs.caltech.edu/ cgi-bin/sysadmin/account_request.cgi need to know UNIX www.its.caltech.edu/its/facilities/labsclusters/ unix/unixtutorial.shtml

More information

Certified Core Java Developer VS-1036

Certified Core Java Developer VS-1036 VS-1036 1. LANGUAGE FUNDAMENTALS The Java language's programming paradigm is implementation and improvement of Object Oriented Programming (OOP) concepts. The Java language has its own rules, syntax, structure

More information

Java 11 and MAKING ECLIPSE JDT FUTURE READY MANOJ PALAT IBM

Java 11 and MAKING ECLIPSE JDT FUTURE READY MANOJ PALAT IBM Java 11 and Beyond MAKING ECLIPSE JDT FUTURE READY MANOJ PALAT IBM @manojnp Java Releases Road Traveled++ Version 1.0 1.1,1.2,1.3,1.4,1.5,1.6 1.7 1.8 9 10 11 12 13 Release Date 1996 1997, 1998, 2000, 2002,

More information

PrettyProlog: A Java Interpreter and Visualizer of Prolog Programs

PrettyProlog: A Java Interpreter and Visualizer of Prolog Programs PrettyProlog: A Java Interpreter and Visualizer of Prolog Programs Poster Paper Alessio Stalla Viviana Mascardi Maurizio Martelli DISI - Università di Genova, Via Dodecaneso 35, 16146, Genova, Italy. alessiostalla@gmail.com,

More information

Future of Java. Post-JDK 9 Candidate Features. Jan Lahoda Java compiler developer Java Product Group, Oracle September, 2017

Future of Java. Post-JDK 9 Candidate Features. Jan Lahoda Java compiler developer Java Product Group, Oracle September, 2017 Future of Java Post-JDK 9 Candidate Features Jan Lahoda Java compiler developer Java Product Group, Oracle September, 2017 Safe Harbor Statement The following is intended to outline our general product

More information

Programming Language Concepts: Lecture 2

Programming Language Concepts: Lecture 2 Programming Language Concepts: Lecture 2 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 2, 19 January 2009 Classes and

More information

Introducing Scala-like function types into Java-TX

Introducing Scala-like function types into Java-TX Introducing Scala-like function types into Java-TX ManLang 2017 Martin Plümicke Andreas Stadelmeier www.dhbw-stuttgart.de/horb Overview 1 Type of lambda expressions in Java-8 2 Introducing real function

More information

generic programming alberto ferrari university of parma

generic programming alberto ferrari university of parma generic programming alberto ferrari university of parma contents generic programming java generic programming methods & generic programming classes & generic programming java with generics generic methods

More information

Introduction to Java Programming

Introduction to Java Programming Introduction to Java Programming Lecture 1 CGS 3416 Spring 2017 1/9/2017 Main Components of a computer CPU - Central Processing Unit: The brain of the computer ISA - Instruction Set Architecture: the specific

More information

Atelier Java - J1. Marwan Burelle. EPITA Première Année Cycle Ingénieur.

Atelier Java - J1. Marwan Burelle.  EPITA Première Année Cycle Ingénieur. marwan.burelle@lse.epita.fr http://wiki-prog.kh405.net Plan 1 2 Plan 3 4 Plan 1 2 3 4 A Bit of History JAVA was created in 1991 by James Gosling of SUN. The first public implementation (v1.0) in 1995.

More information

Initializers: Array initializers can be used with class base types as well. The elements of the initializer can be expressions (not just constants).

Initializers: Array initializers can be used with class base types as well. The elements of the initializer can be expressions (not just constants). CMSC 131: Chapter 15 (Supplement) Arrays II Arrays of Objects Array of Objects: The base type of an array can be a class object. Example: Array of Strings. String[ ] greatcities = new String[5]; greatcities[2]

More information

Java Collections Framework

Java Collections Framework Java Collections Framework Introduction In this article from my free Java 8 course, you will be given a high-level introduction of the Java Collections Framework (JCF). The term Collection has several

More information

C02: Overview of Software Development and Java

C02: Overview of Software Development and Java CISC 3120 C02: Overview of Software Development and Java Hui Chen Department of Computer & Information Science CUNY Brooklyn College 08/31/2017 CUNY Brooklyn College 1 Outline Recap and issues Brief introduction

More information

MODELLING COMPOSITIONS OF MODULAR EMBEDDED SOFTWARE PRODUCT LINES

MODELLING COMPOSITIONS OF MODULAR EMBEDDED SOFTWARE PRODUCT LINES MODELLING COMPOSITIONS OF MODULAR EMBEDDED SOFTWARE PRODUCT LINES Wolfgang Friess AUDI AG wolfgang.friess@audi.de Julio Sincero University Erlangen-Nuernberg sincero@informatik.uni-erlangen.de Wolfgang

More information

Exercise 8 Parametric polymorphism November 18, 2016

Exercise 8 Parametric polymorphism November 18, 2016 Concepts of Object-Oriented Programming AS 2016 Exercise 8 Parametric polymorphism November 18, 2016 Task 1 Consider the following Scala classes: class A class B extends A class P1[+T] class P2[T

More information

JML and Java 1.5+ David R. Cok Eastman Kodak Company, Research Laboratories 9 October 2008 SAVCBS08 workshop

JML and Java 1.5+ David R. Cok Eastman Kodak Company, Research Laboratories 9 October 2008 SAVCBS08 workshop JML and Java 1.5+ David R. Cok Eastman Kodak Company, Research Laboratories 9 October 2008 SAVCBS08 workshop Java 1.5 was a big step (in 2004) Tools built on or for Java had to make a considerable infrastructure

More information

NetBeans IDE Field Guide

NetBeans IDE Field Guide NetBeans IDE Field Guide Copyright 2004 Sun Microsystems, Inc. All rights reserved. Debugging Java Applications Table of Contents Starting a Debugging Session...2 Debugger Windows...3 Attaching the Debugger

More information

Testing Exceptions with Enforcer

Testing Exceptions with Enforcer Testing Exceptions with Enforcer Cyrille Artho February 23, 2010 National Institute of Advanced Industrial Science and Technology (AIST), Research Center for Information Security (RCIS) Abstract Java library

More information

DSL vs. Library API Shootout

DSL vs. Library API Shootout DSL vs. Library API Shootout Rich Unger Salesforce.com Jaroslav Tulach Oracle Agenda What do we mean by DSL? What do we mean by library? When is it good to use a DSL? When is it a bad idea? Evolution Versioning

More information

Announcements. Lecture 14 Generics 1. Announcements. CSE 331 Software Design and Implementation. Leah Perlmutter / Summer 2018

Announcements. Lecture 14 Generics 1. Announcements. CSE 331 Software Design and Implementation. Leah Perlmutter / Summer 2018 CSE 331 Software Design and Implementation Lecture 14 Generics 1 Announcements Leah Perlmutter / Summer 2018 Announcements Quiz 5 is due Thursday Homework 6 due Thursday Midterm grades and feedback will

More information

CSE 331 Software Design and Implementation. Lecture 14 Generics 1

CSE 331 Software Design and Implementation. Lecture 14 Generics 1 CSE 331 Software Design and Implementation Lecture 14 Generics 1 Leah Perlmutter / Summer 2018 Announcements Announcements Quiz 5 is due Thursday Homework 6 due Thursday Midterm grades and feedback will

More information

What are Generics? e.g. Generics, Generic Programming, Generic Types, Generic Methods

What are Generics? e.g. Generics, Generic Programming, Generic Types, Generic Methods What are Generics? e.g. Generics, Generic Programming, Generic Types, Generic Methods 6 Defining the idea Behind Java Generics Data Types are now used as TypeParameters 7 Defining the idea Behind Java

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

ABSTRACT DATA TYPES: COLLECTIONS, LISTS, SETS, MAP, QUEUES. Thursday, June 30, 2011

ABSTRACT DATA TYPES: COLLECTIONS, LISTS, SETS, MAP, QUEUES. Thursday, June 30, 2011 1 ABSTRACT DATA TYPES: COLLECTIONS, LISTS, SETS, MAP, QUEUES Lecture 4 CS 2110 Summer 2011 Lists are Iterable 4 for public static void printlist(list strings) { for (int idx = 0; idx < strings.size();

More information

Classes and Objects 3/28/2017. How can multiple methods within a Java class read and write the same variable?

Classes and Objects 3/28/2017. How can multiple methods within a Java class read and write the same variable? Peer Instruction 8 Classes and Objects How can multiple methods within a Java class read and write the same variable? A. Allow one method to reference a local variable of the other B. Declare a variable

More information

JavaFX on javac: A Case Study

JavaFX on javac: A Case Study JavaFX on javac: A Case Study September 25, 2008 JVM Language Summit Tom Ball Google Overview JavaFX Script Compiler Requirements Why Use javac? javafxc Design Lessons Learned JavaFX Script Compiler Requirements

More information

Outline. Object Oriented Programming. Course goals. Staff. Course resources. Assignments. Course organization Introduction Java overview Autumn 2003

Outline. Object Oriented Programming. Course goals. Staff. Course resources. Assignments. Course organization Introduction Java overview Autumn 2003 Outline Object Oriented Programming Autumn 2003 2 Course goals Software design vs hacking Abstractions vs language (syntax) Java used to illustrate concepts NOT a course about Java Prerequisites knowledge

More information

IBD Intergiciels et Bases de Données

IBD Intergiciels et Bases de Données IBD Intergiciels et Bases de Données RMI-based distributed systems Fabien Gaud, Fabien.Gaud@inrialpes.fr Overview of lectures and practical work Lectures Introduction to distributed systems and middleware

More information

<Insert Picture Here> JSR-335 Update for JCP EC Meeting, January 2012

<Insert Picture Here> JSR-335 Update for JCP EC Meeting, January 2012 JSR-335 Update for JCP EC Meeting, January 2012 Alex Buckley Oracle Corporation The following is intended to outline our general product direction. It is intended for information

More information

Concurrent Programming Constructs and First-Class Logic Engines

Concurrent Programming Constructs and First-Class Logic Engines Concurrent Programming Constructs and First-Class Logic Engines Paul Tarau University of North Texas tarau@cs.unt.edu Multi-threading has been adopted in today s Prolog implementations as it became widely

More information