L3mt_print

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

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

View Full Document Right Arrow Icon

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

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

Unformatted text preview: CSE 12 : Basic data structures and object-oriented design Jacob Whitehill jake@mplab.ucsd.edu Lecture Three 3 Aug 2011 Wednesday, August 3, 2011 The Java Virtual Machine (JVM). Wednesday, August 3, 2011 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 Real machines To appreciate virtual machines, lets f rst 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 speci f c to the particular hardware platform. Wednesday, August 3, 2011 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 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 f le ARM executable f le Snapdragon executable f le Wednesday, August 3, 2011 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 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 The JVM was also designed from the ground-up to provide security , e.g.: Bounds checking: it wont let you access the 9th element of an 8-element array. Type safety: it wont let you treat an Integer as a String . Java Virtual Machine Wednesday, August 3, 2011 Java Virtual Machine Source code Intel JVM ARM JVM Snapdragon JVM Java compiler Java machine language (bytecode) Java object f le ( .class ) Wednesday, August 3, 2011 Java Virtual Machine Every compiled Java .class f le will run on every Java Virtual Machine for every hardware platform in the same way....
View Full Document

Page1 / 9

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

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