Featherweight Java - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Featherweight Java

Description:

Featherweight Java (FJ) is a minimal core calculus for modelling Java's type system ... Featherweight Generic Java extends FJ with Generic Types (as in Java 5 ... – PowerPoint PPT presentation

Number of Views:47
Avg rating:3.0/5.0
Slides: 18
Provided by: mcsV
Category:

less

Transcript and Presenter's Notes

Title: Featherweight Java


1
Featherweight Java
  • COMP431 (Compilers) by Dr Alex Potanin

2
Featherweight Java
  • class A extends Object
  • A() super()
  • class B extends Object
  • B() super()
  • class Pair extends Object
  • Object fst Object snd
  • Pair(Object fst, Object snd)
  • super() this.fst fst this.snd snd
  • Pair setfst(Object newfst)
  • return new Pair(newfst, this.snd)

3
Featherweight Java
  • Inside every large language is a small language
    struggling to get out (Tony Hoare)
  • Featherweight Java (FJ) is a minimal core
    calculus for modelling Javas type system
  • It only has five expressions
  • Object creation
  • Method invocation
  • Field access
  • Casting
  • Variable
  • FJ is only a little larger than lambda calculus!

4
Featherweight Java
  • FJ has no assignment (trivially fixable see
    Types and Programming Languages by Benjamin
    Pierce)
  • FJs type system is proved to be sound
  • FJ used as a starting point for modelling new
    features to be introduced to Java (e.g.
    Featherweight Generic Ownership, Featherweight
    Immutable Java, etc.)
  • Featherweight Generic Java extends FJ with
    Generic Types (as in Java 5)
  • Uses the typing environment Gto keep track of
    variable types

5
FJ Program
  • FJ program is a collection of class definitions
    followed by an expression to be evaluated (think
    of the latter as the main method in Java)
  • class Foo extends Object
  • class Bar extends Object
  • new Pair(new Foo(), new Bar()).fst
  • The above evaluates to new Foo() which is an
    example of normal form in FJ.

6
FJ Syntax
7
FJ Class
8
FJ Method
9
Lecture 11
  • Starts here

10
FJ Expressions (1 of 2)
11
FJ Expressions (2 of 2)
12
FJ Subtyping
13
FJ Field Lookup
14
FJ Method Type and Body Lookups
15
FJ Computation Rules
16
FJ Congruence Rules
17
Featherweight Generic Java
  • class A extends Object
  • A() super()
  • class B extends Object
  • B() super()
  • class PairltX extends Object, Y extends Objectgt
  • extends Object
  • X fst Y snd
  • Pair(X fst, Y snd)
  • super() this.fst fst this.snd snd
  • ltZ extends Objectgt PairltZ, Ygt setfst(Z newfst)
  • return new PairltZ, Ygt(newfst, this.snd)
Write a Comment
User Comments (0)
About PowerShow.com