public class Type extends Object
Modifier and Type | Field | Description |
---|---|---|
static Type |
B |
|
static Type |
BOOLEAN |
|
static Type |
BYTE |
|
static Type |
C |
|
static Type |
CHARACTER |
|
static Type |
D |
|
static Type |
DOUBLE |
|
static Type |
F |
|
static int |
F_ARRAY |
|
static int |
F_BOOLEAN |
|
static int |
F_FLOATING |
|
static int |
F_INTEGRAL |
|
static int |
F_NUMERIC |
|
static int |
F_OBJECT |
|
static int |
F_PRIMITIVE |
|
static int |
F_STRING |
|
static int |
F_UNKNOWN |
|
static int |
F_VALUE |
|
static int |
F_VOID |
|
static Type |
FLOAT |
|
static Type |
I |
|
static Type |
INTEGER |
|
static Type |
J |
|
static Type |
LONG |
|
static Type |
N |
|
static Type |
NUMBER |
|
static Type |
OBJECT |
|
static Type |
S |
|
static Type |
SHORT |
|
static Type |
STRING |
|
static Type |
UNDEFINED |
|
static Type |
VOID |
|
static Type |
Z |
Modifier | Constructor | Description |
---|---|---|
|
Type(String typeName) |
create a type with a given name and no associated class
|
|
Type(String typeName,
Class clazz) |
create a type with a given name and optionally an associated class
|
protected |
Type(String typeName,
Class clazz,
int flags,
int nBytes) |
|
protected |
Type(String typeName,
Class clazz,
int flags,
int nBytes,
Type baseType) |
Modifier and Type | Method | Description |
---|---|---|
boolean |
aliasTo(Type target) |
attempt to establish an alias from an package unqualified named object type to a package
qualified named object type whose unqualified name equals this type's name
|
Type |
arrayType() |
create an array type from this base type
|
Type |
arrayType(Class clazz) |
create an array type from this base type
|
static Type |
boxType(Class clazz) |
return the primitive type whose boxed equivalent is associated with a given class
|
static Type |
boxType(Type type) |
return the primitive type for a boxed type or vice versa
|
static Type |
builtinType(Class clazz) |
return the builtin type associated with a given class
|
static Type |
dereference(Type target) |
dereference an object type to the fully qualified named type to which it is aliased where
such an alias has been found to exist or return the supplied type if no alias exists or the
type is a non-objecttype or was originally specified using a fully qualified type name.
|
static String |
fixArrayType(String baseType,
int dimension) |
|
Type |
getBaseType() |
retrieve the base type for an array type or null if this is not an array type
|
String |
getInternalName() |
get the internal name for this type used by the class loader.
|
String |
getInternalName(boolean forDescriptor,
boolean slashSeparate) |
get the internal name for this type used by the class
loader.
|
String |
getName() |
get the possibly unqualified name with which this type was created
|
int |
getNBytes() |
return the number of stack words occupied by instances of this type
|
String |
getPackageName() |
get the package component of the name associated with this type or the empty String
if it has no package or is was defiend with an unqualified name or is a builtin type
|
Class |
getTargetClass() |
get the class associated with this type if it has one or a special undefined class if
the type is not defined or null if there is no associated class
|
static String |
internalName(Class<?> clazz) |
|
static String |
internalName(Class<?> clazz,
boolean forField) |
|
boolean |
isArray() |
return true if this is an array type
|
boolean |
isAssignableFrom(Type type) |
check whether this type can be assigned with values of the supplied type including
the case where numeric conversion from known or unknown numeric types but excluding
any other cases where this type is undefined
n.b.
|
boolean |
isBoolean() |
return true if this is a boolean type
|
boolean |
isDefined() |
check if this type is a known type.
|
boolean |
isFloating() |
return true if this is a floating type of whatever size, including the unknown
primitive numeric type
|
boolean |
isIntegral() |
return true if this is an integral type of whatever size, including the unknown
primitive numeric type
|
boolean |
isNumeric() |
return true if this is a numeric type, including the unknown primitive numeric type
|
boolean |
isObject() |
return true if this is an object type, including unbound types mentioned in rules
|
boolean |
isPrimitive() |
return true if this is a primitive value type
|
boolean |
isString() |
return true if this is the string type
|
boolean |
isUnbound() |
return true if this is a type mentioned in a rule but not yet bound to a specific class
|
boolean |
isUndefined() |
test if this type is an unknown type.
|
boolean |
isValue() |
return true if this is a value type, which includes the boxed versions of primitive types
|
boolean |
isVoid() |
return true if this is the void type
|
static int |
paramSlotIdx(int access,
String desc,
int paramIdx) |
identify the local var slot used to store a method parameter identified by parameter index
|
static String |
parseFieldDescriptor(String descriptor) |
|
static List<String> |
parseMethodDescriptor(String descriptor,
boolean includeReturnType) |
|
static String |
parseMethodReturnType(String descriptor) |
|
static Type |
promote(Type type1,
Type type2) |
compute the type to which a binary arithmetic operator should promote its operands
before combination based on the two operand types which is also the type to be
used for the result of the operation
|
void |
resolve(ClassLoader loader) |
|
String |
toString() |
public static final int F_BOOLEAN
public static final int F_INTEGRAL
public static final int F_FLOATING
public static final int F_OBJECT
public static final int F_VOID
public static final int F_ARRAY
public static final int F_NUMERIC
public static final int F_VALUE
public static final int F_UNKNOWN
public static final int F_PRIMITIVE
public static final int F_STRING
public static final Type Z
public static final Type B
public static final Type S
public static final Type C
public static final Type I
public static final Type J
public static final Type F
public static final Type D
public static final Type N
public static final Type BOOLEAN
public static final Type BYTE
public static final Type SHORT
public static final Type CHARACTER
public static final Type INTEGER
public static final Type LONG
public static final Type FLOAT
public static final Type DOUBLE
public static final Type STRING
public static final Type VOID
public static final Type NUMBER
public static final Type OBJECT
public static final Type UNDEFINED
public Type(String typeName, Class clazz)
typeName
- the name of the type which may or may not be fully qualifiedclazz
- the class associated with this name if it is know otherwise nullpublic Type(String typeName)
typeName
- the name of the type which may or may not be fully qualifiedpublic Type arrayType()
public Type arrayType(Class clazz)
clazz
- the class for the array type derived from the class of base type or
null if the base type is undefinedpublic Type getBaseType()
public String getName()
public String getInternalName()
public String getInternalName(boolean forDescriptor, boolean slashSeparate)
forDescriptor
- true if we need the name to appear in a
decriptor false if notslashSeparate
- true if the package separator should be
slash false if it should be dotpublic Class getTargetClass()
public String getPackageName()
public static Type dereference(Type target)
target
- the type to be dereferencedpublic void resolve(ClassLoader loader)
public boolean aliasTo(Type target)
target
- the package qualified named type for which this type should become an aliaspublic boolean isAssignableFrom(Type type)
type
- the type poviding RHS valuespublic boolean isUndefined()
public boolean isDefined()
public boolean isUnbound()
public boolean isPrimitive()
public boolean isValue()
public boolean isVoid()
public boolean isString()
public boolean isNumeric()
public boolean isIntegral()
public boolean isFloating()
public boolean isBoolean()
public boolean isObject()
public boolean isArray()
public int getNBytes()
public static Type builtinType(Class clazz)
clazz
- the class for the builtin typepublic static Type boxType(Class clazz)
clazz
- the class for the primitivebuiltin typepublic static Type boxType(Type type)
type
- the boxed typepublic static Type promote(Type type1, Type type2) throws TypeException
type1
- the type of the left operand which must be numeric but may be undefinedtype2
- the type of the right operand which must be numeric but may be undefinedTypeException
- if types are undefined or promotion is invalidpublic static List<String> parseMethodDescriptor(String descriptor, boolean includeReturnType)
public static int paramSlotIdx(int access, String desc, int paramIdx)
access
- the access flags for the method including whether or not it is staticdesc
- the intrenal form descriptor for the maethodparamIdx
- the index of the parameter in the parameter lost starting with 0 for this or 1 for
actual parametersCopyright © 2018. All rights reserved.