Package net.bytebuddy.utility
Enum JavaType
- java.lang.Object
-
- java.lang.Enum<JavaType>
-
- net.bytebuddy.utility.JavaType
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classJavaType.LatentTypeWithSimpleNameA latent type that resolves the simple name without considering the declaring type which is not normally available.
-
Enum Constant Summary
Enum Constants Enum Constant Description ACCESS_CONTROL_CONTEXTThejava.security.AccessControlContexttype which is deprecated for removal beginning in Java 17.CALL_SITEThe Java 7java.lang.invoke.CallSitetype.CLASS_DESCRIPTIONThe Java 12java.lang.constant.ClassDesctype.CONSTABLEThe Java 12java.lang.constant.Constabletype.CONSTANT_BOOTSTRAPSThe Java 12java.lang.invoke.ConstantBootstrapstype.CONSTANT_DESCRIPTIONThe Java 12java.lang.constant.ConstableDesctype.DIRECT_METHOD_HANDLE_DESCRIPTIONThe Java 12java.lang.constant.DirectMethodHandleDesctype.DYNAMIC_CONSTANT_DESCRIPTIONThe Java 12java.lang.constant.DynamicConstantDesctype.EXECUTABLEThe Java 7java.lang.reflect.Executabletype.METHOD_HANDLEThe Java 7java.lang.invoke.MethodHandletype.METHOD_HANDLE_DESCRIPTIONThe Java 12java.lang.constant.MethodHandleDesctype.METHOD_HANDLESThe Java 7java.lang.invoke.MethodHandlestype.METHOD_HANDLES_LOOKUPThe Java 7java.lang.invoke.MethodTypes.Lookuptype.METHOD_TYPEThe Java 7java.lang.invoke.MethodTypetype.METHOD_TYPE_DESCRIPTIONThe Java 12java.lang.constant.MethodTypeDesctype.MODULEThe Java 9java.lang.Moduletype.OBJECT_METHODSThe Java 14java.lang.runtime.ObjectMethodstype.PARAMETERThe Java 8java.lang.reflect.Parametertype.RECORDThe Java 14java.lang.Recordtype.TYPE_DESCRIPTORThe Java 12java.lang.invoke.TypeDescriptortype.TYPE_DESCRIPTOR_OF_FIELDThe Java 12java.lang.invoke.TypeDescriptor$OfMethodtype.TYPE_DESCRIPTOR_OF_METHODThe Java 12java.lang.invoke.TypeDescriptor$OfMethodtype.VAR_HANDLEThe Java 9java.lang.invoke.VarHandletype.
-
Field Summary
Fields Modifier and Type Field Description private TypeDescriptiontypeDescriptionThe type description to represent this type which is either a loaded type or a stub.
-
Constructor Summary
Constructors Modifier Constructor Description privateJavaType(java.lang.String typeName, int modifiers, java.lang.reflect.Type superClass, java.lang.reflect.Type... anInterface)Creates a new java type representation.privateJavaType(java.lang.String typeName, int modifiers, TypeDefinition superClass, TypeDefinition... anInterface)Creates a new java type representation.privateJavaType(java.lang.String typeName, int modifiers, TypeDescription.Generic superClass, TypeList.Generic interfaces)Creates a new java type representation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.BooleandoIsAvailable()Returnstrueif this type is available on the current VM.TypeDescriptiongetTypeStub()Returns at least a stub representing this type where the stub does not define any methods or fields.booleanisAvailable()Returnstrueif this type is available on the current JVM.booleanisInstance(java.lang.Object instance)Checks if the supplied object is an instance of this type.java.lang.Class<?>load()Loads the class that is represented by this Java type.TypeDescriptionloadAsDescription()Loads the class that is represented by this Java type and represents it as aTypeDescription.static JavaTypevalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static JavaType[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
CONSTABLE
public static final JavaType CONSTABLE
The Java 12java.lang.constant.Constabletype.
-
TYPE_DESCRIPTOR
public static final JavaType TYPE_DESCRIPTOR
The Java 12java.lang.invoke.TypeDescriptortype.
-
TYPE_DESCRIPTOR_OF_FIELD
public static final JavaType TYPE_DESCRIPTOR_OF_FIELD
The Java 12java.lang.invoke.TypeDescriptor$OfMethodtype.
-
TYPE_DESCRIPTOR_OF_METHOD
public static final JavaType TYPE_DESCRIPTOR_OF_METHOD
The Java 12java.lang.invoke.TypeDescriptor$OfMethodtype.
-
CONSTANT_DESCRIPTION
public static final JavaType CONSTANT_DESCRIPTION
The Java 12java.lang.constant.ConstableDesctype.
-
DYNAMIC_CONSTANT_DESCRIPTION
public static final JavaType DYNAMIC_CONSTANT_DESCRIPTION
The Java 12java.lang.constant.DynamicConstantDesctype.
-
CLASS_DESCRIPTION
public static final JavaType CLASS_DESCRIPTION
The Java 12java.lang.constant.ClassDesctype.
-
METHOD_TYPE_DESCRIPTION
public static final JavaType METHOD_TYPE_DESCRIPTION
The Java 12java.lang.constant.MethodTypeDesctype.
-
METHOD_HANDLE_DESCRIPTION
public static final JavaType METHOD_HANDLE_DESCRIPTION
The Java 12java.lang.constant.MethodHandleDesctype.
-
DIRECT_METHOD_HANDLE_DESCRIPTION
public static final JavaType DIRECT_METHOD_HANDLE_DESCRIPTION
The Java 12java.lang.constant.DirectMethodHandleDesctype.
-
METHOD_HANDLE
public static final JavaType METHOD_HANDLE
The Java 7java.lang.invoke.MethodHandletype.
-
METHOD_HANDLES
public static final JavaType METHOD_HANDLES
The Java 7java.lang.invoke.MethodHandlestype.
-
METHOD_TYPE
public static final JavaType METHOD_TYPE
The Java 7java.lang.invoke.MethodTypetype.
-
METHOD_HANDLES_LOOKUP
public static final JavaType METHOD_HANDLES_LOOKUP
The Java 7java.lang.invoke.MethodTypes.Lookuptype.
-
CALL_SITE
public static final JavaType CALL_SITE
The Java 7java.lang.invoke.CallSitetype.
-
VAR_HANDLE
public static final JavaType VAR_HANDLE
The Java 9java.lang.invoke.VarHandletype.
-
PARAMETER
public static final JavaType PARAMETER
The Java 8java.lang.reflect.Parametertype.
-
EXECUTABLE
public static final JavaType EXECUTABLE
The Java 7java.lang.reflect.Executabletype.
-
MODULE
public static final JavaType MODULE
The Java 9java.lang.Moduletype.
-
CONSTANT_BOOTSTRAPS
public static final JavaType CONSTANT_BOOTSTRAPS
The Java 12java.lang.invoke.ConstantBootstrapstype.
-
RECORD
public static final JavaType RECORD
The Java 14java.lang.Recordtype.
-
OBJECT_METHODS
public static final JavaType OBJECT_METHODS
The Java 14java.lang.runtime.ObjectMethodstype.
-
ACCESS_CONTROL_CONTEXT
public static final JavaType ACCESS_CONTROL_CONTEXT
Thejava.security.AccessControlContexttype which is deprecated for removal beginning in Java 17.
-
-
Field Detail
-
typeDescription
private final TypeDescription typeDescription
The type description to represent this type which is either a loaded type or a stub.
-
-
Constructor Detail
-
JavaType
private JavaType(java.lang.String typeName, int modifiers, @MaybeNull java.lang.reflect.Type superClass, java.lang.reflect.Type... 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 ornullif no super class is defined.anInterface- The interfaces of this type when creating a stub.
-
JavaType
private JavaType(java.lang.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 ornullif no super class is defined.anInterface- The interfaces of this type when creating a stub.
-
JavaType
private JavaType(java.lang.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 ornullif no super class is defined.interfaces- The interfaces of this type when creating a stub.
-
-
Method Detail
-
values
public static JavaType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (JavaType c : JavaType.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static JavaType valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- if the argument is null
-
getTypeStub
public TypeDescription 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
@Enhance("loaded") public java.lang.Class<?> load() throws java.lang.ClassNotFoundException
Loads the class that is represented by this Java type.- Returns:
- A loaded type of this Java type.
- Throws:
java.lang.ClassNotFoundException- If the represented type cannot be loaded.
-
loadAsDescription
public TypeDescription loadAsDescription() throws java.lang.ClassNotFoundException
Loads the class that is represented by this Java type and represents it as aTypeDescription.- Returns:
- A loaded type of this Java type.
- Throws:
java.lang.ClassNotFoundException- If the represented type cannot be loaded.
-
isAvailable
public boolean isAvailable()
Returnstrueif this type is available on the current JVM.- Returns:
trueif this type is available on the current JVM.
-
doIsAvailable
@Enhance("available") private java.lang.Boolean doIsAvailable()
Returnstrueif 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:
trueif this type is available on the current JVM.
-
isInstance
public boolean isInstance(java.lang.Object instance)
Checks if the supplied object is an instance of this type.- Parameters:
instance- The instance to check.- Returns:
trueif the supplied object is an instance of this type.
-
-