Contents. Softwaretechnik. Type Safety of Java. Featherweight Java. Lecture 21: Featherweight Java

Size: px
Start display at page:

Download "Contents. Softwaretechnik. Type Safety of Java. Featherweight Java. Lecture 21: Featherweight Java"

Transcription

1 Contents Softwaretechnik Lecture 21: Peter Thiemann Universität Freiburg, Germany Operational Semantics SS 2011 Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 1 / 40 Type Safety of Java Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 2 / public presentation of Java obtain importance very fast Questions type safety? What does Java mean? 1997/98 resolved Drossopoulou/Eisenbach Flatt/Krishnamurthi/Felleisen Igarashi/Pierce/Wadler (, FJ) Construction of a formal model: consideration of completeness and compactness FJ: minimal model (compactness) complete definition: one page ambition: the most important language features short proof of type soundness FJ Java Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 3 / 40 Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 4 / 40

2 The Language FJ Omitted class definition object creation new method call (dynamic dispatch), recursion with this field access type cast override of methods subtypes assignments interfaces overload super-calls null-references primitive types abstract methods inner classes shadowing of fields of super classes access control (private, public, protected) exceptions concurrency reflections Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 5 / 40 Example Programs Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 6 / 40 Explanation class A extends Object { A() { super (); class B extends Object { B() { super (); class Pair extends Object { Object fst; Object snd; // Constructor Pair (Object fst, Object snd) { super(); this.fst = fst; this.snd = snd; // Method definition Pair setfst (Object newfst) { return new Pair (newfst, this.snd); class definition: always define super class constructors: one per class, always defined arguments correspond to fields always the same form: super-call, then copy the arguments into the fields field accesses and method calls always with recipient object method body: always in the form return... Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 7 / 40 Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 8 / 40

3 Examples for Evaluation Examples for Evaluation method call method call new Pair (new A(), new B()).setfst (new B()) // will be evaluated to new Pair (new B(), new B()) new Pair (new A(), new B()).setfst (new B()) // will be evaluated to new Pair (new B(), new B()) type cast ((Pair) new Pair (new Pair (new A(), new B ()), new A()).fst).snd includes type cast (Pair) It s needed, because new Pair (...).fst has the type Object. Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 9 / 40 Examples for Evaluation field access new Pair (new A (), new B ()).snd // will be evaluated to new B() Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 9 / 40 Examples for Evaluation field access new Pair (new A (), new B ()).snd // will be evaluated to new B() method call new Pair (new A(), new B()).setfst (new B()) yields a substitution [new B()/newfst, new Pair (new A(), new B())/this] We have to evaluate the method body new Pair (newfst, this.snd) under this this substitution. The substitution yields new Pair (new B(), new Pair (new A(), new B()).snd) Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 10 / 40 Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 10 / 40

4 Examples of Evaluation type cast (Pair)new Pair (new A (), new B ()) // evaluates to new Pair (new A (), new B ()) Examples of Evaluation type cast (Pair)new Pair (new A (), new B ()) // evaluates to new Pair (new A (), new B ()) runtime check if Pair is a subtype of Pair. runtime check if Pair is a subtype of Pair. call-by-value evaluation ((Pair) new Pair (new Pair (new A(), new B ()), new A()).fst).snd // ((Pair) new Pair (new A(), new B ())).snd // new Pair (new A(), new B ()).snd // new B() Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 11 / 40 Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 11 / 40 Runtime Error Runtime Error access to non existing field new A().fst no value, no evaluation rule matches access to non existing field new A().fst no value, no evaluation rule matches call of non existing method new A().setfst (new B()) no value, no evaluation rule matches Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 12 / 40 Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 12 / 40

5 Runtime Error access to non existing field Guarantees of Java s Type System new A().fst no value, no evaluation rule matches call of non existing method new A().setfst (new B()) no value, no evaluation rule matches If a Java program is type correct, then all field accesses refer to existing fields all method calls refer to existing methods, but failing type casts are possible. failing type cast (B)new A () A is not subtype of B no value, no evaluation rule matches Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 12 / 40 Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 13 / 40 Syntax CL ::= class definition class C extends D {C 1 f 1 ;... K M 1... K ::= constructor definition C(C 1 f 1,... ) {super(g 1,... ); this.f 1 = f 1 ;... M ::= method definition C m(c 1 x 1,... ) {return t; t ::= expressions x variable t.f field access t.m(t 1,... ) method call new C(t 1,... ) object creation (C) t type cast v ::= values new C(v 1,... ) object creation Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 14 / 40 Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 15 / 40

6 Syntax Conventions Syntax Conventions this special variable, do not use it as field name or parameter implicit bound in each method body sequences of field names, parameter names and method names include no repetition class C extends D {C 1 f 1 ;... K M 1... defines class C as subclass of D fields f 1... with types C 1... constructor K methods M 1... fields from D will be added to C, shadowing is not supported C(D 1 g 1,..., C 1 f 1,... ) {super(g 1,... ); this.f 1 = f 1 ;... define the constructor of class C fully specified by the fields of C and the fields of the super classes. number of parameters is equal to number of fields in C and all its super classes. body start with super(g 1,... ), where g 1,... corresponds to the fields of the super classes D m(c 1 x 1,... ) {return t; defines method m result type D parameter x 1... with types C 1... body is a return statement Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 16 / 40 Class Table Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 17 / 40 Subtype Relation The class table CT is a map from class names to class definitions each class has exactly one definition the CT is global, it corresponds to the program arbitrary but fixed Each class except Object has a superclass Object is not part of CT Object has no fields Object has no methods ( Java) The class table defines a subtype relation C <: D over class names the reflexive and transitive closure of subclass definitions. EXT TRANS REFL C <: C C <: D D <: E C <: E CT(C) = class C extends D... C <: D Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 18 / 40 Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 19 / 40

7 Consistency of CT Example: Classes Do Refer to Each Other 1. CT(C) = class C... for all C dom(ct) 2. Object / dom(ct) 3. For each class name C mentioned in CT : C dom(ct) {Object 4. The relation <: is antisymmetric (no cycles) class Author extends Object { String name; Book bk; Author (String name, Book bk) { super(); this.name = name; this.bk = bk; class Book extends Object { String title; Author ath; Book (String title, Author ath) { super(); this.title = title; this.ath = ath; Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 20 / 40 Auxiliary Definitions collect Fields of classes Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 21 / 40 Auxiliary Definitions detect type of methods empty list fields(object) = CT(C) = class C extends D {C 1 f 1 ;... K M 1... fields(d) = D 1 g 1,... fields(c) = D 1 g 1,..., C 1 f 1,... fields(author) = String name; Book bk; Usage: evaluation steps, typing rules CT(C) = class C extends D {C 1 f 1 ;... K M 1... M j = E m(e 1 x 1,... ) {return t; mtype(m, C) = (E 1,... ) E CT(C) = class C extends D {C 1 f 1 ;... K M 1... ( j) M j F m(f 1 x 1,... ) {return t; mtype(m, D) = (E 1,... ) E mtype(m, C) = (E 1,... ) E Usage: typing rules Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 22 / 40 Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 23 / 40

8 Auxiliary Definitions determine body of method Auxiliary Definitions correct overriding of methods CT(C) = class C extends D {C 1 f 1 ;... K M 1... M j = E m(e 1 x 1,... ) {return t; mbody(m, C) = (x 1..., t) CT(C) = class C extends D {C 1 f 1 ;... K M 1... ( j) M j F m(f 1 x 1,... ) {return t; mbody(m, D) = (y 1..., u) mbody(m, C) = (y 1..., u) Usage: evaluation steps override(m, Object, (E 1... ) E) CT(C) = class C extends D {C 1 f 1 ;... K M 1... M j = E m(e 1 x 1,... ) {return t; override(m, C, (E 1... ) E) CT(C) = class C extends D {C 1 f 1 ;... K M 1... ( j) M j F m(f 1 x 1,... ) {return t; override(m, D, (E 1,... ) E) override(m, C, (E 1,... ) E) Usage: typing rules Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 24 / 40 Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 25 / 40 Example class Recording extends Object { int high; int today; int low; Recording (int high, int today, int low) {... int dhigh() { return this.high; int dlow() { return this.low String unit() { return not set ; String asstring() { return String.valueOf(high).concat( ).concat (String.valueOf(low)).concat (unit()); class Temperature extends ARecording { Temperature (int high, int today, int low) { super(high, today, low); String unit() { return C ; fields(object) = fields(temperature) = fields(recording) = int high; int today; int low; mtype(unit, Recording) = () String mtype(unit, Temperature) = () String mtype(dhigh, Recording) = () int mtype(dhigh, Temperature) = () int override(dhigh, Object, () int) override(dhigh, Recording, () int) override(dhigh, Temperature, () int) mbody(unit, Recording) = (ε, not set ) mtype(unit, Temperature) = (ε, C ) Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 26 / 40 Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 27 / 40

9 Operational Semantics Operational Semantics Direct Evaluation Steps Operational Semantics (definition of the evaluation steps) evaluation: relation t t for one evaluation step E-InvkNew E-ProjNew fields(c) = C 1 f 1,... (new C(v 1,... )).f i v i mbody(m, C) = (x 1..., t) (new C(v 1,... )).m(u 1,... ) t[new C(v 1,... )/this, u 1,... /x 1,... ] E-CastNew C <: D (D)(new C(v 1,... )) new C(v 1,... ) Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 28 / 40 Operational Semantics Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 29 / 40 Operational Semantics Evaluation Steps in Context Example: Evaluation Steps E-Field t t t.f t.f ((Pair) (new Pair (new Pair (new A(), new B()).setfst (new B()), new B()).fst)).fst // [E Field], [E Cast], [E New Arg], [E InvkNew] E-Invk-Recv t t t.m(t 1,... ) t.m(t 1,... ) ((Pair) (new Pair (new Pair (new B(), new B()), new B()).fst)).fst // [E Field], [E Cast], [E ProjNew] E-Invk-Arg t i t i v.m(v 1,..., t i,... ) v.m(v 1,..., t i,... ) ((Pair) (new Pair (new B(), new B()))).fst // [E Field], [E CastNew] E-New-Arg t i t i new C(v 1,..., t i,... ) new C(v 1,..., t i,... ) (new Pair (new B(), new B())).fst // [E ProjNew] E-Cast t t (C)t (C)t new B() Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 30 / 40 Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 31 / 40

10 involved type judgments C <: D C is subtype of D A t : C Under type assumption A, the expression t has type C. F m(c 1 x 1,... ) {return t; OK in C Method declaration is accepted in class C. class C extends D {C 1 f 1 ;... K M 1... OK Class declaration is accepted Type assumptions defined by A ::= A, x : C Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 32 / 40 Accepted Class Declaration Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 33 / 40 Accepted Method Declaration K = C(D 1 g 1,..., C 1 f 1,... ) {super(g 1,... ); this.f 1 = f 1 ;... fields(d) = D 1 g 1... ( j) M j OK in C class C extends D {C 1 f 1 ;... K M 1... x 1 : C 1,..., this : C t : E E <: F CT(C) = class C extends D... override(m, D, (C 1,... ) F) F m(c 1 x 1,... ) {return t; OK in C Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 34 / 40 Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 35 / 40

11 Expression Has Type Type Rules for Type Casts T-Var x : C A A x : C T-Field A t : C fields(c) = C 1 f 1,... A t.f i : C i T-UCast A t : D D <: C A (C)t : C F-Invk A t : C ( i) A t i : C i ( i) C i <: D i mtype(m, C) = (D 1,... ) D A t.m(t 1,... ) : D T-DCast A t : D C <: D C D A (C)t : C F-New ( i) A t i : C i ( i) C i <: D i fields(c) = D 1 f 1,... A new C(t 1,... ) : C Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 36 / 40 Type Safety for Preservation and Progress yields type safety Preservation : If A t : C and t t, then A t : C with C <: C. Progress : (short version) If A t : C, then t v is a value or t contains a subexpression e Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 37 / 40 Problems in the Preservation Proof Type casts destroy preservation Consider the expression (A) ((Object)new B()) It holds (A) ((Object)new B()): A It holds (A) ((Object)new B()) (A) (new B()) But (A) (new B()) has no type! e (C)(new D(v 1,... )) with D <:C. All method calls and field accesses evaluate without errors. Type casts can fail. Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 38 / 40 Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 39 / 40

12 Problems in the Preservation Proof Type casts destroy preservation Consider the expression (A) ((Object)new B()) It holds (A) ((Object)new B()): A It holds (A) ((Object)new B()) (A) (new B()) But (A) (new B()) has no type! workaround: add additional rule for this case (stupid cast) next evaluation step fail Statement of Type Safety If A t : C, then one of the following cases applies: 1. t does not terminate i.e., there exists an infinite sequence of evaluation steps t = t 0 t 1 t t evaluates to a value v after a finite number of evaluation steps i.e., there exists a finite sequence of evaluation steps t = t 0 t 1... t n = v T-SCast A t : D C <:D D <:C A (C)t : C 3. t gets stuck at a failing cast i.e., there exists a finite sequence of evaluation steps We can prove preservation with this rule. t = t 0 t 1... t n where t n contains a subterm (C)(new D(v 1,... )) such that D <:C. Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 39 / 40 Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 40 / 40

Softwaretechnik. Lecture 18: Featherweight Java. Peter Thiemann. University of Freiburg, Germany

Softwaretechnik. Lecture 18: Featherweight Java. Peter Thiemann. University of Freiburg, Germany Softwaretechnik Lecture 18: Peter Thiemann University of Freiburg, Germany 19.07.2012 Peter Thiemann (Univ. Freiburg) Softwaretechnik 19.07.2012 1 / 40 Contents The language shown in examples Formal Definition

More information

Software Engineering

Software Engineering Software Engineering Lecture 18: Featherweight Java Peter Thiemann University of Freiburg, Germany 15.07.2013 Peter Thiemann (Univ. Freiburg) Software Engineering 15.07.2013 1 / 41 Contents Featherweight

More information

Featherweight Java. Lecture 12 CS 565 3/18/08

Featherweight Java. Lecture 12 CS 565 3/18/08 Featherweight Java Lecture 12 CS 565 3/18/08 Objects vs Functions Will start exploring an object model that treats objects and classes as primitives Avoids some of the complexities faced when encoding

More information

Softwaretechnik. Lecture 03: Types and Type Soundness. Peter Thiemann. University of Freiburg, Germany SS 2008

Softwaretechnik. Lecture 03: Types and Type Soundness. Peter Thiemann. University of Freiburg, Germany SS 2008 Softwaretechnik Lecture 03: Types and Type Soundness Peter Thiemann University of Freiburg, Germany SS 2008 Peter Thiemann (Univ. Freiburg) Softwaretechnik SWT 1 / 35 Table of Contents Types and Type correctness

More information

Featherweight Java (FJ)

Featherweight Java (FJ) x = 1 let x = 1 in... x(1).!x(1) x.set(1) Programming Language Theory Featherweight Java (FJ) Ralf Lämmel This lecture is based on David Walker s lecture: Computer Science 441, Programming Languages, Princeton

More information

Type-Safe Feature-Oriented Product Lines

Type-Safe Feature-Oriented Product Lines Type-Safe Feature-Oriented Product Lines arxiv:1001.3604v1 [cs.se] 20 Jan 2010 Sven Apel, Christian Kästner, Armin Größlinger, and Christian Lengauer Department of Informatics and Mathematics, University

More information

An Overview of Feature Featherweight Java

An Overview of Feature Featherweight Java An Overview of Feature Featherweight Java Sven Apel, Christian Kästner, and Christian Lengauer Department of Informatics and Mathematics, University of Passau, Germany {apel,lengauer}@uni-passau.de School

More information

CS 4110 Programming Languages & Logics. Lecture 30 Featherweight Java and Object Encodings

CS 4110 Programming Languages & Logics. Lecture 30 Featherweight Java and Object Encodings CS 4110 Programming Languages & Logics Lecture 30 Featherweight Java and Object Encodings 11 November 2016 Properties 2 Lemma (Preservation) If Γ e : C and e e then there exists a type C such that Γ e

More information

On Inner Classes 1. Atsushi Igarashi 2. and. Benjamin C. Pierce. Received April 17, 2000; revised November 20,

On Inner Classes 1. Atsushi Igarashi 2. and. Benjamin C. Pierce. Received April 17, 2000; revised November 20, Information and Computation 177, 56 89 (2002) doi:10.1006/inco.2002.3092 On Inner Classes 1 Atsushi Igarashi 2 Department of Intelligence Science and Technology, Graduate School of Informatics, Kyoto University,

More information

On Inner Classes. 200 South 33rd St., Philadelphia, PA 19104, USA

On Inner Classes. 200 South 33rd St., Philadelphia, PA 19104, USA On Inner Classes Atsushi Igarashi 1 and Benjamin C. Pierce 2 1 Department of Information Science, University of Tokyo 7-3-1 Hongo, Bunkyo-ku, Tokyo 113-0033, Japan igarashi@is.s.u-tokyo.ac.jp 2 Department

More information

Inference, Targeting and Compatibility in a Type System for Java with SAM Typed Closures

Inference, Targeting and Compatibility in a Type System for Java with SAM Typed Closures Inference, Targeting and Compatibility in a Type System for Java with SAM Typed Closures Marco Bellia and M. Eugenia Occhiuto Dipartimento di Informatica, Università di Pisa, Italy {bellia,occhiuto}@di.unipi.it

More information

Research Reports on Mathematical and Computing Sciences

Research Reports on Mathematical and Computing Sciences ISSN 1342-2812 Research Reports on Mathematical and Computing Sciences Mostly modular composition of crosscutting structures by contextual predicate dispatch (extended version) Shigeru Chiba and Atsushi

More information

Science of Computer Programming

Science of Computer Programming Science of Computer Programming 74 (2009) 261 278 Contents lists available at ScienceDirect Science of Computer Programming journal homepage: www.elsevier.com/locate/scico Featherweight Java with dynamic

More information

A Co-contextual Type Checker for Featherweight Java (incl. Proofs)

A Co-contextual Type Checker for Featherweight Java (incl. Proofs) A Co-contextual Type Checker for Featherweight Java (incl. Proofs) Edlira Kuci 1, Sebastian Erdweg 2, Oliver Bračevac 1, Andi Bejleri 1, and Mira Mezini 1,3 1 Technische Universität Darmstadt, Germany

More information

Delegation by Object Composition

Delegation by Object Composition Delegation by Object Composition Lorenzo Bettini,a, Viviana Bono a, Betti Venneri b a Dipartimento di Informatica, Università di Torino b Dipartimento di Sistemi e Informatica, Università di Firenze Abstract

More information

The Substitution Model

The Substitution Model The Substitution Model Prof. Clarkson Fall 2017 Today s music: Substitute by The Who Review Previously in 3110: simple interpreter for expression language abstract syntax tree (AST) evaluation based on

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Fall 2016 Lecture 7a Andrew Tolmach Portland State University 1994-2016 Values and Types We divide the universe of values according to types A type is a set of values and a

More information

Science of Computer Programming

Science of Computer Programming Science of Computer Programming 76 (2011) 992 1014 Contents lists available at ScienceDirect Science of Computer Programming journal homepage: www.elsevier.com/locate/scico Delegation by object composition

More information

LazyJ: Seamless Lazy Evaluation in Java

LazyJ: Seamless Lazy Evaluation in Java LazyJ: Seamless Lazy Evaluation in Java Alessandro Warth Computer Science Department University of California, Los Angeles awarth@cs.ucla.edu Abstract LazyJ is a backward-compatible extension of the Java

More information

CS Lecture 7: The dynamic environment. Prof. Clarkson Spring Today s music: Down to Earth by Peter Gabriel from the WALL-E soundtrack

CS Lecture 7: The dynamic environment. Prof. Clarkson Spring Today s music: Down to Earth by Peter Gabriel from the WALL-E soundtrack CS 3110 Lecture 7: The dynamic environment Prof. Clarkson Spring 2015 Today s music: Down to Earth by Peter Gabriel from the WALL-E soundtrack Review Course so far: Syntax and semantics of (most of) OCaml

More information

Formal Semantics. Prof. Clarkson Fall Today s music: Down to Earth by Peter Gabriel from the WALL-E soundtrack

Formal Semantics. Prof. Clarkson Fall Today s music: Down to Earth by Peter Gabriel from the WALL-E soundtrack Formal Semantics Prof. Clarkson Fall 2015 Today s music: Down to Earth by Peter Gabriel from the WALL-E soundtrack Review Previously in 3110: simple interpreter for expression language: abstract syntax

More information

Type Hierarchy. Lecture 6: OOP, autumn 2003

Type Hierarchy. Lecture 6: OOP, autumn 2003 Type Hierarchy Lecture 6: OOP, autumn 2003 The idea Many types have common behavior => type families share common behavior organized into a hierarchy Most common on the top - supertypes Most specific at

More information

Programming Languages Lecture 14: Sum, Product, Recursive Types

Programming Languages Lecture 14: Sum, Product, Recursive Types CSE 230: Winter 200 Principles of Programming Languages Lecture 4: Sum, Product, Recursive Types The end is nigh HW 3 No HW 4 (= Final) Project (Meeting + Talk) Ranjit Jhala UC San Diego Recap Goal: Relate

More information

The Substitution Model. Nate Foster Spring 2018

The Substitution Model. Nate Foster Spring 2018 The Substitution Model Nate Foster Spring 2018 Review Previously in 3110: simple interpreter for expression language abstract syntax tree (AST) evaluation based on single steps parser and lexer (in lab)

More information

Featherweight Wrap Java: wrapping objects and methods

Featherweight Wrap Java: wrapping objects and methods Vol. 7, No. 2, Special Issue OOPS Track at SAC 2007, February 2008 Featherweight Wrap Java: wrapping objects and methods Lorenzo Bettini, bettini@dsi.unifi.it Dipartimento di Informatica, Università di

More information

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

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

More information

Javari: Adding Reference Immutability to Java

Javari: Adding Reference Immutability to Java Javari: Adding Reference Immutability to Java Matthew S. Tschantz Michael D. Ernst MIT CSAIL Cambridge, MA, USA tschantz@mit.edu, mernst@csail.mit.edu Abstract This paper describes a type system that is

More information

CS4215 Programming Language Implementation. Martin Henz

CS4215 Programming Language Implementation. Martin Henz CS4215 Programming Language Implementation Martin Henz Thursday 26 January, 2012 2 Chapter 4 The Language simpl In this chapter, we are exting the language epl in order to provide a more powerful programming

More information

CSE 401/M501 Compilers

CSE 401/M501 Compilers CSE 401/M501 Compilers Code Shape II Objects & Classes Hal Perkins Autumn 2018 UW CSE 401/M501 Autumn 2018 L-1 Administrivia Semantics/type check due next Thur. 11/15 How s it going? Reminder: if you want

More information

Java Design Goals. Lecture 32: Java. Java Original implementations slow! Exceptions & Subtyping. - void method readfiles() throws IOException {...}!

Java Design Goals. Lecture 32: Java. Java Original implementations slow! Exceptions & Subtyping. - void method readfiles() throws IOException {...}! Java Design Goals Lecture 32: Java CSC 131 Fall, 2014 Kim Bruce Portability across platforms Reliability Safety (no viruses) Dynamic Linking Multithreaded execution Simplicity and Familiarity Efficiency

More information

2 In the denition of the method actionperformed, the eld x of the enclosing Counter object is changed. The method listento creates a new listener obje

2 In the denition of the method actionperformed, the eld x of the enclosing Counter object is changed. The method listento creates a new listener obje On Inner Classes Atsushi Igarashi Benjamin C. Pierce Department of Computer & Information Science University of Pennsylvania 200 South 33rd St., Philadelphia, PA 19104, USA figarasha,bcpierceg@saul.cis.upenn.edu

More information

Java Object Oriented Design. CSC207 Fall 2014

Java Object Oriented Design. CSC207 Fall 2014 Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code

More information

Argument Passing All primitive data types (int etc.) are passed by value and all reference types (arrays, strings, objects) are used through refs.

Argument Passing All primitive data types (int etc.) are passed by value and all reference types (arrays, strings, objects) are used through refs. Local Variable Initialization Unlike instance vars, local vars must be initialized before they can be used. Eg. void mymethod() { int foo = 42; int bar; bar = bar + 1; //compile error bar = 99; bar = bar

More information

A Short Summary of Javali

A Short Summary of Javali A Short Summary of Javali October 15, 2015 1 Introduction Javali is a simple language based on ideas found in languages like C++ or Java. Its purpose is to serve as the source language for a simple compiler

More information

Type-based Confinement

Type-based Confinement Under consideration for publication in J. Functional Programming 1 Type-based Confinement Tian Zhao University of Wisconsin Milwaukee Jens Palsberg UCLA Jan Vitek Purdue University Abstract Confinement

More information

Lifted Java: A Minimal Calculus for Translation Polymorphism

Lifted Java: A Minimal Calculus for Translation Polymorphism Lifted Java: A Minimal Calculus for Translation Polymorphism Matthias Diehn Ingesman and Erik Ernst Department of Computer Science, Aarhus University, Denmark, {mdi,eernst}@cs.au.dk Abstract. To support

More information

1 Introduction. 3 Syntax

1 Introduction. 3 Syntax CS 6110 S18 Lecture 19 Typed λ-calculus 1 Introduction Type checking is a lightweight technique for proving simple properties of programs. Unlike theorem-proving techniques based on axiomatic semantics,

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Winter 2017 Lecture 7b Andrew Tolmach Portland State University 1994-2017 Values and Types We divide the universe of values according to types A type is a set of values and

More information

Programming Languages Lecture 15: Recursive Types & Subtyping

Programming Languages Lecture 15: Recursive Types & Subtyping CSE 230: Winter 2008 Principles of Programming Languages Lecture 15: Recursive Types & Subtyping Ranjit Jhala UC San Diego News? Formalize first-order type systems Simple types (integers and booleans)

More information

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011 CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics Dan Grossman Spring 2011 Review e ::= λx. e x e e c v ::= λx. e c τ ::= int τ τ Γ ::= Γ, x : τ (λx. e) v e[v/x] e 1 e 1 e 1 e

More information

Type Relaxed Weaving

Type Relaxed Weaving Type Relaxed Weaving Hidehiko Masuhara University of Tokyo masuhara@acm.org Atsushi Igarashi Kyoto University igarashi@kuis.kyotou.ac.jp Manabu Toyama University of Tokyo touyama@graco.c.utokyo.ac.jp ABSTRACT

More information

A Model of Mutation in Java

A Model of Mutation in Java Object-Oriented Design Lecture 18 CSU 370 Fall 2008 (Pucella) Friday, Nov 21, 2008 A Model of Mutation in Java We have been avoiding mutations until now; but there are there, in the Java system, for better

More information

EXAMINATIONS 2008 MID-YEAR COMP431 COMPILERS. Instructions: Read each question carefully before attempting it.

EXAMINATIONS 2008 MID-YEAR COMP431 COMPILERS. Instructions: Read each question carefully before attempting it. T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON EXAMINATIONS 2008 MID-YEAR COMP431 COMPILERS Time Allowed: 3 Hours Instructions: Read each

More information

Compiler Construction 2009/2010 Polymorphic Types and Generics

Compiler Construction 2009/2010 Polymorphic Types and Generics Compiler Construction 2009/2010 Polymorphic Types and Generics Peter Thiemann January 10, 2010 Outline 1 Polymorphic Types and Generics 2 Parametric Polymorphism 3 Polymorphic Type Checking 4 Translation

More information

Semantic Subtyping. Alain Frisch (ENS Paris) Giuseppe Castagna (ENS Paris) Véronique Benzaken (LRI U Paris Sud)

Semantic Subtyping.  Alain Frisch (ENS Paris) Giuseppe Castagna (ENS Paris) Véronique Benzaken (LRI U Paris Sud) Semantic Subtyping Alain Frisch (ENS Paris) Giuseppe Castagna (ENS Paris) Véronique Benzaken (LRI U Paris Sud) http://www.cduce.org/ Semantic Subtyping - Groupe de travail BD LRI p.1/28 CDuce A functional

More information

Type Hierarchy. Comp-303 : Programming Techniques Lecture 9. Alexandre Denault Computer Science McGill University Winter 2004

Type Hierarchy. Comp-303 : Programming Techniques Lecture 9. Alexandre Denault Computer Science McGill University Winter 2004 Type Hierarchy Comp-303 : Programming Techniques Lecture 9 Alexandre Denault Computer Science McGill University Winter 2004 February 16, 2004 Lecture 9 Comp 303 : Programming Techniques Page 1 Last lecture...

More information

Java: introduction to object-oriented features

Java: introduction to object-oriented features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: introduction to object-oriented features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer

More information

A Type System for Dynamic Layer Composition

A Type System for Dynamic Layer Composition A Type System for Dynamic Layer Composition Atsushi Igarashi Kyoto University igarashi@kuis.kyoto-u.ac.jp Robert Hirschfeld Hasso-Plattner-Institut Potsdam hirschfeld@hpi.uni-potsdam.de Hidehiko Masuhara

More information

Lightweight Confinement for Featherweight Java

Lightweight Confinement for Featherweight Java Lightweight Confinement for Featherweight Java Tian Zhao Jens Palsberg Jan Vitek University of Wisconsin, Milwaukee Purdue University ABSTRACT Confinement properties impose a structure on object graphs

More information

Inheritance. Inheritance allows the following two changes in derived class: 1. add new members; 2. override existing (in base class) methods.

Inheritance. Inheritance allows the following two changes in derived class: 1. add new members; 2. override existing (in base class) methods. Inheritance Inheritance is the act of deriving a new class from an existing one. Inheritance allows us to extend the functionality of the object. The new class automatically contains some or all methods

More information

Project 6 Due 11:59:59pm Thu, Dec 10, 2015

Project 6 Due 11:59:59pm Thu, Dec 10, 2015 Project 6 Due 11:59:59pm Thu, Dec 10, 2015 Updates None yet. Introduction In this project, you will add a static type checking system to the Rube programming language. Recall the formal syntax for Rube

More information

Recursive Types and Subtyping

Recursive Types and Subtyping Recursive Types and Subtyping #1 One-Slide Summary Recursive types (e.g., list) make the typed lambda calculus as powerful as the untyped lambda calculus. If is a subtype of then any expression of type

More information

Operational Semantics 1 / 13

Operational Semantics 1 / 13 Operational Semantics 1 / 13 Outline What is semantics? Operational Semantics What is semantics? 2 / 13 What is the meaning of a program? Recall: aspects of a language syntax: the structure of its programs

More information

Dependent Object Types - A foundation for Scala s type system

Dependent Object Types - A foundation for Scala s type system Dependent Object Types - A foundation for Scala s type system Draft of September 9, 2012 Do Not Distrubute Martin Odersky, Geoffrey Alan Washburn EPFL Abstract. 1 Introduction This paper presents a proposal

More information

(Not Quite) Minijava

(Not Quite) Minijava (Not Quite) Minijava CMCS22620, Spring 2004 April 5, 2004 1 Syntax program mainclass classdecl mainclass class identifier { public static void main ( String [] identifier ) block } classdecl class identifier

More information

CS/ENGRD 2110 FALL Lecture 5: Local vars; Inside-out rule; constructors

CS/ENGRD 2110 FALL Lecture 5: Local vars; Inside-out rule; constructors 1 CS/ENGRD 2110 FALL 2018 Lecture 5: Local vars; Inside-out rule; constructors http://courses.cs.cornell.edu/cs2110 Announcements 2 A1 is due tomorrow If you are working with a partner: form a group on

More information

From IMP to Java. Andreas Lochbihler. parts based on work by Gerwin Klein and Tobias Nipkow ETH Zurich

From IMP to Java. Andreas Lochbihler. parts based on work by Gerwin Klein and Tobias Nipkow ETH Zurich From IMP to Java Andreas Lochbihler ETH Zurich parts based on work by Gerwin Klein and Tobias Nipkow 2015-07-14 1 Subtyping 2 Objects and Inheritance 3 Multithreading 1 Subtyping 2 Objects and Inheritance

More information

Today. CSE341: Programming Languages. Late Binding in Ruby Multiple Inheritance, Interfaces, Mixins. Ruby instance variables and methods

Today. CSE341: Programming Languages. Late Binding in Ruby Multiple Inheritance, Interfaces, Mixins. Ruby instance variables and methods Today CSE341: Programming Languages Late Binding in Ruby Multiple Inheritance, Interfaces, Mixins Alan Borning Spring 2018 Dynamic dispatch aka late binding aka virtual method calls Call to self.m2() in

More information

HAS-A Relationship. Association is a relationship where all objects have their own lifecycle and there is no owner.

HAS-A Relationship. Association is a relationship where all objects have their own lifecycle and there is no owner. HAS-A Relationship Association is a relationship where all objects have their own lifecycle and there is no owner. For example, teacher student Aggregation is a specialized form of association where all

More information

COS 320. Compiling Techniques

COS 320. Compiling Techniques Topic 5: Types COS 320 Compiling Techniques Princeton University Spring 2016 Lennart Beringer 1 Types: potential benefits (I) 2 For programmers: help to eliminate common programming mistakes, particularly

More information

Event Type Polymorphism

Event Type Polymorphism Event Type Polymorphism Rex D. Fernando Robert Dyer Hridesh Rajan Department of Computer Science Iowa State University {fernanre,rdyer,hridesh}@iastate.edu This work was supported in part by NSF grant

More information

CSE331 Spring 2015, Final Examination June 8, 2015

CSE331 Spring 2015, Final Examination June 8, 2015 CSE331 Spring 2015, Final Examination June 8, 2015 Please do not turn the page until 8:30. Rules: The exam is closed-book, closed-note, etc. Please stop promptly at 10:20. There are 158 points (not 100),

More information

Exercise 6 Multiple Inheritance, Multiple Dispatch and Linearization November 4, 2016

Exercise 6 Multiple Inheritance, Multiple Dispatch and Linearization November 4, 2016 Concepts of Object-Oriented Programming AS 2016 Exercise 6 Multiple Inheritance, Multiple Dispatch and Linearization November 4, 2016 Task 1 Consider the following C++ program: class X X(int p) : fx(p)

More information

Type Systems. Pierce Ch. 3, 8, 11, 15 CSE

Type Systems. Pierce Ch. 3, 8, 11, 15 CSE Type Systems Pierce Ch. 3, 8, 11, 15 CSE 6341 1 A Simple Language ::= true false if then else 0 succ pred iszero Simple untyped expressions Natural numbers encoded as succ succ

More information

Outline of lecture. i219 Software Design Methodology 5. Object oriented programming language 2. Kazuhiro Ogata (JAIST)

Outline of lecture. i219 Software Design Methodology 5. Object oriented programming language 2. Kazuhiro Ogata (JAIST) i219 Software Design Methodology 5. Object oriented programming language 2 Kazuhiro Ogata (JAIST) Outline of lecture 2 Method dispatch Inner interface/class Enum type Method dispatch (1) For a while, let

More information

Topics Covered Thus Far. CMSC 330: Organization of Programming Languages. Language Features Covered Thus Far. Programming Languages Revisited

Topics Covered Thus Far. CMSC 330: Organization of Programming Languages. Language Features Covered Thus Far. Programming Languages Revisited CMSC 330: Organization of Programming Languages Type Systems, Names & Binding Topics Covered Thus Far Programming languages Syntax specification Regular expressions Context free grammars Implementation

More information

Exercise: Singleton 1

Exercise: Singleton 1 Exercise: Singleton 1 In some situations, you may create the only instance of the class. 1 class mysingleton { 2 3 // Will be ready as soon as the class is loaded. 4 private static mysingleton Instance

More information

Course Content. Objectives of Lecture 24 Inheritance. Outline of Lecture 24. Inheritance Hierarchy. The Idea Behind Inheritance

Course Content. Objectives of Lecture 24 Inheritance. Outline of Lecture 24. Inheritance Hierarchy. The Idea Behind Inheritance Structural Programming and Data Structures Winter 2000 CMPUT 102: Dr. Osmar R. Zaïane Course Content Introduction Objects Methods Tracing Programs Object State Sharing resources Selection Repetition Vectors

More information

Course Content. Objectives of Lecture 24 Inheritance. Outline of Lecture 24. CMPUT 102: Inheritance Dr. Osmar R. Zaïane. University of Alberta 4

Course Content. Objectives of Lecture 24 Inheritance. Outline of Lecture 24. CMPUT 102: Inheritance Dr. Osmar R. Zaïane. University of Alberta 4 Structural Programming and Data Structures Winter 2000 CMPUT 102: Inheritance Dr. Osmar R. Zaïane Course Content Introduction Objects Methods Tracing Programs Object State Sharing resources Selection Repetition

More information

Types. Type checking. Why Do We Need Type Systems? Types and Operations. What is a type? Consensus

Types. Type checking. Why Do We Need Type Systems? Types and Operations. What is a type? Consensus Types Type checking What is a type? The notion varies from language to language Consensus A set of values A set of operations on those values Classes are one instantiation of the modern notion of type

More information

COMPUTER SCIENCE TRIPOS

COMPUTER SCIENCE TRIPOS CST1.2018.4.1 COMPUTER SCIENCE TRIPOS Part IB Monday 4 June 2018 1.30 to 4.30 COMPUTER SCIENCE Paper 4 Answer five questions: up to four questions from Section A, and at least one question from Section

More information

Konzepte von Programmiersprachen

Konzepte von Programmiersprachen Konzepte von Programmiersprachen Chapter 9: Objects and Classes Peter Thiemann Universität Freiburg 9. Juli 2009 Konzepte von Programmiersprachen 1 / 22 Objects state encapsulation (instance vars, fields)

More information

Java 8 Programming for OO Experienced Developers

Java 8 Programming for OO Experienced Developers www.peaklearningllc.com Java 8 Programming for OO Experienced Developers (5 Days) This course is geared for developers who have prior working knowledge of object-oriented programming languages such as

More information

Fast Track to Core Java 8 Programming for OO Developers (TT2101-J8) Day(s): 3. Course Code: GK1965. Overview

Fast Track to Core Java 8 Programming for OO Developers (TT2101-J8) Day(s): 3. Course Code: GK1965. Overview Fast Track to Core Java 8 Programming for OO Developers (TT2101-J8) Day(s): 3 Course Code: GK1965 Overview Java 8 Essentials for OO Developers is a three-day, fast-paced, quick start to Java 8 training

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Type Systems, Names and Binding CMSC 330 - Spring 2013 1 Topics Covered Thus Far! Programming languages Ruby OCaml! Syntax specification Regular expressions

More information

Modularly Typesafe Interface Dispatch in JPred

Modularly Typesafe Interface Dispatch in JPred Modularly Typesafe Interface Dispatch in JPred Christopher Frost Todd Millstein University of California, Los Angeles {frost,todd@cs.ucla.edu Abstract Multiple dispatch generalizes the receiver-oriented

More information

2.4 Structuring programs

2.4 Structuring programs 2.4 Structuring programs While theoretically a program could be written as one big expression, in reality we want some structure so that l The programmer has it easier to read the program l A compiler

More information

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17 List of Programs xxv List of Figures xxix List of Tables xxxiii Preface to second version xxxv PART 1 Structured Programming 1 1 Getting started 3 1.1 Programming 3 1.2 Editing source code 5 Source code

More information

Subtyping. Lecture 13 CS 565 3/27/06

Subtyping. Lecture 13 CS 565 3/27/06 Subtyping Lecture 13 CS 565 3/27/06 Polymorphism Different varieties of polymorphism: Parametric (ML) type variables are abstract, and used to encode the fact that the same term can be used in many different

More information

HAS-A Relationship. If A uses B, then it is an aggregation, stating that B exists independently from A.

HAS-A Relationship. If A uses B, then it is an aggregation, stating that B exists independently from A. HAS-A Relationship Association is a weak relationship where all objects have their own lifetime and there is no ownership. For example, teacher student; doctor patient. If A uses B, then it is an aggregation,

More information

University of Magdeburg. School of Computer Science. Diplomarbeit. A Machine-Checked Proof for a Product-Line Aware Type System. Author: Thomas Thüm

University of Magdeburg. School of Computer Science. Diplomarbeit. A Machine-Checked Proof for a Product-Line Aware Type System. Author: Thomas Thüm University of Magdeburg School of Computer Science Diplomarbeit A Machine-Checked Proof for a Product-Line Aware Type System Author: Thomas Thüm January 15, 2010 Advisors: Prof. Dr. rer. nat. habil. Gunter

More information

CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011

CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011 CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011 1 Introduction Type checking is a lightweight technique for proving simple properties of programs. Unlike theorem-proving techniques based on axiomatic

More information

Subclassing for ADTs Implementation

Subclassing for ADTs Implementation Object-Oriented Design Lecture 8 CS 3500 Fall 2009 (Pucella) Tuesday, Oct 6, 2009 Subclassing for ADTs Implementation An interesting use of subclassing is to implement some forms of ADTs more cleanly,

More information

Chapter 5 Object-Oriented Programming

Chapter 5 Object-Oriented Programming Chapter 5 Object-Oriented Programming Develop code that implements tight encapsulation, loose coupling, and high cohesion Develop code that demonstrates the use of polymorphism Develop code that declares

More information

Review. CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Let bindings (CBV) Adding Stuff. Booleans and Conditionals

Review. CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Let bindings (CBV) Adding Stuff. Booleans and Conditionals Review CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics e ::= λx. e x ee c v ::= λx. e c (λx. e) v e[v/x] e 1 e 2 e 1 e 2 τ ::= int τ τ Γ ::= Γ,x : τ e 2 e 2 ve 2 ve 2 e[e /x]:

More information

Array. Prepared By - Rifat Shahriyar

Array. Prepared By - Rifat Shahriyar Java More Details Array 2 Arrays A group of variables containing values that all have the same type Arrays are fixed length entities In Java, arrays are objects, so they are considered reference types

More information

PROGRAMMING LANGUAGE 2

PROGRAMMING LANGUAGE 2 31/10/2013 Ebtsam Abd elhakam 1 PROGRAMMING LANGUAGE 2 Java lecture (7) Inheritance 31/10/2013 Ebtsam Abd elhakam 2 Inheritance Inheritance is one of the cornerstones of object-oriented programming. It

More information

CS-XXX: Graduate Programming Languages. Lecture 9 Simply Typed Lambda Calculus. Dan Grossman 2012

CS-XXX: Graduate Programming Languages. Lecture 9 Simply Typed Lambda Calculus. Dan Grossman 2012 CS-XXX: Graduate Programming Languages Lecture 9 Simply Typed Lambda Calculus Dan Grossman 2012 Types Major new topic worthy of several lectures: Type systems Continue to use (CBV) Lambda Caluclus as our

More information

Inheritance (Chapter 7)

Inheritance (Chapter 7) Inheritance (Chapter 7) Prof. Dr. Wolfgang Pree Department of Computer Science University of Salzburg cs.uni-salzburg.at Inheritance the soup of the day?! Inheritance combines three aspects: inheritance

More information

Rules and syntax for inheritance. The boring stuff

Rules and syntax for inheritance. The boring stuff Rules and syntax for inheritance The boring stuff The compiler adds a call to super() Unless you explicitly call the constructor of the superclass, using super(), the compiler will add such a call for

More information

Modal Logic: Implications for Design of a Language for Distributed Computation p.1/53

Modal Logic: Implications for Design of a Language for Distributed Computation p.1/53 Modal Logic: Implications for Design of a Language for Distributed Computation Jonathan Moody (with Frank Pfenning) Department of Computer Science Carnegie Mellon University Modal Logic: Implications for

More information

Part III. Chapter 15: Subtyping

Part III. Chapter 15: Subtyping Part III Chapter 15: Subtyping Subsumption Subtype relation Properties of subtyping and typing Subtyping and other features Intersection and union types Subtyping Motivation With the usual typing rule

More information

Compiler Construction 2016/2017 Polymorphic Types and Generics

Compiler Construction 2016/2017 Polymorphic Types and Generics Compiler Construction 2016/2017 Polymorphic Types and Generics Peter Thiemann January 8, 2017 Outline 1 Polymorphic Types and Generics 2 Parametric Polymorphism 3 Translation of Polymorphic Programs 4

More information

Object typing and subtypes

Object typing and subtypes CS 242 2012 Object typing and subtypes Reading Chapter 10, section 10.2.3 Chapter 11, sections 11.3.2 and 11.7 Chapter 12, section 12.4 Chapter 13, section 13.3 Subtyping and Inheritance Interface The

More information

Extending FeatherTrait Java with Interfaces

Extending FeatherTrait Java with Interfaces Theoretical Computer Science 398 (2008) 243 260 www.elsevier.com/locate/tcs Extending FeatherTrait Java with Interfaces Luigi Liquori a,, Arnaud Spiwack b a INRIA Sophia Antipolis - Méditerranée, 2004

More information

Homogeneous Family Sharing: Technical report

Homogeneous Family Sharing: Technical report Homogeneous Family Sharing: Technical report Xin Qi Andrew C. Myers {qixin, andru}@cs.cornell.edu Abstract Recent work has introduced class sharing as a mechanism for adapting a family of related classes

More information

Recursive Types and Subtyping

Recursive Types and Subtyping Recursive Types and Subtyping #1 One-Slide Summary Recall: Recursive types (e.g., τ list) make the typed lambda calculus as powerful as the untyped lambda calculus. If τ is a subtype of σ then any expression

More information

Lecture 16: Object Programming Languages

Lecture 16: Object Programming Languages Lecture 16: Object Programming Languages Introduction Corresponds to EOPL 5.1 and 5.2 Goal: to introduce Object Oriented Programming Language (OOPL) concepts using the EOPL extensible language framework

More information

McJava A Design and Implementation of Java with Mixin-Types

McJava A Design and Implementation of Java with Mixin-Types McJava A Design and Implementation of Java with Mixin-Types Tetsuo Kamina and Tetsuo Tamai University of Tokyo 3-8-1, Komaba, Meguro-ku, Tokyo, 153-8902, Japan {kamina,tamai}@graco.c.u-tokyo.ac.jp Abstract.

More information

Lecture 3. Lecture

Lecture 3. Lecture True Object-Oriented programming: Dynamic Objects Static Object-Oriented Programming Reference Variables Eckel: 30-31, 41-46, 107-111, 114-115 Riley: 5.1, 5.2 D0010E Object-Oriented Programming and Design

More information