diff options
Diffstat (limited to 'test/843-default-interface')
| -rw-r--r-- | test/843-default-interface/Android.bp | 50 | ||||
| -rw-r--r-- | test/843-default-interface/expected-stderr.txt | 0 | ||||
| -rw-r--r-- | test/843-default-interface/expected-stdout.txt | 0 | ||||
| -rw-r--r-- | test/843-default-interface/info.txt | 2 | ||||
| -rw-r--r-- | test/843-default-interface/src/Impl.java | 21 | ||||
| -rw-r--r-- | test/843-default-interface/src/Itf.java | 21 | ||||
| -rw-r--r-- | test/843-default-interface/src/Main.java | 29 | ||||
| -rw-r--r-- | test/843-default-interface/src/OtherItf.java | 24 | ||||
| -rw-r--r-- | test/843-default-interface/src/SubItf.java | 23 | ||||
| -rw-r--r-- | test/843-default-interface/src2/OtherItf.java | 21 |
10 files changed, 191 insertions, 0 deletions
diff --git a/test/843-default-interface/Android.bp b/test/843-default-interface/Android.bp new file mode 100644 index 0000000000..ff942e6651 --- /dev/null +++ b/test/843-default-interface/Android.bp @@ -0,0 +1,50 @@ +// Generated by `regen-test-files`. Do not edit manually. + +// Build rules for ART run-test `843-default-interface`. + +package { + // See: http://go/android-license-faq + // A large-scale-change added 'default_applicable_licenses' to import + // all of the 'license_kinds' from "art_license" + // to get the below license kinds: + // SPDX-license-identifier-Apache-2.0 + default_applicable_licenses: ["art_license"], +} + +// Library with src/ sources for the test. +java_library { + name: "art-run-test-843-default-interface-src", + defaults: ["art-run-test-defaults"], + srcs: ["src/**/*.java"], +} + +// Test's Dex code. +java_test { + name: "art-run-test-843-default-interface", + defaults: ["art-run-test-defaults"], + test_config_template: ":art-run-test-target-template", + srcs: ["src2/**/*.java"], + static_libs: [ + "art-run-test-843-default-interface-src" + ], + data: [ + ":art-run-test-843-default-interface-expected-stdout", + ":art-run-test-843-default-interface-expected-stderr", + ], +} + +// Test's expected standard output. +genrule { + name: "art-run-test-843-default-interface-expected-stdout", + out: ["art-run-test-843-default-interface-expected-stdout.txt"], + srcs: ["expected-stdout.txt"], + cmd: "cp -f $(in) $(out)", +} + +// Test's expected standard error. +genrule { + name: "art-run-test-843-default-interface-expected-stderr", + out: ["art-run-test-843-default-interface-expected-stderr.txt"], + srcs: ["expected-stderr.txt"], + cmd: "cp -f $(in) $(out)", +} diff --git a/test/843-default-interface/expected-stderr.txt b/test/843-default-interface/expected-stderr.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/843-default-interface/expected-stderr.txt diff --git a/test/843-default-interface/expected-stdout.txt b/test/843-default-interface/expected-stdout.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/843-default-interface/expected-stdout.txt diff --git a/test/843-default-interface/info.txt b/test/843-default-interface/info.txt new file mode 100644 index 0000000000..3586e7f225 --- /dev/null +++ b/test/843-default-interface/info.txt @@ -0,0 +1,2 @@ +Regression test for ArtMethod::CopyFrom, which used to wrongly override the +imt_index_ of abstract methods with 0. diff --git a/test/843-default-interface/src/Impl.java b/test/843-default-interface/src/Impl.java new file mode 100644 index 0000000000..8c9d76c565 --- /dev/null +++ b/test/843-default-interface/src/Impl.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2022 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 Impl implements SubItf { + public String foo() { + return "Impl"; + } +} diff --git a/test/843-default-interface/src/Itf.java b/test/843-default-interface/src/Itf.java new file mode 100644 index 0000000000..0625429238 --- /dev/null +++ b/test/843-default-interface/src/Itf.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2022 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 Itf { + public default String bar() { + return "Itf"; + } +} diff --git a/test/843-default-interface/src/Main.java b/test/843-default-interface/src/Main.java new file mode 100644 index 0000000000..8b2b2dae92 --- /dev/null +++ b/test/843-default-interface/src/Main.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2022 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 Main { + static SubItf itf = new Impl(); + public static void main(String[] args) throws Exception { + // Loop enough to trigger the native OOME. + for (int i = 0; i < 50000; ++i) { + // Because the imt index was overwritten to 0, this call ended up + // in the conflict trampoline which wrongly updated the 0th entry + // of the imt table. This lead to this call always calling the + // conflict trampoline. + itf.foo(); + } + } +} diff --git a/test/843-default-interface/src/OtherItf.java b/test/843-default-interface/src/OtherItf.java new file mode 100644 index 0000000000..368631c4e6 --- /dev/null +++ b/test/843-default-interface/src/OtherItf.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2022 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 OtherItf { + // javac will complain when compiling SubItf if both superinterfaces Itf and OtherItf + // define a default method bar(), so we do not define bar() here. + // What will be loaded at runtime will actually be src2/OtherItf. + // public default String bar() { + // return "OtherItf"; + // } +} diff --git a/test/843-default-interface/src/SubItf.java b/test/843-default-interface/src/SubItf.java new file mode 100644 index 0000000000..6983b185db --- /dev/null +++ b/test/843-default-interface/src/SubItf.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2022 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. + */ + +// The method bar will be a default conflict for this class. That used to make +// the class linker re-allocate its ArtMethod array, and calling CopyFrom. +// The bug was that CopyFrom was overwriting the imt index of interface methods, +// and for this example `foo`. +public interface SubItf extends Itf, OtherItf { + public String foo(); +} diff --git a/test/843-default-interface/src2/OtherItf.java b/test/843-default-interface/src2/OtherItf.java new file mode 100644 index 0000000000..08028f4ced --- /dev/null +++ b/test/843-default-interface/src2/OtherItf.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2022 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 OtherItf { + public default String bar() { + return "OtherItf"; + } +} |