Programming for Java Virtual Machine / With CD-rom (99 Edition)
by Joshua Engel
|
|
|
About This Book
ISBN13: 9780201309720 |
Only 1 left in stock at $41.40!
This item will ship separately from others in your shopping cart.
Synopses & Reviews
Publisher Comments:
The core of Java(tm) technology, the Java virtual machine is an abstract computing machine that enables the Java(tm) platform to host applications on any computer or operating system without rewriting or recompiling. Anyone interested in designing a language or writing a compiler for the Java virtual machine must have an in-depth understanding of its binary class format and instruction set. If you are programming with the Java programming language, knowledge of the Java virtual machine will give you valuable insight into the Java platform's security capabilities and cross-platform portability. It will increase your understanding of the Java programming language, enabling you to improve the security and performance of your programs.
The author employs a tutorial approach that provides a detailed look into the central workings of the technology and teaches the reader how to write real programs for the Java virtual machine. He describes methods to becoming a better programmer through an advanced understanding of the Java virtual machine and Java technology. Programming for the Java Virtual Machine offers comprehensive coverage of all the major elements of the Java virtual machine-classes and objects, control instructions, debugging, class loaders, compiling the Java programming language, performance issues, security, and threads and synchronization. The book provides an introduction to the Java(tm) Virtual Machine Specification (JVMS), with a collection of topics that help programmers understand the Java virtual machine and the JVMS better. In addition, the book features implementations of Prolog and Scheme, a language that runs on top of the Java virtual machine, generating Java virtual machine code as it runs and using a Java virtual machine class loader to load the generated code into the system.
You will find detailed information on such topics as:
x The Java virtual machine verification algorithm
x How Java virtual machine security works, and what it can and can't do
x Using class loaders to incorporate code and dynamically generated code from the Internet, the Java(tm) Foundation Classes, database queries, and other languages
x The mechanics of compiling the Java programming language for the Java virtual machine
x Implementing other languages using the Java virtual machine, including Scheme, Prolog, Sather, Eiffel, and regular expressions
Numerous examples illustrate techniques and concepts, and exercises with solutions help you gain practical experience.
Book News Annotation:
A tutorial explaining how to write real programs for the Java virtual
machine, the abstract computing machine that enables the Java
platform to host applications on any computer or operating system
without rewriting or recompiling. Assumes a previous working
knowledge of Java. The disk contains libraries and programs in Java,
source code, sample compilers, examples, and other material.
Annotation c. Book News, Inc., Portland, OR (booknews.com)
Annotation c. Book News, Inc., Portland, OR (booknews.com)
Table of Contents
Preface 1 Introduction to the Java Virtual Machine
1.1 Java Virtual Machine and Java
1.2 What Is the Java Virtual Machine?
1.2.1 Instruction Set
1.2.2 class File Format
1.2.3 Verification
1.3 Java Platform
1.4 Organization of the Java Virtual Machine
1.4.1 Class Area
1.4.2 Java Stack
1.4.3 Heap
1.4.4 Native Method Stacks
1.4.5 Example
1.5 Garbage Collection
1.5.1 Finalization
1.5.2 Timing of Garbage Collection
1.6 JVM Implementations
1.7 Versions of the Virtual Machine
1.8 Future of the Java Virtual Machine
2 Oolong
2.1 Hello, World
2.1.1 .class and .super Directives
2.1.2 main Method
2.1.3 Instructions
2.2 Structure of an Oolong Program
2.3 Defining the Class
2.4 Superclasses
2.5 Declaring Fields
2.6 Declaring Methods
2.7 Interfaces
3 Writing Methods
3.1 Some Definitions
3.2 Types
3.2.1 Numeric Types
3.2.2 Object Types
3.2.3 Type returnAddress
3.3 Mnemonic Naming Conventions
3.4 Testing Code Examples
3.5 Returns
3.6 Constants
3.6.1 General Constants
3.6.2 Small Constants and null
3.7 Local Variables
3.7.1 Initializing Variables
3.7.2 Local Variables as Method Arguments
3.8 Math
3.8.1 Arithmetic Operations
3.8.2 Nonnumbers and Infinity
3.8.3 Bitwise Operations
3.8.4 Floating-Point Arithmetic and strictfp
3.9 Type Conversions
3.9.1 Conversion Example
3.9.2 Widening and Narrowing
3.10 Stack Manipulations
3.11 Arrays of Numbers
3.12 Just Biding Your Time
4 Classes and Objects
4.1 What Is an Object?
4.1.1 Objects and References
4.1.2 Class Names
4.1.3 Packages
4.2 Creating Objects
4.3 Constructors
4.4 Using Fields
4.4.1 Types and getfield
4.4.2 Inheriting Fields
4.4.3 Changing Field Values
4.5 Invoking Methods on Objects
4.5.1 Virtual Invocation
4.5.2 Method Inheritance and Overriding
4.5.3 Overloading and Method Matching
4.5.4 Invoking a Method Directly
4.5.5 invokespecial and super
4.6 Casting
4.7 Casting, Fields, Methods, and Java
4.8 Returning Objects
4.9 Interfaces
4.10 Static Fields and Methods
4.11 Class Initialization
4.12 Arrays
4.12.1 Arrays of Reference
4.12.2 Multidimensional Arrays
4.12.3 Length of Arrays
5 Control Instructions
5.1 Comparing Integers
5.2 Comparing References
5.3 Other Comparisons
5.4 Switches
5.5 Subroutines
5.6 Exceptions
5.6.1 Multiple Exception Handlers
5.6.2 .throws Directive
5.6.3 Other Ways to Throw Exceptions
5.7 A Gentler Way of Checking Type
6 Verification Process
6.1 How the Verification Algorithm Works
6.2 Is It a Structurally Valid class File?
6.3 Are All Constant References Correct?
6.5 Will Each Instruction Always Find a Correctly Formed Stack and Local Variable Array?
6.5.1 Example 1: Hello, World
6.5.2 Example 2: gotos and ifs
6.5.3 Example 3: Code That Doesn't Verify
6.5.4 Example 4: Dealing with Subclasses
6.5.5 Algorithm
6.6 Do External References Check Out?
6.7 Java Language and Verification Algorithm
6.7.1 Fooling the Virtual Machine with a Java Compiler
6.7.2 Other Languages and the Verification Algorithm
6.8 Other Safety Requirements
6.9 Checking Verification
7 Debugging
7.1 Debugging Directives in Oolong
7.1.1 .source Directive and .line Directives
7.1.2 .var Directive
7.2 Debugging Oolong Programs
7.3 Runtime Tracing
8 Class Loaders
8.1 How Classes Are Loaded
8.1.1 Loading
8.1.2 Linking
8.2 Loading Classes without a Class Loader
8.3 Making Your Own Class Loader
8.3.1 Caching Classes
8.3.2 Examples
8.4 Working with Class Objects
8.5 Reflection
9 Inside a Java class File
9.1 class File Header
9.2 Constant Pool
9.2.1 UTF8 Entries
9.2.2 Constant Entries
9.2.3 Field, Method, and Class Entries
9.3 Class Information
9.4 Fields and Methods
9.5 Class Attributes
9.6 Other Attributes
9.6.1 ConstantValue Attribute
9.6.2 Exceptions Attribute
9.6.3 InnerClasses Attribute
10 Compiling Java
10.1 Expressions and Statements
10.2 Expression Types
10.2.1 Numeric Types
10.2.2 Object Types
10.2.3 Expression Result Types
10.2.4 Compile-Time Types and Type Restrictions
10.2.5 Type Safety and Verifiability
10.3 Compiling Statements and Expressions
10.4 Local Variable Declarations
10.5 Fields and Variables
10.5.1 Abbreviations
10.5.2 Other Assignments
10.5.3 Assignments as Expressions
10.5.4 Type-Checking in Assignments
10.6 Creating New Objects
10.7 Class Name Abbreviations
10.8 Arithmetic Expressions
10.8.1 Numeric Coercions
10.8.2 Casting Numeric Values
10.8.3 ~ Operator
10.9 Method Calls
10.9.1 Virtual Method Calls
10.9.2 Static Method Calls
10.9.3 Example of Method Calls
10.9.4 Overriding
10.9.5 Overloading
10.9.6 Interfaces
10.10 Expressions as Statements
10.11 Ifs and Booleans
10.11.1 Boolean Values
10.11.2 if Statements
10.11.3 Comparisons
10.11.4 Floating-Point Comparisons and NaN
10.11.5 Integer Comparisons
10.11.6 References and Object Equality
10.11.7 Boolean Operators
10.12 Other Control Structures
10.12.1 Loops
10.12.2 Compiling Control Constructs
10.12.3 Compound Statements and Verification
10.13 Returns
10.14 Field Declarations
10.15 Method Declarations
10.16 Constructors
10.16.1 Using Other Constructors in the Same Class
10.16.2 Default Constructors
10.16.3 Field Initializers and the Constructor
10.17 Conclusion
11 Compiling Other Languages
11.1 Java Version 1.1
11.1.1 Class Literals
11.1.2 Inner Classes
11.1.3 Variable Scoping with Inner Classes
11.2 Regular Expressions
11.3 Iterators
11.3.1 Iterators in Sather
11.3.2 Implementing Iterators
11.3.3 Iterators with Arguments
11.3.4 Using Iterators
11.4 Parameterized Types
11.4.1 Implementing Parameterized Types with a Generic Class
11.4.2 Implementing Parameterized Types as Templates
11.5 Multiple Inheritance
11.5.1 Interfaces for Multiple Inheritance
11.5.2 Implementing the Interfaces
11.5.3 Fields
11.6 Conclusion
12 Implementing Scheme
12.1 Scheme Concepts
12.2 Compiling Scheme into Bytecodes
12.3 Compiling Lambda Expressions
12.4 Example
12.5 Scheme Library
12.6 Optimizing Scheme
12.6.1 Static Scoping
12.6.2 Using Local Variables
12.6.3 Inlining
12.6.4 Tail Recursion
12.6.5 Using Type Information
13 Implementing Prolog
13.1 Introduction to Prolog
13.1.1 Asking Questions
13.1.2 Binding Patterns
13.1.3 Implications
13.1.4 Binding Patterns and Implications
13.1.5 Facts as Rules
13.1.6 More About Unification
13.2 Implementation Basics
13.3 Unification
13.3.1 Unification Algorithm
13.3.2 Managing Bindings
13.4 Rules as Programs
13.4.1 inside
13.4.2 within
13.4.3 yield and Backtracking
13.5 Implementing Rules
13.5.1 Implementing within
13.5.2 Implementing Conjunctions
13.5.3 Constructing within
13.6 Compiling Facts
13.7 Case Study
14 Performance
14.1 Fast Virtual Machines
14.1.1 Garbage Collection Performance
14.1.2 Implementing References
14.2 Bytecode Optimization Techniques
14.2.1 Warning
14.2.2 Constant Propagation
14.2.3 Strength Reduction
14.2.4 Loop Unrolling
14.2.5 Peephole Optimization
14.3 Inlining
14.3.1 Inlining Fields
14.3.2 Separate Compilation
15 Security and the Virtual Machine
15.1 Java platform and Need for Security
15.2 Security Promises of the JVM
15.3 Security Architecture and Security Policy
15.3.1 Example
15.3.2 Basic Applet Security Policy
15.3.3 More Sophisticated Policies
15.4 Some Potential Attacks
15.4.1 Implementation Details
15.4.2 Protecting the Security Manager
15.4.3 Bypassing Java Security
15.4.4 Using Unconstructed Objects
15.4.5 Invalid Casts
15.4.6 Changing the Class of a Reference
15.4.7 Reading Uninitialized Fields
15.4.8 Array Bounds Checks
15.4.9 Catching Exceptions
15.4.10 Hidden Code
15.5 Conclusion
16 Threads and Synchronization
16.1 Threads
16.1.1 Example: Multithreaded Web Server
16.1.2 Exceptions and Threads
16.2 Sharing State Between Threads
16.2.1 Need for Synchronization
16.2.2 Exception: longs and doubles
16.3 Monitors and Object Locks
16.3.1 Synchronization in Java
16.3.2 Synchronized Methods
16.4 Scheduling
16.4.1 Surrendering Control of the CPU
16.4.2 Waiting for Another Thread
16.5 Conclusion
A Tables
A.1 Instructions by Opcode
A.2 Instructions Alphabetically
A.3 Instructions by Category
A.3.1 Arithmetic
A.3.2 Array
A.3.3 Constant
A.3.4 Control
A.3.5 Data Type Conversion
A.3.6 Object
A.3.7 Stack Manipulation
A.3.8 Synchronization
A.3.9 Variable
B Oolong Reference
B.1 Using the Oolong Assembler
B.2 Gnoloo
B.3 DumpClass
B.4 Oolong Language
B.4.1 Comments
B.4.2 .source
B.4.3 .class
B.4.4 .interface
B.4.5 .end class
B.4.6 .super
B.4.7 .implements
B.4.8 .field
B.4.9 .method
B.4.10 .limit locals
B.4.11 .limit stack
B.4.12 .line
B.4.13 .var
B.4.14 .throws
B.4.15 .catch
B.4.16 .end method
B.5 Instructions
B.5.1 Instructions with No Arguments
B.5.2 Integers
B.5.3 Labels
B.5.4 Classes
B.5.5 Fields and Methods
B.5.6 invokeinterface
B.5.7 multianewarray
B.5.8 ldc, ldc_w, and ldc2_w
B.5.9 newarray
B.5.10 tableswitch
B.5.11 lookupswitch
C Answers to Selected Exercises
Further Readings
Java and the JVM
Newsgroup
Other Languages
Compilers
Index:
What Our Readers Are Saying
Be the first to add a comment for a chance to win!
Product Details
- ISBN:
- 9780201309720
- Author:
- Publisher:
- Addison-Wesley Professional
- Author:
- Location:
- Reading, Mass.
- Subject:
- Programming Languages - General
- Subject:
- Java (Computer program language)
- Subject:
- Programming Languages - Java
- Subject:
- Java
- Subject:
- Java virtual machine
- Edition Number:
- 1st
- Series Volume:
- 1943/E
- Publication Date:
- June 1999
- Binding:
- Paper Textbook
- Language:
- English
- Illustrations:
- Yes
- Pages:
- 512
- Dimensions:
- 23 cm. +









