hotspot/test/compiler/jvmci/meta/StableFieldTest.java
author dnsimon
Thu, 10 Mar 2016 14:06:21 -0800
changeset 36596 d0e06b2ecfbe
child 36616 5172e3dd60f2
permissions -rw-r--r--
8151664: [JVMCI] add missing test in 8151266 integration Reviewed-by: never, twisti
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 /
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    29
 * @compile StableFieldTest.java
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    30
 * @run main ClassFileInstaller compiler.jvmci.meta.StableFieldTest
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    31
 * @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
    32
 */
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    33
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    34
package compiler.jvmci.meta;
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    35
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    36
import java.lang.reflect.Field;
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    37
import jdk.internal.vm.annotation.Stable;
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    38
import jdk.vm.ci.hotspot.HotSpotResolvedJavaField;
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    39
import jdk.vm.ci.meta.MetaAccessProvider;
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    40
import jdk.vm.ci.meta.ResolvedJavaField;
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    41
import jdk.vm.ci.runtime.JVMCI;
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    42
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    43
public class StableFieldTest {
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    44
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    45
    @Stable static int myStaticField = 5;
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    46
    @Stable int myInstanceField = 10;
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    47
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    48
    public static void main(String[] args) throws Throwable {
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    49
        MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess();
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    50
        for (String name : new String[] {"myStaticField", "myInstanceField"}) {
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    51
            java.lang.reflect.Field javaField = StableFieldTest.class.getDeclaredField(name);
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    52
            HotSpotResolvedJavaField field = (HotSpotResolvedJavaField) metaAccess.lookupJavaField(javaField);
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    53
            if (!field.isStable()) {
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    54
                throw new AssertionError("Expected HotSpotResolvedJavaField.isStable() to return true for " + javaField);
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    55
            }
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    56
        }
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    57
    }
d0e06b2ecfbe 8151664: [JVMCI] add missing test in 8151266 integration
dnsimon
parents:
diff changeset
    58
}