Understanding Java. Virtual/ Machine. Alpha Science International Ltd. Oxford, U.K. Sachin Seth

Similar documents
Lecture 32: The Java Virtual Machine. The Java Virtual Machine

Java Interview Questions and Answers

Replication on Virtual Machines

Java Programming. Binnur Kurt Istanbul Technical University Computer Engineering Department. Java Programming. Version 0.0.

Java Virtual Machine, JVM

- Applet java appaiono di frequente nelle pagine web - Come funziona l'interprete contenuto in ogni browser di un certo livello? - Per approfondire

The Java Virtual Machine Specification

Tuning WebSphere Application Server ND 7.0. Royal Cyber Inc.

Habanero Extreme Scale Software Research Project

IBM SDK, Java Technology Edition Version 1. IBM JVM messages IBM

Instrumentation Software Profiling

1 The Java Virtual Machine

Under the Hood: The Java Virtual Machine. Lecture 24 CS 2110 Fall 2011

Trace-Based and Sample-Based Profiling in Rational Application Developer

Real-time Java Processor for Monitoring and Test

Java and Java Virtual Machine Security

JVM Tool Interface. Michal Pokorný

Performance Tools for Parallel Java Environments

The Java Virtual Machine and Mobile Devices. John Buford, Ph.D. Oct 2003 Presented to Gordon College CS 311

Java Troubleshooting and Performance

University of Twente. A simulation of the Java Virtual Machine using graph grammars

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

The Java Virtual Machine (JVM) Pat Morin COMP 3002

Performance Improvement In Java Application

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

General Introduction

Virtual vs Physical Addresses

Cloud Computing. Up until now

02 B The Java Virtual Machine

C Compiler Targeting the Java Virtual Machine

Memory Allocation. Static Allocation. Dynamic Allocation. Memory Management. Dynamic Allocation. Dynamic Storage Allocation

Crash Course in Java

The Hotspot Java Virtual Machine: Memory and Architecture

Computing Concepts with Java Essentials

Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C

University of Dayton Department of Computer Science Undergraduate Programs Assessment Plan DRAFT September 14, 2011

Hardware/Software Co-Design of a Java Virtual Machine

picojava TM : A Hardware Implementation of the Java Virtual Machine

language 1 (source) compiler language 2 (target) Figure 1: Compiling a program

Fachbereich Informatik und Elektrotechnik SunSPOT. Ubiquitous Computing. Ubiquitous Computing, Helmut Dispert

THE BUSY DEVELOPER'S GUIDE TO JVM TROUBLESHOOTING

Zing Vision. Answering your toughest production Java performance questions

Java Virtual Machine Locks

Practical Performance Understanding the Performance of Your Application

An Overview of Java. overview-1

Interpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters

Multithreading and Java Native Interface (JNI)!

What s Cool in the SAP JVM (CON3243)

Java and Java Virtual Machine security vulnerabilities and their exploitation techniques

HeapStats: Your Dependable Helper for Java Applications, from Development to Operation

Using jvmstat and visualgc to Solve Memory Management Problems

WebSphere Architect (Performance and Monitoring) 2011 IBM Corporation

Data Structures. Level 6 C Module Descriptor

Jonathan Worthington Scarborough Linux User Group

DATA STRUCTURES USING C

Glossary of Object Oriented Terms

Java's garbage-collected heap

Java 6 'th. Concepts INTERNATIONAL STUDENT VERSION. edition

Built-in Concurrency Primitives in Java Programming Language. by Yourii Martiak and Mahir Atmis

System Structures. Services Interface Structure

Stack Allocation. Run-Time Data Structures. Static Structures

Security Vulnerability Notice

PC Based Escape Analysis in the Java Virtual Machine

PART IV Performance oriented design, Performance testing, Performance tuning & Performance solutions. Outline. Performance oriented design

Multi-core Programming System Overview

Reach 4 million Unity developers

Java Coding Practices for Improved Application Performance

Data Structures and Algorithms V Otávio Braga

PROGRAMMING CONCEPTS AND EMBEDDED PROGRAMMING IN C, C++ and JAVA: Lesson-4: Data Structures: Stacks

Eclipse Visualization and Performance Monitoring

CSCI E 98: Managed Environments for the Execution of Programs

Operating Systems. 05. Threads. Paul Krzyzanowski. Rutgers University. Spring 2015

Mobile Application Languages XML, Java, J2ME and JavaCard Lesson 04 Java

CSC 2405: Computer Systems II

Monitoring Java enviroment / applications

The Design of the Inferno Virtual Machine. Introduction

Research and Design of Universal and Open Software Development Platform for Digital Home

HVM TP : A Time Predictable and Portable Java Virtual Machine for Hard Real-Time Embedded Systems JTRES 2014

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

JavaCard. Java Card - old vs new

Restraining Execution Environments

High-Availability. Configurations for Liferay Portal. James Min. Senior Consultant / Sales Engineer, Liferay, Inc.

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas

How To Use Java On An Ipa (Jspa) With A Microsoft Powerbook (Jempa) With An Ipad And A Microos 2.5 (Microos)

Chapter 3 Operating-System Structures

Table of Contents. Adding Build Targets to the SDK 8 The Android Developer Tools (ADT) Plug-in for Eclipse 9

Cloud Computing and Robotics for Disaster Management

C++ INTERVIEW QUESTIONS

Lab Experience 17. Programming Language Translation

Common Operating-System Components

Memory management. Announcements. Safe user input. Function pointers. Uses of function pointers. Function pointer example

Effective Java Programming. measurement as the basis

Precise and Efficient Garbage Collection in VMKit with MMTk

Gildart Haase School of Computer Sciences and Engineering

Transcription:

Understanding Java Virtual/ Machine Sachin Seth Alpha Science International Ltd. Oxford, U.K.

Contents Preface v WEM PLATFORM DEPENDENCY AND VISUALIZATION VA_ 1.1 Introduction 1.1 1.2 How Programs Are Platform Dependent 1.1 1.2.1 Windows Segmented Executable File Format 1.2 1.2.2 A.out (File Format) 1.3 1.2.3 Executable and Linking Format (ELF) 1.3 1.3 How Platform Independence is Achieved 1.5 1.3.1 Hardware Virtual Machines 1.5 1.3.2 Application Virtual Machines 1.6 1.3.3 Machine Aggregation 1.6 1.4 Java Virtual Machine 1.6 1.5 Why Byte Codes 1.7 flf^h CLASS FILE FORMAT 2.1 Introduction 2.1 2.2 Signature or Magic Byte 2.2 2.3 Major and Minor Version Number 2.2 2.4 Constant Pool Count 2.2 2.5 Constant Pool Table 2.3 2.5.1 Constant_Utf8 2.3 2.5.2 Constant lnteger and Constant_Float 2.4 2.5.3 Constant Long and Constant_Double 2.5 2.5.4 Constant_Class 2.5 2.5.5 Constant_String 2.6

VIII Contents 2.5.6 Constant_Fieldref, Constant_Methodref, Constant_InterfaceMethodref 2.6 2.5.7 ConstantNameAndType 2.6 Access Flags 2.7 This_class 2.8 superclass 2.8 2.9 Interface_count 2.10 Interfaces table 2.9 2.11 Fields Count 2.9 2.12 Field table 2.9 2.12.1 Access_Flags 2.9 2.12.2 Name Index 2.10 2.12.3 Descriptorlndex 2.10 2.12.4 Attributes_Count 2.10 2.12.5 Attributes_Table 2.10 2.13 Methods count 2.10 2.14 Method table 2.10 2.15 Attributes Count 2.11 2.16 Attributesjable 2.11 2.16.1 Attribute Information Structure 2.11 2.17 Code Attribute 2.11 2.18 Exceptions Attribute 2.13 2.19 C data structure to represent the class file 2.13 2.20 Internal Representation of descriptor 2.14 2.20.1 Field Descriptors 2.15 2.20.2 Method Descriptors 2.15 2.7 2.8 2.8 2.9 MEM DESIGNING PLATFORM INDEPENDENT LANGUAGE 3.1 3.1 Designing Your Own Platform Independent Language 3.1 mjjh IVM INTERNAL DATA STRUCTURE 4.1 Introduction 4.1 4.2 Java Virtual Machine Data Types 4.1 4.2.1 Integral Types 4.1 4.2.2 Floating Point Types 4.2 4.2.3 Return Address Type 4.2 4.2.4 Boolean Type 4.2

Contents IX 4.2.5 Reference Type 4.2 4.3 JVM Data Types Storage Area 4.2 4.4 JVM Internal Data Structures 4.3 4.4.1 Thepc Register 4.3 4.4.2 Class Heap 4.3 4.4.3 Object Heap 4.4 4.4.4 Array Heap 4.5 4.4.5 Stack Frame 4.6 4.4.6 Method Area 4.6 4.4.7 Operand Stack 4.7 IVM INSTRUCTION SET 5.1 Introduction 5.1 5.2 Virtual Machine Error 5.1 5.3 Operations Involved in Executing Instructions 5.1 5.3.1 Push and Pop on Operand Stack 5.1 5.3.2 Push and Pop on Parameter Stack 5.3 5.3.3 Creating Function Stack Frame 5.3 5.3.4 Retrieving and Storing Values in Function Stack Frame 5.3 5.3.5 Creating an Object of Class 5.5 5.3.6 Storing Field Value 5.6 5.3.7 Getting Field Value 5.9 5.3.8 Allocating Memory for Static Fields 5.10 5.3.9 Storing Static Field Values 5.11 5.3.10 Get Static Field Values 5.14 5.3.11 Creating Array 5.14 5.3.12 Creating the Muti-dimensional Array 5.15 5.3.13 Storing and Retrieving Value from Array 5.17 5.3.14 Executing a Method 5.19 5.3.15 Throw an Exception 5.24 5.3.16 Acquiring Monitor 5.26 5.3.17 Releasing Monitor 5.27 5.3.18 Constant. utf8 to String 5.27 5.4 Instruction Set 5-28 CT GENERAL ALGORITHM OF JAVA VIRTUAL MACHINES 6.1 6.1 What Happens Behind the Scene 6.1 6.1.1 Loading of Class 61

X Contents 6.1.2 Verification of Class 6.3 6.1.3 Preparation of Class 6.3 6.1.4 Resolution of Symbols 6.4 6.1.5 Initialization 6.4 6.1.6 Initialize System Class Function 6.4 6.1.7 Load and Execute Test Class Class 6.4 6.2 Changes in JVM's Internal Data Structure 6.4 UNDERSTANDING JAVA NATIVE INTERFACE 7.1 7.1 WhyJNI 7.1 7.2 JNI Interface Functions 7.1 7.3 Loading and Linking Native Library 7.2 7.4 Referencing Java Objects 7.3 7.5 JNI Types and Data Structures 7.4 7.6 JNI by Example 7.4 7.7 JNI behind the Scene 7.5 7.7.1 Calling Native Function from Java 7.5 7.7.2 Calling Java Function from Native Language 7.10 IMPLEMENTING JNI FUNCTIONS 8.1 JNI Function Table 8.1 8.2 Initializing JNI Environment 8.2 8.3 JNI Helper Functions 8.2 8.3.1 Call Method 8.2 8.3.2 Call Method AO 8.3 8.3.3 Call Static Method 0 8.3 8.3.4 Call Static Method AO 8.4 8.3.5 Release Array Elements 0 8.4 8.3.6 Add to Local Ref List 8.4 8.4 JNI Functions 8.5 8.4.1 GetVersion 8.5 8.4.2 DefineClass 8.5 8.4.3 Find Class 8.7 8.4.4 GetSuperclass 8.8 8.4.5 Is Assignable From 8.9 8.4.6 Throw 8.10 8.4.7 ThrowNew 8.11 8.4.8 Throws 8.12

Contents xi 8.4.9 Exception Describe 8.12 8.4.10 Exception Clear 8.13 8.4.11 Fatal Error 8.13 8.4.12 New Local Ref 8.13 8.4.13 New Global Ref 8.14 8.4.14 New Weak Global Ref 8.14 8.4.15 Delete Global Ref 8.15 8.4.16 Delete Local Ref 8.15 8.4.17 Delete Weak Local Ref 8.16 8.4.18 AllocObject 8.16 8.4.19 New Object, New ObjectA & New ObjectV 8.17 8.4.20 Get Object Class 8.18 8.4.21 Is Instance Of 8.19 8.4.22 Is Same Object 8.19 8.4.23 Get Field ID 8.20 8.4.24 Get<type>Field 8.21 8.4.25 Set<type>Field 8.22 8.4.26 Get Method ID 8.23 8.4.27 Call<type>Method 8.24 8.4.28 Call Nonvirtual<type>Method 8.24 8.4.29 Get Static Field ID 8.25 8.4.30 Get Static<type>Field Routines 8.26 8.4.31 Set Static<type>Field Routines 8.26 8.4.32 Get Static Method ID 8.27 8.4.33 Call Static<type>Method 8.28 8.4.34 New String 8.28 8.4.35 Get String Length 8.29 8.4.36 Get String Region 8.30 8.4.37 Get String Chars 8.31 8.4.38 Get String Critical 8.31 8.4.39 Release String Chars 8.31 8.4.40 Release String Critical 8.32 8.4.41 New String UTF 8.32 8.4.42 Get String UTF Chars 8.33 8.4.43 Get String UTF Region 8.33 8.4.44 Get String UTF Length 8.34 8.4.45 Release String UTF Chars 8.34 8.4.46 Get Array Length 8.34 8.4.47 New Object Array 8.35 8.4.48 Get Object Array Element 8.36

xii Contents 8.4.49 Set Object Array Element 8 37 8.4.50 New<PrimitiveType>Array 8.37 8.4.51 Get<PrimitiveType>ArrayElements Routines 8.38 8.4.52 Release<PrimitiveType>ArrayElements Routines 8.39 8.4.53 Get<PrimitiveType>ArrayRegion Routines 8.40 8.4.54 Set<PrimitiveType>ArrayRegion Routines 8.41 8.4.55 Register Natives 8.42 8.4.56 Unregister Natives 8.42 8.4.57 Push Local Frame 8.43 8.4.58 Pop Local Frame 8.43 8.4.59 Monitor Enter 8.44 8.4.60 Monitor Exit 8.45 8.4.61 Get Java VM 8.45 MULTITHREADING IN JAVA 9J. 9.1 Introduction 91 9.2 Multithreading in Java 9.1 9.3 Memory Model for Thread 9.1 9.4 Creating Thread in Java 9.2 9.5 Why Multithreading in Java is Platform Dependent? 9.6 9.5.1 SleepO 9.6 9.5.2 StopO 9.6 9.5.3 SuspendO 9.5.4 ResumeO 9.5.5 isalive() 9.5.6 Interrupt () 9.5.7 Join() 9.8 9.5.8 Yield() 9.8 9.5.9 SetPriorityO 9.8 9.6 Thread local storage 9.9 Volatile keyword 9.9 9.8 Thread Synchronization in Java 9.9 111 GARBAGE COLLECTION 10.1 10.1 Introduction 10.1 10.2 Drawbacks of Legacy Languages 10.1 10.3 Solution to Memory Leak in Java 10.2 10.4 How JVM Recognizes that an Object is not Being Referenced 10.3 10.5 Garbage Collection Thread 10.5