Type inference in Java 8

Size: px
Start display at page:

Download "Type inference in Java 8"

Transcription

1 Type inference in Java 8 Martin Plümicke Baden-Wuerttemberg Cooperative State University Stuttgart/Horb 10. Januar 2013

2 Overview Introduction The function TYPE The sub-function TYPEExpr The sub-function TYPEStmt The function SOLVE The whole algorithm TI

3 Martin Pluemicke s research on type inference for Java with generics and lambda expressions (version 5 8) UNIF 04: Type unification in Generic Java Type unification for generic java types without wildcards PPPJ 2006: Typeless programming in Java 5.0 Type inference for generic java types without wildcards WLP2007/INAP2007: Java type unification with wildcards Type unification for generic java types with wildcards PPPJ 2007: Typeless programming in Java 5.0 with wildcards Type inference for generic java types with wildcards PPPJ 2011: Well typings for Java λ λ expressions, but no methods Function types as types of λ expressions Adaption of the type inference algorithm of Fuh and Mishra 88 results: well typings (condtional types) PPPJ 2008: Imtersection types in java Resolving the intersection types for code generation 2014 (to publish): More type inference in java 8 Functional interfaces as types of λ expressions Type inference for λ expressions result: set of type results with some constraints 2014 (to publish): Functional interfaces vs. function types in Java with lambdas function types as types of λ expressions Additional functional interfaces as target types of lambda expressions KPS 2013: Implementierung eines Typinferenzalgorithmus für Java 8 Work in progress/to DO: Eclipse PlugIn Resolving the intersection types for code generation

4 History of Java type system Version 1: Subtyping on classes (without parameters) Ex.: Integer Object

5 History of Java type system Version 1: Version 5: Subtyping on classes (without parameters) Ex.: Integer Object Parametrized classes (type constructors) Ex.: Vector<X> Subtyping extension Ex.: Matrix Vector<Vector<Integer>> Wildcards (with lower and upper bounds) Ex.: Vector<? extends Integer>

6 History of Java type system Version 1: Version 5: Subtyping on classes (without parameters) Ex.: Integer Object Parametrized classes (type constructors) Ex.: Vector<X> Subtyping extension Ex.: Matrix Vector<Vector<Integer>> Wildcards (with lower and upper bounds) Ex.: Vector<? extends Integer> Version 8: Functional interfaces, but no function types

7 Motivating Example: External Iteration public class Student { String name; int graduationyear; double score; }

8 Motivating Example: External Iteration public class Student { String name; int graduationyear; double score; } List<Student> students =... double highestscore = 0.0; for (Student s : students) { if (s.gradyear == 2013) { if (s.score > highestscore) { highestscore = s.score; } } }

9 Motivating Example: External Iteration public class Student { String name; int graduationyear; double score; } List<Student> students =... double highestscore = 0.0; for (Student s : students) { if (s.gradyear == 2013) { if (s.score > highestscore) { highestscore = s.score; } } } external iteration serial iteration not thread-safe

10 Motivating Example: Inner classes public class Student { String name; int graduationyear; double score; } SomeCoolList<Student> students =... double highestscore = students.filter(new Predicate<Student>() { public boolean op(student s) { return s.getgradyear() == 2013; } })

11 Motivating Example: Inner classes public class Student { String name; int graduationyear; double score; } SomeCoolList<Student> students =... double highestscore = students.filter(new Predicate<Student>() { public boolean op(student s) { return s.getgradyear() == 2013; } }).map(new Mapper<Student,Double>() { public Double extract(student s) { return s.getscore(); } })

12 Motivating Example: Inner classes public class Student { String name; int graduationyear; double score; } SomeCoolList<Student> students =... double highestscore = students.filter(new Predicate<Student>() { public boolean op(student s) { return s.getgradyear() == 2013; } }).map(new Mapper<Student,Double>() { public Double extract(student s) { return s.getscore(); } }).max();

13 Motivating Example: Inner classes public class Student { String name; int graduationyear; double score; } SomeCoolList<Student> students =... double highestscore = students.filter(new Predicate<Student>() { public boolean op(student s) { return s.getgradyear() == 2013; } }).map(new Mapper<Student,Double>() { public Double extract(student s) { return s.getscore(); } }).max(); internal iteration by inner classes traversal may be done in parallel but ugly syntax

14 Motivating Example: Inner classes public class Student { String name; int graduationyear; double score; } SomeCoolList<Student> students =... double highestscore = students.filter(new Predicate<Student>() { public boolean op(student s) { return s.getgradyear() == 2013; } }).map(new Mapper<Student,Double>() { public Double extract(student s) { return s.getscore(); } }).max(); Idea: internal iteration by inner classes traversal may be done in parallel but ugly syntax

15 Lambda expression Well-known from functional programming languages. Example: Identity function \x -> x -- HASKELL fn x => x (lambda (x) x) -- SML -- SCHEME

16 Lambda expression Well-known from functional programming languages. Example: Identity function \x -> x -- HASKELL fn x => x (lambda (x) x) -- SML -- SCHEME Application: (\x -> x) 1 = 1

17 Lambda expression Well-known from functional programming languages. Example: Identity function \x -> x -- HASKELL fn x => x (lambda (x) x) -- SML -- SCHEME Application: (\x -> x) 1 = 1 Function-types: (\x -> x) :: a -> a

18 Motivating Example: public class Student { String name; int graduationyear; double score; } SomeCoolList<Student> students =... double highestscore = students.filter(student s -> s.getgradyear() == 2013).map(Student s -> s.getscore()).max();

19 Motivating Example: public class Student { String name; int graduationyear; double score; } SomeCoolList<Student> students =... double highestscore = students.filter(student s -> s.getgradyear() == 2013).map(Student s -> s.getscore()).max(); Lambda expressions more readable

20 functional interfaces restricted type inference method references default methods

21 Functional interfaces (SAM Types) An interface with one method Example: interface Operation { public int op (int x, int y); } int doop(operation o, int a, int b) { return o.op(a, b); }...

22 Functional interfaces (SAM Types) An interface with one method Example: interface Operation { public int op (int x, int y); } int doop(operation o, int a, int b) { return o.op(a, b); }... doop((int x, int y) -> x + y, 5, 7);

23 Functional interfaces in the Java library interface Comparator<T> { int compare(t x, T y); } interface FileFilter { boolean accept(file x); } interface DirectoryStream.Filter<T> { boolean accept(t x); } interface Runnable { void run(); } interface ActionListener { void actionperformed(...); } interface Callable<T> { T call(); }

24 Target types lambda expressions have no explicit type a target type is deduced from the context

25 Target types lambda expressions have no explicit type a target type is deduced from the context Example: Operation op = (int x, int y) -> x + y Target type: Operation Runnable op = (int x, int y) -> x + y Target type: Runnable

26 Target types lambda expressions have no explicit type a target type is deduced from the context Example: Operation op = (int x, int y) -> x + y Target type: Operation Runnable op = (int x, int y) -> x + y Target type: Runnable Which is a correct target type?

27 Functional interfaces as compatible target types A lambda expression is compatible with a type T, if T is a functional interface type The lambda expression has the same number of parameters as T s method, and those parameters types are the same Each expression returned by the lambda body is compatible with T s method s return type Each exception thrown by the lambda body is allowed by T s method s throws clause

28 Functional interfaces as compatible target types A lambda expression is compatible with a type T, if T is a functional interface type The lambda expression has the same number of parameters as T s method, and those parameters types are the same Each expression returned by the lambda body is compatible with T s method s return type Each exception thrown by the lambda body is allowed by T s method s throws clause Lemma: There is an equivalence class of compatible target types for a lambda expression.

29 Canonical representative For the equivalence class of the compatible target types of a lambda expression, there is a canonical representative with FunN <R, T 1,..., T N> interface FunN <R,T1,..., TN > { R apply(t1 arg1,..., TN argn ); } if the type of the single method of a compatible target type is (T 1,..., T N) R

30 Matrices in Java 8 class Matrix extends Vector<Vector<Integer>> { //Matrix -> ((Matrix, Matrix) -> Matrix) -> Matrix Fun1<Fun1<Matrix, Fun2<Matrix, Matrix,Matrix>>, Matrix> op = (Matrix m) -> (Fun2<Matrix, Matrix,Matrix> f) -> f.apply(this, m);

31 Matrices in Java 8 class Matrix extends Vector<Vector<Integer>> { //Matrix -> ((Matrix, Matrix) -> Matrix) -> Matrix Fun1<Fun1<Matrix, Fun2<Matrix, Matrix,Matrix>>, Matrix> op = (Matrix m) -> (Fun2<Matrix, Matrix,Matrix> f) -> f.apply(this, m); //(Matrix, Matrix) -> Matrix Fun2<Matrix, Matrix,Matrix> mul = (Matrix m1, Matrix m2) -> { Matrix ret = new Matrix ();... //matrix multiplication return ret; }

32 Matrices in Java 8 class Matrix extends Vector<Vector<Integer>> { //Matrix -> ((Matrix, Matrix) -> Matrix) -> Matrix Fun1<Fun1<Matrix, Fun2<Matrix, Matrix,Matrix>>, Matrix> op = (Matrix m) -> (Fun2<Matrix, Matrix,Matrix> f) -> f.apply(this, m); //(Matrix, Matrix) -> Matrix Fun2<Matrix, Matrix,Matrix> mul = (Matrix m1, Matrix m2) -> { Matrix ret = new Matrix ();... //matrix multiplication return ret; } public static void main(string[] args) { Matrix m1 = new Matrix(...); Matrix m2 = new Matrix(...); (m1.op.apply(m2)).apply(m1.mul);} } }

33 Goal class Matrix extends Vector<Vector<Integer>> { op = (m) -> (f) -> f.apply(this, m); mul = (m1, m2) -> { ret = new Matrix ();... //matrix multiplication return ret; } public static void main(string[] args) { Matrix m1 = new Matrix(...); Matrix m2 = new Matrix(...); (m1.op.apply(m2)).apply(m1.mul);} } }

34 The language Source := class class := Class(stype, [ extends( stype ), ]FieldDecl ) FieldDecl := Field( [type, ]var[, expr] ) block := Block( stmt ) stmt := block Return( expr ) While( bexpr, block ) LocalVarDecl( var[, type] ) If( bexpr, block[, block] ) stmtexpr lambdaexpr := Lambda( ((var[, type])), (stmt expr) ) stmtexpr := Assign( var, expr ) New( stype, expr ) MethodCall( iexpr, apply, expr ) vexpr := LocalVar( var ) InstVar( iexpr, var ) iexpr = vexpr stmtexpr Cast( type, iexpr ) this super expr := lambdaexpr iexp bexp sexp

35 Type parameter instatiation (Java 5.0): id: a a id(1) : for a the type Integer is inferred. Diamond operator (Java 7): Vector <Integer> v = new Vector <> Parameter s type inference in (Java 8): (T1 x1,..., TN xn) h( x1,..., XN ) The types T1,..., TN can be inferred: (x1,..., xn) h( x1,..., XN ) is a correct Lambda expression in Java 8.

36 More type inference

37 Sketch of the algorithm TI The function TYPE The function SOLVE The whole algorithm TI TYPE: Introduces fresh type variables and collects the constraints SOLVE: Solves the constraints by type unification

38 Data-structures Introduction The function TYPE The function SOLVE The whole algorithm TI Set of type assumptions: v : θ: Assumptions for fields or local variables of the actual class. τ.v : θ: Assumptions for fields of the class τ.

39 Data-structures Introduction The function TYPE The function SOLVE The whole algorithm TI Set of type assumptions: v : θ: Assumptions for fields or local variables of the actual class. τ.v : θ: Assumptions for fields of the class τ. Set of constraints: { θ R θ R {,?,. = } }

40 The function TYPE The function SOLVE The whole algorithm TI TYPE: TypeAssumptions Class TClass ConstraintsSet

41 The function TYPE The function SOLVE The whole algorithm TI TYPE: TypeAssumptions Class TClass ConstraintsSet TYPE( Ass, Class( τ, extends( τ ), fdecls ) ) = let fdecls = [Field( f 1, lexpr 1 ),..., Field( f n, lexpr n )] ftypeass = { this.f i : a i a i fresh type variables } { this : τ, super : τ } { visible types of fields of τ } AssAll = Ass ftypeass

42 The function TYPE The function SOLVE The whole algorithm TI TYPE: TypeAssumptions Class TClass ConstraintsSet TYPE( Ass, Class( τ, extends( τ ), fdecls ) ) = let fdecls = [Field( f 1, lexpr 1 ),..., Field( f n, lexpr n )] ftypeass = { this.f i : a i a i fresh type variables } { this : τ, super : τ } { visible types of fields of τ } AssAll = Ass ftypeass Forall 1 i n (lexp it : rtyf i, ConSF i ) = TYPEExpr( AssAll, lexpr i )

43 The function TYPE The function SOLVE The whole algorithm TI TYPE: TypeAssumptions Class TClass ConstraintsSet TYPE( Ass, Class( τ, extends( τ ), fdecls ) ) = let fdecls = [Field( f 1, lexpr 1 ),..., Field( f n, lexpr n )] ftypeass = { this.f i : a i a i fresh type variables } { this : τ, super : τ } { visible types of fields of τ } AssAll = Ass ftypeass Forall 1 i n (lexp it : rtyf i, ConSF i ) = TYPEExpr( AssAll, lexpr i ) fdecls t = [Field( a 1, f 1, lexpr 1t : rtyf 1 ),..., Field( a n, f n, lexpr nt : rtyf nt )]

44 The function TYPE The function SOLVE The whole algorithm TI TYPE: TypeAssumptions Class TClass ConstraintsSet TYPE( Ass, Class( τ, extends( τ ), fdecls ) ) = let fdecls = [Field( f 1, lexpr 1 ),..., Field( f n, lexpr n )] ftypeass = { this.f i : a i a i fresh type variables } { this : τ, super : τ } { visible types of fields of τ } AssAll = Ass ftypeass Forall 1 i n (lexp it : rtyf i, ConSF i ) = TYPEExpr( AssAll, lexpr i ) fdecls t = [Field( a 1, f 1, lexpr 1t : rtyf 1 ),..., Field( a n, f n, lexpr nt : rtyf nt )] in (Class( τ, extends( τ ), fdecls t ), ( i ConSF i { (rtyf i a i ) 1 i n }))

45 The function TYPE The function SOLVE The whole algorithm TI TYPEExpr: TypeAssumptions Expr TExpr ConstraintsSet

46 The function TYPE The function SOLVE The whole algorithm TI TYPEExpr: TypeAssumptions Expr TExpr ConstraintsSet For Lambda: TYPEExpr( Ass, Lambda( (x 1,..., x N ), expr stmt ) ) = let AssArgs = { x i : a i a i fresh type variables } (expr t : rty, ConS) = TYPEExpr( Ass AssArgs, expr ) (stmt t : rty, ConS) = TYPEStmt( Ass AssArgs, stmt ) in (Lambda( (x 1 :a 1,..., x N :a N ), expr t :rty stmt t :rty ) : FunN <a, a 1,..., a N >, ConS { (rty a) }), where a is a fresh type variable

47 The function TYPE The function SOLVE The whole algorithm TI For MethodCall: TYPEExpr( Ass, MethodCall( re, apply( e 1,..., e n ) ) ) = let (re t : rty, ConS) = TYPEExpr( Ass, re ) (e it : rty i, ConS i ) = TYPEExpr( Ass, e i ), 1 i n in (MethodCall( re t : rty, apply( e 1t :rty 1,..., e nt :rty n ) ):a, (ConS i ConS i) { rty FunN <a, a 1,..., a N > } { rty i a i 1 i N } where a 1,..., a N and a are fresh type variables

48 The function TYPE The function SOLVE The whole algorithm TI TYPEStmt: TypeAssumptions Stmt TStmt ConstraintsSet

49 The function TYPE The function SOLVE The whole algorithm TI TYPEStmt: TypeAssumptions Stmt TStmt ConstraintsSet For Return: TYPEStmt( Ass, Return( e ) ) = let (e t : rty, ConS) = TYPEExpr( Ass, e ) in (Return( e t : rty ) : rty, ConS))

50 For Block: Introduction The function TYPE The function SOLVE The whole algorithm TI TYPEStmt( Ass, Block( s ) ) = let (s t : rty, ConS) = TYPEStmt( Ass, s ) in (Block( s t : rty ) : rty, ConS)

51 For Block: Introduction The function TYPE The function SOLVE The whole algorithm TI TYPEStmt( Ass, Block( s ) ) = let (s t : rty, ConS) = TYPEStmt( Ass, s ) in (Block( s t : rty ) : rty, ConS) TYPEStmt( Ass, Block( s 1,..., s n ) ) = let (s 1t : rty 1, ConS 1 ) = TYPEStmt( Ass, s 1 ) (Block( s 2t,..., s nt ) : rty 2, ConS 2 ) = TYPEStmt( Ass, Block( s 2,..., s n ) ) in (Block( s 1t : rty 1, s 2t,..., s nt ) : a, ConS 1 ConS 2 { (rty 1 a), (rty 2 a) }) where a is a fresh type variable

52 The function TYPE The function SOLVE The whole algorithm TI Example class Matrix extends Vector<Vector<Integer>> { op = (m) -> (f) -> f.apply(this, m); }

53 The function TYPE The function SOLVE The whole algorithm TI Example class Matrix extends Vector<Vector<Integer>> { op = (m) -> (f) -> f.apply(this, m); } The result contains: lexpr 1t = Lam( m : a m, Lam( f : a f, MCall( LoVar( f ) : a f, apply( this : Matrix, LoVar( m ) : a m ) ) : a 3 ) : Fun1<a app, a f > ) : Fun1<a λf, a m >

54 The function TYPE The function SOLVE The whole algorithm TI Example class Matrix extends Vector<Vector<Integer>> { op = (m) -> (f) -> f.apply(this, m); } The result contains: lexpr 1t = Lam( m : a m, Lam( f : a f, MCall( LoVar( f ) : a f, apply( this : Matrix, LoVar( m ) : a m ) ) : a 3 ) : Fun1<a app, a f > ) : Fun1<a λf, a m > and the set of constraint: { (Fun1<a λf, a m > a op ), (Fun1<a app, a f > a λf ), (a f Fun2<a 3, a 1, a 2 >), (Matrix a 1 ), (a m a 2 ), (a 3 a app ) }

55 The function TYPE The function SOLVE The whole algorithm TI SOLVE: ConstraintsSet Constraints SubstSet { fail } SOLVE( ConS ) = let subs = TUnify( ConS ) in if (there are σ subs in solved form) then { σ subs σ is in solved form } if (there are σ subs, which has the form { v R v v, v are type vars } { v. = θ v is a type vars }) then { v R v v, v are type vars } { v. = θ v is a type vars } else fail

56 The function TYPE The function SOLVE The whole algorithm TI The sub-function TUnify 1 TUnify: ConstraintsSet { ConstraintsSet } { fail } Input: { (θ 1 θ 1 ),..., (θ n θ n) } Output: { σ 1,..., σ m } Post-condition: j { (σ j ( θ 1 ) σ j ( θ 1 )),..., (σ j( θ n ) σ j ( θ n )) } where is the sub-typing relation 1 [Pluemicke 2009]: Java type unification with wildcards, INAP 07

57 The function TYPE The function SOLVE The whole algorithm TI TI: TypeAssumptions Class { (Constraints, TClass) } { fail }

58 The function TYPE The function SOLVE The whole algorithm TI TI: TypeAssumptions Class { (Constraints, TClass) } { fail } TI( Ass, Class( τ, extends( τ ), fdecls ) ) = let (Class( τ, extends( τ ), fdecls t ), ConS) = TYPE( Ass, Class( τ, extends( τ ), fdecls ) ) { (cs 1, σ 1 ),..., (cs n, σ n ) } = SOLVE( ConS ) in { (cs i, σ i ( Class( τ, extends( τ ), fdecls t ) )) 1 i n }

59 Example Introduction The function TYPE The function SOLVE The whole algorithm TI ConS = { (Fun1<a λf, a m > a op ), (Fun1<a app, a f > a λf ), (a f Fun2<a 3, a 1, a 2 >), (Matrix a 1 ), (a m a 2 ), (a 3 a app ) }

60 Example Introduction The function TYPE The function SOLVE The whole algorithm TI ConS = { (Fun1<a λf, a m > a op ), (Fun1<a app, a f > a λf ), (a f Fun2<a 3, a 1, a 2 >), (Matrix a 1 ), (a m a 2 ), (a 3 a app ) } The result of SOLVE (without wildcard-types): { ({ a m a 2, a 3 a app } { a op. = Fun1<Fun1<aapp, Fun2<a 3, Matrix, a 2 >>, a m >, a λf. = Fun1<aapp, Fun2<a 3, Matrix, a 2 >>, a f. = Fun2<a3, Matrix, a 2 >, a 1. = Matrix }) ({ a m a 2, a 3 a app } { a op. = Fun1<Fun1<aapp, Fun2<a 3, Vec<Vec<Int>>, a 2 >>, a m >, a λf. = Fun1<aapp, Fun2<a 3, Vec<Vec<Int>>, a 2 >>, a f. = Fun2<a3, Vec<Vec<Int>>, a 2 >, a 1. = Vec<Vec<Int>> }) }

61 The function TYPE The function SOLVE The whole algorithm TI Example cont. class Matrix<a 2, a m extends a 2, a app, a 3 extends a app> extends Vector<Vector<Integer>> { Fun1<Fun1<a app, Fun2<a 3, Matrix,a 2>>, a_m> op = (a m m) -> (Fun2<a 3, Matrix,a 2> f) -> f.apply(this, m); }

62 The function TYPE The function SOLVE The whole algorithm TI Example cont. class Matrix<a 2, a m extends a 2, a app, a 3 extends a app> extends Vector<Vector<Integer>> { Fun1<Fun1<a app, Fun2<a 3, Matrix,a 2>>, a_m> op = (a m m) -> (Fun2<a 3, Matrix,a 2> f) -> f.apply(this, m); } more principal than... class Matrix extends Vector<Vector<Integer>> { Fun1<Fun1<Matrix, Fun2<Matrix, Matrix,Matrix>>, Matrix> op = (Matrix m) -> (Fun2<Matrix, Matrix,Matrix> f) -> f.apply(this, m); }

63 The function TYPE The function SOLVE The whole algorithm TI Solution of multiple results 1. Select one correct type in an Eclipse-PlugIn. standard generation of byte-code 2. Extend Java type-system by a restricted form of intersection types. a changed generation of byte-code is necessary 2 2 [Pluemicke 2008],Intersection Types in Java, PPPJ 08]

64 Java 8: ThisTest TestLambda Matrix (TestFunN) Outlook: Methods TestMethodCall Java 7: Overloading OL

65 Summary Complete type inference for a core of Java 8. Prototypical implementation

66 Summary Complete type inference for a core of Java 8. Prototypical implementation Outlook Methods with overloading and overriding. Introduction of intersection types in the code generation

Ausblick auf Java 8. Martin Plümicke. 25. Mai Baden-Wuerttemberg Cooperative State University Stuttgart/Horb

Ausblick auf Java 8. Martin Plümicke. 25. Mai Baden-Wuerttemberg Cooperative State University Stuttgart/Horb Ausblick auf Java 8 Martin Plümicke Baden-Wuerttemberg Cooperative State University Stuttgart/Horb 25. Mai 2012 Overview Introduction Introduction Closures Java s motivation λ expressions Functional interfaces

More information

Introducing Scala-like function types into Java-TX

Introducing Scala-like function types into Java-TX Introducing Scala-like function types into Java-TX ManLang 2017 Martin Plümicke Andreas Stadelmeier www.dhbw-stuttgart.de/horb Overview 1 Type of lambda expressions in Java-8 2 Introducing real function

More information

Copyright 2012, Oracle and/or its affiliates. All rights reserved.

Copyright 2012, Oracle and/or its affiliates. All rights reserved. 1 Lambda Expressions in Java Simon Ritter Java Technology Evangelist Twitter: @speakjava With thanks to Brian Goetz 2 The following is intended to outline our general product direction. It is intended

More information

Lambdas & Streams: Taking the Hard Work Out of Bulk Operations in Java SE 8.

Lambdas & Streams: Taking the Hard Work Out of Bulk Operations in Java SE 8. Lambdas & Streams: Taking the Hard Work Out of Bulk Operations in Java SE 8 Simon Ritter Head of Java Evangelism Oracle Corporation Twitter: @speakjava 1 Concurrency in Java Project Lambda java.util.concurrent

More information

Project Lambda: Functional Programming Constructs and Simpler Concurrency in Java SE 8

Project Lambda: Functional Programming Constructs and Simpler Concurrency in Java SE 8 Project Lambda: Functional Programming Constructs and Simpler Concurrency in Java SE 8 Michael Cui Principle Engineer, Java Platform Group Oracle Corporation 1 The following is intended to outline our

More information

1 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8

1 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8 1 Copyright 2012, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 Project Lambda: To Multicore and Beyond David Holmes 2 Copyright 2012, Oracle

More information

Lambda expressions in Java: a compiler writer's perspective. Maurizio Cimadamore Type-system engineer, Oracle Corporation

Lambda expressions in Java: a compiler writer's perspective. Maurizio Cimadamore Type-system engineer, Oracle Corporation Lambda expressions in Java: a compiler writer's perspective Maurizio Cimadamore Type-system engineer, Oracle Corporation The following is intended to outline our general product direction. It is intended

More information

Resolving of Intersection Types in Java

Resolving of Intersection Types in Java Resolving of Intersection Types in Java Martin Plümicke University of Cooperative Education Stuttgart Department of Information Technology Florianstraße 15, D 72160 Horb m.pluemicke@ba-horb.de Abstract.

More information

<Insert Picture Here> Project Lambda: To Multicore and Beyond

<Insert Picture Here> Project Lambda: To Multicore and Beyond Project Lambda: To Multicore and Beyond Brian Goetz Java Language Architect, Oracle Corporation The following is intended to outline our general product direction. It is intended

More information

Java SE 8: Lambda Expressions And The Stream API

Java SE 8: Lambda Expressions And The Stream API Java SE 8: Lambda Expressions And The Stream API Simon Ritter Head of Java Technology Evangelism Java Product Management Java Day Tokyo 2015 April 8, 2015 Safe Harbor Statement The following is intended

More information

Wednesday, November 16, 11

Wednesday, November 16, 11 Java SE 8, and Beyond! Danny Coward Principal Engineer 8 9 2012 2020? Priorities for the Java Platforms Grow Developer Base Grow Adoption Increase Competitiveness Adapt to change

More information

Lecture #23: Conversion and Type Inference

Lecture #23: Conversion and Type Inference Lecture #23: Conversion and Type Inference Administrivia. Due date for Project #2 moved to midnight tonight. Midterm mean 20, median 21 (my expectation: 17.5). Last modified: Fri Oct 20 10:46:40 2006 CS164:

More information

Conversion vs. Subtyping. Lecture #23: Conversion and Type Inference. Integer Conversions. Conversions: Implicit vs. Explicit. Object x = "Hello";

Conversion vs. Subtyping. Lecture #23: Conversion and Type Inference. Integer Conversions. Conversions: Implicit vs. Explicit. Object x = Hello; Lecture #23: Conversion and Type Inference Administrivia. Due date for Project #2 moved to midnight tonight. Midterm mean 20, median 21 (my expectation: 17.5). In Java, this is legal: Object x = "Hello";

More information

<Insert Picture Here> Project Lambda: To Multicore and Beyond

<Insert Picture Here> Project Lambda: To Multicore and Beyond Project Lambda: To Multicore and Beyond Brian Goetz Alex Buckley Maurizio Cimadamore Java Platform Group The following is intended to outline our general product direction. It is

More information

Formalization of the Java 5.0 Type System

Formalization of the Java 5.0 Type System Formalization of the Java 5.0 Type System Martin Plümicke University of Cooperative Education Stuttgart/Horb Department of Information Technology Florianstraße 15 D 72160 Horb tel. +49-7451-521142 fax.

More information

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question) CS/B.TECH/CSE(New)/SEM-5/CS-504D/2013-14 2013 OBJECT ORIENTED PROGRAMMING Time Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks. Candidates are required to give their answers

More information

<Insert Picture Here> To Java SE 8, and Beyond!

<Insert Picture Here> To Java SE 8, and Beyond! To Java SE 8, and Beyond! Simon Ritter Technology Evangelist The following is intended to outline our general product direction. It is intended for information purposes only, and

More information

Types-2. Polymorphism

Types-2. Polymorphism Types-2 Polymorphism Type reconstruction (type inference) for a simple PL Typing functions Coercion, conversion, reconstruction Rich area of programming language research as people try to provide safety

More information

Type Checking and Type Inference

Type Checking and Type Inference Type Checking and Type Inference Principles of Programming Languages CSE 307 1 Types in Programming Languages 2 Static Type Checking 3 Polymorphic Type Inference Version: 1.8 17:20:56 2014/08/25 Compiled

More information

Program Representations

Program Representations Program Representations 17-654/17-765 Analysis of Software Artifacts Jonathan Aldrich Representing Programs To analyze software automatically, we must be able to represent it precisely Some representations

More information

Lambda Expressions In JDK8: Going Beyond The Basics

Lambda Expressions In JDK8: Going Beyond The Basics Lambda Expressions In JDK8: Going Beyond The Basics Simon Ri?er Head of Java Technology Evangelism Oracle Corp Twi?er: @speakjava Copyright 2014, Oracle and/or its affiliates. All rights reserved. Safe Harbor

More information

COMP520 - GoLite Type Checking Specification

COMP520 - GoLite Type Checking Specification COMP520 - GoLite Type Checking Specification Vincent Foley March 5, 2017 1 Introduction This document presents the typing rules for all the language constructs (i.e. declarations, statements, expressions)

More information

Exercise 1 (2+2+2 points)

Exercise 1 (2+2+2 points) 1 Exercise 1 (2+2+2 points) The following data structure represents binary trees only containing values in the inner nodes: data Tree a = Leaf Node (Tree a) a (Tree a) 1 Consider the tree t of integers

More information

Principles of Programming Languages

Principles of Programming Languages Principles of Programming Languages Lesson 14 Type Checking Collaboration and Management Dana Fisman www.cs.bgu.ac.il/~ppl172 1 Type Checking We return to the issue of type safety we discussed informally,

More information

Fontys Hogeschool voor Techniek en Logistiek. March 13, 2018

Fontys Hogeschool voor Techniek en Logistiek. March 13, 2018 Java 8 s and Java 8 Fontys Hogeschool voor Techniek en Logistiek March 13, 2018 and? /FHTenL s and Java 8 March 13, 2018 1/34 talk The other anonymous and? Java 8 and? /FHTenL s and Java 8 March 13, 2018

More information

Java type unification with wildcards

Java type unification with wildcards Java type unification with wildcards Martin Plümicke University of Cooperative Education Stuttgart/Horb Florianstraße 15, D 72160 Horb m.pluemicke@ba-horb.de Abstract. With the introduction of Java 5.0

More information

Lecture #13: Type Inference and Unification. Typing In the Language ML. Type Inference. Doing Type Inference

Lecture #13: Type Inference and Unification. Typing In the Language ML. Type Inference. Doing Type Inference Lecture #13: Type Inference and Unification Typing In the Language ML Examples from the language ML: fun map f [] = [] map f (a :: y) = (f a) :: (map f y) fun reduce f init [] = init reduce f init (a ::

More information

G Programming Languages Spring 2010 Lecture 6. Robert Grimm, New York University

G Programming Languages Spring 2010 Lecture 6. Robert Grimm, New York University G22.2110-001 Programming Languages Spring 2010 Lecture 6 Robert Grimm, New York University 1 Review Last week Function Languages Lambda Calculus SCHEME review 2 Outline Promises, promises, promises Types,

More information

CSC Java Programming, Fall Java Data Types and Control Constructs

CSC Java Programming, Fall Java Data Types and Control Constructs CSC 243 - Java Programming, Fall 2016 Java Data Types and Control Constructs Java Types In general, a type is collection of possible values Main categories of Java types: Primitive/built-in Object/Reference

More information

Principles of Programming Languages

Principles of Programming Languages Principles of Programming Languages Slides by Dana Fisman based on book by Mira Balaban and lecuture notes by Michael Elhadad Lesson 15 Type Inference Collaboration and Management Dana Fisman www.cs.bgu.ac.il/~ppl172

More information

COMP520 - GoLite Type Checking Specification

COMP520 - GoLite Type Checking Specification COMP520 - GoLite Type Checking Specification Vincent Foley April 8, 2018 1 Introduction This document presents the typing rules for all the language constructs (i.e. declarations, statements, expressions)

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

Type Soundness. Type soundness is a theorem of the form If e : τ, then running e never produces an error

Type Soundness. Type soundness is a theorem of the form If e : τ, then running e never produces an error Type Soundness Type soundness is a theorem of the form If e : τ, then running e never produces an error 1 Type Soundness Type soundness is a theorem of the form If e : τ, then running e never produces

More information

Type Declarations. Γ <num> : num [... <id> τ... ] <id> : τ Γ true : bool Γ false : bool Γ e 1 : num Γ e 2 : num Γ. {+ e 1 e 2 } : num

Type Declarations. Γ <num> : num [... <id> τ... ] <id> : τ Γ true : bool Γ false : bool Γ e 1 : num Γ e 2 : num Γ. {+ e 1 e 2 } : num Type Declarations Γ : num [... τ... ] : τ Γ true : bool Γ false : bool Γ e 1 : num Γ e 2 : num Γ {+ e 1 e 2 } : num Γ e 1 : bool Γ e 2 : τ 0 Γ e 3 : τ 0 Γ {if e 1 e 2 e 3 } : τ 0 Γ[

More information

Array. Array Declaration:

Array. Array Declaration: Array Arrays are continuous memory locations having fixed size. Where we require storing multiple data elements under single name, there we can use arrays. Arrays are homogenous in nature. It means and

More information

INF 212/CS 253 Type Systems. Instructors: Harry Xu Crista Lopes

INF 212/CS 253 Type Systems. Instructors: Harry Xu Crista Lopes INF 212/CS 253 Type Systems Instructors: Harry Xu Crista Lopes What is a Data Type? A type is a collection of computational entities that share some common property Programming languages are designed to

More information

<Insert Picture Here> Java SE: Where We ve Been, Where We re Going

<Insert Picture Here> Java SE: Where We ve Been, Where We re Going Java SE: Where We ve Been, Where We re Going Alex Buckley Spec Lead, Java Language & VM November 2011 The following is intended to outline our general product direction. It is intended

More information

Intermediate Code Generation Part II

Intermediate Code Generation Part II Intermediate Code Generation Part II Chapter 6: Type checking, Control Flow Slides adapted from : Robert van Engelen, Florida State University Static versus Dynamic Checking Static checking: the compiler

More information

Types and Programming Languages. Lecture 5. Extensions of simple types

Types and Programming Languages. Lecture 5. Extensions of simple types Types and Programming Languages Lecture 5. Extensions of simple types Xiaojuan Cai cxj@sjtu.edu.cn BASICS Lab, Shanghai Jiao Tong University Fall, 2016 Coming soon Simply typed λ-calculus has enough structure

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Week 13 - Part 1 Thomas Wies New York University Review Last lecture Object Oriented Programming Outline Today: Scala Sources: Programming in Scala, Second

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Fall 2017 Lecture 7b Andrew Tolmach Portland State University 1994-2017 Type Inference Some statically typed languages, like ML (and to a lesser extent Scala), offer alternative

More information

Exercise 1 ( = 22 points)

Exercise 1 ( = 22 points) 1 Exercise 1 (4 + 3 + 4 + 5 + 6 = 22 points) The following data structure represents polymorphic lists that can contain values of two types in arbitrary order: data DuoList a b = C a (DuoList a b) D b

More information

CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall Office hours:

CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall Office hours: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu Office hours: Tuesday 10:00 AM 12:00 PM * Wednesday 4:00 PM 5:00 PM Friday 11:00 AM 12:00 PM OR

More information

CSE-321 Programming Languages 2012 Midterm

CSE-321 Programming Languages 2012 Midterm Name: Hemos ID: CSE-321 Programming Languages 2012 Midterm Prob 1 Prob 2 Prob 3 Prob 4 Prob 5 Prob 6 Total Score Max 14 15 29 20 7 15 100 There are six problems on 24 pages in this exam. The maximum score

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Winter 2018 Lecture 7b Andrew Tolmach Portland State University 1994-2018 Dynamic Type Checking Static type checking offers the great advantage of catching errors early And

More information

Declarations and Access Control SCJP tips

Declarations and Access Control  SCJP tips Declarations and Access Control www.techfaq360.com SCJP tips Write code that declares, constructs, and initializes arrays of any base type using any of the permitted forms both for declaration and for

More information

n Closed book n You are allowed 5 cheat pages n Practice problems available in Course Materials n Check grades in Rainbow grades

n Closed book n You are allowed 5 cheat pages n Practice problems available in Course Materials n Check grades in Rainbow grades Announcements Announcements n HW12: Transaction server n Due today at 2pm n You can use up to 2 late days, as always n Final Exam, December 17, 3-6pm, in DCC 308 and 318 n Closed book n You are allowed

More information

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this

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

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

Note 3. Types. Yunheung Paek. Associate Professor Software Optimizations and Restructuring Lab. Seoul National University

Note 3. Types. Yunheung Paek. Associate Professor Software Optimizations and Restructuring Lab. Seoul National University Note 3 Types Yunheung Paek Associate Professor Software Optimizations and Restructuring Lab. Seoul National University Topics Definition of a type Kinds of types Issues on types Type checking Type conversion

More information

6.821 Programming Languages Handout Fall MASSACHVSETTS INSTITVTE OF TECHNOLOGY Department of Electrical Engineering and Compvter Science

6.821 Programming Languages Handout Fall MASSACHVSETTS INSTITVTE OF TECHNOLOGY Department of Electrical Engineering and Compvter Science 6.821 Programming Languages Handout Fall 2002 MASSACHVSETTS INSTITVTE OF TECHNOLOGY Department of Electrical Engineering and Compvter Science Problem Set 6 Problem 1: cellof Subtyping Do exercise 11.6

More information

UMBC CMSC 331 Final Exam

UMBC CMSC 331 Final Exam UMBC CMSC 331 Final Exam Name: UMBC Username: You have two hours to complete this closed book exam. We reserve the right to assign partial credit, and to deduct points for answers that are needlessly wordy

More information

Binghamton University. CS-140 Fall Functional Java

Binghamton University. CS-140 Fall Functional Java Functional Java 1 First Class Data We have learned how to manipulate data with programs We can pass data to methods via arguments We can return data from methods via return types We can encapsulate data

More information

IC Language Specification

IC Language Specification CS 301 Spring 2016 IC Language Specification The IC Language For the implementation project, you will build a compiler for an object-oriented language called IC (for Irish Coffee 1 ), which is essentially

More information

Some instance messages and methods

Some instance messages and methods Some instance messages and methods x ^x y ^y movedx: dx Dy: dy x

More information

Lecture 7: Type Systems and Symbol Tables. CS 540 George Mason University

Lecture 7: Type Systems and Symbol Tables. CS 540 George Mason University Lecture 7: Type Systems and Symbol Tables CS 540 George Mason University Static Analysis Compilers examine code to find semantic problems. Easy: undeclared variables, tag matching Difficult: preventing

More information

Polymorphism. CMSC 330: Organization of Programming Languages. Two Kinds of Polymorphism. Polymorphism Overview. Polymorphism

Polymorphism. CMSC 330: Organization of Programming Languages. Two Kinds of Polymorphism. Polymorphism Overview. Polymorphism CMSC 330: Organization of Programming Languages Polymorphism Polymorphism Definition Feature that allows values of different data types to be handled using a uniform interface Applicable to Functions Ø

More information

INF 212 ANALYSIS OF PROG. LANGS Type Systems. Instructors: Crista Lopes Copyright Instructors.

INF 212 ANALYSIS OF PROG. LANGS Type Systems. Instructors: Crista Lopes Copyright Instructors. INF 212 ANALYSIS OF PROG. LANGS Type Systems Instructors: Crista Lopes Copyright Instructors. What is a Data Type? A type is a collection of computational entities that share some common property Programming

More information

Static Checking and Type Systems

Static Checking and Type Systems 1 Static Checking and Type Systems Chapter 6 COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University, 2007-2009 2 The Structure of our Compiler Revisited Character stream Lexical

More information

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE PART A UNIT I 1. Differentiate object oriented programming from procedure oriented programming. 2. Define abstraction and encapsulation. 3. Differentiate

More information

CSE 452: Programming Languages. Previous Lecture. From ADTs to OOP. Data Abstraction and Object-Orientation

CSE 452: Programming Languages. Previous Lecture. From ADTs to OOP. Data Abstraction and Object-Orientation CSE 452: Programming Languages Data Abstraction and Object-Orientation Previous Lecture Abstraction Abstraction is the elimination of the irrelevant and the amplification of the essential Robert C Martin

More information

Programming Languages Assignment #7

Programming Languages Assignment #7 Programming Languages Assignment #7 December 2, 2007 1 Introduction This assignment has 20 points total. In this assignment, you will write a type-checker for the PolyMinML language (a language that is

More information

Java Workshop Lambda Expressions

Java Workshop Lambda Expressions Java Workshop Lambda Expressions AP Java Workshop 2015 Hanno Hüther and Martin Stein Agenda 1. Origin and syntax 2. History and motivation 3. Exercise 1: Refactoring to lambdas 4. Method references 5.

More information

CS S-08 Arrays and Midterm Review 1

CS S-08 Arrays and Midterm Review 1 CS112-2012S-08 Arrays and Midterm Review 1 08-0: Arrays ArrayLists are not part of Java proper 08-1: Arrays Library class Created using lower-level Java construct: Array Arrays are like a stripped-down

More information

Exceptions Questions https://www.journaldev.com/2167/java-exception-interview-questionsand-answers https://www.baeldung.com/java-exceptions-interview-questions https://javaconceptoftheday.com/java-exception-handling-interviewquestions-and-answers/

More information

B2.52-R3: INTRODUCTION TO OBJECT ORIENTATED PROGRAMMING THROUGH JAVA

B2.52-R3: INTRODUCTION TO OBJECT ORIENTATED PROGRAMMING THROUGH JAVA B2.52-R3: INTRODUCTION TO OBJECT ORIENTATED PROGRAMMING THROUGH JAVA NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE

More information

Java SE 8 Programming

Java SE 8 Programming Oracle University Contact Us: Local: 1800 103 4775 Intl: +91 80 67863102 Java SE 8 Programming Duration: 5 Days What you will learn This Java SE 8 Programming training covers the core language features

More information

Overview of Java 8 Functional Interfaces

Overview of Java 8 Functional Interfaces Overview of Java 8 Functional Interfaces Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Professor of Computer Science Institute for Software Integrated Systems Vanderbilt University

More information

CS/B.TECH/CSE(OLD)/SEM-6/CS-605/2012 OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70

CS/B.TECH/CSE(OLD)/SEM-6/CS-605/2012 OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 CS/B.TECH/CSE(OLD)/SEM-6/CS-605/2012 2012 OBJECT ORIENTED PROGRAMMING Time Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks. Candidates are required to give their answers

More information

UNIT II Structuring the Data, Computations and Program. Kainjan Sanghavi

UNIT II Structuring the Data, Computations and Program. Kainjan Sanghavi UNIT II Structuring the Data, Computations and Program B y Kainjan Sanghavi Contents Monomorphic versus polymorphic type systems Case Study- The type structure of C++ and Java Structuring the computation

More information

CS Internet programming Unit- I Part - A 1 Define Java. 2. What is a Class? 3. What is an Object? 4. What is an Instance?

CS Internet programming Unit- I Part - A 1 Define Java. 2. What is a Class? 3. What is an Object? 4. What is an Instance? CS6501 - Internet programming Unit- I Part - A 1 Define Java. Java is a programming language expressly designed for use in the distributed environment of the Internet. It was designed to have the "look

More information

Introduction to Functional Programming in Java 8

Introduction to Functional Programming in Java 8 1 Introduction to Functional Programming in Java 8 Java 8 is the current version of Java that was released in March, 2014. While there are many new features in Java 8, the core addition is functional programming

More information

CSCE 314 Programming Languages. Type System

CSCE 314 Programming Languages. Type System CSCE 314 Programming Languages Type System Dr. Hyunyoung Lee 1 Names Names refer to different kinds of entities in programs, such as variables, functions, classes, templates, modules,.... Names can be

More information

Class, Variable, Constructor, Object, Method Questions

Class, Variable, Constructor, Object, Method Questions Class, Variable, Constructor, Object, Method Questions http://www.wideskills.com/java-interview-questions/java-classes-andobjects-interview-questions https://www.careerride.com/java-objects-classes-methods.aspx

More information

Java Inheritance. Written by John Bell for CS 342, Spring Based on chapter 6 of Learning Java by Niemeyer & Leuck, and other sources.

Java Inheritance. Written by John Bell for CS 342, Spring Based on chapter 6 of Learning Java by Niemeyer & Leuck, and other sources. Java Inheritance Written by John Bell for CS 342, Spring 2018 Based on chapter 6 of Learning Java by Niemeyer & Leuck, and other sources. Review Which of the following is true? A. Java classes may either

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

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

Type Inference; Parametric Polymorphism; Records and Subtyping Section and Practice Problems Mar 20-23, 2018

Type Inference; Parametric Polymorphism; Records and Subtyping Section and Practice Problems Mar 20-23, 2018 Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Type Inference; Parametric Polymorphism; Records and Subtyping Mar 20-23, 2018 1 Type Inference (a) Recall the constraint-based

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

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

Java SE 8 Programming

Java SE 8 Programming Oracle University Contact Us: +52 1 55 8525 3225 Java SE 8 Programming Duration: 5 Days What you will learn This Java SE 8 Programming training covers the core language features and Application Programming

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

CSE 505. Lecture #9. October 1, Lambda Calculus. Recursion and Fixed-points. Typed Lambda Calculi. Least Fixed Point

CSE 505. Lecture #9. October 1, Lambda Calculus. Recursion and Fixed-points. Typed Lambda Calculi. Least Fixed Point Lambda Calculus CSE 505 Lecture #9 October 1, 2012 Expr ::= Var λ Var. Expr (Expr Expr) Key Concepts: Bound and Free Occurrences Substitution, Reduction Rules: α, β, η Confluence and Unique Normal Form

More information

5/23/2015. Core Java Syllabus. VikRam ShaRma

5/23/2015. Core Java Syllabus. VikRam ShaRma 5/23/2015 Core Java Syllabus VikRam ShaRma Basic Concepts of Core Java 1 Introduction to Java 1.1 Need of java i.e. History 1.2 What is java? 1.3 Java Buzzwords 1.4 JDK JRE JVM JIT - Java Compiler 1.5

More information

Distributed Systems Recitation 1. Tamim Jabban

Distributed Systems Recitation 1. Tamim Jabban 15-440 Distributed Systems Recitation 1 Tamim Jabban Office Hours Office 1004 Tuesday: 9:30-11:59 AM Thursday: 10:30-11:59 AM Appointment: send an e-mail Open door policy Java: Object Oriented Programming

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

VALLIAMMAI ENGINEERING COLLEGE

VALLIAMMAI ENGINEERING COLLEGE VALLIAMMAI ENGINEERING COLLEGE SRM Nagar, Kattankulathur 603 203 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK B.E. - Electrical and Electronics Engineering IV SEMESTER CS6456 - OBJECT ORIENTED

More information

Administrivia. Java Review. Objects and Variables. Demo. Example. Example: Assignments

Administrivia. Java Review. Objects and Variables. Demo. Example. Example: Assignments CMSC433, Spring 2004 Programming Language Technology and Paradigms Java Review Jeff Foster Feburary 3, 2004 Administrivia Reading: Liskov, ch 4, optional Eckel, ch 8, 9 Project 1 posted Part 2 was revised

More information

Intermediate Code Generation

Intermediate Code Generation Intermediate Code Generation In the analysis-synthesis model of a compiler, the front end analyzes a source program and creates an intermediate representation, from which the back end generates target

More information

Type Systems, Type Inference, and Polymorphism

Type Systems, Type Inference, and Polymorphism 6 Type Systems, Type Inference, and Polymorphism Programming involves a wide range of computational constructs, such as data structures, functions, objects, communication channels, and threads of control.

More information

λ calculus is inconsistent

λ calculus is inconsistent Content Rough timeline COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Gerwin Klein, June Andronick, Toby Murray λ Intro & motivation, getting started [1] Foundations & Principles

More information

PROGRAMMING FUNDAMENTALS

PROGRAMMING FUNDAMENTALS PROGRAMMING FUNDAMENTALS Q1. Name any two Object Oriented Programming languages? Q2. Why is java called a platform independent language? Q3. Elaborate the java Compilation process. Q4. Why do we write

More information

Compilation 2012 Static Type Checking

Compilation 2012 Static Type Checking Compilation 2012 Jan Midtgaard Michael I. Schwartzbach Aarhus University The Type Checker The type checker has several tasks: determine the types of all expressions check that values and variables are

More information

Le L c e t c ur u e e 5 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Exception Handling

Le L c e t c ur u e e 5 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Exception Handling Course Name: Advanced Java Lecture 5 Topics to be covered Exception Handling Exception HandlingHandlingIntroduction An exception is an abnormal condition that arises in a code sequence at run time A Java

More information

COP 3330 Final Exam Review

COP 3330 Final Exam Review COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time

More information

Compiler Construction I

Compiler Construction I TECHNISCHE UNIVERSITÄT MÜNCHEN FAKULTÄT FÜR INFORMATIK Compiler Construction I Dr. Michael Petter, Dr. Axel Simon SoSe 2014 1 / 30 Topic: Semantic Analysis 2 / 30 Semantic Analysis Chapter 1: Type Checking

More information

I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++

I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++ No. of Printed Pages : 3 I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination 05723. June, 2015 BCS-031 : PROGRAMMING IN C ++ Time : 3 hours Maximum Marks : 100 (Weightage 75%)

More information

(2½ hours) Total Marks: 75

(2½ hours) Total Marks: 75 (2½ hours) Total Marks: 75 N. B.: (1) All questions are compulsory. (2) Makesuitable assumptions wherever necessary and state the assumptions mad (3) Answers to the same question must be written together.

More information