// it's okay to decode it without worrying about unexpectedly marking it alive.
mirror::ClassLoader* loader = soa.Decode<mirror::ClassLoader*>(class_loader);
class_loader_allocator =
- Runtime::Current()->GetClassLinker()->GetAllocatorForClassLoader(loader);
+ Runtime::Current()->GetClassLinker()->GetOrCreateAllocatorForClassLoader(loader);
CHECK(class_loader_allocator != nullptr);
}
if (library != nullptr) {
static final String CLASS_PATH = "classes-ex/";
/* this is the "alternate" DEX/Jar file */
- static final String DEX_FILE = System.getenv("DEX_LOCATION") + "/068-classloader-ex.jar";
+ public static final String DEX_FILE = System.getenv("DEX_LOCATION") + "/068-classloader-ex.jar";
/* on Dalvik, this is a DexFile; otherwise, it's null */
private Class mDexClass;
* limitations under the License.
*/
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
/**
* Class loader test.
*/
testSeparation();
testClassForName();
+
+ // Attempt to load without a class table, regression test for b/25866849.
+ testLoadNativeLibrary(args[0]);
+ }
+
+ static void testLoadNativeLibrary(String libName) throws Exception {
+ Class pathClassLoader = Class.forName("dalvik.system.PathClassLoader");
+ if (pathClassLoader == null) {
+ throw new AssertionError("Couldn't find path class loader class");
+ }
+ Constructor constructor =
+ pathClassLoader.getDeclaredConstructor(String.class, ClassLoader.class);
+ ClassLoader loader = (ClassLoader) constructor.newInstance(
+ FancyLoader.DEX_FILE, ClassLoader.getSystemClassLoader());
+ Runtime runtime = Runtime.getRuntime();
+ Method method = runtime.getClass().getDeclaredMethod("loadLibrary", String.class,
+ ClassLoader.class);
+ if (method == null) {
+ throw new RuntimeException("loadLibrary not found");
+ }
+ method.setAccessible(true);
+ method.invoke(runtime, libName, loader);
}
static void testSeparation() {