001/*
002 * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation.
008 *
009 * This code is distributed in the hope that it will be useful, but WITHOUT
010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
011 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
012 * version 2 for more details (a copy is included in the LICENSE file that
013 * accompanied this code).
014 *
015 * You should have received a copy of the GNU General Public License version
016 * 2 along with this work; if not, write to the Free Software Foundation,
017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
018 *
019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
020 * or visit www.oracle.com if you need additional information or have any
021 * questions.
022 */
023package com.oracle.graal.jtt.reflect;
024
025import java.lang.reflect.*;
026
027import org.junit.*;
028
029import com.oracle.graal.jtt.*;
030
031/*
032 */
033public class Field_get03 extends JTTTest {
034
035    private static Field ByteField;
036    private static Field ShortField;
037    private static Field CharField;
038    private static Field IntField;
039    private static Field LongField;
040    private static Field FloatField;
041    private static Field DoubleField;
042    private static Field BooleanField;
043
044    static {
045        try {
046            ByteField = TestClass.class.getField("byteField");
047            ShortField = TestClass.class.getField("shortField");
048            CharField = TestClass.class.getField("charField");
049            IntField = TestClass.class.getField("intField");
050            LongField = TestClass.class.getField("longField");
051            FloatField = TestClass.class.getField("floatField");
052            DoubleField = TestClass.class.getField("doubleField");
053            BooleanField = TestClass.class.getField("booleanField");
054        } catch (SecurityException | NoSuchFieldException e) {
055            throw new RuntimeException(e);
056        }
057    }
058
059    private static class TestClass {
060        public final byte byteField = 11;
061        public final short shortField = 12;
062        public final char charField = 13;
063        public final int intField = 14;
064        public final long longField = 15;
065        public final float floatField = 16;
066        public final double doubleField = 17;
067        public final boolean booleanField = true;
068    }
069
070    private static final TestClass object = new TestClass();
071
072    public static boolean test(int arg) throws IllegalAccessException {
073        if (arg == 0) {
074            return ByteField.get(object).equals(object.byteField);
075        } else if (arg == 1) {
076            return ShortField.get(object).equals(object.shortField);
077        } else if (arg == 2) {
078            return CharField.get(object).equals(object.charField);
079        } else if (arg == 3) {
080            return IntField.get(object).equals(object.intField);
081        } else if (arg == 4) {
082            return LongField.get(object).equals(object.longField);
083        } else if (arg == 5) {
084            return FloatField.get(object).equals(object.floatField);
085        } else if (arg == 6) {
086            return DoubleField.get(object).equals(object.doubleField);
087        } else if (arg == 7) {
088            return BooleanField.get(object).equals(object.booleanField);
089        }
090        return false;
091    }
092
093    @Test
094    public void run0() throws Throwable {
095        runTest("test", 0);
096    }
097
098    @Test
099    public void run1() throws Throwable {
100        runTest("test", 1);
101    }
102
103    @Test
104    public void run2() throws Throwable {
105        runTest("test", 2);
106    }
107
108    @Test
109    public void run3() throws Throwable {
110        runTest("test", 3);
111    }
112
113    @Test
114    public void run4() throws Throwable {
115        runTest("test", 4);
116    }
117
118    @Test
119    public void run5() throws Throwable {
120        runTest("test", 5);
121    }
122
123    @Test
124    public void run6() throws Throwable {
125        runTest("test", 6);
126    }
127
128    @Test
129    public void run7() throws Throwable {
130        runTest("test", 7);
131    }
132
133    @Test
134    public void run8() throws Throwable {
135        runTest("test", 8);
136    }
137
138}