diff options
author | Jeff Hao <jeffhao@google.com> | 2014-04-01 13:27:02 -0700 |
---|---|---|
committer | Jeff Hao <jeffhao@google.com> | 2014-04-01 13:27:02 -0700 |
commit | 96e2e4faf806aa22ca205354c16b04288d51ddbf (patch) | |
tree | c8534f0d6111b10cc9f413f8e4691925d79fb3cb /libart/src | |
parent | 148c6fae519d9f484bbf9ce49fca504b331b43da (diff) | |
download | libcore-96e2e4faf806aa22ca205354c16b04288d51ddbf.zip libcore-96e2e4faf806aa22ca205354c16b04288d51ddbf.tar.gz libcore-96e2e4faf806aa22ca205354c16b04288d51ddbf.tar.bz2 |
Fix reflection access checks for app compatibility in libcore.
Libcore side of this change. Corresponding art change here:
https://android-review.googlesource.com/#/c/89620/
Change-Id: I00610421438155fc60d6780b06581b874419ca2b
Diffstat (limited to 'libart/src')
-rw-r--r-- | libart/src/main/java/java/lang/Class.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libart/src/main/java/java/lang/Class.java b/libart/src/main/java/java/lang/Class.java index 36a55f5..ea41d6e 100644 --- a/libart/src/main/java/java/lang/Class.java +++ b/libart/src/main/java/java/lang/Class.java @@ -1551,6 +1551,10 @@ public final class Class<T> implements Serializable, AnnotatedElement, GenericDe if (isPrimitive() || isInterface() || isArray() || Modifier.isAbstract(accessFlags)) { throw new InstantiationException(this + " cannot be instantiated"); } + Class<?> caller = VMStack.getStackClass1(); + if (!caller.canAccess(this)) { + throw new IllegalAccessException(this + " is not accessible from " + caller); + } Constructor<T> init; try { init = getDeclaredConstructor(); @@ -1560,6 +1564,9 @@ public final class Class<T> implements Serializable, AnnotatedElement, GenericDe t.initCause(e); throw t; } + if (!caller.canAccessMember(this, init.getAccessFlags())) { + throw new IllegalAccessException(init + " is not accessible from " + caller); + } try { return init.newInstance(null, init.isAccessible()); } catch (InvocationTargetException e) { |