Java virtual machine learning notes 2

xiaoxiao2021-03-06  27

11. A array array is also an object of a class. An array with the same type and dimension belongs to the same class (regardless of the length of only the dimension). The length of the array belongs to an object instance. The multidimensional array is also a one-dimensional array. Two

Dimensional group, which is a one-dimensional array, each element of the one-dimensional array is a reference to an array. The array is also stored in a heap as a common object. The array name is a reference to the array, and the array content is accessed by the index, ie the array label.

12. An exception is saved in the frame data area of ​​the Java stack frame to be referenced for the exception table for this method. The abnormal table describes the bytecode (* .class) of the method (* .class) is protected by the CatCH clause (ie in the Try clause.

Bytecode). When a method throws an exception, the virtual machine looks for matching catch clauses in the corresponding exception table and handles control to the code in the CATCH clause.

13. Java Execute Engine Implementation Platform Unrelated, in the center of Java method frame, the local variable array as a register of the CPU. Each operation must operate the operator, then return to the local

Variable area. Java virtual machine specifies strong type conversion, that is, low precision can be implicitly converted to high precision, high precision must be forced to transform to low precision.

14. The thread thread is present in a certain actuator in the process. Each thread must comply with object lock, thread wait, and notifications. Object locks the access object resource for thread mutual exclusion. Waiting and notice is to comply with the thread syndrome to achieve the same purpose. The Java object reaches the order of locks through the instruction set, with the same inheritance

Wait (), Notify (), NotifyAll () method of the Object class come to wait and notify. When a thread calls a WAIT () method of an object, the thread is blocked and joined to the line of the object.

In the process of blocking queues, the thread in the blocking queue can be awakened until the other thread calls the notification method of the same object.

15. Constant pool constant tanks are used to store various information of the type, including various direct constants of the type, and symbolic reference to other types, fields, methods. The constant pool is divided into two, the constant pool stored in the .CLASS bytecode and the runtime constant pool stored in the method area. The constant pool appears in an inlet form (similar to the interrupt vector table), each entry points to a table, and stores the constant information. However, the corresponding table can be judged from the flag of the entrance of the constant pool.

The constant type stored in the store. The constant pool entry begins with a flag bit, which indicates the type of constant. Each entry corresponds to a table, which is the end of the symbol _info, and the constant form of constant is stored in the table. The constant pool is accommodated in addition to the storage of direct constants, and the following symbols are accommodated: the list of classes and interfaces. Field names and descriptors (this descriptor is a string indicating the field type. Field is a class or interface class variable or instance variable). Method Name and Descriptor (This descriptor indicates method returns type, parameter type, quantity, order).

When running, the virtual machine's constant pool's list of constant names and methods, the descriptor of the fields creates a relationship between classes and classes.

The constant pool is just a collection of references and descriptors and does not accept any assignment operation.

All objects creation, methods, and class variables are invoked from the constant pool, but the call of the instance variable is obtained from the heap. (guess)

The symbol reference is used by the virtual machine to obtain a specific address.

A constant pool parsing is to replace the symbol reference in the constant pool to direct reference.

When you use a class method or field, first find the symbol reference of the method or field from the constant pool, then analyze, find its physical address.

Convey the various symbols, classes and classes of the code, and perform a constant pool resolution called dynamic connection.

16. The constant pool structure constant pool consists of a lot of units, each unit is shaped (inlet | content), and the entry is found by the index when accessing a constant pool unit, and then accesses its content. But sometimes the content of the unit is also

It may be a constant pool entry (such as a constant pool unit of class or interface, the entrance contains the symbol reference of the class is constant_class_info, and the content points to one

Constant_utf8_info's constant pool unit, which stores the full-qualified name of this class). Direct constants such as int, float, etc., the content is the value of constant. 17. The structural method area of ​​the method area stores all information about type, interface. The method area contains:

Confarus Pool: Storage Type Direct Constants and All Fields, Methods, Other Type Symbolic references (just references, do not store specific information).

Field information: All declarations of fields (including field name, type, modifier).

Method Information: All defined methods (including method names, return types, modifiers, method of bytecodes, method stack frames, and abnormal methods).

Class variable information: The virtual machine is allocated in the method area for all class variables, and later initialization, assignment, etc. are also performed in the method area to share all kinds of instances.

In order to improve access speed, the virtual machine sets a method table for each non-abstract class in the method area, which is an array, and each element is a method of direct reference. Take the class object call

When the method is searched in the method table (the abstract class has no instance, so there is no way to call the method, so there is no method table).

18. The instances and arrays of the stack storage (including instance variables, pointing to references to class data in the corresponding method area).

19. An 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 parties are the same object.

First: String a = new string ("Hello") String B = New String ("Hello") A and B respectively create a new Hello object and reference variable, that is, two Hello in the heap, their respective references are A and B.

And: string c = "hello" string d = "hello" first creates a string-class instance hello, then establish two string reference variables C and D, then let C and D point to the Hello instance that starts establishing. Therefore, C and D point to the same object.

转载请注明原文地址:https://www.9cbs.com/read-40617.html

New Post(0)