summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/verifier/method_verifier.cc10
-rw-r--r--test/735-interface-clone/expected-stderr.txt0
-rw-r--r--test/735-interface-clone/expected-stdout.txt0
-rw-r--r--test/735-interface-clone/info.txt1
-rw-r--r--test/735-interface-clone/smali/Cls.smali23
-rw-r--r--test/735-interface-clone/smali/Itf.smali22
-rw-r--r--test/735-interface-clone/src/Main.java31
7 files changed, 87 insertions, 0 deletions
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index 15ca562978..bf5ec7b745 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -4238,6 +4238,16 @@ ArtMethod* MethodVerifierImpl::ResolveMethodAndCheckAccess(
<< " is in an interface class " << klass->PrettyClass();
return nullptr;
}
+ if (method_type == METHOD_SUPER &&
+ res_method->GetDeclaringClass()->IsObjectClass()) {
+ Fail(VERIFY_ERROR_NO_METHOD) << "invoke-super " << klass->PrettyDescriptor() << "."
+ << dex_file_->GetMethodName(method_id) << " "
+ << dex_file_->GetMethodSignature(method_id) << " resolved to "
+ << "object method " << res_method->PrettyMethod() << " "
+ << "but Object methods are excluded from super "
+ << "method resolution on interfaces.";
+ return nullptr;
+ }
} else {
if (method_type == METHOD_INTERFACE) {
Fail(VERIFY_ERROR_CLASS_CHANGE)
diff --git a/test/735-interface-clone/expected-stderr.txt b/test/735-interface-clone/expected-stderr.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/735-interface-clone/expected-stderr.txt
diff --git a/test/735-interface-clone/expected-stdout.txt b/test/735-interface-clone/expected-stdout.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/735-interface-clone/expected-stdout.txt
diff --git a/test/735-interface-clone/info.txt b/test/735-interface-clone/info.txt
new file mode 100644
index 0000000000..6a4ac1de2e
--- /dev/null
+++ b/test/735-interface-clone/info.txt
@@ -0,0 +1 @@
+Regression test calling super.clone from an interface method.
diff --git a/test/735-interface-clone/smali/Cls.smali b/test/735-interface-clone/smali/Cls.smali
new file mode 100644
index 0000000000..df8a0c2cd1
--- /dev/null
+++ b/test/735-interface-clone/smali/Cls.smali
@@ -0,0 +1,23 @@
+# Copyright (C) 2025 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.
+
+.class LCls;
+.super Ljava/lang/Object;
+.implements LItf;
+
+.method public constructor <init>()V
+.registers 2
+ invoke-direct {v1}, Ljava/lang/Object;-><init>()V
+ return-void
+.end method
diff --git a/test/735-interface-clone/smali/Itf.smali b/test/735-interface-clone/smali/Itf.smali
new file mode 100644
index 0000000000..891a56195a
--- /dev/null
+++ b/test/735-interface-clone/smali/Itf.smali
@@ -0,0 +1,22 @@
+# Copyright (C) 2025 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.
+
+.class public abstract interface LItf;
+.super Ljava/lang/Object;
+
+.method public doClone()V
+.registers 1
+ invoke-super {p0}, LItf;->clone()Ljava/lang/Object;
+ return-void
+.end method
diff --git a/test/735-interface-clone/src/Main.java b/test/735-interface-clone/src/Main.java
new file mode 100644
index 0000000000..8e7cd008b0
--- /dev/null
+++ b/test/735-interface-clone/src/Main.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2025 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.
+ */
+
+import java.lang.reflect.InvocationTargetException;
+
+public class Main {
+
+ public static void main(String[] args) throws Exception {
+ Class<?> cls = Class.forName("Cls");
+ try {
+ cls.getMethod("doClone").invoke(cls.newInstance(), null);
+ } catch (InvocationTargetException e) {
+ if (!(e.getCause() instanceof IncompatibleClassChangeError)) {
+ throw new Error("Expected IncompatibleClassChangeError, got " + e.getCause());
+ }
+ }
+ }
+}