// simplify the javac classpath by not depending directly on 'dalvik.system' classes
ClassLoader mainLoader = (ClassLoader) Class.forName("dalvik.system.PathClassLoader")
.getConstructor(String.class, ClassLoader.class)
.newInstance("out/classes.dex", MainDexListTest.class.getClassLoader());
ClassLoader secondaryLoader = (ClassLoader) Class.forName("dalvik.system.PathClassLoader")
.getConstructor(String.class, ClassLoader.class)
.newInstance("out/classes2.dex", MainDexListTest.class.getClassLoader());
mainLoader.loadClass("testdata.InMainDex");
secondaryLoader.loadClass("testdata.InSecondaryDex");
try {
secondaryLoader.loadClass("testdata.InMainDex");
throw new AssertionError();
} catch (ClassNotFoundException e) {
// expected
}
try {
mainLoader.loadClass("testdata.InSecondaryDex");
throw new AssertionError();
} catch (ClassNotFoundException e) {
// expected
}