diff options
Diffstat (limited to 'test/843-default-interface/src')
| -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 |
5 files changed, 118 insertions, 0 deletions
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(); +} |