Constable interface in Java

java.lang.constant.Constable

Represents a type that is constable. A constable type is one whose values are constants that can be represented in the constant pool of a Java class file.

Some constable types have a native representation in the constant pool:

String, Integer, Long, Float, Double, Class, MethodType, and MethodHandle.The types String, Integer, Long, Float, and Double serve as their own nominal descriptors; Class, MethodType, and MethodHandle have the corresponding nominal descriptors ClassDesc, MethodTypeDesc, and MethodHandleDesc.

Declaration

public interface Constable {

    Optional<? extends ConstantDesc> describeConstable();
}

Methods

1. describeConstable()

Optional<? extends ConstantDesc> java.lang.constant.Constable.describeConstable()

This method returns an Optional containing the nominal descriptor for this instance, if one can be constructed, or an empty Optional if one cannot be constructed.

Parameters: NA

Returns: An Optional containing the resulting nominal descriptor, or an empty Optional if one cannot be constructed.

Exceptions: NA


Some other classes/interfaces of java.lang.constant

MethodTypeDescA nominal descriptor for a MethodType constant.

MethodHandleDescA nominal descriptor for a MethodHandle constant.

DynamicConstantDescA nominal descriptor for a dynamic constant.

DynamicCallSiteDescA nominal descriptor for an invoke dynamic call site.

DirectMethodHandleDescA nominal descriptor for a direct MethodHandle. A DirectMethodHandleDesc corresponds to a Constant_MethodHandle_info entry in the constant pool of a class file.

ConstantDescsPredefined values of nominal descriptors for common constants, including descriptors for primitive class types and other common platform types, and descriptors for method handles for standard bootstrap methods.

ConstantDescA nominal descriptor for a loadable constant value. Such a descriptor can be resolved via ConstantDesc.resolveConstantDesc(MethodHandles.Lookup) to yield the constant value itself.

ConstableRepresents a type that is constable. A constable type is one whose values are constants that can be represented in the constant pool of a Java class file.

ClassDescA nominal descriptor for a Class constant.

No comments:

Post a Comment