hotspot/test/compiler/jvmci/meta/StableFieldTest.java
author dnsimon
Fri, 28 Apr 2017 02:54:05 -0700
changeset 44836 45196b7066e3
parent 43972 1ade39b8381b
permissions -rw-r--r--
8177845: Need a mechanism to load Graal Reviewed-by: kvn, iveresov, mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36596
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
     1
/*
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
     4
 *
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
     8
 *
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    13
 * accompanied this code).
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    14
 *
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    18
 *
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    21
 * questions.
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    22
 */
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    23
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    24
/**
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    25
 * @test
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    26
 * @bug 8151664
42607
acd91f1875d4 8170227: use vm.jvmci property in compiler/jvmci tests
iignatyev
parents: 40631
diff changeset
    27
 * @requires vm.jvmci
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40059
diff changeset
    28
 * @library /test/lib /
38152
80e5da81fb2c 8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents: 36616
diff changeset
    29
 * @modules java.base/jdk.internal.misc
36616
chegar
parents: 36596
diff changeset
    30
 * @modules java.base/jdk.internal.vm.annotation
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents: 42607
diff changeset
    31
 *          jdk.internal.vm.ci/jdk.vm.ci.hotspot
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents: 42607
diff changeset
    32
 *          jdk.internal.vm.ci/jdk.vm.ci.meta
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents: 42607
diff changeset
    33
 *          jdk.internal.vm.ci/jdk.vm.ci.runtime
40053
b3617982544e 8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents: 39291
diff changeset
    34
 *
36596
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    35
 * @compile StableFieldTest.java
40053
b3617982544e 8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents: 39291
diff changeset
    36
 * @run driver ClassFileInstaller compiler.jvmci.meta.StableFieldTest
44836
45196b7066e3 8177845: Need a mechanism to load Graal
dnsimon
parents: 43972
diff changeset
    37
 * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -Djvmci.Compiler=null -Xbootclasspath/a:. compiler.jvmci.meta.StableFieldTest
36596
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    38
 */
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    39
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    40
package compiler.jvmci.meta;
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    41
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    42
import jdk.internal.vm.annotation.Stable;
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    43
import jdk.vm.ci.hotspot.HotSpotResolvedJavaField;
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    44
import jdk.vm.ci.meta.MetaAccessProvider;
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    45
import jdk.vm.ci.runtime.JVMCI;
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    46
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    47
public class StableFieldTest {
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    48
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    49
    @Stable static int myStaticField = 5;
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    50
    @Stable int myInstanceField = 10;
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    51
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    52
    public static void main(String[] args) throws Throwable {
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    53
        MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess();
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    54
        for (String name : new String[] {"myStaticField", "myInstanceField"}) {
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    55
            java.lang.reflect.Field javaField = StableFieldTest.class.getDeclaredField(name);
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    56
            HotSpotResolvedJavaField field = (HotSpotResolvedJavaField) metaAccess.lookupJavaField(javaField);
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    57
            if (!field.isStable()) {
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    58
                throw new AssertionError("Expected HotSpotResolvedJavaField.isStable() to return true for " + javaField);
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    59
            }
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    60
        }
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    61
    }
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    62
}