1 /*
2  * Copyright (C) 2023 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 public class Main {
18   public float myFloatField = 42f;
19   public double myDoubleField = 42d;
20   public boolean myBooleanField = true;
21 
returnFloat()22   public float returnFloat() {
23     return myFloatField;
24   }
25 
returnDouble()26   public double returnDouble() {
27     return myDoubleField;
28   }
29 
returnBoolean()30   public boolean returnBoolean() {
31     return myBooleanField;
32   }
33 
assertEquals(float a, float b)34   public static void assertEquals(float a, float b) {
35     if (a != b) {
36       throw new Error("Expected " + a + ", got " + b);
37     }
38   }
39 
assertEquals(double a, double b)40   public static void assertEquals(double a, double b) {
41     if (a != b) {
42       throw new Error("Expected " + a + ", got " + b);
43     }
44   }
45 
assertEquals(boolean a, boolean b)46   public static void assertEquals(boolean a, boolean b) {
47     if (a != b) {
48       throw new Error("Expected " + a + ", got " + b);
49     }
50   }
51 
main(String[] args)52   public static void main(String[] args) {
53     System.loadLibrary(args[0]);
54     ensureJitBaselineCompiled(Main.class, "returnFloat");
55     ensureJitBaselineCompiled(Main.class, "returnDouble");
56     ensureJitBaselineCompiled(Main.class, "returnBoolean");
57     Main m = new Main();
58     assertEquals(m.myFloatField, m.returnFloat());
59     assertEquals(m.myDoubleField, m.returnDouble());
60     assertEquals(m.myBooleanField, m.returnBoolean());
61   }
62 
ensureJitBaselineCompiled(Class<?> cls, String methodName)63   public static native void ensureJitBaselineCompiled(Class<?> cls, String methodName);
64 }
65