Package net.bytebuddy.utility
Enum Class JavaType
- All Implemented Interfaces:
Serializable
,Comparable<JavaType>
,Constable
Representations of Java types that do not exist in Java 6 but that have a special meaning to the JVM.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
A latent type that resolves the simple name without considering the declaring type which is not normally available.Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionThejava.security.AccessControlContext
type which is deprecated for removal beginning in Java 17.The Java 7java.lang.invoke.CallSite
type.The Java 12java.lang.constant.ClassDesc
type.The Java 12java.lang.constant.Constable
type.The Java 12java.lang.invoke.ConstantBootstraps
type.The Java 12java.lang.constant.ConstableDesc
type.The Java 12java.lang.constant.DirectMethodHandleDesc
type.The Java 12java.lang.constant.DynamicConstantDesc
type.The Java 7java.lang.reflect.Executable
type.The Java 7java.lang.invoke.MethodHandle
type.The Java 12java.lang.constant.MethodHandleDesc
type.The Java 7java.lang.invoke.MethodHandles
type.The Java 7java.lang.invoke.MethodTypes.Lookup
type.The Java 7java.lang.invoke.MethodType
type.The Java 12java.lang.constant.MethodTypeDesc
type.The Java 9java.lang.Module
type.The Java 14java.lang.runtime.ObjectMethods
type.The Java 8java.lang.reflect.Parameter
type.The Java 14java.lang.Record
type.The Java 12java.lang.invoke.TypeDescriptor
type.The Java 12java.lang.invoke.TypeDescriptor$OfMethod
type.The Java 12java.lang.invoke.TypeDescriptor$OfMethod
type.The Java 9java.lang.invoke.VarHandle
type. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final TypeDescription
The type description to represent this type which is either a loaded type or a stub. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Creates a new java type representation.private
JavaType
(String typeName, int modifiers, TypeDefinition superClass, TypeDefinition... anInterface) Creates a new java type representation.private
JavaType
(String typeName, int modifiers, TypeDescription.Generic superClass, TypeList.Generic interfaces) Creates a new java type representation. -
Method Summary
Modifier and TypeMethodDescriptionprivate Boolean
Returnstrue
if this type is available on the current VM.Returns at least a stub representing this type where the stub does not define any methods or fields.boolean
Returnstrue
if this type is available on the current JVM.boolean
isInstance
(Object instance) Checks if the supplied object is an instance of this type.Class
<?> load()
Loads the class that is represented by this Java type.Loads the class that is represented by this Java type and represents it as aTypeDescription
.static JavaType
Returns the enum constant of this class with the specified name.static JavaType[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
CONSTABLE
The Java 12java.lang.constant.Constable
type. -
TYPE_DESCRIPTOR
The Java 12java.lang.invoke.TypeDescriptor
type. -
TYPE_DESCRIPTOR_OF_FIELD
The Java 12java.lang.invoke.TypeDescriptor$OfMethod
type. -
TYPE_DESCRIPTOR_OF_METHOD
The Java 12java.lang.invoke.TypeDescriptor$OfMethod
type. -
CONSTANT_DESCRIPTION
The Java 12java.lang.constant.ConstableDesc
type. -
DYNAMIC_CONSTANT_DESCRIPTION
The Java 12java.lang.constant.DynamicConstantDesc
type. -
CLASS_DESCRIPTION
The Java 12java.lang.constant.ClassDesc
type. -
METHOD_TYPE_DESCRIPTION
The Java 12java.lang.constant.MethodTypeDesc
type. -
METHOD_HANDLE_DESCRIPTION
The Java 12java.lang.constant.MethodHandleDesc
type. -
DIRECT_METHOD_HANDLE_DESCRIPTION
The Java 12java.lang.constant.DirectMethodHandleDesc
type. -
METHOD_HANDLE
The Java 7java.lang.invoke.MethodHandle
type. -
METHOD_HANDLES
The Java 7java.lang.invoke.MethodHandles
type. -
METHOD_TYPE
The Java 7java.lang.invoke.MethodType
type. -
METHOD_HANDLES_LOOKUP
The Java 7java.lang.invoke.MethodTypes.Lookup
type. -
CALL_SITE
The Java 7java.lang.invoke.CallSite
type. -
VAR_HANDLE
The Java 9java.lang.invoke.VarHandle
type. -
PARAMETER
The Java 8java.lang.reflect.Parameter
type. -
EXECUTABLE
The Java 7java.lang.reflect.Executable
type. -
MODULE
The Java 9java.lang.Module
type. -
CONSTANT_BOOTSTRAPS
The Java 12java.lang.invoke.ConstantBootstraps
type. -
RECORD
The Java 14java.lang.Record
type. -
OBJECT_METHODS
The Java 14java.lang.runtime.ObjectMethods
type. -
ACCESS_CONTROL_CONTEXT
Thejava.security.AccessControlContext
type which is deprecated for removal beginning in Java 17.
-
-
Field Details
-
typeDescription
The type description to represent this type which is either a loaded type or a stub.
-
-
Constructor Details
-
JavaType
Creates a new java type representation.- Parameters:
typeName
- The binary name of this type.modifiers
- The modifiers of this type when creating a stub.superClass
- The super class of this type when creating a stub ornull
if no super class is defined.anInterface
- The interfaces of this type when creating a stub.
-
JavaType
private JavaType(String typeName, int modifiers, @MaybeNull TypeDefinition superClass, TypeDefinition... anInterface) Creates a new java type representation.- Parameters:
typeName
- The binary name of this type.modifiers
- The modifiers of this type when creating a stub.superClass
- The super class of this type when creating a stub ornull
if no super class is defined.anInterface
- The interfaces of this type when creating a stub.
-
JavaType
private JavaType(String typeName, int modifiers, @MaybeNull TypeDescription.Generic superClass, TypeList.Generic interfaces) Creates a new java type representation.- Parameters:
typeName
- The binary name of this type.modifiers
- The modifiers of this type when creating a stub.superClass
- The super class of this type when creating a stub ornull
if no super class is defined.interfaces
- The interfaces of this type when creating a stub.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
getTypeStub
Returns at least a stub representing this type where the stub does not define any methods or fields. If a type exists for the current runtime, a loaded type representation is returned.- Returns:
- A type description for this Java type.
-
load
Loads the class that is represented by this Java type.- Returns:
- A loaded type of this Java type.
- Throws:
ClassNotFoundException
- If the represented type cannot be loaded.
-
loadAsDescription
Loads the class that is represented by this Java type and represents it as aTypeDescription
.- Returns:
- A loaded type of this Java type.
- Throws:
ClassNotFoundException
- If the represented type cannot be loaded.
-
isAvailable
public boolean isAvailable()Returnstrue
if this type is available on the current JVM.- Returns:
true
if this type is available on the current JVM.
-
doIsAvailable
Returnstrue
if this type is available on the current VM. By boxing the result, the result can be cached efficiently what is not possible when using a primitive type.- Returns:
true
if this type is available on the current JVM.
-
isInstance
Checks if the supplied object is an instance of this type.- Parameters:
instance
- The instance to check.- Returns:
true
if the supplied object is an instance of this type.
-