src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ConstantReflectionProvider.java

Print this page




  63     JavaConstant readConstantArrayElement(JavaConstant array, int index);
  64 
  65     /**
  66      * Reads a value from the given array at the given offset if it is a stable array. The offset
  67      * will be decoded relative to the platform addressing into an index into the array. Returns
  68      * {@code null} if the constant is not a stable array, if it is a default value, if the offset
  69      * is out of bounds, or if the value is not available at this point.
  70      */
  71     JavaConstant readConstantArrayElementForOffset(JavaConstant array, long offset);
  72 
  73     /**
  74      * Gets the constant value of this field. Note that a {@code static final} field may not be
  75      * considered constant if its declaring class is not yet initialized or if it is a well known
  76      * field that can be updated via other means (e.g., {@link System#setOut(java.io.PrintStream)}).
  77      *
  78      * @param receiver object from which this field's value is to be read. This value is ignored if
  79      *            this field is static.
  80      * @return the constant value of this field or {@code null} if this field is not considered
  81      *         constant by the runtime
  82      */
  83     JavaConstant readConstantFieldValue(JavaField field, JavaConstant receiver);
  84 
  85     /**
  86      * Gets the current value of this field for a given object, if available.
  87      *
  88      * There is no guarantee that the same value will be returned by this method for a field unless
  89      * the field is considered to be {@linkplain #readConstantFieldValue(JavaField, JavaConstant)
  90      * constant} by the runtime.

  91      *
  92      * @param receiver object from which this field's value is to be read. This value is ignored if
  93      *            this field is static.
  94      * @return the value of this field or {@code null} if the value is not available (e.g., because
  95      *         the field holder is not yet initialized).
  96      */
  97     JavaConstant readFieldValue(JavaField field, JavaConstant receiver);
  98 
  99     /**
 100      * Gets the current value of this field for a given object, if available. Like
 101      * {@link #readFieldValue(JavaField, JavaConstant)} but treats array fields as stable.
 102      *
 103      * There is no guarantee that the same value will be returned by this method for a field unless
 104      * the field is considered to be {@linkplain #readConstantFieldValue(JavaField, JavaConstant)
 105      * constant} by the runtime.

 106      *
 107      * @param receiver object from which this field's value is to be read. This value is ignored if
 108      *            this field is static.
 109      * @param isDefaultStable if {@code true}, default values are considered stable
 110      * @return the value of this field or {@code null} if the value is not available (e.g., because
 111      *         the field holder is not yet initialized).
 112      */
 113     JavaConstant readStableFieldValue(JavaField field, JavaConstant receiver, boolean isDefaultStable);
 114 
 115     /**
 116      * Converts the given {@link JavaKind#isPrimitive() primitive} constant to a boxed
 117      * {@link JavaKind#Object object} constant, according to the Java boxing rules. Returns
 118      * {@code null} if the source is is not a primitive constant, or the boxed value is not
 119      * available at this point.
 120      */
 121     JavaConstant boxPrimitive(JavaConstant source);
 122 
 123     /**
 124      * Converts the given {@link JavaKind#Object object} constant to a
 125      * {@link JavaKind#isPrimitive() primitive} constant, according to the Java unboxing rules.
 126      * Returns {@code null} if the source is is not an object constant that can be unboxed, or the
 127      * unboxed value is not available at this point.
 128      */
 129     JavaConstant unboxPrimitive(JavaConstant source);
 130 
 131     /**
 132      * Gets a string as a {@link JavaConstant}.
 133      */




  63     JavaConstant readConstantArrayElement(JavaConstant array, int index);
  64 
  65     /**
  66      * Reads a value from the given array at the given offset if it is a stable array. The offset
  67      * will be decoded relative to the platform addressing into an index into the array. Returns
  68      * {@code null} if the constant is not a stable array, if it is a default value, if the offset
  69      * is out of bounds, or if the value is not available at this point.
  70      */
  71     JavaConstant readConstantArrayElementForOffset(JavaConstant array, long offset);
  72 
  73     /**
  74      * Gets the constant value of this field. Note that a {@code static final} field may not be
  75      * considered constant if its declaring class is not yet initialized or if it is a well known
  76      * field that can be updated via other means (e.g., {@link System#setOut(java.io.PrintStream)}).
  77      *
  78      * @param receiver object from which this field's value is to be read. This value is ignored if
  79      *            this field is static.
  80      * @return the constant value of this field or {@code null} if this field is not considered
  81      *         constant by the runtime
  82      */
  83     JavaConstant readConstantFieldValue(ResolvedJavaField field, JavaConstant receiver);
  84 
  85     /**
  86      * Gets the current value of this field for a given object, if available.
  87      *
  88      * There is no guarantee that the same value will be returned by this method for a field unless
  89      * the field is considered to be
  90      * {@linkplain #readConstantFieldValue(ResolvedJavaField, JavaConstant) constant} by the
  91      * runtime.
  92      *
  93      * @param receiver object from which this field's value is to be read. This value is ignored if
  94      *            this field is static.
  95      * @return the value of this field or {@code null} if the value is not available (e.g., because
  96      *         the field holder is not yet initialized).
  97      */
  98     JavaConstant readFieldValue(ResolvedJavaField field, JavaConstant receiver);
  99 
 100     /**
 101      * Gets the current value of this field for a given object, if available. Like
 102      * {@link #readFieldValue(ResolvedJavaField, JavaConstant)} but treats array fields as stable.
 103      *
 104      * There is no guarantee that the same value will be returned by this method for a field unless
 105      * the field is considered to be
 106      * {@linkplain #readConstantFieldValue(ResolvedJavaField, JavaConstant) constant} by the
 107      * runtime.
 108      *
 109      * @param receiver object from which this field's value is to be read. This value is ignored if
 110      *            this field is static.
 111      * @param isDefaultStable if {@code true}, default values are considered stable
 112      * @return the value of this field or {@code null} if the value is not available (e.g., because
 113      *         the field holder is not yet initialized).
 114      */
 115     JavaConstant readStableFieldValue(ResolvedJavaField field, JavaConstant receiver, boolean isDefaultStable);
 116 
 117     /**
 118      * Converts the given {@link JavaKind#isPrimitive() primitive} constant to a boxed
 119      * {@link JavaKind#Object object} constant, according to the Java boxing rules. Returns
 120      * {@code null} if the source is is not a primitive constant, or the boxed value is not
 121      * available at this point.
 122      */
 123     JavaConstant boxPrimitive(JavaConstant source);
 124 
 125     /**
 126      * Converts the given {@link JavaKind#Object object} constant to a
 127      * {@link JavaKind#isPrimitive() primitive} constant, according to the Java unboxing rules.
 128      * Returns {@code null} if the source is is not an object constant that can be unboxed, or the
 129      * unboxed value is not available at this point.
 130      */
 131     JavaConstant unboxPrimitive(JavaConstant source);
 132 
 133     /**
 134      * Gets a string as a {@link JavaConstant}.
 135      */