When the virtual opportunity goes to a new command, the first thing to do is to detect if the parameter of the directive can be used to locate a class's symbolic reference in a constant pool, and to detect whether the class is loaded, parsed, initialized, or not loaded first.
Object creation in the heap partition space available pointer collisions (used memory put aside unused side) and idle list, space may occur when the thread is insecure #, so when allocating memory using CAS (Compare and Swap) with the failure retry to ensure atomicity or using Tlab ( Thread local allocation buffer each thread pre-allocates a chunk of memory in the heap, and which thread allocates memory and is allocated on the tlab of that thread.
Once the memory is allocated, the virtual machine needs to initialize the memory space, which guarantees that the object can be used directly after it is created, such as new object (). The initialization here means that the field is set to 0, not the assigned value.
The next virtual Opportunity sets the object header, such as the instance of which class, the hash code of the object, the age of the GC for the object, how to find the metadata information for the class, and so on. Whether to enable biased locking to set header information
Finally execute the Init method, the object according to the programmer's intention to initialize the assignment (the object reference into the stack, @ is not sure whether the init after the stack or after the object header information set after the stack)
Object contains three areas: 1, Object header 2, instance Data 3, align fill
The object header contains two pieces of information, part of which is used to store the data at its own runtime, with data lengths of up to 32 or 64bit
Another part is the storage type pointer, which is a pointer to its class metadata, which the virtual machine uses to determine which class the object is an instance of (not all virtual machine implementations must keep the type pointer on the object), and if the object is an array, the object header must also have a piece of data to record the length of the array. Because a virtual machine can determine how much space an object needs based on the metadata it contains (that is, all the data that the object contains), it cannot determine the size of the array by its metadata.
The instance data section is a valid piece of information that the object actually stores, that is, the contents of the various types of fields defined in the code. Both inherited and defined by the parent class are recorded.
How Java objects are created