java.lang.Object
io.smallrye.classfile.extras.constant.ConstantUtils
Helper methods for the implementation of
java.lang.constant.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ClassDescstatic ClassDescstatic final ClassDesc[]static final ConstantDesc[]an empty constant descriptorstatic final int -
Method Summary
Modifier and TypeMethodDescriptionstatic intarrayDepth(String descriptorString, int off) Retrieves the array depth on a trusted descriptor.static ClassDescbinaryNameToDesc(String binaryName) Creates a ClassDesc from a pre-validated binary name for a class or interface type.static StringbinaryToInternal(String name) static ClassDescCreates a ClassDesc from a Class object, requires that this class can always be described nominally, i.e. this class is not a hidden class or interface or an array with a hidden component type.static Stringstatic Stringstatic ClassDescforPrimitiveType(String descriptor, int offset) static ClassDescinternalNameToDesc(String internalName) Creates a ClassDesc from a pre-validated internal name for a class or interface type.static StringinternalToBinary(String name) static MethodTypeDescmethodTypeDesc(Class<?> returnType, Class<?>[] parameterTypes) Creates a MethodTypeDesc from return class and parameter class objects, requires that all of them can be described nominally.static MethodTypeDescmethodTypeDesc(MethodType type) Creates a MethodTypeDesc from a MethodType object, requires that the type can be described nominally, i.e. all of its return type and parameter types can be described nominally.static ClassDescreferenceClassDesc(Class<?> type) Creates a ClassDesc from a Class object representing a non-hidden class or interface or an array type with a non-hidden component type.static ClassDescreferenceClassDesc(String descriptor) Creates a ClassDesc from a pre-validated descriptor string for a class or interface type or an array type.static voidvalidateArrayRank(int rank) static StringValidates the correctness of a binary class name.static StringValidates the correctness of a binary package name.static voidvalidateClassOrInterface(ClassDesc classDesc) static StringValidates the correctness of an internal class name.static StringValidates the correctness of an internal package name.static StringvalidateMemberName(String name, boolean method) Validates a member namestatic StringvalidateModuleName(String name) Validates the correctness of a module name.
-
Field Details
-
EMPTY_CONSTANTDESC
an empty constant descriptor -
EMPTY_CLASSDESC
-
MAX_ARRAY_TYPE_DESC_DIMENSIONS
public static final int MAX_ARRAY_TYPE_DESC_DIMENSIONS- See Also:
-
CD_module_info
-
CD_Object_array
-
-
Method Details
-
binaryNameToDesc
Creates a ClassDesc from a pre-validated binary name for a class or interface type. Validated version ofClassDesc.of(String).- Parameters:
binaryName- a binary name
-
internalNameToDesc
Creates a ClassDesc from a pre-validated internal name for a class or interface type. Validated version of.invalid reference
ClassDesc#ofInternalName(String)- Parameters:
internalName- a binary name
-
classDesc
Creates a ClassDesc from a Class object, requires that this class can always be described nominally, i.e. this class is not a hidden class or interface or an array with a hidden component type. -
referenceClassDesc
Creates a ClassDesc from a Class object representing a non-hidden class or interface or an array type with a non-hidden component type. -
referenceClassDesc
Creates a ClassDesc from a pre-validated descriptor string for a class or interface type or an array type.- Parameters:
descriptor- a field descriptor string for a class or interface type
-
methodTypeDesc
Creates a MethodTypeDesc from a MethodType object, requires that the type can be described nominally, i.e. all of its return type and parameter types can be described nominally. -
methodTypeDesc
Creates a MethodTypeDesc from return class and parameter class objects, requires that all of them can be described nominally. This version is mainly useful for working with Method objects. -
validateBinaryClassName
Validates the correctness of a binary class name. In particular checks for the presence of invalid characters, empty name, consecutive, leading, or trailing..- Parameters:
name- the class name- Returns:
- the class name passed if valid
- Throws:
IllegalArgumentException- if the class name is invalidNullPointerException- if class name isnull
-
validateInternalClassName
Validates the correctness of an internal class name. In particular checks for the presence of invalid characters, empty name, consecutive, leading, or trailing/.- Parameters:
name- the class name- Returns:
- the class name passed if valid
- Throws:
IllegalArgumentException- if the class name is invalidNullPointerException- if class name isnull
-
validateBinaryPackageName
Validates the correctness of a binary package name. In particular checks for the presence of invalid characters, consecutive, leading, or trailing.. Allows empty strings for the unnamed package.- Parameters:
name- the package name- Returns:
- the package name passed if valid
- Throws:
IllegalArgumentException- if the package name is invalidNullPointerException- if the package name isnull
-
validateInternalPackageName
Validates the correctness of an internal package name. In particular checks for the presence of invalid characters, consecutive, leading, or trailing/. Allows empty strings for the unnamed package.- Parameters:
name- the package name- Returns:
- the package name passed if valid
- Throws:
IllegalArgumentException- if the package name is invalidNullPointerException- if the package name isnull
-
validateModuleName
Validates the correctness of a module name. In particular checks for the presence of invalid characters in the name. Empty module name is allowed. Module and Package Names- Parameters:
name- the module name- Returns:
- the module name passed if valid
- Throws:
IllegalArgumentException- if the module name is invalidNullPointerException- if the module name isnull
-
validateMemberName
Validates a member name- Parameters:
name- the name of the member- Returns:
- the name passed if valid
- Throws:
IllegalArgumentException- if the member name is invalidNullPointerException- if the member name isnull
-
validateClassOrInterface
-
validateArrayRank
public static void validateArrayRank(int rank) -
arrayDepth
Retrieves the array depth on a trusted descriptor. Uses a simple loop with the assumption that most descriptors have 0 or very low array depths. -
binaryToInternal
-
internalToBinary
-
dropFirstAndLastChar
-
forPrimitiveType
-
concat
-