From f1c8d808ea349df134c0ee0908c1fc8c91493e0a Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Fri, 8 Aug 2014 16:09:58 -0700 Subject: Don't allow Class.class.getDeclaredConstructor().setAccessible(). The new behavior is to throw a SecurityException. Bug: 16866726 Bug: https://code.google.com/p/android-developer-preview/issues/detail?id=561 Change-Id: I1fa0d9617f8b25bf4e93a52c4aed22f0be27555b --- libart/src/main/java/java/lang/reflect/AccessibleObject.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'libart') diff --git a/libart/src/main/java/java/lang/reflect/AccessibleObject.java b/libart/src/main/java/java/lang/reflect/AccessibleObject.java index dd57a12..a1e2743 100644 --- a/libart/src/main/java/java/lang/reflect/AccessibleObject.java +++ b/libart/src/main/java/java/lang/reflect/AccessibleObject.java @@ -71,6 +71,13 @@ public class AccessibleObject implements AnnotatedElement { * IllegalAccessExceptions}. */ public void setAccessible(boolean flag) { + try { + if (equals(Class.class.getDeclaredConstructor())) { + throw new SecurityException("Can't make class constructor accessible"); + } + } catch (NoSuchMethodException e) { + throw new AssertionError("Couldn't find class constructor"); + } this.flag = flag; } -- cgit v1.1