1*795d594fSAndroid Build Coastguard WorkerTests the fix for b/74116990 2*795d594fSAndroid Build Coastguard Worker 3*795d594fSAndroid Build Coastguard WorkerThe JIT was reading into incorrect dex files during class redefinition if a 4*795d594fSAndroid Build Coastguard Workernative method was present. 5*795d594fSAndroid Build Coastguard Worker 6*795d594fSAndroid Build Coastguard WorkerThe transformed dex file is specifically crafted to have exactly 4 methodIDs in 7*795d594fSAndroid Build Coastguard Workerit. They are (in order): 8*795d594fSAndroid Build Coastguard Worker (0) Ljava/lang/Object;-><init>()V 9*795d594fSAndroid Build Coastguard Worker (1) Lxyz/Transform;-><init>()V 10*795d594fSAndroid Build Coastguard Worker (2) Lxyz/Transform;->bar()V 11*795d594fSAndroid Build Coastguard Worker (3) Lxyz/Transform;->foo()V 12*795d594fSAndroid Build Coastguard Worker 13*795d594fSAndroid Build Coastguard WorkerIn the transformed version of the dex file there is a new method. The new list of methodIDs is: 14*795d594fSAndroid Build Coastguard Worker (0) Lart/Test1949;->doNothing()V 15*795d594fSAndroid Build Coastguard Worker (1) Ljava/lang/Object;-><init>()V 16*795d594fSAndroid Build Coastguard Worker (2) Lxyz/Transform;-><init>()V 17*795d594fSAndroid Build Coastguard Worker (3) Lxyz/Transform;->bar()V 18*795d594fSAndroid Build Coastguard Worker (4) Lxyz/Transform;->foo()V 19*795d594fSAndroid Build Coastguard Worker 20*795d594fSAndroid Build Coastguard WorkerThis test tries to get the JIT to read out-of-bounds on the initial dex file by getting it to 21*795d594fSAndroid Build Coastguard Workerread the 5th method id of the new file (Lxyz/Transform;->foo()V) from the old dex file (which 22*795d594fSAndroid Build Coastguard Workeronly has 4 method ids). 23*795d594fSAndroid Build Coastguard Worker 24*795d594fSAndroid Build Coastguard WorkerTo do this we need to make sure that the class being transformed is near the end of the 25*795d594fSAndroid Build Coastguard Workeralphabet (package xyz, method foo). If it is further forward than the other method-ids then the 26*795d594fSAndroid Build Coastguard WorkerJIT will read an incorrect (but valid) method-id from the old-dex file. This is why the error 27*795d594fSAndroid Build Coastguard Workerwasn't caught in our other tests (package art is always at the front). 28*795d594fSAndroid Build Coastguard Worker 29*795d594fSAndroid Build Coastguard WorkerThe final method that causes the OOB read needs to be a native method because that is the only 30*795d594fSAndroid Build Coastguard Workermethod-type the jit uses dex-file information to keep track of. 31