42 * and {@link Double} serve as their own nominal descriptors; {@link Class},
43 * {@link MethodType}, and {@link MethodHandle} have corresponding nominal
44 * descriptors {@link ClassDesc}, {@link MethodTypeDesc}, and {@link MethodHandleDesc}.
45 *
46 * <p>Other reference types can be constable if their instances can describe
47 * themselves in nominal form as a {@link ConstantDesc}. Examples in the Java SE
48 * Platform API are types that support Java language features such as {@link Enum},
49 * and runtime support classes such as {@link VarHandle}. These are typically
50 * described with a {@link DynamicConstantDesc}, which describes dynamically
51 * generated constants (JVMS 4.4.10).
52 *
53 * <p>The nominal form of an instance of a constable type is obtained via
54 * {@link #describeConstable()}. A {@linkplain Constable} need
55 * not be able to (or may choose not to) describe all its instances in the form of
56 * a {@link ConstantDesc}; this method returns an {@link Optional} that can be
57 * empty to indicate that a nominal descriptor could not be created for an instance.
58 * (For example, {@link MethodHandle} will produce nominal descriptors for direct
59 * method handles, but not necessarily those produced by method handle
60 * combinators.)
61 * @jvms 4.4 The Constant Pool
62 * @jvms 4.4.10 The CONSTANT_InvokeDynamic_info Structure
63 *
64 * @since 12
65 */
66 public interface Constable {
67 /**
68 * Returns an {@link Optional} containing the nominal descriptor for this
69 * instance, if one can be constructed, or an empty {@link Optional}
70 * if one cannot be constructed.
71 *
72 * @return An {@link Optional} containing the resulting nominal descriptor,
73 * or an empty {@link Optional} if one cannot be constructed.
74 */
75 Optional<? extends ConstantDesc> describeConstable();
76 }
|
42 * and {@link Double} serve as their own nominal descriptors; {@link Class},
43 * {@link MethodType}, and {@link MethodHandle} have corresponding nominal
44 * descriptors {@link ClassDesc}, {@link MethodTypeDesc}, and {@link MethodHandleDesc}.
45 *
46 * <p>Other reference types can be constable if their instances can describe
47 * themselves in nominal form as a {@link ConstantDesc}. Examples in the Java SE
48 * Platform API are types that support Java language features such as {@link Enum},
49 * and runtime support classes such as {@link VarHandle}. These are typically
50 * described with a {@link DynamicConstantDesc}, which describes dynamically
51 * generated constants (JVMS 4.4.10).
52 *
53 * <p>The nominal form of an instance of a constable type is obtained via
54 * {@link #describeConstable()}. A {@linkplain Constable} need
55 * not be able to (or may choose not to) describe all its instances in the form of
56 * a {@link ConstantDesc}; this method returns an {@link Optional} that can be
57 * empty to indicate that a nominal descriptor could not be created for an instance.
58 * (For example, {@link MethodHandle} will produce nominal descriptors for direct
59 * method handles, but not necessarily those produced by method handle
60 * combinators.)
61 * @jvms 4.4 The Constant Pool
62 * @jvms 4.4.10 The {@code CONSTANT_Dynamic_info} and {@code CONSTANT_InvokeDynamic_info} Structures
63 *
64 * @since 12
65 */
66 public interface Constable {
67 /**
68 * Returns an {@link Optional} containing the nominal descriptor for this
69 * instance, if one can be constructed, or an empty {@link Optional}
70 * if one cannot be constructed.
71 *
72 * @return An {@link Optional} containing the resulting nominal descriptor,
73 * or an empty {@link Optional} if one cannot be constructed.
74 */
75 Optional<? extends ConstantDesc> describeConstable();
76 }
|