ART: Add ClassLoadCallback
Add callback for class-load and class-prepare events. Move Dbg
over. Add tests.
Bug: 31684920
Test: m test-art-host-gtest-runtime_callbacks_test
Test: art/tools/run-jdwp-tests.sh --mode=host
Change-Id: I871f6b3c54448fd6ece8d9a7571b2042be50d525
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index f0a64f1..92d1554 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -2678,6 +2678,11 @@
return nullptr;
}
CHECK(klass->IsLoaded());
+
+ // At this point the class is loaded. Publish a ClassLoad even.
+ // Note: this may be a temporary class. It is a listener's responsibility to handle this.
+ Runtime::Current()->GetRuntimeCallbacks().ClassLoad(klass);
+
// Link the class (if necessary)
CHECK(!klass->IsResolved());
// TODO: Use fast jobjects?
@@ -2718,7 +2723,7 @@
* The class has been prepared and resolved but possibly not yet verified
* at this point.
*/
- Dbg::PostClassPrepare(h_new_class.Get());
+ Runtime::Current()->GetRuntimeCallbacks().ClassPrepare(klass, h_new_class);
// Notify native debugger of the new class and its layout.
jit::Jit::NewTypeLoadedIfUsingJit(h_new_class.Get());