1 /*
2  * Copyright (C) 2017 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 import java.lang.reflect.Method;
18 import java.lang.reflect.Field;
19 
20 public class Main {
21 
22   // Workaround for b/18051191.
23   class InnerClass {}
24 
main(String[] args)25   public static void main(String[] args) throws Exception {
26     Class<?> c = Class.forName("StoreLoad");
27     Method m = c.getMethod("test", int.class);
28     int result = (Integer)m.invoke(null, 0x12345678);
29     if (result != (0x78 + 0x78)) {
30       throw new Error("Expected 240, got " + result);
31     }
32     m = c.getMethod("test2", int.class);
33     result = (Integer)m.invoke(null, 0xdeadbeef);
34     if (result != 0xdeadbeef) {
35       throw new Error("Expected 0xdeadbeef, got " + result);
36     }
37     Field f = c.getDeclaredField("byteField");
38     byte b = f.getByte(null);
39     if (b != (byte)0xef) {
40       throw new Error("Expected 0xef, got " + b);
41     }
42     f = c.getDeclaredField("byteField2");
43     b = f.getByte(null);
44     if (b != (byte)0x78) {
45       throw new Error("Expected 0xef, got " + b);
46     }
47   }
48 }
49