Java & Lambda: a Featherweight Story

01/15/2018
by   Lorenzo Bettini, et al.
0

We present FJ&Lambda, a new core calculus that extends Featherweight Java (FJ) with interfaces, supporting multiple inheritance, lambda-expressions, and intersection types. Our main goal is to formalise how lambdas and intersection types are grafted on Java 8, by studying their properties in a formal setting. We show how intersection types play a significant role in several cases, in particular in the typecast of a lambda-expression and in the typing of conditional expressions. We also embody interface default methods in FJ&Lambda, since they increase the dynamism of lambda-expressions, by allowing these methods to be called on lambda-expressions. The crucial point in Java 8 and in our calculus is that lambda-expressions can have various types according to the context requirements (target types): indeed, Java code is not correct when lambda-expressions come without target types. In particular, in the operational semantics we must record target types by decorating lambda-expressions, otherwise they would be lost in the runtime expressions. We prove the subject reduction property and progress for the resulting calculus, and we give a type inference algorithm that returns the type of a given program if it is well typed. The design of FJ&Lambda has been driven by the aim of making it a subset of Java 8, while preserving the elegance and compactness of FJ. Indeed, FJ&Lambda programs are typed and behave the same as Java programs.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
10/10/2018

A Simple Java Code Generator for ACL2 Based on a Deep Embedding of ACL2 in Java

AIJ (ACL2 In Java) is a deep embedding in Java of an executable, side-ef...
research
05/24/2020

Featherweight Go

We describe a design for generics in Go inspired by previous work on Fea...
research
05/18/2022

Global Type Inference for Featherweight Generic Java

Java's type system mostly relies on type checking augmented with local t...
research
05/19/2010

Groebner bases in Java with applications in computer graphics

In this paper we present a Java implementation of the algorithm that com...
research
04/03/2021

Intersection Types for a Computational Lambda-Calculus with Global State

We study the semantics of an untyped lambda-calculus equipped with opera...
research
08/09/2022

Lang-n-Send Extended: Sending Regular Expressions to Monitors

In prior work, Cimini has presented Lang-n-Send, a pi-calculus with lang...
research
12/09/2018

Practical Optional Types for Clojure

Typed Clojure is an optional type system for Clojure, a dynamic language...

Please sign up or login with your details

Forgot password? Click here to reset