Fix Class.getModifiers for array classes.
A separate libcore change is needed to fix Class.getModifiers for
arrays of inner classes.
Bug: https://code.google.com/p/android/issues/detail?id=56267
Change-Id: I3d95b266bb14a72b766921fe09e53fdef2f6d01b
diff --git a/src/class_linker.cc b/src/class_linker.cc
index 6e32065..93de3f5 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -2021,15 +2021,16 @@
CHECK(array_iftable_ != NULL);
new_class->SetIfTable(array_iftable_);
- // Inherit access flags from the component type. Arrays can't be
- // used as a superclass or interface, so we want to add "final"
+ // Inherit access flags from the component type.
+ int access_flags = new_class->GetComponentType()->GetAccessFlags();
+ // Lose any implementation detail flags; in particular, arrays aren't finalizable.
+ access_flags &= kAccJavaFlagsMask;
+ // Arrays can't be used as a superclass or interface, so we want to add "abstract final"
// and remove "interface".
- //
- // Don't inherit any non-standard flags (e.g., kAccFinal)
- // from component_type. We assume that the array class does not
- // override finalize().
- new_class->SetAccessFlags(((new_class->GetComponentType()->GetAccessFlags() &
- ~kAccInterface) | kAccFinal) & kAccJavaFlagsMask);
+ access_flags |= kAccAbstract | kAccFinal;
+ access_flags &= ~kAccInterface;
+
+ new_class->SetAccessFlags(access_flags);
mirror::Class* existing = InsertClass(descriptor, new_class.get(), false);
if (existing == NULL) {