blob: 90890a8b6b70cf27ec12cbb3a9fa45c94706a681 [file] [log] [blame]
Roland Levillain06b66d02015-07-01 12:47:25 +01001/*
2 * Copyright (C) 2015 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
17class Main {
18 public static void assertIntEquals(int expected, int result) {
19 if (expected != result) {
20 throw new Error("Expected: " + expected + ", found: " + result);
21 }
22 }
23
24 public static void main(String[] args) {
25 Main m = new Main();
26
27 m.$noinline$SetInstanceField();
28 assertIntEquals(123456, m.i);
29
30 $noinline$SetStaticField();
31 assertIntEquals(456789, s);
32 }
33
Roland Levillain06b66d02015-07-01 12:47:25 +010034 private void $noinline$SetInstanceField() {
Roland Levillain06b66d02015-07-01 12:47:25 +010035 // Set a value than does not fit in a 16-bit (signed) integer.
36 i = 123456;
37 }
38
39 private static void $noinline$SetStaticField() {
Roland Levillain06b66d02015-07-01 12:47:25 +010040 // Set a value than does not fit in a 16-bit (signed) integer.
41 s = 456789;
42 }
43
44 private int i = 0;
45 private static int s = 0;
46}