lecture18

Lecture18 - Lecture Outline Java COOL on steroids History Java Lecture 18 Prof Aiken CS 143 Lecture 18 Arrays Exceptions Interfaces Coercions

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Prof. Aiken CS 143 Lecture 18 1 Java Lecture 18 Prof. Aiken CS 143 Lecture 18 2 Lecture Outline • Java: COOL on steroids – History • Arrays • Exceptions • Interfaces • Coercions • Threads • Summary Prof. Aiken CS 143 Lecture 18 3 Java History • Began as Oak at SUN – Originally targeted at set-top devices – Initial development took several years (‘91-’94) • Retargeted as the Internet language (‘94-95) – Every new language needs a “killer app” – Beat out TCL, Python – ActiveX came later Prof. Aiken CS 143 Lecture 18 4 The People • James Gosling – Principal designer – CMU Ph.D. • Bill Joy – ABD from Berkeley (Unix) • Guy Steele – MIT PhD – Famous languages researcher Prof. Aiken CS 143 Lecture 18 5 Influences • Modula-3 – types • Eiffel, Objective C, C++ – Object orientation, interfaces • Lisp – Java’s dynamic flavor (lots of features) Prof. Aiken CS 143 Lecture 18 6 Java Design • From our perspective, COOL plus – Exceptions – Interfaces – Threads – Dynamic Loading – Other less important ones . . . • Java is a BIG language – Lots of features – Lots of feature interactions
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Prof. Aiken CS 143 Lecture 18 7 Arrays Assume B < A. What happens in the following? B[] b = new B[10]; A[] a = b; a[0] = new A(); b[0].aMethodNotDeclaredInA(); Prof. Aiken CS 143 Lecture 18 8 Subtyping In Java B < A if B inherits from A as in Cool C < A if C < B and B < A as in Cool B[] < A[] if B < A not as in Cool This last rule is unsound! Prof. Aiken CS 143 Lecture 18 9 What’s Going On? B[] b = new B[10]; A[] a = b; a[0] = new A(); b[0].aMethodNotDeclaredInA(); a b Having multiple aliases to updateable locations with different types is unsound Prof. Aiken CS 143 Lecture 18 10 The Right Solution • Disallow subtyping through arrrays • Standard solution in several languages B < A if B inherits from A C < A if C < B and B < A B[] < A[] if B = A Prof. Aiken CS 143 Lecture 18 11 The Java Solution • Java fixes the problem by checking each array assignment at runtime for type correctness – Is the type of the object being assigned compatible with the type of the array? • Huge overhead on array computations! • But note: arrays of primitive types unaffected
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 04/06/2012.

Page1 / 7

Lecture18 - Lecture Outline Java COOL on steroids History Java Lecture 18 Prof Aiken CS 143 Lecture 18 Arrays Exceptions Interfaces Coercions

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online