L3_updated

L3_updated - CSE 12: Basic data structures and...

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

View Full Document Right Arrow Icon
CSE 12 : Basic data structures and object-oriented design Jacob Whitehill jake@mplab.ucsd.edu Lecture Three 3 Aug 2011 Wednesday, August 3, 2011
Background image of page 1

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

View Full DocumentRight Arrow Icon
The Java Virtual Machine (JVM). Wednesday, August 3, 2011
Background image of page 2
Why study the Java VM? Before studying the more complicated data structures, it is important to understand the relationship between a computer program and the memory on which it operates. In the case of Java, this entails a discussion of the Java Virtual Machine (JVM). Wednesday, August 3, 2011
Background image of page 3

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

View Full DocumentRight Arrow Icon
“Real machines” To appreciate “virtual machines”, let’s frst consider how a source program is converted to an executable program on a “real machine”: The programmer writes some source code . He/she then compiles the source code into machine instructions that are specifc to the particular hardware platForm. Wednesday, August 3, 2011
Background image of page 4
“Real machines” If the programmer wants her program to run on 5 different hardware platforms, she needs to: Write the source code only once (thank goodness!). Compile the source code 5 times. Wednesday, August 3, 2011
Background image of page 5

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

View Full DocumentRight Arrow Icon
“Real machines” Source code class MyClass { void myMethod () { } ... Intel compiler ARM compiler Snapdragon compiler Intel machine language ARM machine language Snapdragon machine language Intel executable fle ARM executable fle Snapdragon executable fle Wednesday, August 3, 2011
Background image of page 6
Java In the 1990s, Sun Microsystems developed a new programming language called “Java”. Motto: “Write once, run everywhere.” This might be more aptly described as, “Compile once, run everywhere.” Once Java code is compiled, it can run on any platform, irrespective of CPU type. How is this possible? Wednesday, August 3, 2011
Background image of page 7

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

View Full DocumentRight Arrow Icon
Java Virtual Machine The designers of Java inserted a layer of abstraction between the Java compiler and the hardware CPUs. This abstraction is called the Java Virtual Machine (JVM). The JVM provides a convenient “abstract machine language” that can run on any CPU . This means that a Java program need only be compiled once , and it can run on any hardware platform. Wednesday, August 3, 2011
Background image of page 8
The JVM was also designed from the ground-up to provide security , e.g.: Bounds checking: it won’t let you access the 9th element of an 8-element array. Type safety: it won’t let you treat an Integer as a String . Java Virtual Machine Wednesday, August 3, 2011
Background image of page 9

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

View Full DocumentRight Arrow Icon
Java Virtual Machine Source code Intel JVM ARM JVM Snapdragon JVM Java compiler Java machine language (“bytecode”) Java object fle ( .class ) Wednesday, August 3, 2011
Background image of page 10
Java Virtual Machine Every compiled Java .class fle will run on every Java Virtual Machine For every hardware platForm in the same way. This convenience through abstraction comes at a price: A new JVM must be created For every hardware platForm.
Background image of page 11

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

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 67

L3_updated - CSE 12: Basic data structures and...

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

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