Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Breaking the Android ClassLoader

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

Breaking the Android ClassLoader

ClassLoaders are not new. They've existed since Java 1.0 and are a core part of how the JVM works. Things work a bit different under the hood in Android, but the core principles are the same and we, as Android developers, largely take it for granted. This talk will be a deep dive into how class loading works in Android and later explore the implications of trying to manipulate the application's ClassLoader at runtime (for better or worse 🔥) in the context of logging, hot fixing, adding features, and interacting with 3rd party code.

Sample project: https://github.com/hzsweers/blackmirror

Avatar for Zac Sweers

Zac Sweers

August 28, 2018
Tweet

More Decks by Zac Sweers

Other Decks in Programming

Transcript

  1. class ClassLoader {a Class<?> loadClass(String name); Class<?> findClass(String name); Class<?>

    defineClass(...); URL getResource(String name); // A few others }a
  2. class ClassLoader {a Class<?> loadClass(String name); Class<?> findClass(String name); Class<?>

    defineClass(...); URL getResource(String name); // A few others }a
  3. package example; class Foo { private Bar bar; }a loadClass("example.Foo")

    Foo.class.getClassLoader().loadClass("example.Bar")
  4. class CustomClassLoader extends PathClassLoader { @Override public Class<?> loadClass(String name)

    { Log.d("ClLoading", "Loading " + name); return super.loadClass(name); } }