summaryrefslogtreecommitdiffstats
path: root/runtime/mirror/class.cc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/mirror/class.cc')
-rw-r--r--runtime/mirror/class.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc
index 2afb4af0e3..1739019755 100644
--- a/runtime/mirror/class.cc
+++ b/runtime/mirror/class.cc
@@ -25,6 +25,7 @@
#include "dex_file-inl.h"
#include "gc/accounting/card_table-inl.h"
#include "handle_scope-inl.h"
+#include "method.h"
#include "object_array-inl.h"
#include "object-inl.h"
#include "runtime.h"
@@ -876,5 +877,26 @@ bool Class::ProxyDescriptorEquals(const char* match) {
return Runtime::Current()->GetClassLinker()->GetDescriptorForProxy(this) == match;
}
+mirror::ArtMethod* Class::GetDeclaredConstructor(
+ Thread* self, Handle<mirror::ObjectArray<mirror::Class>> args) {
+ auto* direct_methods = GetDirectMethods();
+ size_t count = direct_methods != nullptr ? direct_methods->GetLength() : 0u;
+ for (size_t i = 0; i < count; ++i) {
+ auto* m = direct_methods->GetWithoutChecks(i);
+ // Skip <clinit> which is a static constructor, as well as non constructors.
+ if (m->IsStatic() || !m->IsConstructor()) {
+ continue;
+ }
+ // May cause thread suspension and exceptions.
+ if (m->EqualParameters(args)) {
+ return m;
+ }
+ if (self->IsExceptionPending()) {
+ return nullptr;
+ }
+ }
+ return nullptr;
+}
+
} // namespace mirror
} // namespace art