diff options
author | Sebastien Hertz <shertz@google.com> | 2015-04-28 15:00:41 +0200 |
---|---|---|
committer | Sebastien Hertz <shertz@google.com> | 2015-04-28 15:25:47 +0200 |
commit | 2d2f2a9c665b02ca5139f71e37ca5e08389e4191 (patch) | |
tree | 50551b6039ff7924d75077ace60bd4304a8ed3bf /runtime/native | |
parent | 3adfc4bbe6c42d574bd2069d8e38a13d5ad98ccf (diff) | |
download | android_art-2d2f2a9c665b02ca5139f71e37ca5e08389e4191.tar.gz android_art-2d2f2a9c665b02ca5139f71e37ca5e08389e4191.tar.bz2 android_art-2d2f2a9c665b02ca5139f71e37ca5e08389e4191.zip |
Fix constructor access check through reflection
We must not throw IllegalAccessException if the constructor has been
made accessible by a previous call to Constructor.setAccessible, even
if the caller cannot access the constructor.
Bug: 20639158
Change-Id: I9a34f05cdbb8825ad88b42223743690228e3f03e
Diffstat (limited to 'runtime/native')
-rw-r--r-- | runtime/native/java_lang_reflect_Constructor.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/runtime/native/java_lang_reflect_Constructor.cc b/runtime/native/java_lang_reflect_Constructor.cc index 036d04eba1..0fd6759d6e 100644 --- a/runtime/native/java_lang_reflect_Constructor.cc +++ b/runtime/native/java_lang_reflect_Constructor.cc @@ -36,7 +36,7 @@ namespace art { */ static jobject Constructor_newInstance(JNIEnv* env, jobject javaMethod, jobjectArray javaArgs) { ScopedFastNativeObjectAccess soa(env); - mirror::Method* m = soa.Decode<mirror::Method*>(javaMethod); + mirror::Constructor* m = soa.Decode<mirror::Constructor*>(javaMethod); StackHandleScope<1> hs(soa.Self()); Handle<mirror::Class> c(hs.NewHandle(m->GetDeclaringClass())); if (UNLIKELY(c->IsAbstract())) { @@ -46,7 +46,7 @@ static jobject Constructor_newInstance(JNIEnv* env, jobject javaMethod, jobjectA return nullptr; } // Verify that we can access the class. - if (!c->IsPublic()) { + if (!m->IsAccessible() && !c->IsPublic()) { auto* caller = GetCallingClass(soa.Self(), 1); // If caller is null, then we called from JNI, just avoid the check since JNI avoids most // access checks anyways. TODO: Investigate if this the correct behavior. |