summaryrefslogtreecommitdiffstats
path: root/runtime/mirror/class.cc
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2016-04-05 18:18:43 -0700
committerAndreas Gampe <agampe@google.com>2016-04-05 18:57:36 -0700
commitf72f19fac0016499d33fd75b0463d0128a58a9f4 (patch)
treeb054e5f92fbc2db09a3c4e920e8b4cbdb98e113a /runtime/mirror/class.cc
parent53b21d03e3ef7fe0c9594c024a4e98e561ab3032 (diff)
downloadart-f72f19fac0016499d33fd75b0463d0128a58a9f4.tar.gz
art-f72f19fac0016499d33fd75b0463d0128a58a9f4.tar.bz2
art-f72f19fac0016499d33fd75b0463d0128a58a9f4.zip
ART: Add getDeclaredConstructor cutout for unstarted runtime
In the vein of getDeclaredMethod and getDeclaredField. Refactor code from java_lang_Class to share code. Allows to compile-time initialize: * sun.security.x509.AVAKeyword * sun.security.x509.X500Name Bug: 27265238 Change-Id: I075c1b11f3408f5b31e4f84140a24fd8d3eaa17e
Diffstat (limited to 'runtime/mirror/class.cc')
-rw-r--r--runtime/mirror/class.cc30
1 files changed, 28 insertions, 2 deletions
diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc
index 7900eac4e0..a1bc4d0cc3 100644
--- a/runtime/mirror/class.cc
+++ b/runtime/mirror/class.cc
@@ -1023,8 +1023,8 @@ bool Class::ProxyDescriptorEquals(const char* match) {
// TODO: Move this to java_lang_Class.cc?
ArtMethod* Class::GetDeclaredConstructor(
- Thread* self, Handle<mirror::ObjectArray<mirror::Class>> args) {
- for (auto& m : GetDirectMethods(sizeof(void*))) {
+ Thread* self, Handle<mirror::ObjectArray<mirror::Class>> args, size_t pointer_size) {
+ for (auto& m : GetDirectMethods(pointer_size)) {
// Skip <clinit> which is a static constructor, as well as non constructors.
if (m.IsStatic() || !m.IsConstructor()) {
continue;
@@ -1138,5 +1138,31 @@ mirror::Method* Class::GetDeclaredMethodInternal<true>(Thread* self,
mirror::String* name,
mirror::ObjectArray<mirror::Class>* args);
+template <bool kTransactionActive>
+mirror::Constructor* Class::GetDeclaredConstructorInternal(
+ Thread* self,
+ mirror::Class* klass,
+ mirror::ObjectArray<mirror::Class>* args) {
+ StackHandleScope<1> hs(self);
+ const size_t pointer_size = kTransactionActive
+ ? Runtime::Current()->GetClassLinker()->GetImagePointerSize()
+ : sizeof(void*);
+ ArtMethod* result = klass->GetDeclaredConstructor(self, hs.NewHandle(args), pointer_size);
+ return result != nullptr
+ ? mirror::Constructor::CreateFromArtMethod<kTransactionActive>(self, result)
+ : nullptr;
+}
+
+// mirror::Constructor::CreateFromArtMethod<kTransactionActive>(self, result)
+
+template mirror::Constructor* Class::GetDeclaredConstructorInternal<false>(
+ Thread* self,
+ mirror::Class* klass,
+ mirror::ObjectArray<mirror::Class>* args);
+template mirror::Constructor* Class::GetDeclaredConstructorInternal<true>(
+ Thread* self,
+ mirror::Class* klass,
+ mirror::ObjectArray<mirror::Class>* args);
+
} // namespace mirror
} // namespace art