Java page 20 helloclass dr s gannouni dr a touir

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: machine code using a Java Interpreter Source Code Page 19 Bytecode Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP Platform Independent Java Programs Compiling • You can run bytecode on an computer that has a Java Interpreter installed “Hello.java” Page 20 “Hello.class” Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP Multipurpose Java Compiling Page 21 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP Running The Program Class Loader Running Bytecode Verifier The Bytecode (the “.class” file) Bytecode Interpreter JVM Operating System Hardware Page 22 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP The Java Virtual Machine Components • The Class Loader • stores bytecodes in memory • Bytecode Verifier • ensures bytecodes do not violate security requirements • Bytecode Interpreter • translates bytecodes into machine language Page 23 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP The Java Virtual Machine • The class Loader, the Bytecode Verifier and Interpreter constitute the Java Virtual Machine (JVM). • JVM is platform specific. • The interpreter translates the bytecodes into specific machine commands. Page 24 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP Testing and Debugging the Program • Testing – Be sure that the output of the program conforms with the input. – There are two types of errors: • Logical Errors: The program run but provides wrong output. • Runtime errors: The program stop running suddenly when asking the OS executing a non accepted statement (divide by zero, etc). • Debugging – Find, Understand and correct the error Page 25 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP Phase 1 Editor Disk Program is created in an editor and stored on disk in a file ending with .java. Phase 2 Compiler Disk Compiler creates bytecodes and stores them on disk in a file ending with .class. Primary Memory Phase 3 Class Loader Disk Phase 4 Bytecode Verifier .. . .. . Class loader reads .class files containing bytecodes from disk and puts those bytecodes in memory. Primary Memory Bytecode verifier confirms that all bytecodes are valid and do not violate Java’s security restrictions. .. . .. . Primary Memory Phase 5 Interpreter .. . .. . Page 26 Interpreter reads bytecodes and translates them into a language that the computer can understand, possibly storing data values as the program executes. Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP Some Characteristics of Java • Object-Oriented – – – – Combines data and behavior into one unit objects Provides Data abstraction and encapsulation Decompose program into objects. Programs are collections of interacting and cooperating objects. • Platform-independent – Portable – Architecture neutral – ”Write-once, run-anywhere” • Secure – The bytecode verifier of the JVM : • checks untrusted bytecode • controls the permissions for high level actions. Page 27 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP...
View Full Document

This document was uploaded on 03/03/2014.

Ask a homework question - tutors are online