1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 18 // Define enough methods to enter the conflict trampoline. 19 interface Itf { $noinline$def1()20 default int $noinline$def1() { return 42; } $noinline$def2()21 default int $noinline$def2() { return 42; } $noinline$def3()22 default int $noinline$def3() { return 42; } $noinline$def4()23 default int $noinline$def4() { return 42; } $noinline$def5()24 default int $noinline$def5() { return 42; } $noinline$def6()25 default int $noinline$def6() { return 42; } $noinline$def7()26 default int $noinline$def7() { return 42; } $noinline$def8()27 default int $noinline$def8() { return 42; } $noinline$def9()28 default int $noinline$def9() { return 42; } $noinline$def10()29 default int $noinline$def10() { return 42; } $noinline$def11()30 default int $noinline$def11() { return 42; } $noinline$def12()31 default int $noinline$def12() { return 42; } $noinline$def13()32 default int $noinline$def13() { return 42; } $noinline$def14()33 default int $noinline$def14() { return 42; } $noinline$def15()34 default int $noinline$def15() { return 42; } $noinline$def16()35 default int $noinline$def16() { return 42; } $noinline$def17()36 default int $noinline$def17() { return 42; } $noinline$def18()37 default int $noinline$def18() { return 42; } $noinline$def19()38 default int $noinline$def19() { return 42; } $noinline$def20()39 default int $noinline$def20() { return 42; } $noinline$def21()40 default int $noinline$def21() { return 42; } $noinline$def22()41 default int $noinline$def22() { return 42; } 42 43 // Known name conflict in OC-dev. $noinline$defAa()44 default int $noinline$defAa() { return 42; } $noinline$defbb()45 default int $noinline$defbb() { return 42; } 46 } 47 48 // Define an abstract class so that the super calls in Main.instanceMethod 49 // end up finding the miranda method (which was then wrongly stashed into 50 // the dex cache). 51 class AbstractItf implements Itf { 52 } 53 54 55 public class Main extends AbstractItf { 56 static Itf itf = new Main(); main(String[] args)57 public static void main(String[] args) throws Exception { 58 new Main().instanceMethod(); 59 } 60 instanceMethod()61 public void instanceMethod() { 62 // Do super calls to invoke artQuickResolutionTrampoline, which used to 63 // put the copied method AbstractIf.<name> into the slot for the MethodId 64 // referencing the Itf method. 65 super.$noinline$def1(); 66 super.$noinline$def2(); 67 super.$noinline$def3(); 68 super.$noinline$def4(); 69 super.$noinline$def5(); 70 super.$noinline$def6(); 71 super.$noinline$def7(); 72 super.$noinline$def8(); 73 super.$noinline$def9(); 74 super.$noinline$def10(); 75 super.$noinline$def11(); 76 super.$noinline$def12(); 77 super.$noinline$def13(); 78 super.$noinline$def14(); 79 super.$noinline$def15(); 80 super.$noinline$def16(); 81 super.$noinline$def17(); 82 super.$noinline$def18(); 83 super.$noinline$def19(); 84 super.$noinline$def20(); 85 super.$noinline$def21(); 86 super.$noinline$def22(); 87 super.$noinline$defAa(); 88 super.$noinline$defbb(); 89 90 // Now call the same methods but through an invoke-interface, which used to crash 91 // if the wrong method was in the dex cache. 92 itf.$noinline$def1(); 93 itf.$noinline$def2(); 94 itf.$noinline$def3(); 95 itf.$noinline$def4(); 96 itf.$noinline$def5(); 97 itf.$noinline$def6(); 98 itf.$noinline$def7(); 99 itf.$noinline$def8(); 100 itf.$noinline$def9(); 101 itf.$noinline$def10(); 102 itf.$noinline$def11(); 103 itf.$noinline$def12(); 104 itf.$noinline$def13(); 105 itf.$noinline$def14(); 106 itf.$noinline$def15(); 107 itf.$noinline$def16(); 108 itf.$noinline$def17(); 109 itf.$noinline$def18(); 110 itf.$noinline$def19(); 111 itf.$noinline$def20(); 112 itf.$noinline$def21(); 113 itf.$noinline$def22(); 114 itf.$noinline$defAa(); 115 itf.$noinline$defbb(); 116 } 117 } 118