Java Virtual machine Learning notes 2

Source: Internet
Author: User
Tags abstract array arrays variables string variable thread access
Notes
11. Array arrays are also objects of the class. An array with the same type and number of dimensions belongs to the same class (regardless of the length of the dimension only). The length of an array is part of an object instance. A multidimensional array is also a one-dimensional array. such as two

Dimension array, a one-dimensional array in which each element of the one-dimensional array is a reference to an array. Arrays are stored in the heap as well as normal objects. An array name is a reference to an array, which is accessed by means of an index, an array label.

12. Exceptions hold a reference to the exception table for the method in the frame data area of the Java stack frame. The exception table records the scope of the method's bytecode (*.class) that is protected by a catch clause (that is, in the TRY clause.

byte code). When a method throws an exception, the virtual machine looks for a matching catch clause in the corresponding exception table and hands control to the code in the Catch clause.

The 13.java execution engine realizes platform independence, takes the operand stack in the Java method frame as the center, and treats the local variable array as the CPU register. Each operation of a data to press the operator stack, and then return to the local

Variable area. Java virtual machines require strongly typed conversions, where low precision can be implicitly converted to high precision, and high precision must be cast to low precision.

14. A thread thread is present in the process of an executing body. Each thread must adhere to object locking, thread waiting, and notification. Object locks the Access object resource that makes a thread mutually exclusive. The wait and notice is followed by a reasonable scheduling of threads to achieve the same goal. Java objects are locked by instruction set and inherited

The object class waits (), notify (), and Notifyall () method to wait and notify. When a thread invokes the wait () method of an object, the thread is blocked and added to the object's line

Process to block a thread in the queue until another thread calls the notification method of the same object.

15. Constant pool constant pools are used to hold various types of information, including various direct constants of types, and symbolic references to other types, fields, and methods. There are two types of constant pools, Chang stored in the. Class bytecode, and a running constant pool stored in the method area. Chang appear in the form of an entry (similar to the interrupt vector table), where each entry points to a table that stores the information for the constant. But the table can be judged from the flag bit of the entry of the constant pool

The type of constants stored in the The constant pool entry begins with a flag bit indicating the type of the constant. Each entry corresponds to a table that ends with a symbolic _info that holds the compressed form of the constant. The constant pool holds the following symbolic references in addition to the direct constants: the fully qualified name of the class and interface. The field name and descriptor, which is a string indicating the type of the field. A field is a class or instance variable of a class or interface. The method name and descriptor (the descriptor indicates the method return type, parameter type, quantity, order).

At runtime, the virtual machine uses the fully qualified name and method of the constant pool, and the descriptor of the field establishes the relationship between the class and the class.

A constant pool is simply a collection of references and descriptors and does not accept any assignment operations.

All object creation, methods, and invocation of class variables are to get information from the constant pool, but the invocation of instance variables is obtained from the heap. Guess

A symbolic reference is used by a virtual machine after parsing it to obtain a specific address.

Constant pool resolution is to replace a symbolic reference in a constant pool with a direct reference.

When you want to use a method or field of a class, you first find the symbol reference for the method or field from the constant pool, and then parse it to find its physical address.

A constant pool parsing, called a dynamic connection, refers to the various symbolic references, classes, and classes that appear in the code.

16. Constant pool structure constant pool is made up of many ruthless units, each of which is shaped like (the entry | content), accessed through the index when accessing the constant pool cell, and then accesses its contents. But sometimes the contents of the unit are also

It may be a constant pool entry, such as a constant pool unit of a class or interface, where the entry contains a symbolic reference to the class that is Constant_class_info, and the content points to a

A Constant_utf8_info constant pool unit in which the fully qualified name of the class is stored. and direct constants such as Int,float, the content is the value of the constant.

17. The structure method area of the method area stores all information about the type, interface. The method area contains:

Chang: A direct constant of the storage type and all fields, methods, other types of symbolic references (just references, no specific information is stored).

Field information: All declared fields (including field names, types, modifiers).

Method information: All defined methods (including method name, return type, modifier, method byte code, method stack frame size, method exception).

Class variable information: the virtual machine allocates space for all class variables in the method area, and the subsequent initialization, assignment, and so on, is also done in the method area to share for all class instances.

To improve access speed, a virtual machine sets a method table for each Non-abstract class in the method area, which is an array, and each element is a direct reference to a method. When the object of the class calls the

method is searched in the method table (there is no instance of the abstract class, so there is no method table).

18. The heap heap holds instances and arrays of classes (including instance variables that point to references to class data in the corresponding method area).

19. One example class Test{public static void Main (string args[]) {string A=new string ("Hello"); string b=new string ("Hello") ; string c= "Hello"; string d= "Hello";} a==b returns False,c==d returns ture. because: = = Compare whether the two sides are the same object.

First: String A=new string ("Hello") string b=new string ("Hello") A and B respectively create new Hello objects and reference variables, that is, there are two hello in the heap, and their respective references are A and B.

And: String c= "Hello" string d= "Hello" first create a String class instance Hello, then create two strings to reference the variables C and D, and then let C and D all point to the Hello instance that you started to build. So C and D are pointing to the same object.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.