The origin of
After typing apK files, how is the bytecode file loaded by Dvk/Art using Classloader
composition
use
Parent delegation mechanism
When a class loader loads a class, it first delegates the loading task to the parent class loader and recurses in turn. If the parent class loader can complete the class loading task, it will return successfully. Only if the parent class loader is unable to complete the load task or there is no parent class loader, it will be loaded by itself.
protected Class<? > loadClass(String name, boolean resolve) throws ClassNotFoundException { // First, check if the class has already been loaded Class<? > c = findLoadedClass(name); if (c == null) { try { if (parent ! = null) { c = parent.loadClass(name, false); } else { c = findBootstrapClassOrNull(name); } } catch (ClassNotFoundException e) { // ClassNotFoundException thrown if class not found // from the non-null parent class loader } if (c == null) { // If still not found, then invoke findClass in order // to find the class. c = findClass(name); } } return c; }Copy the code
The advantage of doing this is that it prevents the core FramWork classes from being tampered with and saves resources by not having to load the parent class once and then reload the child class