Field_set01.java revision 12651:6ef01bd40ce2
1/*
2 * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23package org.graalvm.compiler.jtt.reflect;
24
25import org.junit.Test;
26
27import org.graalvm.compiler.jtt.JTTTest;
28
29/*
30 */
31public class Field_set01 extends JTTTest {
32
33    public static byte byteField;
34    public static short shortField;
35    public static char charField;
36    public static int intField;
37    public static long longField;
38    public static float floatField;
39    public static double doubleField;
40    public static boolean booleanField;
41
42    public static boolean test(int arg) throws NoSuchFieldException, IllegalAccessException {
43        if (arg == 0) {
44            Field_set01.class.getField("byteField").set(null, Byte.valueOf((byte) 11));
45            return byteField == 11;
46        } else if (arg == 1) {
47            Field_set01.class.getField("shortField").set(null, Short.valueOf((short) 12));
48            return shortField == 12;
49        } else if (arg == 2) {
50            Field_set01.class.getField("charField").set(null, Character.valueOf((char) 13));
51            return charField == 13;
52        } else if (arg == 3) {
53            Field_set01.class.getField("intField").set(null, Integer.valueOf(14));
54            return intField == 14;
55        } else if (arg == 4) {
56            Field_set01.class.getField("longField").set(null, Long.valueOf(15L));
57            return longField == 15;
58        } else if (arg == 5) {
59            Field_set01.class.getField("floatField").set(null, Float.valueOf(16));
60            return floatField == 16;
61        } else if (arg == 6) {
62            Field_set01.class.getField("doubleField").set(null, Double.valueOf(17));
63            return doubleField == 17;
64        } else if (arg == 7) {
65            Field_set01.class.getField("booleanField").set(null, true);
66            return booleanField == true;
67        }
68        return false;
69    }
70
71    @Test
72    public void run0() throws Throwable {
73        runTest("test", 0);
74    }
75
76    @Test
77    public void run1() throws Throwable {
78        runTest("test", 1);
79    }
80
81    @Test
82    public void run2() throws Throwable {
83        runTest("test", 2);
84    }
85
86    @Test
87    public void run3() throws Throwable {
88        runTest("test", 3);
89    }
90
91    @Test
92    public void run4() throws Throwable {
93        runTest("test", 4);
94    }
95
96    @Test
97    public void run5() throws Throwable {
98        runTest("test", 5);
99    }
100
101    @Test
102    public void run6() throws Throwable {
103        runTest("test", 6);
104    }
105
106    @Test
107    public void run7() throws Throwable {
108        runTest("test", 7);
109    }
110
111    @Test
112    public void run8() throws Throwable {
113        runTest("test", 8);
114    }
115
116}
117