Path: blob/master/test/hotspot/jtreg/compiler/jvmci/meta/StableFieldTest.java
41153 views
/*1* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 815166426* @requires vm.jvmci27* @library /test/lib /28* @modules java.base/jdk.internal.misc29* @modules java.base/jdk.internal.vm.annotation30* jdk.internal.vm.ci/jdk.vm.ci.hotspot31* jdk.internal.vm.ci/jdk.vm.ci.meta32* jdk.internal.vm.ci/jdk.vm.ci.runtime33*34* @compile StableFieldTest.java35* @run driver jdk.test.lib.helpers.ClassFileInstaller compiler.jvmci.meta.StableFieldTest36* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler -Xbootclasspath/a:. compiler.jvmci.meta.StableFieldTest37*/3839package compiler.jvmci.meta;4041import jdk.internal.vm.annotation.Stable;42import jdk.vm.ci.hotspot.HotSpotResolvedJavaField;43import jdk.vm.ci.meta.MetaAccessProvider;44import jdk.vm.ci.runtime.JVMCI;4546public class StableFieldTest {4748@Stable static int myStaticField = 5;49@Stable int myInstanceField = 10;5051public static void main(String[] args) throws Throwable {52MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess();53for (String name : new String[] {"myStaticField", "myInstanceField"}) {54java.lang.reflect.Field javaField = StableFieldTest.class.getDeclaredField(name);55HotSpotResolvedJavaField field = (HotSpotResolvedJavaField) metaAccess.lookupJavaField(javaField);56if (!field.isStable()) {57throw new AssertionError("Expected HotSpotResolvedJavaField.isStable() to return true for " + javaField);58}59}60}61}626364