[Reprinted] JVM knowledge point questions

Source: Internet
Author: User

Reprinted from bi Xuan technology blog: http://www.blogjava.net/BlueDavy/archive/2009/03/27/262419.html

JVM is the runtime environment of Java programs. Therefore, mastering JVM helps you understand Java program execution and writing, especially some strange problems encountered during runtime, so how can I learn about the key JVM knowledge points and learn about the JVM mechanism? I will discuss it in this blog.

For Java programs, the key mechanisms of JVM are: bytecode loading, method execution, Object Memory Allocation and recovery, thread and lock mechanisms, the knowledge of JVM involved in these mechanisms is far less simple than writing these words, and the complexity is still very high.

Bytecode Loading
The JVM uses classloader to dynamically load bytecode. This mainly involves the parent delegation of classloader, the compiling method of classloader, the unique identifier of the class to be loaded, and the loading process of the class.
During the investigation, I think we can examine these two simple questions:
1. Write a program that loads the specified. Class file in the directory to JVM, and obtain the complete class name and other information through the class object;
2. A piece of display code contains a Global static integer variable. If two classloader are used to load this object, what will happen after the integer variable ++ operation is executed?

Method execution
JVM has its own command system, which is already an instruction in the bytecode. It needs to master the JVM's different execution methods for static, interface, instance, and constructor, in addition, it refers to the implementation of reflection in JVM (for example, Sun JDK), the implementation of dynamic proxy, and the method of JVM to execute bytecode (interpretation, JIT, and hotspot ), and when to trigger compilation into machine code and how to control it.
During the investigation, I thought we could examine the following three questions:
1. What is the difference between a A = new a(;;a.exe cute (); and ia a = new a(;;;a.exe cute;
2. Why is the reflection performance low?
3. Write a program, dynamically create an interface implementation, and load it to the JVM for execution. (bcel and other tools can be used)

Allocation and recovery of Object Memory
This section involves a lot of knowledge points, for example, the Division of JVM memory areas, the distribution of natural and reference types of memory, the tlab and GC algorithms, the implementation of GC by Sun JDK, the timing of GC triggering, GC tracking and analysis method.
During the investigation, I thought we could examine the following three questions:
1. Classic string Comparison Program questions:
String A = "";
String B = "B ";
String AB = "AB ";
(A + B) = AB ;?? (How can I make (a + B) = AB)
("A" + "B") = AB ;??
2. Write a program for outofmemory, or frequently execute minor GC, but not trigger full GC, or frequently execute full GC, but do not execute minor GC, and do not outofmemory, even a full GC occurs after several minor GC times are controlled;
3. explain in detail the implementation of GC, such as how to recycle the object memory during minor GC, and how to recycle the object memory during full GC.

Thread and lock mechanism
This section involves a lot of knowledge points, for example, the variable operation mechanism in the thread, thread scheduling mechanism, thread status and control method, thread tracking and analysis method, synchronization keyword, lock/unlock principle, and so on.
During the study, I think we can examine the following questions:
1. Execution Process of I ++;
2. A thread needs to wait for another thread to set a variable to true to continue execution, write this program, or control multiple threads to start together;
3. How to control the thread state conversion, or give several thread dump to analyze which thread has a problem and where the problem is;
4. What are the differences between static attribute locking, global variable attribute locking, and method locking?

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.