1 /*
2  * Copyright (C) 2016 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.Field;
18 import java.lang.reflect.Method;
19 import java.lang.reflect.InvocationTargetException;
20 
21 public class Main {
22   // Workaround for b/18051191.
23   class Inner {}
24 
25   public static boolean field0;
26   public static boolean field1;
27   public static boolean field2;
28 
assertTrue(boolean result)29   public static void assertTrue(boolean result) {
30     if (!result) {
31       throw new Error("Expected true");
32     }
33   }
34 
assertFalse(boolean result)35   public static void assertFalse(boolean result) {
36     if (result) {
37       throw new Error("Expected false");
38     }
39   }
40 
main(String[] args)41   public static void main(String[] args) throws Throwable {
42     Class<?> c = Class.forName("TestCase");
43     Method m = c.getMethod("testCase");
44 
45     try {
46       field0 = true;
47       field1 = false;
48       assertTrue((Boolean) m.invoke(null, null));
49 
50       field0 = true;
51       field1 = true;
52       assertTrue((Boolean) m.invoke(null, null));
53 
54       field0 = false;
55       field1 = false;
56       assertFalse((Boolean) m.invoke(null, null));
57     } catch (Exception e) {
58       throw new Error(e);
59     }
60   }
61 }
62