xref: /aosp_15_r20/art/test/542-unresolved-access-check/src/p1/InP1.java (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1*795d594fSAndroid Build Coastguard Worker /*
2*795d594fSAndroid Build Coastguard Worker  * Copyright (C) 2015 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 package p1;
18*795d594fSAndroid Build Coastguard Worker 
19*795d594fSAndroid Build Coastguard Worker public class InP1 {
$inline$AllocateOtherInP1(int i)20*795d594fSAndroid Build Coastguard Worker     public static Object $inline$AllocateOtherInP1(int i) {
21*795d594fSAndroid Build Coastguard Worker       // Let this method execute a while to make sure the JIT sees it hot.
22*795d594fSAndroid Build Coastguard Worker       if (i <= 10000) {
23*795d594fSAndroid Build Coastguard Worker         return null;
24*795d594fSAndroid Build Coastguard Worker       }
25*795d594fSAndroid Build Coastguard Worker       // Set the flag that we have entered InP1 code to get OtherInP1 loaded.
26*795d594fSAndroid Build Coastguard Worker       PlaceHolder.entered = true;
27*795d594fSAndroid Build Coastguard Worker       return new OtherInP1();
28*795d594fSAndroid Build Coastguard Worker     }
29*795d594fSAndroid Build Coastguard Worker 
$inline$AllocateArrayOtherInP1(int i)30*795d594fSAndroid Build Coastguard Worker     public static Object $inline$AllocateArrayOtherInP1(int i) {
31*795d594fSAndroid Build Coastguard Worker       if (i <= 10000) {
32*795d594fSAndroid Build Coastguard Worker         return null;
33*795d594fSAndroid Build Coastguard Worker       }
34*795d594fSAndroid Build Coastguard Worker       return new OtherInP1[10];
35*795d594fSAndroid Build Coastguard Worker     }
36*795d594fSAndroid Build Coastguard Worker 
$inline$UseStaticFieldOtherInP1(int i)37*795d594fSAndroid Build Coastguard Worker     public static Object $inline$UseStaticFieldOtherInP1(int i) {
38*795d594fSAndroid Build Coastguard Worker       if (i <= 10000) {
39*795d594fSAndroid Build Coastguard Worker         return null;
40*795d594fSAndroid Build Coastguard Worker       }
41*795d594fSAndroid Build Coastguard Worker       return OtherInP1.staticField;
42*795d594fSAndroid Build Coastguard Worker     }
43*795d594fSAndroid Build Coastguard Worker 
$inline$SetStaticFieldOtherInP1(int i)44*795d594fSAndroid Build Coastguard Worker     public static void $inline$SetStaticFieldOtherInP1(int i) {
45*795d594fSAndroid Build Coastguard Worker       if (i <= 10000) {
46*795d594fSAndroid Build Coastguard Worker         return;
47*795d594fSAndroid Build Coastguard Worker       }
48*795d594fSAndroid Build Coastguard Worker       OtherInP1.staticField = new Object();
49*795d594fSAndroid Build Coastguard Worker     }
50*795d594fSAndroid Build Coastguard Worker 
$inline$UseInstanceFieldOtherInP1(int i)51*795d594fSAndroid Build Coastguard Worker     public static Object $inline$UseInstanceFieldOtherInP1(int i) {
52*795d594fSAndroid Build Coastguard Worker       if (i <= 10000) {
53*795d594fSAndroid Build Coastguard Worker         return null;
54*795d594fSAndroid Build Coastguard Worker       }
55*795d594fSAndroid Build Coastguard Worker       return $noinline$AllocateOtherInP1().instanceField;
56*795d594fSAndroid Build Coastguard Worker     }
57*795d594fSAndroid Build Coastguard Worker 
$inline$SetInstanceFieldOtherInP1(int i)58*795d594fSAndroid Build Coastguard Worker     public static void $inline$SetInstanceFieldOtherInP1(int i) {
59*795d594fSAndroid Build Coastguard Worker       if (i <= 10000) {
60*795d594fSAndroid Build Coastguard Worker         return;
61*795d594fSAndroid Build Coastguard Worker       }
62*795d594fSAndroid Build Coastguard Worker       $noinline$AllocateOtherInP1().instanceField = new Object();
63*795d594fSAndroid Build Coastguard Worker     }
64*795d594fSAndroid Build Coastguard Worker 
$noinline$AllocateOtherInP1()65*795d594fSAndroid Build Coastguard Worker     public static OtherInP1 $noinline$AllocateOtherInP1() {
66*795d594fSAndroid Build Coastguard Worker       try {
67*795d594fSAndroid Build Coastguard Worker         return new OtherInP1();
68*795d594fSAndroid Build Coastguard Worker       } catch (Exception e) {
69*795d594fSAndroid Build Coastguard Worker         throw new Error(e);
70*795d594fSAndroid Build Coastguard Worker       }
71*795d594fSAndroid Build Coastguard Worker     }
72*795d594fSAndroid Build Coastguard Worker 
$inline$LoadOtherInP1(int i)73*795d594fSAndroid Build Coastguard Worker     public static Object $inline$LoadOtherInP1(int i) {
74*795d594fSAndroid Build Coastguard Worker       if (i <= 10000) {
75*795d594fSAndroid Build Coastguard Worker         return null;
76*795d594fSAndroid Build Coastguard Worker       }
77*795d594fSAndroid Build Coastguard Worker       return OtherInP1.class;
78*795d594fSAndroid Build Coastguard Worker     }
79*795d594fSAndroid Build Coastguard Worker 
$inline$StaticCallOtherInP1(int i)80*795d594fSAndroid Build Coastguard Worker     public static Object $inline$StaticCallOtherInP1(int i) {
81*795d594fSAndroid Build Coastguard Worker       if (i <= 10000) {
82*795d594fSAndroid Build Coastguard Worker         return null;
83*795d594fSAndroid Build Coastguard Worker       }
84*795d594fSAndroid Build Coastguard Worker       return OtherInP1.doTheStaticCall();
85*795d594fSAndroid Build Coastguard Worker     }
86*795d594fSAndroid Build Coastguard Worker 
$inline$InstanceCallOtherInP1(int i)87*795d594fSAndroid Build Coastguard Worker     public static Object $inline$InstanceCallOtherInP1(int i) {
88*795d594fSAndroid Build Coastguard Worker       if (i <= 10000) {
89*795d594fSAndroid Build Coastguard Worker         return null;
90*795d594fSAndroid Build Coastguard Worker       }
91*795d594fSAndroid Build Coastguard Worker       return $noinline$AllocateOtherInP1().doTheInstanceCall();
92*795d594fSAndroid Build Coastguard Worker     }
93*795d594fSAndroid Build Coastguard Worker }
94