diff options
author | Elliott Hughes <enh@google.com> | 2013-06-14 15:08:02 -0700 |
---|---|---|
committer | Brian Carlstrom <bdc@google.com> | 2013-07-09 21:47:26 -0700 |
commit | 78728ebce868f5949739e6e204e3e0fbf0356f8d (patch) | |
tree | c8f740cdc813c9e65f0218a69398d8b0f9ed57bf | |
parent | 26376765d7333ddf04c021365a1eadd9d47feb7e (diff) | |
download | libcore-78728ebce868f5949739e6e204e3e0fbf0356f8d.zip libcore-78728ebce868f5949739e6e204e3e0fbf0356f8d.tar.gz libcore-78728ebce868f5949739e6e204e3e0fbf0356f8d.tar.bz2 |
Fix Class.getModifiers for arrays of inner classes.
Bug: https://code.google.com/p/android/issues/detail?id=56267
(cherry picked from commit 8aa5892195543e80b1c4eb10d8764268927cc1be)
Change-Id: I3be5433b04607e5f41e7c68f03cfabc166b56d54
-rw-r--r-- | libart/src/main/java/java/lang/Class.java | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/libart/src/main/java/java/lang/Class.java b/libart/src/main/java/java/lang/Class.java index 9e3f74c..98b50d3 100644 --- a/libart/src/main/java/java/lang/Class.java +++ b/libart/src/main/java/java/lang/Class.java @@ -608,7 +608,7 @@ public final class Class<T> implements Serializable, AnnotatedElement, GenericDe return getMethod(name, parameterTypes, true); } - private Method getMethod(String name, Class<?>[] parameterTypes, boolean recursivePublicMethods) + private Method getMethod(String name, Class<?>[] parameterTypes, boolean recursivePublicMethods) throws NoSuchMethodException { if (name == null) { throw new NullPointerException("name == null"); @@ -1113,6 +1113,19 @@ public final class Class<T> implements Serializable, AnnotatedElement, GenericDe * defined by constants in the {@link Modifier} class. */ public int getModifiers() { + // Array classes inherit modifiers from their component types, but in the case of arrays + // of an inner class, the class file may contain "fake" access flags because it's not valid + // for a top-level class to private, say. The real access flags are stored in the InnerClass + // attribute, so we need to make sure we drill down to the inner class: the accessFlags + // field is not the value we want to return, and the synthesized array class does not itself + // have an InnerClass attribute. https://code.google.com/p/android/issues/detail?id=56267 + if (isArray()) { + int componentModifiers = getComponentType().getModifiers(); + if ((componentModifiers & Modifier.INTERFACE) != 0) { + componentModifiers &= ~(Modifier.INTERFACE | Modifier.STATIC); + } + return Modifier.ABSTRACT | Modifier.FINAL | componentModifiers; + } int JAVA_FLAGS_MASK = 0xffff; int modifiers = AnnotationAccess.getInnerClassFlags(this, accessFlags & JAVA_FLAGS_MASK); return modifiers & JAVA_FLAGS_MASK; |