ART: Do not check interface being subclass for member access

When checking access to a protected member, do not try to see
whether an interface is a subclass of the declaring class.

Bug: 16904661

(cherry picked from commit 81db6a7c20aa008c7edbb7377b4bc3a9afe91bb7)

Change-Id: I3e1fa4ce9753e0a96633fff0fba807d72bc0b19d
diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h
index 519685a..2a3f104 100644
--- a/runtime/mirror/class.h
+++ b/runtime/mirror/class.h
@@ -555,7 +555,7 @@
     }
     // Check for protected access from a sub-class, which may or may not be in the same package.
     if (member_flags & kAccProtected) {
-      if (this->IsSubClass(access_to)) {
+      if (!this->IsInterface() && this->IsSubClass(access_to)) {
         return true;
       }
     }
diff --git a/test/026-access/expected.txt b/test/026-access/expected.txt
index dabfb37..89fa21a 100644
--- a/test/026-access/expected.txt
+++ b/test/026-access/expected.txt
@@ -1,2 +1,6 @@
 access test
 Blort.
+1
+2
+3
+5
diff --git a/test/026-access/src/Iface.java b/test/026-access/src/Iface.java
new file mode 100644
index 0000000..24f4b03
--- /dev/null
+++ b/test/026-access/src/Iface.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Another interface.
+ */
+public interface Iface {
+    public final static int X = 1;
+}
diff --git a/test/026-access/src/Iface2.java b/test/026-access/src/Iface2.java
new file mode 100644
index 0000000..d2de3f7
--- /dev/null
+++ b/test/026-access/src/Iface2.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Another interface.
+ */
+public interface Iface2 extends Iface {
+    public final static int Y = Iface.X + 1;
+
+    public final static int A = new Unrelated(3).instance_x;
+    public final static int B = Unrelated.static_x;
+}
diff --git a/test/026-access/src/Main.java b/test/026-access/src/Main.java
index 6b509a3..fe1a1eb 100644
--- a/test/026-access/src/Main.java
+++ b/test/026-access/src/Main.java
@@ -22,5 +22,10 @@
 
         PublicAccess pa = new PublicAccess();
         pa.main();
+
+        System.out.println(Iface.X);
+        System.out.println(Iface2.Y);
+        System.out.println(Iface2.A);
+        System.out.println(Iface2.B);
     }
 }
diff --git a/test/026-access/src/Unrelated.java b/test/026-access/src/Unrelated.java
new file mode 100644
index 0000000..c3e4248
--- /dev/null
+++ b/test/026-access/src/Unrelated.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class Unrelated {
+    protected int instance_x;
+    protected static int static_x = 5;
+
+    protected Unrelated(int x) {
+        instance_x = x;
+    }
+}