diff graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ConstantReflectionProvider.java @ 18465:f0a8b72315c1

Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
author Andreas Woess <andreas.woess@jku.at>
date Wed, 19 Nov 2014 17:00:12 +0100
parents a3a2359ac88e
children de179c27cad3
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ConstantReflectionProvider.java	Wed Nov 19 16:06:49 2014 +0100
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ConstantReflectionProvider.java	Wed Nov 19 17:00:12 2014 +0100
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.api.meta;
 
+import java.lang.invoke.*;
+
 /**
  * Reflection operations on values represented as {@linkplain JavaConstant constants}. All methods
  * in this interface require the VM to access the actual object encapsulated in {@link Kind#Object
@@ -54,6 +56,31 @@
     JavaConstant readArrayElement(JavaConstant array, int index);
 
     /**
+     * Gets the constant value of this field. Note that a {@code static final} field may not be
+     * considered constant if its declaring class is not yet initialized or if it is a well known
+     * field that can be updated via other means (e.g., {@link System#setOut(java.io.PrintStream)}).
+     *
+     * @param receiver object from which this field's value is to be read. This value is ignored if
+     *            this field is static.
+     * @return the constant value of this field or {@code null} if this field is not considered
+     *         constant by the runtime
+     */
+    JavaConstant readConstantFieldValue(JavaField field, JavaConstant receiver);
+
+    /**
+     * Gets the current value of this field for a given object, if available. There is no guarantee
+     * that the same value will be returned by this method for a field unless the field is
+     * considered to be {@linkplain #readConstantFieldValue(JavaField, JavaConstant) constant} by
+     * the runtime.
+     *
+     * @param receiver object from which this field's value is to be read. This value is ignored if
+     *            this field is static.
+     * @return the value of this field or {@code null} if the value is not available (e.g., because
+     *         the field holder is not yet initialized).
+     */
+    JavaConstant readFieldValue(JavaField field, JavaConstant receiver);
+
+    /**
      * Reads a value of this kind using a base address and a displacement. No bounds checking or
      * type checking is performed. Returns {@code null} if the value is not available at this point.
      *
@@ -112,4 +139,9 @@
      * constant does not encapsulate a class, or if the type is not available at this point.
      */
     ResolvedJavaType asJavaType(JavaConstant constant);
+
+    /**
+     * Gets access to the internals of {@link MethodHandle}.
+     */
+    MethodHandleAccessProvider getMethodHandleAccess();
 }