- Class loading: After compiling the.java file, execute the.class file. Start the JVM process, find the.class file from the classpath path, and load the class information into the method area.
- Execute the main method.
- Student stu = new Student(” Jack “); At this point, there is no information about Student in the method area, so load the Student class and put it in the method area.
- After the Student class is loaded, the JVM allocates memory for the Stu instance in the heap and calls the constructor to initialize the Stu instance, which holds a reference to the type information of the Stu class in the method area.
- When executing stu.say(), the JVM finds the stu object based on the reference held by the stu object. Based on the reference held by the stu object, the JVM locates the method table of the type information of the student class in the method area to get the bytecode address of say.
- Perform say