hotspot/test/compiler/jvmci/meta/StableFieldTest.java
author chegar
Tue, 22 Mar 2016 17:04:25 +0000
changeset 36616 5172e3dd60f2
parent 36596 d0e06b2ecfbe
child 38152 80e5da81fb2c
permissions -rw-r--r--
Merge
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
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    27
 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    28
 * @library /testlibrary /test/lib /
36616
chegar
parents: 36596
diff changeset
    29
 * @modules java.base/jdk.internal.vm.annotation
chegar
parents: 36596
diff changeset
    30
 *          jdk.vm.ci/jdk.vm.ci.hotspot
chegar
parents: 36596
diff changeset
    31
 *          jdk.vm.ci/jdk.vm.ci.meta
chegar
parents: 36596
diff changeset
    32
 *          jdk.vm.ci/jdk.vm.ci.runtime
36596
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    33
 * @compile StableFieldTest.java
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    34
 * @run main ClassFileInstaller compiler.jvmci.meta.StableFieldTest
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    35
 * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -Xbootclasspath/a:. compiler.jvmci.meta.StableFieldTest
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    36
 */
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    37
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    38
package compiler.jvmci.meta;
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
import java.lang.reflect.Field;
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    41
import jdk.internal.vm.annotation.Stable;
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    42
import jdk.vm.ci.hotspot.HotSpotResolvedJavaField;
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    43
import jdk.vm.ci.meta.MetaAccessProvider;
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    44
import jdk.vm.ci.meta.ResolvedJavaField;
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
}