diff options
author | Ian Rogers <irogers@google.com> | 2012-01-18 22:11:47 -0800 |
---|---|---|
committer | Ian Rogers <irogers@google.com> | 2012-01-18 22:35:30 -0800 |
commit | 94c0e33ac8773f250564cd024647a65c23761fb3 (patch) | |
tree | 29bdbd1c0a5d23cc3850dc60a3bc911cc18b10d2 /test/022-interface | |
parent | c20a83e440557924dacaf8ec519e086865aaf5a5 (diff) | |
download | art-94c0e33ac8773f250564cd024647a65c23761fb3.zip art-94c0e33ac8773f250564cd024647a65c23761fb3.tar.gz art-94c0e33ac8773f250564cd024647a65c23761fb3.tar.bz2 |
Interface dispatch bug
Interface methods should bind to the lowest sub-interface. Only search
declared methods in a class before trying to find the interface method
via the iftables.
Unit test that declares toString in an concrete class, where toString
has been made an interface method in CharSequence. ecj compiles this
method call into an invokeinterface (hence the custom build).
Change-Id: Iefa394c9e7a22da9c6ea58f07a77880102c2f966
Diffstat (limited to 'test/022-interface')
-rw-r--r-- | test/022-interface/build | 24 | ||||
-rw-r--r-- | test/022-interface/classes/Iface1.class | bin | 0 -> 389 bytes | |||
-rw-r--r-- | test/022-interface/classes/Iface2.class | bin | 0 -> 117 bytes | |||
-rw-r--r-- | test/022-interface/classes/Iface2Sub1.class | bin | 0 -> 142 bytes | |||
-rw-r--r-- | test/022-interface/classes/ImplA.class | bin | 0 -> 321 bytes | |||
-rw-r--r-- | test/022-interface/classes/ImplB.class | bin | 0 -> 506 bytes | |||
-rw-r--r-- | test/022-interface/classes/ImplBSub.class | bin | 0 -> 309 bytes | |||
-rw-r--r-- | test/022-interface/classes/Main$1.class | bin | 0 -> 757 bytes | |||
-rw-r--r-- | test/022-interface/classes/Main.class | bin | 0 -> 1307 bytes | |||
-rw-r--r-- | test/022-interface/classes/ObjectOverridingInterface.class | bin | 0 -> 227 bytes | |||
-rw-r--r-- | test/022-interface/expected.txt | 1 | ||||
-rw-r--r-- | test/022-interface/src/Main.java | 41 | ||||
-rw-r--r-- | test/022-interface/src/ObjectOverridingInterface.java | 23 |
13 files changed, 88 insertions, 1 deletions
diff --git a/test/022-interface/build b/test/022-interface/build new file mode 100644 index 0000000..37da755 --- /dev/null +++ b/test/022-interface/build @@ -0,0 +1,24 @@ +#!/bin/bash +# +# Copyright (C) 2012 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. + +# Stop if something fails. +set -e + +# Use classes that are compiled with ecj that exposes an invokeinterface +# issue when interfaces override methods in Object +dx --debug --dex --dump-to=classes.lst --output=classes.dex classes +zip ${ANDROID_PRODUCT_OUT}/data/art-test/$TEST_NAME.jar classes.dex +dex2oat --boot-image=${ANDROID_PRODUCT_OUT}/data/art-test/core.art --dex-file=${ANDROID_PRODUCT_OUT}/data/art-test/$TEST_NAME.jar --oat-file=${ANDROID_PRODUCT_OUT}/data/art-test/$TEST_NAME.oat diff --git a/test/022-interface/classes/Iface1.class b/test/022-interface/classes/Iface1.class Binary files differnew file mode 100644 index 0000000..d11704c --- /dev/null +++ b/test/022-interface/classes/Iface1.class diff --git a/test/022-interface/classes/Iface2.class b/test/022-interface/classes/Iface2.class Binary files differnew file mode 100644 index 0000000..6160a61 --- /dev/null +++ b/test/022-interface/classes/Iface2.class diff --git a/test/022-interface/classes/Iface2Sub1.class b/test/022-interface/classes/Iface2Sub1.class Binary files differnew file mode 100644 index 0000000..6d3b8d2 --- /dev/null +++ b/test/022-interface/classes/Iface2Sub1.class diff --git a/test/022-interface/classes/ImplA.class b/test/022-interface/classes/ImplA.class Binary files differnew file mode 100644 index 0000000..de175bf --- /dev/null +++ b/test/022-interface/classes/ImplA.class diff --git a/test/022-interface/classes/ImplB.class b/test/022-interface/classes/ImplB.class Binary files differnew file mode 100644 index 0000000..951bebd --- /dev/null +++ b/test/022-interface/classes/ImplB.class diff --git a/test/022-interface/classes/ImplBSub.class b/test/022-interface/classes/ImplBSub.class Binary files differnew file mode 100644 index 0000000..1c1dcfd --- /dev/null +++ b/test/022-interface/classes/ImplBSub.class diff --git a/test/022-interface/classes/Main$1.class b/test/022-interface/classes/Main$1.class Binary files differnew file mode 100644 index 0000000..301dde0 --- /dev/null +++ b/test/022-interface/classes/Main$1.class diff --git a/test/022-interface/classes/Main.class b/test/022-interface/classes/Main.class Binary files differnew file mode 100644 index 0000000..d9f22f7 --- /dev/null +++ b/test/022-interface/classes/Main.class diff --git a/test/022-interface/classes/ObjectOverridingInterface.class b/test/022-interface/classes/ObjectOverridingInterface.class Binary files differnew file mode 100644 index 0000000..e9e8db5 --- /dev/null +++ b/test/022-interface/classes/ObjectOverridingInterface.class diff --git a/test/022-interface/expected.txt b/test/022-interface/expected.txt index 1212663..e627b69 100644 --- a/test/022-interface/expected.txt +++ b/test/022-interface/expected.txt @@ -1,2 +1,3 @@ ImplBSub intf: 205 ImplA: 7 +objectOverrideTests: SUCCESS diff --git a/test/022-interface/src/Main.java b/test/022-interface/src/Main.java index 9151e89..3c3c21a 100644 --- a/test/022-interface/src/Main.java +++ b/test/022-interface/src/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 The Android Open Source Project + * Copyright (C) 2012 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. @@ -33,5 +33,44 @@ public class Main { result = faceObj2.iFunc2(5); System.out.print("ImplA: "); System.out.println(result); + + objectOverrideTests(); + } + + static void check(boolean z) { + if (!z) { + throw new AssertionError(); } + } + + static void objectOverrideTests() { + ObjectOverridingInterface o = + new ObjectOverridingInterface() { + public boolean equals(Object o) { + return true; + } + public int hashCode() { + return 0xC001D00D; + } + public String toString() { + return "Mallet's Mallet"; + } + public int length() { + return toString().length(); + } + public char charAt(int i) { + return toString().charAt(i); + } + public CharSequence subSequence(int s, int e) { + return toString().subSequence(s, e); + } + }; + doObjectOverrideTests(o); + } + static void doObjectOverrideTests(ObjectOverridingInterface o) { + check(o.equals(null)); + check(o.hashCode() == 0xC001D00D); + check(o.toString().equals("Mallet's Mallet")); + System.out.println("objectOverrideTests: SUCCESS"); + } } diff --git a/test/022-interface/src/ObjectOverridingInterface.java b/test/022-interface/src/ObjectOverridingInterface.java new file mode 100644 index 0000000..a44cdf5 --- /dev/null +++ b/test/022-interface/src/ObjectOverridingInterface.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2012 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. + */ + +/** + * Interface methods that override those of Object, the parent of all interfaces + */ +public interface ObjectOverridingInterface extends CharSequence { + public boolean equals(Object o); + public int hashCode(); +} |