diff options
author | Jeff Hao <jeffhao@google.com> | 2014-04-01 11:21:30 -0700 |
---|---|---|
committer | Jeff Hao <jeffhao@google.com> | 2014-04-01 18:28:13 +0000 |
commit | 925b687c29ddfe952c29e13e6c05c2491e3b37f7 (patch) | |
tree | de09aba0c9f2419feb880f8842d59202a27f7c9f | |
parent | d265a8ab12e1b783af42bf07a264edbb86826d2c (diff) | |
download | art-925b687c29ddfe952c29e13e6c05c2491e3b37f7.zip art-925b687c29ddfe952c29e13e6c05c2491e3b37f7.tar.gz art-925b687c29ddfe952c29e13e6c05c2491e3b37f7.tar.bz2 |
Fix reflection access checks for app compatibility.
Also updates field access test.
Bug: 13740995
Change-Id: I224712cfcb0c05429b831c26980cabad7bdef49a
-rw-r--r-- | runtime/reflection.cc | 3 | ||||
-rw-r--r-- | test/064-field-access/src/Main.java | 12 |
2 files changed, 8 insertions, 7 deletions
diff --git a/runtime/reflection.cc b/runtime/reflection.cc index 6ed61f6..f0ba003 100644 --- a/runtime/reflection.cc +++ b/runtime/reflection.cc @@ -799,8 +799,7 @@ bool VerifyAccess(mirror::Object* obj, mirror::Class* declaring_class, uint32_t visitor.WalkStack(); mirror::Class* caller_class = visitor.caller->GetDeclaringClass(); - if ((((access_flags & kAccPublic) != 0) && declaring_class->IsPublic()) || - caller_class == declaring_class) { + if (((access_flags & kAccPublic) != 0) || (caller_class == declaring_class)) { return true; } if ((access_flags & kAccPrivate) != 0) { diff --git a/test/064-field-access/src/Main.java b/test/064-field-access/src/Main.java index c9b93ba..8dd22ba 100644 --- a/test/064-field-access/src/Main.java +++ b/test/064-field-access/src/Main.java @@ -554,15 +554,17 @@ class SubClass extends PublicClass { } // Check access or lack of to field. Class<?> subClassAccessExceptionClass = null; - if (f.getName().contains("Private") || + if ((f.getName().contains("Private") || (!same_package && f.getName().contains("Package")) || - (!same_package && f.getName().contains("Protected"))) { + (!same_package && f.getName().contains("Protected"))) && + !(protected_class && f.getName().contains("Public"))) { subClassAccessExceptionClass = IllegalAccessException.class; } Class<?> mainClassAccessExceptionClass = null; - if (f.getName().contains("Private") || + if ((f.getName().contains("Private") || (!same_package && f.getName().contains("Package")) || - (!same_package && f.getName().contains("Protected"))) { + (!same_package && f.getName().contains("Protected"))) && + !(protected_class && f.getName().contains("Public"))) { mainClassAccessExceptionClass = IllegalAccessException.class; } @@ -605,7 +607,7 @@ class SubClass extends PublicClass { for (Method m : methods) { Class<?> subClassAccessExceptionClass = null; - if (protected_class || m.getName().contains("Private") || + if (m.getName().contains("Private") || (!same_package && m.getName().contains("Package")) || (!same_package && m.getName().contains("Protected"))) { subClassAccessExceptionClass = IllegalAccessException.class; |