java.lang.constant.DirectMethodHandleDesc
A nominal descriptor for a direct MethodHandle. A DirectMethodHandleDesc corresponds to a Constant_MethodHandle_info entry in the constant pool of a class file.
Declaration
public interface DirectMethodHandleDesc extends MethodHandleDesc {enum Kind {STATIC(REF_invokeStatic),INTERFACE_STATIC(REF_invokeStatic, true),VIRTUAL(REF_invokeVirtual),INTERFACE_VIRTUAL(REF_invokeInterface, true),SPECIAL(REF_invokeSpecial),INTERFACE_SPECIAL(REF_invokeSpecial, true),CONSTRUCTOR(REF_newInvokeSpecial),GETTER(REF_getField),SETTER(REF_putField),STATIC_GETTER(REF_getStatic),STATIC_SETTER(REF_putStatic);public final int refKind;public final boolean isInterface;Kind(int refKind) {this(refKind, false);}Kind(int refKind, boolean isInterface) {this.refKind = refKind;this.isInterface = isInterface;}public static Kind valueOf(int refKind) {return valueOf(refKind, false);}public static Kind valueOf(int refKind, boolean isInterface) {int i = tableIndex(refKind, isInterface);if (i >= 0 && i < TABLE.length) {Kind kind = TABLE[i];if (kind == null) {throw new IllegalArgumentException(String.format("refKind=%d", refKind));}if (kind.refKind == refKind && kind.isInterface == isInterface) {return kind;}}throw new IllegalArgumentException(String.format("refKind=%d", refKind));}private static int tableIndex(int refKind, boolean isInterface) {if (refKind < 0)return refKind;return (refKind * 2) + (isInterface ? 1 : 0);}private static final @Stable Kind[] TABLE;static {// Pack the static table.int max = 0;for (Kind k : values())max = Math.max(max, tableIndex(k.refKind, true));TABLE = new Kind[max + 1];for (Kind kind : values()) {int i = tableIndex(kind.refKind, kind.isInterface);if (i >= TABLE.length || TABLE[i] != null)throw new AssertionError("TABLE entry for " + kind);TABLE[i] = kind;}int ii = tableIndex(REF_invokeInterface, false);if (TABLE[ii] != null)throw new AssertionError("TABLE entry for (invokeInterface, false) used by " + TABLE[ii]);TABLE[ii] = INTERFACE_VIRTUAL;for (Kind kind : values()) {if (!kind.isInterface) {int i = tableIndex(kind.refKind, true);if (TABLE[i] == null) {// There is not a specific Kind for interfacesif (kind == VIRTUAL)kind = INTERFACE_VIRTUAL;if (TABLE[i] == null)TABLE[i] = kind;}}}}boolean isVirtualMethod() {switch (this) {case VIRTUAL:case SPECIAL:case INTERFACE_VIRTUAL:case INTERFACE_SPECIAL:return true;default:return false;}}}Kind kind();int refKind();boolean isOwnerInterface();ClassDesc owner();String methodName();String lookupDescriptor();}
Methods
1. Kind
java.lang.constant.DirectMethodHandleDesc.Kind
Kinds of method handle that can be described with DirectMethodHandleDesc.
2. valueOf(int refKind)
Kind java.lang.constant.DirectMethodHandleDesc.Kind.valueOf(int refKind)
This method takes one argument. This method returns the enumeration member with the given refKind field.
Parameters: One parameter is required for this method.
refKind: refKind of desired member.
Returns: the matching enumeration member.
Throws:
1. IllegalArgumentException - if there is no such member
3. valueOf(int refKind, boolean isInterface)
Kind java.lang.constant.DirectMethodHandleDesc.Kind.valueOf(int refKind, boolean isInterface)
This method takes two arguments. This method returns the enumeration member with the given refKind and isInterface arguments.
Parameters: Two parameters are required for this method.
refKind: refKind of the desired member.
isInterface: whether the desired member is for interface methods.
Returns: the matching enumeration member.
Throws:
1. IllegalArgumentException - if there is no such member
4. isVirtualMethod()
boolean java.lang.constant.DirectMethodHandleDesc.Kind.isVirtualMethod()
Does this Kind correspond to a virtual method invocation?
Returns: if this Kind corresponds to a virtual method invocation.
5. kind()
Kind java.lang.constant.DirectMethodHandleDesc.kind()
This method returns the kind of method handle described by this nominal descriptor.
Returns: the Kind
6. refKind()
int java.lang.constant.DirectMethodHandleDesc.refKind()
This method returns the refKind of the method handle described by this nominal reference, as defined by MethodHandleInfo.
Returns: the reference kind.
7. isOwnerInterface()
boolean java.lang.constant.DirectMethodHandleDesc.isOwnerInterface()
This method indicates if the method is declared by an interface
Returns: true if the method is declared by an interface
8. owner()
ClassDesc java.lang.constant.DirectMethodHandleDesc.owner()
This method returns a ClassDesc describing the class declaring the method or field described by this nominal descriptor.
Returns: the class declaring the method or field.
9. methodName()
String java.lang.constant.DirectMethodHandleDesc.methodName()
This method returns the name of the method or field described by this nominal descriptor. For constructors, returns the reserved name "<init>".
Returns: the name of the method or field.
10. lookupDescriptor()
String java.lang.constant.DirectMethodHandleDesc.lookupDescriptor()
This method returns the lookup descriptor of the method handle described by this descriptor, after adjusting for the invocation mode.
Some other classes/interfaces of java.lang.constant
MethodTypeDesc: A nominal descriptor for a MethodType constant.
MethodHandleDesc: A nominal descriptor for a MethodHandle constant.
DynamicConstantDesc: A nominal descriptor for a dynamic constant.
DynamicCallSiteDesc: A nominal descriptor for an invoke dynamic call site.
DirectMethodHandleDesc: A nominal descriptor for a direct MethodHandle. A DirectMethodHandleDesc corresponds to a Constant_MethodHandle_info entry in the constant pool of a class file.
ConstantDescs: Predefined 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.
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.
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.
ClassDesc: A nominal descriptor for a Class constant.
No comments:
Post a Comment