< prev index next >

src/java.base/share/classes/java/lang/constant/Constable.java

Print this page
rev 52981 : 8215300: additional changes to constants API


  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 a nominal descriptor for this instance, if one can be
  69      * constructed, or an empty {@link Optional} if one cannot be constructed.

  70      *
  71      * @return An {@link Optional} containing the resulting nominal descriptor,
  72      * or an empty {@link Optional} if one cannot be constructed.
  73      */
  74     Optional<? extends ConstantDesc> describeConstable();
  75 }


  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 }
< prev index next >