lecture18 - Lecture Outline Java COOL on steroids History...

Info icon This 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 Dynamic Loading & Initialization • 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
Image of page 1

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

View Full Document Right 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 Primitive types are not classes Prof. Aiken CS 143 Lecture 18 12 A Common Problem Deep in a section of code, you encounter an unexpected error Out of memory A list that is supposed to be sorted is not – etc.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern