Encoding Ownership Types in Java Nicholas Cameron James Noble Victoria University of Wellington, New Zealand.

Slides:



Advertisements
Similar presentations
CPSC 388 – Compiler Design and Construction
Advertisements

CS 211 Inheritance AAA.
CSE 1302 Lecture 8 Inheritance Richard Gesick Figures from Deitel, “Visual C#”, Pearson.
Georgia Institute of Technology Workshop for CS-AP Teachers Chapter 3 Advanced Object-Oriented Concepts.
Ownership, Encapsulation and the Disjointness of Type and Effect Dave Clarke, Sophia Drossopoulou/2002 Encapsulation seminar Dec Sharon Goldschlager.
External Uniqueness Presented by Nir Atias Dave Clarke Tobias Wrigstad Encapsulation Seminar 2006.
Programming with Objects: Class Libraries and Reusable Code.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Laboratory for Computer Science Massachusetts Institute of Technology Ownership Types for Safe Region-Based Memory Management in Real-Time Java Chandrasekhar.
On the Relationship Between Concurrent Separation Logic and Assume-Guarantee Reasoning Xinyu Feng Yale University Joint work with Rodrigo Ferreira and.
Abstract Data Types and Encapsulation Concepts
Ownership Types for Object Encapsulation Authors:Chandrasekhar Boyapati Barbara Liskov Liuba Shrira Presented by: Charles Lin Course: CMSC 631.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
The different kinds of variables in a Java program.
CSCI-383 Object-Oriented Programming & Design Lecture 15.
(c) University of Washington03-1 CSC 143 Java Inheritance Reading: Ch. 10.
The different types of variables in a Java program.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 17 Animated Version Generics and Type Safety.
OOPs Object oriented programming. Based on ADT principles  Representation of type and operations in a single unit  Available for other units to create.
Lecture 8 Inheritance Richard Gesick. 2 OBJECTIVES How inheritance promotes software reusability. The concepts of base classes and derived classes. To.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Names Variables Type Checking Strong Typing Type Compatibility 1.
The Procedure Abstraction, Part V: Support for OOLs Comp 412 Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in.
Generic Ownership for Generic Java Alex Potanin, Dave Clarke (CWI) James Noble, Robert Biddle (Carleton)
Ownership and Immutability in Generic Java (OIGJ) Yoav Zibin +, Alex Potanin * Paley Li *, Mahmood Ali ^, and Michael Ernst $ Presenter: Yossi Gil + +
Existential Quantification for Variant Ownership Nicholas Cameron Sophia Drossopoulou Imperial College London (Victoria University of Wellington)‏
OOP: Encapsulation,Abstraction & Polymorphism. What is Encapsulation Described as a protective barrier that prevents the code and data being randomly.
Writing Systems Software in a Functional Language An Experience Report Iavor Diatchki, Thomas Hallgren, Mark Jones, Rebekah Leslie, Andrew Tolmach.
Objects & Dynamic Dispatch CSE 413 Autumn Plan We’ve learned a great deal about functional and object-oriented programming Now,  Look at semantics.
Programming in Java CSCI-2220 Object Oriented Programming.
Types in programming languages1 What are types, and why do we need them?
Lecture 10 Concepts of Programming Languages Arne Kutzner Hanyang University / Seoul Korea.
Sadegh Aliakbary Sharif University of Technology Spring 2011.
Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith.
Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith.
Featherweight Generic Ownership Alex Potanin, James Noble Victoria University of Wellington Dave Clarke CWI, Netherlands Robert Biddle Carlton University.
OOPs Object oriented programming. Abstract data types  Representationof type and operations in a single unit  Available for other units to create variables.
2-1 Copyright (c) 1999 N. Afshartous Contents 1.Classes and Objects 2.Inheritance 3.Interfaces 4.Exceptions and Error Handling 5.Intro to Concurrency 6.Concurrency.
Saving the World from Bad Beans Dave Clarke, Utrecht Michael Richmond, IBM ARC James Noble, VUW.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
SHEEP CLONING Paley Li, Nicholas Cameron, and James Noble 1.
CMSC 202 Polymorphism. 10/20102 Topics Binding (early and late) Upcasting and downcasting Extensibility The final modifier with  methods  classes.
Zach Tatlock / Winter 2016 CSE 331 Software Design and Implementation Lecture 13 Generics 1.
Inheritance ndex.html ndex.htmland “Java.
Exceptions Lecture 11 COMP 401, Fall /25/2014.
Towards a Semantic Model for Java Wildcards Sophia Drossopoulou Mariangiola Dezani-Ciancaglini Imperial College London Università di Torino Italy Nicholas.
Notices Assn 2 is due tomorrow, 7pm. Moodle quiz next week – written in the lab as before. Everything up to and including today’s lecture: Big Topics are.
Object Oriented Programming in Java Habib Rostami Lecture 2.
Tribal Ownership Nicholas Cameron James Noble Tobias Wrigstad Victoria University of Wellington Uppsala University.
CSCI 383 Object-Oriented Programming & Design Lecture 15 Martin van Bommel.
Comparing Universes and Existential Ownership Types Nicholas Cameron Werner Dietl ETH Zurich Victoria University of Wellington.
On Subtyping, Wildcards, and Existential Types
Design issues for Object-Oriented Languages
Data Types In Text: Chapter 6.
Sections Inheritance and Abstract Classes
Nicholas Cameron James Noble Victoria University of Wellington
Multi-Methods in Cecil
Inheritance and Polymorphism
Dr. Charles W. Kann III JavaScript Objects Dr. Charles W. Kann III
Names, Binding, and Scope
Scope, Visibility, and Lifetime
Lecture 22 Inheritance Richard Gesick.
Interfaces.
Objects and Aspects: What we’ve seen so far
Object Oriented Programming
Pointers Dr. Bhargavi Goswami Department of Computer Science
Java Programming Course
CISC/CMPE320 - Prof. McLeod
Fundaments of Game Design
Presentation transcript:

Encoding Ownership Types in Java Nicholas Cameron James Noble Victoria University of Wellington, New Zealand

Ownership types for real life Ownership types are great! – (More later...)

Ownership types for real life But ownership type systems are big and complex – And writing compilers is hard – And the type systems are not well-understood

Ownership types for real life There is another way...

Ownership Types Are a facilitating type system: – Effects Parallelisation Optimisation – Concurrency – Memory management – Security –...

Ownership Types When the heap gets large, reasoning gets hard Solution: break it up into smaller regions – BUT, we don’t program this way Nest the regions – Welcome to ownership types!

Ownership Types owner:ClassName – this:C – world:D owner keyword names the owner of this – owner:C Context parameters add flexibility

Java Generics – List

Java Wildcards – List

End of Background...

Basic idea We use type parameters to mimic ownership parameters (OGJ)

An object’s owner (and the ‘world’ context) class C {...} world:C class C {...} C – class World {}

Context parameters Become type parameters

Bounds

The ‘this’ context This* is where it gets interesting We depart from OGJ – (OGJ does this with magic) Must correspond with the this variable *no pun intended

The ‘this’ context Kind of like another context parameter – class C {... } We can name This within the class

The ‘this’ context But this cannot be named outside the class – So neither should This Use a wildcard to hide This

The ‘this’ context class E world:E class E E

The ‘this’ context But, what about nesting?

The ‘this’ context Use bounds – class C Wildcards inherit declared bounds – C

The ‘this’ context class E world:E class E<C1, C2, Owner, This extends Owner> E

The ‘this’ context class E world:E class E<C1, C2, Owner, This extends Owner> E (E ) new

The ‘this’ context

The type system thinks there is a hierarchy –  X inside  Y inside  Z inside... But in reality all owners are World

Nice...

Existential Owners and variant ownership Use wildcards

Inner Classes Require inner classes to be able to name surrounding This parameter – Comes naturally with Java generics

Type Parameters Work alongside translated context parameters class F {... } world:F class F {... } F

Universes rep CC peer CC any CC

and... Ownership Domains Context-parametric methods Dynamic aliases Fields as contexts Existential downcasting

Owners-as-Dominators Most of the work is done by the hiding of This using wildcards Must ensure it cannot be named indirectly Works with the extensions too – Including inner classes

Owners-as-Dominators Cannot be enforced by translating compiler Requires enforcing well-formedness of intermediate types

Contributions Prototype compilers – Ownership types++ – Universes How to leverage existing compiler technology for OTs Formalisation of OTs in Java – Proved sound – Ownership hierarchy is preserved and enforced at runtime Better understanding of OTs

Thank you!