Class ReferenceType
java.lang.Object
org.apache.bcel.generic.Type
org.apache.bcel.generic.ReferenceType
- Direct Known Subclasses:
ArrayType, ObjectType, UninitializedObjectType
Superclass for object and array types.
-
Field Summary
Fields inherited from class Type
BOOLEAN, BYTE, CHAR, CLASS, DOUBLE, FLOAT, INT, LONG, NO_ARGS, NULL, OBJECT, SHORT, signature, STRING, STRINGBUFFER, THROWABLE, type, UNKNOWN, VOIDModifier and TypeFieldDescriptionstatic final BasicTypePredefined constant for boolean type.static final BasicTypePredefined constant for byte type.static final BasicTypePredefined constant for char type.static final ObjectTypePredefined constant for Class type.static final BasicTypePredefined constant for double type.static final BasicTypePredefined constant for float type.static final BasicTypePredefined constant for int type.static final BasicTypePredefined constant for long type.static final Type[]Empty array.static final ReferenceTypePredefined constant for null type.static final ObjectTypePredefined constant for Object type.static final BasicTypePredefined constant for short type.protected StringDeprecated.(since 6.0) will be made private; do not access directly, use getter/setterstatic final ObjectTypePredefined constant for String type.static final ObjectTypePredefined constant for StringBuffer type.static final ObjectTypePredefined constant for Throwable type.protected byteDeprecated.(since 6.0) will be made private; do not access directly, use getter/setterstatic final TypePredefined constant for unknown type.static final BasicTypePredefined constants -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedReferenceType(byte t, String s) Constructs a ReferenceType. -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.Use getFirstCommonSuperclass(ReferenceType t) which has slightly changed semantics.Gets the first common superclass (narrowest ReferenceType referencing a class, not an interface).booleanTests whether this type is assignment compatible with another type t as defined in the JVM specification; see the AASTORE definition there.booleanisCastableTo(Type t) Tests whether this type is castable to another type t as defined in the JVM specification.Methods inherited from class Type
equals, getArgumentTypes, getClassName, getMethodSignature, getReturnType, getSignature, getSignature, getSize, getType, getType, getType, getTypes, hashCode, normalizeForStackOrLocal, toStringModifier and TypeMethodDescriptionbooleanstatic Type[]getArgumentTypes(String signature) Gets the argument types of a method from its signature as an array of Type objects.Gets the class name.static StringgetMethodSignature(Type returnType, Type[] argTypes) Gets the Java method signature for the given types, for example, int[] f(java.lang.String x) becomes (Ljava/lang/String;)[I.static TypegetReturnType(String signature) Gets the return type of a method from its signature as a Type object.Gets the signature for this type.static StringgetSignature(Method meth) Gets the signature for a method.intgetSize()Gets the stack size of this type.bytegetType()Gets the type as defined in Constants.static TypeGets the BCEL Type object corresponding to a runtimeClass.static TypeGets the Type object corresponding to a signature.static Type[]Gets the BCEL Type objects corresponding to an array of runtime classes.inthashCode()Gets the hash code of this Type.boolean, short and char variable are considered as int in the stack or local variable area.toString()
-
Constructor Details
-
ReferenceType
Constructs a ReferenceType.- Parameters:
t- The type.s- The signature.
-
-
Method Details
-
firstCommonSuperclass
@Deprecated public ReferenceType firstCommonSuperclass(ReferenceType t) throws ClassNotFoundException Deprecated.Use getFirstCommonSuperclass(ReferenceType t) which has slightly changed semantics.This commutative operation returns the first common superclass (narrowest ReferenceType referencing a class, not an interface). If one of the types is a superclass of the other, the former is returned. If "this" is NULL, then t is returned. If t is NULL, then "this" is returned. If "this" equals t ['this.equals(t)'] "this" is returned. If "this" or t is an ArrayType, thenType.OBJECTis returned. If "this" or t is a ReferenceType referencing an interface, thenType.OBJECTis returned. If not all of the two classes' superclasses cannot be found, "null" is returned. See the JVM specification edition 2, "�4.9.2 The Bytecode Verifier".- Parameters:
t- The other type.- Returns:
- The first common superclass.
- Throws:
ClassNotFoundException- Thrown on failure to find superclasses of this type, or the type passed as a parameter.
-
getFirstCommonSuperclass
Gets the first common superclass (narrowest ReferenceType referencing a class, not an interface). If one of the types is a superclass of the other, the former is returned. If "this" is NULL, then t is returned. If t is NULL, then "this" is returned. If "this" equals t ['this.equals(t)'] "this" is returned. If "this" or t is an ArrayType, thenType.OBJECTis returned; unless their dimensions match. Then an ArrayType of the same number of dimensions is returned, with its basic type being the first common superclass of the basic types of "this" and t. If "this" or t is a ReferenceType referencing an interface, thenType.OBJECTis returned. If not all of the two classes' superclasses cannot be found, "null" is returned. See the JVM specification edition 2, "�4.9.2 The Bytecode Verifier".- Parameters:
t- The other type.- Returns:
- The first common superclass.
- Throws:
ClassNotFoundException- Thrown on failure to find superclasses of this type, or the type passed as a parameter.
-
isAssignmentCompatibleWith
Tests whether this type is assignment compatible with another type t as defined in the JVM specification; see the AASTORE definition there.- Parameters:
t- The other type.- Returns:
- true iff this is assignment compatible with another type t.
- Throws:
ClassNotFoundException- Thrown if any classes or interfaces required to determine assignment compatibility can't be found.
-
isCastableTo
Tests whether this type is castable to another type t as defined in the JVM specification. The case where this isType.NULLis not defined (see the CHECKCAST definition in the JVM specification). However, because for example CHECKCAST doesn't throw a ClassCastException when casting a null reference to any Object, true is returned in this case.- Parameters:
t- The other type.- Returns:
- true iff this type is castable to another type t.
- Throws:
ClassNotFoundException- Thrown if any classes or interfaces required to determine assignment compatibility can't be found.
-