The Class Loader Subsystem
primordial class loader and class loader object
The primordial class loader is a class loader implemented in JVM, and class loader object is the objects of classes that descend from ClassLoader.
only types loaded by primordial class loader are stored in method area.
Loading, Linking and Initialization
1. loading: finding and importing the binary data for a type
2. linking: performing verification, preparation, and (optionally) resolution
a. verification: ensuring the correctness of the imported type
b. preparation: allocating memory for class variables and initializing the memory to default values
c. resolution: transforming symbolic references from the type into direct reference.
3. initialization: invoking java code that initializes class variables to their proper starting values
Class Loader Object
three methods in ClassLoader :
protected final Class defineClass(byte[] data, int offset, int length)
protected final Class findSystemClass(String name)
protected final void resolveClass(Class c)
The defineClass() method accepts a byte array, data[], as input. Starting at position offset in the array and continuing for length bytes, class ClassLoader expects binary data conforming to the Java class file format--binary data that represents a new type for the running application. Every Java Virtual Machine implementation must make sure the defineClass() method of class ClassLoader can cause a new type to be imported into the method area.
The findSystemClass() method accepts a String representing a fully qualified name of a type. When a class loader object invokes this method, it is requesting that the virtual machine attempt to load the named type via its primordial class loader. If the primordial class loader has already loaded or successfully loads the type, it returns a reference to the Class object representing the type. If it canít locate the binary data for the type, it throws ClassNotFoundException. Every Java Virtual Machine implementation must make sure the findSystemClass() method can invoke the primordial class loader in this way.
The resolveClass() method accepts a reference to a Class instance. This method causes the type represented by the Class instance to be linked and initialized (if it hasnít already been linked and initialized). The defineClass() method, described above, only takes care of loading. (See the above section, "Loading, Linking, and Initialization" for definitions of these terms.) When defineClass() returns a Class instance, the binary file for the type has definitely been located and imported into the method area, but not necessarily linked and initialized. Java Virtual Machine implementations make sure the resolveClass() method of class ClassLoader can cause the class loader subsystem to perform linking and initialization.
The Method Area
Type Information
For each type it loads, a Java Virtual Machine must store the following kinds of information in the method area:
The fully qualified name of the type
The fully qualified name of the typeís direct superclass (unless the type is an interface or class java.lang.Object, neither of which have a superclass)
Whether or not the type is a class or an interface
The typeís modifiers ( some subset of` public, abstract, final)
An ordered list of the fully qualified names of any direct superinterfaces
In addition to the basic type information listed above, the virtual machine must also store for each loaded type:
The constant pool for the type
Field information
Method information
All class (static) variables declared in the type, except constants
A reference to class ClassLoader
A reference to class Class
分享到:
相关推荐
5 The Java Virtual Machine What is a Java Virtual Machine? The Lifetime of a Java Virtual Machine The Architecture of the Java Virtual Machine Data Types Word Size The Class Loader Subsystem ...
NULL 博文链接:https://comedsh.iteye.com/blog/670983
Part 5: The Part of Tens . 5 Icons Used in This Book. 5 Beyond the Book. 6 Where to Go from Here. 7 PART 1: GETTING STARTED WITH JAVA. 9 CHAPTER 1: All about Java. 11 What You Can Do with Java. 12 Why...
Generic Code and the Virtual Machine 621 Restrictions and Limitations 626 Inheritance Rules for Generic Types 630 Wildcard Types 632 Reflection and Generics 640 Chapter 13: Collections 649 ...
of the Java Language Specification and Chapter 8 of the Java Virtual Machine Specification. The current document has been written generically to apply to both, the final version will include two ...
Chapter 6 - Performance and the Java Virtual Machine Chapter 7 - Local Area Networking for Java Games Chapter 8 - Faster Math Chapter 9 - Game Databases and JDBC Chapter 10 - Java as a ...
Generic Code and the Virtual Machine 621 Restrictions and Limitations 626 Inheritance Rules for Generic Types 630 Wildcard Types 632 Reflection and Generics 640 Chapter 13: Collections 649 ...
It allows Java code that runs inside a Java Virtual Machine (VM) to interoperate with applications and libraries written in other programming languages, such as C, C++, and assembly The most ...
Understand the basic aspects of the Java virtual machine and application server performance tuning Design guidelines for better enterprise application performance Discover different Java optimization ...
including the Java Virtual Machine configuration, the application server configuration (in our case, JBoss AS), the application code itself, and ultimately the operating system. This book will show ...
Chapter 5: Operators and Casts 131 Operators 131 Operator Shortcuts 133 The Ternary Operator 134 The checked and unchecked Operators 134 The is Operator 135 The as Operator 136 The sizeof Operator 136...
Discover how to use Clojure in the real world, and unlock the speed and power of this beautiful language on the Java Virtual Machine. Clojure Applied gives you the practical, realistic advice and ...
To run the examples in this book, you'll need a computer that can run the Java Virtual Machine and a connection to the Internet. Table of Contents Chapter 1. Getting Started with JRuby Chapter 2. ...
Nicolas is the author of several popular open source tools, including the MTASC open source ActionScript2 compiler, the haXe crossplatform compiler and the Neko Virtual Machine. He is cofounder and ...
It can be used with the Java virtual machine, Microsoft's Common Language Runtime, and JavaScript engines, providing a level of both versatility and functionality that is appealing to more and more ...
Chapter 7 continues the machine learning topic with an examination of machine learning using artificial neural networks (ANN). ANNs are by far the most prevalent AI method used to implement machine ...