Hot update source code flow + handwritten hot update

There is a specific demo address at the end of the article 

Hot update is achieved by replacing class loading

And the loading of class class is realized by classLoader,

Then we can go to see how the loadClass method in the classloader is implemented

First locate pathClassLoader, the smallest subclass of classloader, without loadClass method,

Then continue to view the parent class (BaseDexClass)

BaseDexClass also has no classLoadClass method, and finally check with the ClassLoader method

The process logic is as follows:
pathClassLoader-->BaseDexClass-->ClassLoader-->found that there is a classLoader method in it

The logic of the loadClass method is summarized as follows:
1. First check whether there is a cache in yourself, and if so,
take it from the
cache. Find it in the cache, and there is no parent loader to get it)
3. If there is none, the findClass method will be called

There is no specific implementation of findClass in the ClassLoader class. Check the subclass BaseDexClassLoader and find that there is a specific implementation.

Supongo que te gusta

Origin blog.csdn.net/iblue007/article/details/125584322
Recomendado
Clasificación