Issues related to

Class loading process

Load, validate, prepare, parse, initialize, use, unload

Clinit and init

The static code block is executed only once and corresponds to the Clinit method

Initializing the property of an object corresponds to init. This is executed every time a new object is created

How do I replace JDK classes

When the native API of Java cannot meet the requirements, for example, we need to modify the HashMap class, we must use the endorsed technology of Java. We need to package our HashMap class into a JAR package and put it into the directory specified by -djava.endorsed. Dirs. Note that the class name and package name should be the same as those in the JDK. However, the classes under the java.lang package are excluded because these are specially protected.

Java provides endorsed technology, which is used to replace these classes. Jar packages in this directory have higher priority than rt.jar files and can be loaded first.

Which GC Roots are available

  • In a Java thread, reference type parameters, local variables, temporary values, and so on for all methods currently being called. That is, the various references associated with our stack frame.

  • All currently loaded Java classes.

  • A Java class reference type static variable.

  • A reference type constant (String or Class) in the runtime constant pool.

  • The JVM internal data structures of some references, such as the sun. The JVM. Hotspot. The memory. The Universe.

  • Monitor objects for synchronization, such as objects whose wait() method is called.

  • JNI handles include global handles and Local handles.

The summary is as follows:

Various references to active threads. Class reference to a static variable. JNI references

CMS garbage collector

The initial tag is STW

Concurrent tags

Relabel STW

Concurrent cleaning