- All Superinterfaces:
- ConstantDesc,- TypeDescriptor,- TypeDescriptor.OfField<ClassDesc>
A nominal descriptor for a
 
Class constant.
 For common system types, including all the primitive types, there are
 predefined ClassDesc constants in ConstantDescs.
 (The java.lang.constant APIs consider void to be a primitive type.)
 To create a ClassDesc for a class or interface type, use of(java.lang.String) or
 ofDescriptor(String); to create a ClassDesc for an array
 type, use ofDescriptor(String), or first obtain a
 ClassDesc for the component type and then call the arrayType()
 or arrayType(int) methods.
- Since:
- 12
- See Also:
- 
Nested Class SummaryNested classes/interfaces declared in interface java.lang.invoke.TypeDescriptorTypeDescriptor.OfField<F extends TypeDescriptor.OfField<F>>, TypeDescriptor.OfMethod<F extends TypeDescriptor.OfField<F>,M extends TypeDescriptor.OfMethod<F, M>> 
- 
Method SummaryModifier and TypeMethodDescriptiondefault ClassDescdefault ClassDescarrayType(int rank) default ClassDescReturns the component type of this ClassDesc, if it describes an array type, ornullotherwise.Returns a field type descriptor string for this typedefault StringReturns a human-readable name for the type described by this descriptor.booleanCompare the specified object with this descriptor for equality.default booleanisArray()Returns whether this ClassDesc describes an array type.default booleanReturns whether this ClassDesc describes a class or interface type.default booleanReturns whether this ClassDesc describes a primitive type.default ClassDescdefault ClassDescstatic ClassDescReturns a ClassDesc for a class or interface type, given the name of the class or interface, such as"java.lang.String".static ClassDescReturns a ClassDesc for a class or interface type, given a package name and the unqualified (simple) name for the class or interface.static ClassDescofDescriptor(String descriptor) Returns a ClassDesc given a descriptor string for a class, interface, array, or primitive type.default StringReturns the package name of this ClassDesc, if it describes a class or interface type.Methods declared in interface java.lang.constant.ConstantDescresolveConstantDesc
- 
Method Details- 
ofReturns a ClassDesc for a class or interface type, given the name of the class or interface, such as"java.lang.String". (To create a descriptor for an array type, either useofDescriptor(String)orarrayType(); to create a descriptor for a primitive type, useofDescriptor(String)or use the predefined constants inConstantDescs).- Parameters:
- name- the fully qualified (dot-separated) binary class name
- Returns:
- a ClassDesc describing the desired class
- Throws:
- NullPointerException- if the argument is- null
- IllegalArgumentException- if the name string is not in the correct format
 
- 
ofReturns a ClassDesc for a class or interface type, given a package name and the unqualified (simple) name for the class or interface.- Parameters:
- packageName- the package name (dot-separated); if the package name is the empty string, the class is considered to be in the unnamed package
- className- the unqualified (simple) class name
- Returns:
- a ClassDesc describing the desired class
- Throws:
- NullPointerException- if any argument is- null
- IllegalArgumentException- if the package name or class name are not in the correct format
 
- 
ofDescriptorReturns a ClassDesc given a descriptor string for a class, interface, array, or primitive type.- API Note:
- A field type descriptor string for a non-array type is either
 a one-letter code corresponding to a primitive type
 ("J", "I", "C", "S", "B", "D", "F", "Z", "V"), or the letter"L", followed by the fully qualified binary name of a class, followed by";". A field type descriptor for an array type is the character"["followed by the field descriptor for the component type. Examples of valid type descriptor strings include"Ljava/lang/String;","I","[I","V","[Ljava/lang/String;", etc. See JVMS 4.3.2 ("Field Descriptors") for more detail.
- Parameters:
- descriptor- a field descriptor string
- Returns:
- a ClassDesc describing the desired class
- Throws:
- NullPointerException- if the argument is- null
- IllegalArgumentException- if the name string is not in the correct format
- See Java Virtual Machine Specification:
- 
4.3.2 Field Descriptors
 4.4.1 The CONSTANT_Class_info Structure
 
- 
arrayType- Specified by:
- arrayTypein interface- TypeDescriptor.OfField<ClassDesc>
- Returns:
- a ClassDesc describing the array type
- Throws:
- IllegalStateException- if the resulting ClassDesc would have an array rank of greater than 255
- See Java Virtual Machine Specification:
- 
4.4.1 The CONSTANT_Class_info Structure
 
- 
arrayTypeReturns a ClassDesc for an array type of the specified rank, whose component type is described by this ClassDesc.- Parameters:
- rank- the rank of the array
- Returns:
- a ClassDesc describing the array type
- Throws:
- IllegalArgumentException- if the rank is less than or equal to zero or if the rank of the resulting array type is greater than 255
- See Java Virtual Machine Specification:
- 
4.4.1 The CONSTANT_Class_info Structure
 
- 
nested- API Note:
- Example: If descriptor ddescribes the classjava.util.Map, a descriptor for the classjava.util.Map.Entrycould be obtained byd.nested("Entry").
- Parameters:
- nestedName- the unqualified name of the nested class
- Returns:
- a ClassDesc describing the nested class
- Throws:
- NullPointerException- if the argument is- null
- IllegalStateException- if this ClassDesc does not describe a class or interface type
- IllegalArgumentException- if the nested class name is invalid
 
- 
nested- Parameters:
- firstNestedName- the unqualified name of the first level of nested class
- moreNestedNames- the unqualified name(s) of the remaining levels of nested class
- Returns:
- a ClassDesc describing the nested class
- Throws:
- NullPointerException- if any argument or its contents is- null
- IllegalStateException- if this ClassDesc does not describe a class or interface type
- IllegalArgumentException- if the nested class name is invalid
 
- 
isArraydefault boolean isArray()Returns whether this ClassDesc describes an array type.- Specified by:
- isArrayin interface- TypeDescriptor.OfField<ClassDesc>
- Returns:
- whether this ClassDesc describes an array type
 
- 
isPrimitivedefault boolean isPrimitive()Returns whether this ClassDesc describes a primitive type.- Specified by:
- isPrimitivein interface- TypeDescriptor.OfField<ClassDesc>
- Returns:
- whether this ClassDesc describes a primitive type
 
- 
isClassOrInterfacedefault boolean isClassOrInterface()Returns whether this ClassDesc describes a class or interface type.- Returns:
- whether this ClassDesc describes a class or interface type
 
- 
componentTypeReturns the component type of this ClassDesc, if it describes an array type, ornullotherwise.- Specified by:
- componentTypein interface- TypeDescriptor.OfField<ClassDesc>
- Returns:
- a ClassDesc describing the component type, or nullif this descriptor does not describe an array type
 
- 
packageNameReturns the package name of this ClassDesc, if it describes a class or interface type.- Returns:
- the package name, or the empty string if the class is in the default package, or this ClassDesc does not describe a class or interface type
 
- 
displayNameReturns a human-readable name for the type described by this descriptor.- Implementation Requirements:
- The default implementation returns the simple name (e.g., - int) for primitive types, the unqualified class name for class or interface types, or the display name of the component type suffixed with the appropriate number of- []pairs for array types.
- Returns:
- the human-readable name
 
- 
descriptorStringString descriptorString()Returns a field type descriptor string for this type- Specified by:
- descriptorStringin interface- TypeDescriptor
- Returns:
- the descriptor string
- See Java Virtual Machine Specification:
- 
4.3.2 Field Descriptors
 
- 
equalsCompare the specified object with this descriptor for equality. Returnstrueif and only if the specified object is also a ClassDesc and both describe the same type.
 
-