1 A Model for Java with Wildcards Nicholas Cameron Sophia Drossopoulou Erik Ernst.

Slides:



Advertisements
Similar presentations
Numbers Treasure Hunt Following each question, click on the answer. If correct, the next page will load with a graphic first – these can be used to check.
Advertisements

Repaso: Unidad 1 Lección 2
Scenario: EOT/EOT-R/COT Resident admitted March 10th Admitted for PT and OT following knee replacement for patient with CHF, COPD, shortness of breath.
Angstrom Care 培苗社 Quadratic Equation II
AP STUDY SESSION 2.
1
Feichter_DPG-SYKL03_Bild-01. Feichter_DPG-SYKL03_Bild-02.
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
Copyright © 2011, Elsevier Inc. All rights reserved. Chapter 6 Author: Julia Richards and R. Scott Hawley.
Author: Julia Richards and R. Scott Hawley
1 Copyright © 2013 Elsevier Inc. All rights reserved. Appendix 01.
1 Copyright © 2013 Elsevier Inc. All rights reserved. Chapter 38.
Properties Use, share, or modify this drill on mathematic properties. There is too much material for a single class, so you’ll have to select for your.
Objectives: Generate and describe sequences. Vocabulary:
David Burdett May 11, 2004 Package Binding for WS CDL.
We need a common denominator to add these fractions.
1 RA I Sub-Regional Training Seminar on CLIMAT&CLIMAT TEMP Reporting Casablanca, Morocco, 20 – 22 December 2005 Status of observing programmes in RA I.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Properties of Real Numbers CommutativeAssociativeDistributive Identity + × Inverse + ×
Custom Statutory Programs Chapter 3. Customary Statutory Programs and Titles 3-2 Objectives Add Local Statutory Programs Create Customer Application For.
Custom Services and Training Provider Details Chapter 4.
CALENDAR.
1 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt BlendsDigraphsShort.
1 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt RhymesMapsMathInsects.
FACTORING ax2 + bx + c Think “unfoil” Work down, Show all steps.
Around the World AdditionSubtraction MultiplicationDivision AdditionSubtraction MultiplicationDivision.
PUBLIC KEY CRYPTOSYSTEMS Symmetric Cryptosystems 6/05/2014 | pag. 2.
1 Click here to End Presentation Software: Installation and Updates Internet Download CD release NACIS Updates.
Photo Slideshow Instructions (delete before presenting or this page will show when slideshow loops) 1.Set PowerPoint to work in Outline. View/Normal click.
Break Time Remaining 10:00.
This module: Telling the time
Turing Machines.
Table 12.1: Cash Flows to a Cash and Carry Trading Strategy.
PP Test Review Sections 6-1 to 6-6
1 The Blue Café by Chris Rea My world is miles of endless roads.
Bright Futures Guidelines Priorities and Screening Tables
EIS Bridge Tool and Staging Tables September 1, 2009 Instructor: Way Poteat Slide: 1.
Physical Aspects [Reflection Modelling] Hauptseminar: Augmented Reality for Driving Assistance in Cars.
Bellwork Do the following problem on a ½ sheet of paper and turn in.
Exarte Bezoek aan de Mediacampus Bachelor in de grafische en digitale media April 2014.
15. Oktober Oktober Oktober 2012.
Copyright © 2013, 2009, 2006 Pearson Education, Inc. 1 Section 5.5 Dividing Polynomials Copyright © 2013, 2009, 2006 Pearson Education, Inc. 1.
Copyright © 2012, Elsevier Inc. All rights Reserved. 1 Chapter 7 Modeling Structure with Blocks.
1 RA III - Regional Training Seminar on CLIMAT&CLIMAT TEMP Reporting Buenos Aires, Argentina, 25 – 27 October 2006 Status of observing programmes in RA.
Basel-ICU-Journal Challenge18/20/ Basel-ICU-Journal Challenge8/20/2014.
1..
CONTROL VISION Set-up. Step 1 Step 2 Step 3 Step 5 Step 4.
Adding Up In Chunks.
1 Variant Ownership with Existential Types Nicholas Cameron Sophia Drossopoulou Imperial College London.
MaK_Full ahead loaded 1 Alarm Page Directory (F11)
1 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt Synthetic.
25 seconds left…...
Subtraction: Adding UP
: 3 00.
5 minutes.
1 hi at no doifpi me be go we of at be do go hi if me no of pi we Inorder Traversal Inorder traversal. n Visit the left subtree. n Visit the node. n Visit.
Analyzing Genes and Genomes
Essential Cell Biology
Converting a Fraction to %
Clock will move after 1 minute
PSSA Preparation.
Essential Cell Biology
Immunobiology: The Immune System in Health & Disease Sixth Edition
Physics for Scientists & Engineers, 3rd Edition
Energy Generation in Mitochondria and Chlorplasts
Select a time to count down from the clock above
Murach’s OS/390 and z/OS JCLChapter 16, Slide 1 © 2002, Mike Murach & Associates, Inc.
1 Decidability continued…. 2 Theorem: For a recursively enumerable language it is undecidable to determine whether is finite Proof: We will reduce the.
On Subtyping, Wildcards, and Existential Types
Presentation transcript:

1 A Model for Java with Wildcards Nicholas Cameron Sophia Drossopoulou Erik Ernst

2 Background Wildcards Previous attempts Existential types Subtyping Typing

3 Background

Java Adding Wildcards to the Java Language Torgersen, Ernst, Plesner Hansen, von der Ahé, Bracha, Gafter. SAC 04. Existential types to model wildcards 4

Wild FJ Torgersen, Ernst, Plesner Hansen. FOOL 05. ‘On the fly’ existential types No soundness proof  J Cameron, Ernst, Drossopoulou. FtfJP 07. Explicit existential types Explicit open/close expressions Partial model Variant Parametric Types Igarashi, Viroli. ECOOP 02, TOPLAS 06. Partial model No capture conversion 5

On Decidability of Nominal Subtyping with Variance Kennedy, Pierce. FOOL 07. Variance and Generalized Constraints for C# Generics Emir, Kennedy, Russo, Yu. ECOOP 06 Typeless Programming in Java 5.0 Plümicke, Bäuerle. PPPJ 06 A Flow-Based Approach for Variant Parametric Types Chin, Craciun, Khoo, Popeea. OOPSLA 06. Subtyping Existential Types Weir, Theimann. FTfJP 08. 6

Wildcards A very brief description

Java Type Cup 8

Java Generics Type Cup 9

Generics - Invariant Subtyping Cup 10 /

Java Wildcards Type Cup 11

Bounds Cup 12

Generics - Invariant Subtyping Cup 13 /

Wildcards - Variant Subtyping Cup 14 /

Wildcard Capture void test(Cup cx) {...} void m(Cup c) { this.test(c); } 15

Wildcard Capture void test(Cup cx) {...} void m(Cup c) { this.test(c); //this. test(c); //Z fresh } 16

Our Previous Attempts

Naïve Approach Cup 18

Naïve Approach Cup 19 Expressible but not denotable types

'On the fly' Existential Types capture( Cup ) =  X.Cup 20

'On the fly' Existential Types capture( Cup ) =  X.Cup Too complicated 21

Explicit Existential Types open... close... 22

Explicit Existential Types open... close... Lower Bounds Expressivity 23

Scope Violation void m(  X.Cup x) { this. m2(x); } 24

Scope Violation void m(  X.Cup x) { this. m2(x); } Alpha Renaming 25

... 26

Modelling Concepts

Tame FJ

Explicit existential types Implicit packing (in subtyping ( XS-ENV ))‏ Implicit unpacking (in type rules)‏ Inferred type parameters this. m(x); Separation of subtyping Subclassing, extended subclassing, subtyping Guarding environment... e : T |  Tracks unpacked type variables 29

30 Existential Types

Cup  X.Cup 31

Cup  X  Drink.Cup 32

But Why?

Capture conversion Expressible but not denotable types

Pair make(List x) {...} void test (Pair x) {...} void m(List l, Pair p) { test(p); } 35

36

37

38

 X.Pair Type is expressible but not denotable 39

Pair make(List x) {...} void test (Pair x) {...} void m(  X.List l,  X,Y.Pair p) { test(p); test(make(l));  X.Pair q = make(l); } 40

Pair make(List x) {...} void test (Pair x) {...} void m(  X.List l,  X,Y.Pair p) { test(p); test(make(l));  X.Pair q = make(l); } 41

Pair make(List x) {...} void test (Pair x) {...} void m(  X.List l,  X,Y.Pair p) { test(p); test(make(l));  X.Pair q = make(l); } 42

43 Subtyping

Wildcards Subtyping Cup 44

Wildcards Subtyping Cup .Cup Cup .Cup Cup  Y  Tea.Cup 45

,  ’ T <: B   ’.[T/X]N <:  X  B.N (S-E NV )‏ 46 ┴ ┴

Cup .Cup  Tea <: Object  .[Tea/X]Cup (S-E NV )‏ 47 ┴ ┴

Cup .Cup  Tea <: Drink  .[Tea/X]Cup (S-E NV )‏ 48 ┴ ┴

Cup  Y  Tea.Cup Y  Tea Y <:Tea <: Drink   Y  Tea.[Y/X]Cup (S-E NV )‏ 49 ┴ ┴

3 flavours of subtyping?

Java 4 Subtyping 51 Object CoffeeTea Drink List Vector

Java 5 Subtyping 52 Object CoffeeTea Drink  Z  Drink.List  Z.List List  Z  Drink.Vector  Z.Vector Vector X In class C...  Z  X.List  Z  X.Vector

Tame FJ Subclassing 53 Object CoffeeTea Drink List Vector X In class C...

Tame FJ Extended Subtyping 54  Z  Drink.List  Z.List List  Z  Drink.Vector  Z.Vector Vector In class C...  Z  X.List  Z  X.Vector

Tame FJ Subtyping Tea X In class C...

TameFJ Subtyping 56 Object CoffeeTea Drink  Z  Drink.List  Z.List List  Z  Drink.Vector  Z.Vector Vector X In class C...  Z  X.List  Z  X.Vector

But Why? Subtyping is too flexible and complicated to use directly in the proofs Subclassing Properties of the class hierarchy – e.g., field/method lookup Extended Subclassing If we need wildcard subtyping, but can't deal with lower bounds E.g., preservation of existential types Subtyping Still required – e.g., result of inversion lemmas, due to T-S UBS 57

58 Typing

59

60

61

class Cup { Mug f; void m(Cup c) { c.f; } 62

class Cup { Mug f; void m(Cup c) { c.f; } X;this:Cup c:  Z.Cup |  fType( f, Cup ) = Mug 63 ┴

class Cup { Mug f; void m(Cup c) { c.f; } X;this:Cup c:  Z.Cup |  fType( f, Cup ) = Mug X;this:Cup c.f:Mug | Z 64 ┴ ┴

class Cup { Mug f; void m(Cup c) { c.f; } X;this:Cup c:  Z.Cup |  fType( f, Cup ) = Mug X;this:Cup c.f:Mug | Z 65 ┴ ┴

66

67

68

class Cup { Mug f; void m(Cup c) { c.f; } X;this:Cup c:  Z.Cup |  fType( f, Cup ) = Mug X;this:Cup c.f:Mug | Z 69 ┴ ┴

class Cup { Mug f; void m(Cup c) { c.f; } X;this:Cup c:  Z.Cup |  fType( f, Cup ) = Mug X;Z Mug X;this:Cup c.f:Mug | Z 70 ┴ ┴ ┴

class Cup { Mug f; void m(Cup c) { c.f; } X;this:Cup c:  Z.Cup |  fType( f, Cup ) = Mug X;Z Mug X;this:Cup c.f:Mug | Z X  Z.Mug OK 71 ┴ ┴ ┴ ┴

class Cup { Mug f; void m(Cup c) { c.f; } X;this:Cup c:  Z.Cup |  fType( f, Cup ) = Mug X;Z Mug X;this:Cup c.f:Mug | Z X  Z.Mug OK X;this:Cup c.f:  Z.Mug |  72 ┴ ┴ ┴ ┴ ┴

class Cup { Mug f; void m(Cup c) { c.f; } X;this:Cup c:  Z.Cup |  fType( f, Cup ) = Mug X;Z Mug X;this:Cup c.f:Mug | Z X  Z.Mug OK X;this:Cup c.f:  Z.Mug |  73 ┴ ┴ ┴ ┴ ┴

Full model Proven sound Future Work ‘More full’ - features, translation More expressive? Mechanical proof checking 75

76 Thank You!

class Cup { Cup f; Cup m2(String x) {...} void m(Cup c) { c.f = c.f; c.f = c; c.f = c.m2(“a string”); } 77

Variance in C# and Scala C# is invariant, but variance proposed Declaration site annotations Less complex, but less flexible Vs. use site declaration in Java class CovariantCup... Formalisation and soundness C# - Emir, Kennedy, Russo, Yu. ECOOP 06 Scala - Cremet. PhD Thesis, 06 (Virtual types)‏ 78