summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/075-verification-error/expected.txt1
-rw-r--r--test/075-verification-error/src/BadIfaceImpl.java17
-rw-r--r--test/075-verification-error/src/BadInterface.java21
-rw-r--r--test/075-verification-error/src/Main.java14
-rw-r--r--test/075-verification-error/src2/BadInterface.java17
-rw-r--r--test/162-method-resolution/expected.txt3
-rw-r--r--test/162-method-resolution/jasmin/Test10Base.j25
-rw-r--r--test/162-method-resolution/jasmin/Test10User.j36
-rw-r--r--test/162-method-resolution/multidex.jpp10
-rw-r--r--test/162-method-resolution/src/Main.java26
-rw-r--r--test/162-method-resolution/src/Test10Interface.java18
11 files changed, 188 insertions, 0 deletions
diff --git a/test/075-verification-error/expected.txt b/test/075-verification-error/expected.txt
index 6e4f584d3a..7ccc32cbac 100644
--- a/test/075-verification-error/expected.txt
+++ b/test/075-verification-error/expected.txt
@@ -10,3 +10,4 @@ Got expected IllegalAccessError (smethod)
Got expected IllegalAccessError (meth-class)
Got expected IllegalAccessError (field-class)
Got expected IllegalAccessError (meth-meth)
+Got expected IncompatibleClassChangeError (interface)
diff --git a/test/075-verification-error/src/BadIfaceImpl.java b/test/075-verification-error/src/BadIfaceImpl.java
new file mode 100644
index 0000000000..fa2a970127
--- /dev/null
+++ b/test/075-verification-error/src/BadIfaceImpl.java
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2017 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 BadIfaceImpl implements BadInterface { }
diff --git a/test/075-verification-error/src/BadInterface.java b/test/075-verification-error/src/BadInterface.java
new file mode 100644
index 0000000000..439aba467a
--- /dev/null
+++ b/test/075-verification-error/src/BadInterface.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2017 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 interface BadInterface {
+ public default Object internalClone() {
+ throw new Error("Should not be called");
+ }
+}
diff --git a/test/075-verification-error/src/Main.java b/test/075-verification-error/src/Main.java
index 3f2881eb10..13aeaee7e4 100644
--- a/test/075-verification-error/src/Main.java
+++ b/test/075-verification-error/src/Main.java
@@ -28,6 +28,20 @@ public class Main {
testClassNewInstance();
testMissingStuff();
testBadAccess();
+ testBadInterfaceMethod();
+ }
+ /**
+ * Try to create and invoke a non-existant interface method.
+ */
+ static void testBadInterfaceMethod() {
+ BadInterface badiface = new BadIfaceImpl();
+ try {
+ badiface.internalClone();
+ } catch (IncompatibleClassChangeError icce) {
+ // TODO b/64274113 This should really be an NSME
+ System.out.println("Got expected IncompatibleClassChangeError (interface)");
+ if (VERBOSE) System.out.println("--- " + icce);
+ }
}
/**
diff --git a/test/075-verification-error/src2/BadInterface.java b/test/075-verification-error/src2/BadInterface.java
new file mode 100644
index 0000000000..5d939cb264
--- /dev/null
+++ b/test/075-verification-error/src2/BadInterface.java
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2017 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 interface BadInterface { }
+
diff --git a/test/162-method-resolution/expected.txt b/test/162-method-resolution/expected.txt
index 1bf39c90de..9b48a4cc8f 100644
--- a/test/162-method-resolution/expected.txt
+++ b/test/162-method-resolution/expected.txt
@@ -41,3 +41,6 @@ Test9Derived.foo()
Calling Test9User2.test():
Caught java.lang.reflect.InvocationTargetException
caused by java.lang.IncompatibleClassChangeError
+Calling Test10User.test():
+Caught java.lang.reflect.InvocationTargetException
+ caused by java.lang.IncompatibleClassChangeError
diff --git a/test/162-method-resolution/jasmin/Test10Base.j b/test/162-method-resolution/jasmin/Test10Base.j
new file mode 100644
index 0000000000..628f38d6d5
--- /dev/null
+++ b/test/162-method-resolution/jasmin/Test10Base.j
@@ -0,0 +1,25 @@
+; Copyright (C) 2017 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 Test10Base
+.super java/lang/Object
+.implements Test10Interface
+
+.method public <init>()V
+ .limit stack 1
+ .limit locals 1
+ aload_0
+ invokespecial java/lang/Object/<init>()V
+ return
+.end method
diff --git a/test/162-method-resolution/jasmin/Test10User.j b/test/162-method-resolution/jasmin/Test10User.j
new file mode 100644
index 0000000000..6beadaba12
--- /dev/null
+++ b/test/162-method-resolution/jasmin/Test10User.j
@@ -0,0 +1,36 @@
+; Copyright (C) 2017 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 Test10User
+.super java/lang/Object
+
+.method public static test()V
+ .limit stack 3
+ .limit locals 3
+ new Test10Base
+ dup
+ invokespecial Test10Base.<init>()V
+ invokestatic Test10User.doInvoke(LTest10Interface;)V
+ return
+.end method
+
+.method public static doInvoke(LTest10Interface;)V
+ .limit stack 3
+ .limit locals 3
+ aload_0
+ invokeinterface Test10Interface.clone()Ljava.lang.Object; 1
+ pop
+ return
+.end method
+
diff --git a/test/162-method-resolution/multidex.jpp b/test/162-method-resolution/multidex.jpp
index 22e3aeeadc..5722f7f1d8 100644
--- a/test/162-method-resolution/multidex.jpp
+++ b/test/162-method-resolution/multidex.jpp
@@ -112,6 +112,16 @@ Test9User2:
@@com.android.jack.annotations.ForceInMainDex
class Test9User2
+Test10Base:
+ @@com.android.jack.annotations.ForceInMainDex
+ class Test10Base
+Test10Interface:
+ @@com.android.jack.annotations.ForceInMainDex
+ class Test10Interface
+Test10User:
+ @@com.android.jack.annotations.ForceInMainDex
+ class Test10User
+
Main:
@@com.android.jack.annotations.ForceInMainDex
class Main
diff --git a/test/162-method-resolution/src/Main.java b/test/162-method-resolution/src/Main.java
index fa95aa755c..864c87850b 100644
--- a/test/162-method-resolution/src/Main.java
+++ b/test/162-method-resolution/src/Main.java
@@ -36,6 +36,7 @@ public class Main {
test7();
test8();
test9();
+ test10();
// TODO: How to test that interface method resolution returns the unique
// maximally-specific non-abstract superinterface method if there is one?
@@ -376,6 +377,31 @@ public class Main {
invokeUserTest("Test9User2");
}
+ /*
+ * Test10
+ * -----
+ * Tested function:
+ * public class Test10Base implements Test10Interface { }
+ * public interface Test10Interface { }
+ * Tested invokes:
+ * invoke-interface Test10Interface.clone()Ljava/lang/Object; from Test10Caller in first dex
+ * TODO b/64274113 This should throw a NSME (JLS 13.4.12) but actually throws an ICCE.
+ * expected: Throws NoSuchMethodError (JLS 13.4.12)
+ * actual: Throws IncompatibleClassChangeError
+ *
+ * This test is simulating compiling Test10Interface with "public Object clone()" method, along
+ * with every other class. Then we delete "clone" from Test10Interface only, which under JLS
+ * 13.4.12 is expected to be binary incompatible and throw a NoSuchMethodError.
+ *
+ * Files:
+ * jasmin/Test10Base.j - implements Test10Interface
+ * jasmin/Test10Interface.java - defines empty interface
+ * jasmin/Test10User.j - invokeinterface Test10Interface.clone()Ljava/lang/Object;
+ */
+ private static void test10() throws Exception {
+ invokeUserTest("Test10User");
+ }
+
private static void invokeUserTest(String userName) throws Exception {
System.out.println("Calling " + userName + ".test():");
try {
diff --git a/test/162-method-resolution/src/Test10Interface.java b/test/162-method-resolution/src/Test10Interface.java
new file mode 100644
index 0000000000..3c75ea59be
--- /dev/null
+++ b/test/162-method-resolution/src/Test10Interface.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2017 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 interface Test10Interface { }
+