src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java

Print this page




  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package jdk.vm.ci.hotspot;
  24 
  25 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
  26 import static jdk.vm.ci.hotspot.HotSpotVMConfig.config;
  27 
  28 import java.lang.annotation.Annotation;
  29 import java.lang.reflect.Field;
  30 
  31 import jdk.vm.ci.common.JVMCIError;
  32 import jdk.vm.ci.meta.JavaType;
  33 import jdk.vm.ci.meta.LocationIdentity;
  34 import jdk.vm.ci.meta.MetaAccessProvider;
  35 import jdk.vm.ci.meta.ModifiersProvider;
  36 import jdk.vm.ci.meta.ResolvedJavaField;
  37 import jdk.vm.ci.meta.ResolvedJavaType;
  38 import jdk.vm.ci.options.Option;
  39 import jdk.vm.ci.options.OptionType;
  40 import jdk.vm.ci.options.OptionValue;
  41 
  42 /**
  43  * Represents a field in a HotSpot type.
  44  */
  45 class HotSpotResolvedJavaFieldImpl implements HotSpotResolvedJavaField, HotSpotProxified {
  46 
  47     static class Options {
  48         //@formatter:off
  49         @Option(help = "Mark well-known stable fields as such.", type = OptionType.Debug)
  50         public static final OptionValue<Boolean> ImplicitStableValues = new OptionValue<>(true);
  51         //@formatter:on
  52     }
  53 
  54     private final HotSpotResolvedObjectTypeImpl holder;
  55     private final String name;
  56     private JavaType type;
  57     private final int offset;
  58 
  59     /**
  60      * This value contains all flags as stored in the VM including internal ones.
  61      */
  62     private final int modifiers;
  63     private final LocationIdentity locationIdentity = new FieldLocationIdentity(this);
  64 
  65     public static class FieldLocationIdentity extends LocationIdentity {
  66         HotSpotResolvedJavaField inner;
  67 
  68         public FieldLocationIdentity(HotSpotResolvedJavaFieldImpl inner) {
  69             this.inner = inner;
  70         }
  71 
  72         @Override


 186     @Override
 187     public String toString() {
 188         return format("HotSpotField<%H.%n %t:") + offset + ">";
 189     }
 190 
 191     @Override
 192     public boolean isSynthetic() {
 193         return (config().jvmAccSynthetic & modifiers) != 0;
 194     }
 195 
 196     /**
 197      * Checks if this field has the {@link Stable} annotation.
 198      *
 199      * @return true if field has {@link Stable} annotation, false otherwise
 200      */
 201     public boolean isStable() {
 202         if ((config().jvmAccFieldStable & modifiers) != 0) {
 203             return true;
 204         }
 205         assert getAnnotation(Stable.class) == null;
 206         if (Options.ImplicitStableValues.getValue() && isImplicitStableField()) {
 207             return true;
 208         }
 209         return false;
 210     }
 211 
 212     @Override
 213     public Annotation[] getAnnotations() {
 214         Field javaField = toJava();
 215         if (javaField != null) {
 216             return javaField.getAnnotations();
 217         }
 218         return new Annotation[0];
 219     }
 220 
 221     @Override
 222     public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
 223         Field javaField = toJava();
 224         if (javaField != null) {
 225             return javaField.getAnnotation(annotationClass);
 226         }




  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package jdk.vm.ci.hotspot;
  24 
  25 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
  26 import static jdk.vm.ci.hotspot.HotSpotVMConfig.config;
  27 
  28 import java.lang.annotation.Annotation;
  29 import java.lang.reflect.Field;
  30 
  31 import jdk.vm.ci.common.JVMCIError;
  32 import jdk.vm.ci.meta.JavaType;
  33 import jdk.vm.ci.meta.LocationIdentity;
  34 import jdk.vm.ci.meta.MetaAccessProvider;
  35 import jdk.vm.ci.meta.ModifiersProvider;
  36 import jdk.vm.ci.meta.ResolvedJavaField;
  37 import jdk.vm.ci.meta.ResolvedJavaType;



  38 
  39 /**
  40  * Represents a field in a HotSpot type.
  41  */
  42 class HotSpotResolvedJavaFieldImpl implements HotSpotResolvedJavaField, HotSpotProxified {
  43 
  44     /**
  45      * Mark well-known stable fields as such.
  46      */
  47     private static final boolean ImplicitStableValues = HotSpotJVMCIRuntime.getBooleanProperty("jvmci.ImplicitStableValues", true);


  48 
  49     private final HotSpotResolvedObjectTypeImpl holder;
  50     private final String name;
  51     private JavaType type;
  52     private final int offset;
  53 
  54     /**
  55      * This value contains all flags as stored in the VM including internal ones.
  56      */
  57     private final int modifiers;
  58     private final LocationIdentity locationIdentity = new FieldLocationIdentity(this);
  59 
  60     public static class FieldLocationIdentity extends LocationIdentity {
  61         HotSpotResolvedJavaField inner;
  62 
  63         public FieldLocationIdentity(HotSpotResolvedJavaFieldImpl inner) {
  64             this.inner = inner;
  65         }
  66 
  67         @Override


 181     @Override
 182     public String toString() {
 183         return format("HotSpotField<%H.%n %t:") + offset + ">";
 184     }
 185 
 186     @Override
 187     public boolean isSynthetic() {
 188         return (config().jvmAccSynthetic & modifiers) != 0;
 189     }
 190 
 191     /**
 192      * Checks if this field has the {@link Stable} annotation.
 193      *
 194      * @return true if field has {@link Stable} annotation, false otherwise
 195      */
 196     public boolean isStable() {
 197         if ((config().jvmAccFieldStable & modifiers) != 0) {
 198             return true;
 199         }
 200         assert getAnnotation(Stable.class) == null;
 201         if (ImplicitStableValues && isImplicitStableField()) {
 202             return true;
 203         }
 204         return false;
 205     }
 206 
 207     @Override
 208     public Annotation[] getAnnotations() {
 209         Field javaField = toJava();
 210         if (javaField != null) {
 211             return javaField.getAnnotations();
 212         }
 213         return new Annotation[0];
 214     }
 215 
 216     @Override
 217     public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
 218         Field javaField = toJava();
 219         if (javaField != null) {
 220             return javaField.getAnnotation(annotationClass);
 221         }