5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
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.meta;
24
25 import java.lang.invoke.*;
26
27 /**
28 * Reflection operations on values represented as {@linkplain JavaConstant constants}. All methods
29 * in this interface require the VM to access the actual object encapsulated in
30 * {@link JavaKind#Object object} constants. This access is not always possible, depending on kind
31 * of VM and the state that the VM is in. Therefore, all methods can return {@code null} at any
32 * time, to indicate that the result is not available at this point. The caller is responsible to
33 * check for {@code null} results and handle them properly, e.g., not perform an optimization.
34 */
35 public interface ConstantReflectionProvider {
36
37 /**
38 * Compares two constants for equality. The equality relationship is symmetric. Returns
39 * {@link Boolean#TRUE true} if the two constants represent the same run time value,
40 * {@link Boolean#FALSE false} if they are different. Returns {@code null} if the constants
41 * cannot be compared at this point.
42 */
43 Boolean constantEquals(Constant x, Constant y);
44
45 /**
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 */
134 JavaConstant forString(String value);
135
136 /**
137 * Returns the {@link ResolvedJavaType} for a {@link Class} object (or any other object regarded
138 * as a class by the VM) encapsulated in the given constant. Returns {@code null} if the
139 * constant does not encapsulate a class, or if the type is not available at this point.
140 */
141 ResolvedJavaType asJavaType(Constant constant);
142
143 /**
144 * Check if the constant is embeddable in the code.
145 */
146 boolean isEmbeddable(Constant constant);
147
148 /**
149 * Gets access to the internals of {@link MethodHandle}.
150 */
151 MethodHandleAccessProvider getMethodHandleAccess();
152
153 /**
154 * Gets raw memory access.
155 */
156 MemoryAccessProvider getMemoryAccessProvider();
157 }
|
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
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.meta;
24
25 import java.lang.invoke.MethodHandle;
26
27 /**
28 * Reflection operations on values represented as {@linkplain JavaConstant constants}. All methods
29 * in this interface require the VM to access the actual object encapsulated in
30 * {@link JavaKind#Object object} constants. This access is not always possible, depending on kind
31 * of VM and the state that the VM is in. Therefore, all methods can return {@code null} at any
32 * time, to indicate that the result is not available at this point. The caller is responsible to
33 * check for {@code null} results and handle them properly, e.g., not perform an optimization.
34 */
35 public interface ConstantReflectionProvider {
36
37 /**
38 * Compares two constants for equality. The equality relationship is symmetric. Returns
39 * {@link Boolean#TRUE true} if the two constants represent the same run time value,
40 * {@link Boolean#FALSE false} if they are different. Returns {@code null} if the constants
41 * cannot be compared at this point.
42 */
43 Boolean constantEquals(Constant x, Constant y);
44
45 /**
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 */
134 JavaConstant forString(String value);
135
136 /**
137 * Returns the {@link ResolvedJavaType} for a {@link Class} object (or any other object regarded
138 * as a class by the VM) encapsulated in the given constant. Returns {@code null} if the
139 * constant does not encapsulate a class, or if the type is not available at this point.
140 */
141 ResolvedJavaType asJavaType(Constant constant);
142
143 /**
144 * Check if the constant is embeddable in the code.
145 *
146 * @param constant the constant to test
147 */
148 default boolean isEmbeddable(Constant constant) {
149 return true;
150 }
151
152 /**
153 * Gets access to the internals of {@link MethodHandle}.
154 */
155 MethodHandleAccessProvider getMethodHandleAccess();
156
157 /**
158 * Gets raw memory access.
159 */
160 MemoryAccessProvider getMemoryAccessProvider();
161 }
|