ConstantDesc interface in Java

java.lang.constant.ConstantDesc

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

Class names in a nominal descriptor, like class names in the constant pool of a class file, must be interpreted with respect to a particular classloader, which is not part of the nominal descriptor.

Static constants that are expressible natively in the constant pool (String, Integer, Long, Float, and Double) implement ConstantDesc and serve as nominal descriptors for themselves. Native linkable constants (Class, MethodType, and MethodHandle) have counterpart ConstantDesc types: ClassDesc, MethodTypeDesc, and MethodHandleDesc.Other constants are represented by subtypes of DynamicConstantDesc.

Subinterfaces:

ClassDesc

DirectMethodHandleDesc

MethodHandleDesc

MethodTypeDesc

Declaration

public interface ConstantDesc {

    Object resolveConstantDesc(MethodHandles.Lookup lookup)
throws ReflectiveOperationException;
}

Methods

1. resolveConstantDesc(Lookup lookup) 

Object java.lang.constant.ConstantDesc.resolveConstantDesc(Lookup lookup) throws ReflectiveOperationException

This method takes one argument. This method resolves this descriptor reflectively, emulating the resolution behavior of JVMS 5.4.3 and the access control behavior of JVMS 5.4.4. The resolution and access control context is provided by MethodHandles.Lookupparameter. No caching of the resulting value is performed.

Parameters: One parameter is required for this method.

lookup: The MethodHandles.Lookup to provide name resolution and access control context.

Returns: the resolved constant value.

Throws:

1. ReflectiveOperationException - if a class, method, or field could not be reflectively resolved in the course of resolution.

2. LinkageError - if a linkage error occurs.


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