diff options
| author | Alan Viverette <alanv@google.com> | 2015-05-04 10:32:57 -0700 |
|---|---|---|
| committer | Alan Viverette <alanv@google.com> | 2015-05-04 10:32:57 -0700 |
| commit | 904de2ec9360de2ee54b91aaf9e141d9d8ab1de1 (patch) | |
| tree | e28ae68b8b33ecb3a2e16e4024f3e3989114023c /core/java/android/view | |
| parent | 5551aca2b8ec9fe7ab5ffda8dad82ee104556962 (diff) | |
| download | frameworks_base-904de2ec9360de2ee54b91aaf9e141d9d8ab1de1.zip frameworks_base-904de2ec9360de2ee54b91aaf9e141d9d8ab1de1.tar.gz frameworks_base-904de2ec9360de2ee54b91aaf9e141d9d8ab1de1.tar.bz2 | |
Always force constructors accessible during inflation
We now correctly throw an IllegalAccessException for non-public accesses,
but we were relying on the old incorrect behavior during inflation. This
CL forces constructors to be accessible so that we emulate the old
behavior and don't crash.
Where we were already doing this, the CL moves the setAccessible() call
immediately after the getConstructor() call, since there's no point in
calling it multiple times.
Bug: 20810495
Change-Id: I63dfcb857e445f688080eea05e86ef22760ed49f
Diffstat (limited to 'core/java/android/view')
| -rw-r--r-- | core/java/android/view/LayoutInflater.java | 2 | ||||
| -rw-r--r-- | core/java/android/view/MenuInflater.java | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/core/java/android/view/LayoutInflater.java b/core/java/android/view/LayoutInflater.java index 1503728..37312d0 100644 --- a/core/java/android/view/LayoutInflater.java +++ b/core/java/android/view/LayoutInflater.java @@ -590,6 +590,7 @@ public abstract class LayoutInflater { } } constructor = clazz.getConstructor(mConstructorSignature); + constructor.setAccessible(true); sConstructorMap.put(name, constructor); } else { // If we have a filter, apply it to cached constructor @@ -615,7 +616,6 @@ public abstract class LayoutInflater { Object[] args = mConstructorArgs; args[1] = attrs; - constructor.setAccessible(true); final View view = constructor.newInstance(args); if (view instanceof ViewStub) { // Use the same context when inflating ViewStub later. diff --git a/core/java/android/view/MenuInflater.java b/core/java/android/view/MenuInflater.java index b49a59e..dc8cadf 100644 --- a/core/java/android/view/MenuInflater.java +++ b/core/java/android/view/MenuInflater.java @@ -544,6 +544,7 @@ public class MenuInflater { try { Class<?> clazz = mContext.getClassLoader().loadClass(className); Constructor<?> constructor = clazz.getConstructor(constructorSignature); + constructor.setAccessible(true); return (T) constructor.newInstance(arguments); } catch (Exception e) { Log.w(LOG_TAG, "Cannot instantiate class: " + className, e); |
