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