Recently, I have read the book of in-depth understanding of Java Virtual Machine selectively, and selected several chapters that are helpful for in-depth android development. When interviewing android or Java, you may also be asked, so we have a favorite.

1. Java memory management

Most people only know that Java memory is divided into stacks and heaps, but there is much more to it than that. A simple understanding of virtual machines is essential to becoming an advanced Java/Android developer, so the previous picture is for you to remember.

Pictures uploaded by Jane book will be compressed, so please use this one: http://img.blog.csdn.net/20170423141113568?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYTEwMTg5OTg2MzI=/font/5a6L5L2T/ fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

2. Structure of the class file

Viewing Java bytecode is also an essential skill for advanced Java developers, so I’ve put together a structure diagram of class files for you to look at.

Pictures uploaded by Jane book will be compressed, so please use this one: http://img.blog.csdn.net/20170306172800420?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYTEwMTg5OTg2MzI=/font/5a6L5L2T/ fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

3. Method invocation of the Java VM

Method calls are not equal to the execution of a Java method call not like c + + at compile time, you will know the memory address of the proposed method, when a method is invoked, only the class reference of symbols from the constant pool is called, and symbolic references during the class loading or runtime memory address to the real methods, This gives Java powerful dynamic extension capabilities.

  • 1. Resolution: All method calls are symbolic references in the Class file. During the Class loading phase, some symbolic references are converted to direct references (the address of the specific method in memory). This type of run-time invariant method call is called parsing.
    • 1. These are private methods, which cannot be called externally, and static methods, which are directly related to the class. So it gets resolved during class loading.
    • 2. Invokestatic and Invokespecial are two bytecode instructions corresponding to the above two. These methods are collectively referred to as non-virtual methods. There is also a method that is final because it cannot be overridden and is called by the Invokevirtual directive, but it is still non-virtual.
  • 2. Assignment: [http://blog.csdn.net/ns_code/article/details/17965867] dispatch “(http://blog.csdn.net/ns_code/article/details/17965867)