Revert "Revert "Use IsAssignableFrom instead of IsSubclass for robustness.""
Don't use IsAssignableFrom, but check beforehand if the referrer is an
interface. Otherwise, we are being too aggressive on removing clinit
checks on interfaces (being a subclass doesn't imply the interface
has been initialized).
bug:21870666
This reverts commit 463580ca5a1e75e27ad0207537ffc6252091326a.
Change-Id: I2a13974d28477ee3e5224142cc260cbf46d19aa9
diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc
index 0736693..c497526 100644
--- a/compiler/optimizing/builder.cc
+++ b/compiler/optimizing/builder.cc
@@ -697,7 +697,8 @@
&storage_index);
}
- if (outer_class.Get()->IsSubClass(resolved_method->GetDeclaringClass())) {
+ if (!outer_class->IsInterface()
+ && outer_class->IsSubClass(resolved_method->GetDeclaringClass())) {
// If the outer class is the declaring class or a subclass
// of the declaring class, no class initialization is needed
// before the static method call.