Don't always allocate constructor newInstance as non movable.
We now only allocate these objects as non movable if the class is a
non movable class (currently fields or methods).
Change-Id: I26700272fceb277e00f25ff3078cef6951296b9d
diff --git a/runtime/native/java_lang_reflect_Constructor.cc b/runtime/native/java_lang_reflect_Constructor.cc
index 5811992..c06bf4c 100644
--- a/runtime/native/java_lang_reflect_Constructor.cc
+++ b/runtime/native/java_lang_reflect_Constructor.cc
@@ -56,7 +56,16 @@
return nullptr;
}
- mirror::Object* receiver = c->AllocNonMovableObject(soa.Self());
+ bool movable = true;
+ if (!kMovingMethods && c->IsArtMethodClass()) {
+ movable = false;
+ } else if (!kMovingFields && c->IsArtFieldClass()) {
+ movable = false;
+ } else if (!kMovingClasses && c->IsClassClass()) {
+ movable = false;
+ }
+ mirror::Object* receiver =
+ movable ? c->AllocObject(soa.Self()) : c->AllocNonMovableObject(soa.Self());
if (receiver == nullptr) {
return nullptr;
}