Fix JNI ToReflectedMethod for constructor
Returns java.lang.reflect.Constructor object for <init> and <clinit> methods.
Bug: https://code.google.com/p/android/issues/detail?id=72312
Bug: 15885285
Change-Id: I2f4a266b2d9574659673dc6966104860578d709e
diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc
index 8842f59..083f179 100644
--- a/runtime/jni_internal.cc
+++ b/runtime/jni_internal.cc
@@ -592,7 +592,12 @@
mirror::ArtMethod* m = soa.DecodeMethod(mid);
CHECK(!kMovingMethods);
jobject art_method = soa.AddLocalReference<jobject>(m);
- jobject reflect_method = env->AllocObject(WellKnownClasses::java_lang_reflect_Method);
+ jobject reflect_method;
+ if (m->IsConstructor()) {
+ reflect_method = env->AllocObject(WellKnownClasses::java_lang_reflect_Constructor);
+ } else {
+ reflect_method = env->AllocObject(WellKnownClasses::java_lang_reflect_Method);
+ }
if (env->ExceptionCheck()) {
return nullptr;
}