The TinkerClassLoader is a specialized PathClassLoader used to facilitate hot-patching in Android applications. It allows the application to load patched .dex files at runtime by prioritizing them over the original application classes.
When searching for a class or resource, TinkerClassLoader follows this lookup order:
- The system class loader.
- The patched dex files (via
injectDexPath). - The
mOriginAppClassLoader (the original application's class loader).
Note: The constructor is package-private (TinkerClassLoader(...)), implying that it is intended to be instantiated by the Tinker framework's internal loader components rather than directly by end-users in typical application code.
// Note: The constructor is package-private in the source.
// It is used by the framework to initialize the patched environment.
TinkerClassLoader loader = new TinkerClassLoader(
dexPath, // Path to the patched dex files
optimizedDir, // Directory for optimized dex files
libraryPath, // Path to native libraries
originAppClassLoader // The original application ClassLoader
);