[School Recruitment VIP] Parental Delegation Model of Java Language Test Center

Examination point introduction:

Parental delegation is one of the frequently tested points in school recruitment interviews. Parental delegation mechanism definition: When a class loader receives a class loading request, it will not load the specified class directly, but delegates the request to its own parent loader for loading. Only the parent loader cannot load. When this class is loaded, the current loader will be responsible for loading the class.

Parental Delegation Model of Java Language Test Center - Related questions and analysis content can be viewed by clicking on the link at the end of the article!

1. Test questions

1. Why is parent delegation needed?
Answer: Because there is a strict hierarchical relationship between class loaders, Java classes also have a hierarchical relationship. In other words, this hierarchical relationship is priority...

2. Is the relationship between "father and son loaders" inheritance?
Answer: When many people see names like parent loader and child loader, they think that there is an inheritance relationship between class loaders in Java. Even many articles on the Internet will have similar misconceptions...

3. How is parent delegation implemented?
Answer: The parental delegation model is important to ensure the stable operation of Java programs, but its implementation is not complicated. The code to implement parental delegation is concentrated in the loadClass() method of java.lang.ClassLoader...

4. How to proactively destroy the parental delegation mechanism?
Answer: Knowing the implementation of the parental delegation model, it is very simple to destroy the parental delegation mechanism. Because his parent delegation process is implemented in the loadClass method, if you want to destroy this mechanism, just customize a class loader and rewrite the loadClass method in it so that it does not perform parent delegation.

5. How does Tomcat break the parental delegation mechanism?
Answer: As shown in the picture above, the orange part above is still the same as before, using the parental delegation mechanism. The yellow part is the first part of tomcat's customized class loader. This part is mainly used to load the classes in the tomcat package...

2. Examination articles

1. [School Recruitment VIP] Easy-to-understand parent delegation mechanism.
When introducing the parent delegation mechanism, we have to mention ClassLoader. Before talking about ClassLoader, we must first understand the basic knowledge of Java...

2. [School Recruitment VIP] Java Parental Delegation Model: Why Parental Delegation? How to break it?
Usually when doing business development, I rarely come into contact with class loaders, but if you want to learn more about open source projects such as Tomcat and Spring, or engage in the development of underlying architecture, it is essential to understand or even be familiar with the principles of class loading...

3. [School Recruitment VIP] Take the time to understand the parent delegation mechanism. To understand the parent
delegation mechanism, first you have to understand what a ClassLoader is. We know that Java runs in the JVM virtual machine, how does it run? actually......

3. Test point video

Execution sequence of finally
When there is return in try, should finally be executed? There are global variables in finnally. Will the value change?

Parental Delegation Model of Java Language Test Center - Related questions and analytical content can be viewed by clicking on the link below:
Parental Delegation Model of Java Language Test Center - Mobile Links
Parental Delegation Model of Java Language Test Center - PC Link

Supongo que te gusta

Origin blog.csdn.net/shuize123/article/details/132826897
Recomendado
Clasificación