Hold a ClassLoader reference in NativeAllocationRegistry.
So that the native library isn't unloaded before we have a chance to
call the freeFunction.
Bug: 28406866
(cherry picked from commit 7d3c7390a8cbeff12fe790e5d12da6e07cf8c298)
Change-Id: I38edb9ba6855ef98743001e4bbf4fd80fb27873d
diff --git a/tools/ahat/test-dump/Main.java b/tools/ahat/test-dump/Main.java
index d61a98d..3936f29 100644
--- a/tools/ahat/test-dump/Main.java
+++ b/tools/ahat/test-dump/Main.java
@@ -50,7 +50,8 @@
bigArray[i] = (byte)((i*i) & 0xFF);
}
- NativeAllocationRegistry registry = new NativeAllocationRegistry(0x12345, 42);
+ NativeAllocationRegistry registry = new NativeAllocationRegistry(
+ Main.class.getClassLoader(), 0x12345, 42);
registry.registerNativeAllocation(anObject, 0xABCDABCD);
}
}