11 JVM - Java Virtual Machine Java compilers start with...

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

View Full Document Right Arrow Icon
Java Virtual Machine
Background image of page 1

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

View Full DocumentRight Arrow Icon
Java compilers start with Java source code and create class files containing Java byte code When a Java program is executed, the byte code in the class file is interpreted or compiled (at load or run time) or some mixture of the two
Background image of page 2
Our compiler will also produce class files that can be executed like any other class file. Advantages of this approach architecture independent the JVM architecture is stack based. It is easier to generate code for than a register based architecture we can use Java to implement some of the runtime support for our language public domain tools to help us create class files
Background image of page 3

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

View Full DocumentRight Arrow Icon
Outline Overview of the JVM and class files Not a complete description—for all the details see http://java.sun.com/docs/books/vmspec/index.html or The Java Virtual Machine Specification Second Edition , by Tim Lindholm and Frank Yellin, Addison Wesley, 1999. Mapping constructs in our language to byte code Mechanisms for creating class files
Background image of page 4
Overview of the class file format A java class file is defined as a stream of 8-bit bytes consisting of a single ClassFile structure (where the structure is as in the C programming language): Tools will take care of most of the details of constructing a classfile, but it is useful to understand the overall structure.
Background image of page 5

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

View Full DocumentRight Arrow Icon
ClassFile { u4 magic; u2 minor_version; u2 major_version; u2 constant_pool_count; cp_info constant_pool[constant_pool_count-1]; u2 access_flags; u2 this_class; u2 super_class; u2 interfaces_count; u2 interfaces[interfaces_count]; u2 fields_count; field_info fields[fields_count]; u2 methods_count; method_info methods[methods_count]; u2 attributes_count; attribute_info attributes[attributes_count]; }
Background image of page 6
ClassFile { u4 magic; u2 minor_version; u2 major_version ; u2 constant_pool_count; cp_info constant_pool[constant_pool_count-1]; u2 access_flags; u2 this_class; u2 super_class; u2 interfaces_count; u2 interfaces[interfaces_count]; u2 fields_count; field_info fields[fields_count]; u2 methods_count; method_info methods[methods_count]; u2 attributes_count; attribute_info attributes[attributes_count]; } These values are fixed. Magic=0xCAFEBABE and indicates that this is a Java class file, the others indicate the classfile version
Background image of page 7

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

View Full DocumentRight Arrow Icon
u4 magic; u2 minor_version; u2 major_version; u2 constant_pool_count; cp_info constant_pool[constant_pool_count-1]; u2 access_flags; u2 this_class; u2 super_class; u2 interfaces_count; u2 interfaces[interfaces_count]; u2 fields_count; field_info fields[fields_count]; u2 methods_count; method_info methods[methods_count]; u2 attributes_count; attribute_info attributes[attributes_count]; } The constant pool contains all the constants in the program. This includes
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/09/2009 for the course COP 5555 taught by Professor Staff during the Fall '08 term at University of Florida.

Page1 / 110

11 JVM - Java Virtual Machine Java compilers start with...

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

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