|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.umd.cs.findbugs.ba.type2.TypeRepository
public class TypeRepository
Factory/repository class to ensure that all abstract Java types are represented by a unique Type object. Queries on the type hierarchy can be performed on the types instantiated by the repository.
Typically, this class is used by specifying a
ClassResolver
that does the work of
finding class representations, which will determine
whether particular types are classes or interfaces,
and what the superclasses and superinterfaces of
class and interface types are. The isSubtype(edu.umd.cs.findbugs.ba.type2.ObjectType, edu.umd.cs.findbugs.ba.type2.ObjectType)
method will automatically construct the class hierarchy
using the ClassResolver to determine the hierarchy.
Another way to use TypeRepository is to explicitly mark
ClassType objects as interfaces or classes, and add the
subtype relationships using addSuperclassLink(edu.umd.cs.findbugs.ba.type2.ObjectType, edu.umd.cs.findbugs.ba.type2.ObjectType)
and addInterfaceLink(edu.umd.cs.findbugs.ba.type2.ObjectType, edu.umd.cs.findbugs.ba.type2.ClassType)
for ClassTypes. Subtype
relationships for array types are always added automatically
based on the class hierarchy. Note that if you use this
approach, you must explicitly add java.lang.Object
,
java.io.Serializable
, and java.lang.Cloneable
to the repository.
Type
,
ClassResolver
Constructor Summary | |
---|---|
TypeRepository(ClassResolver resolver)
Constructor. |
Method Summary | |
---|---|
void |
addInterfaceLink(ObjectType implementor,
ClassType iface)
Add a direct implemented interface relationship to types in the repository. |
void |
addSuperclassLink(ObjectType subclass,
ObjectType superclass)
Add a direct superclass relationship to types in the repository. |
ArrayType |
arrayTypeFromDimensionsAndBaseType(int numDimensions,
Type baseType)
Get an ArrayType from number of dimensions and base type. |
ArrayType |
arrayTypeFromElementType(Type elementType)
Create a one-dimensional array type with given element type, which can be an array type. |
ArrayType |
arrayTypeFromSignature(java.lang.String signature)
Get an ArrayType from an array signature, creating it if it doesn't exist. |
BasicType |
basicTypeFromSignature(java.lang.String signature)
Create an BasicType from a basic type signature. |
BasicType |
basicTypeFromTypeCode(byte typeCode)
Create an BasicType from a type code. |
ClassType |
classTypeFromDottedClassName(java.lang.String dottedClassName)
Get a ClassType from a class or interface name using dots to separate package components, creating it if it doesn't exist. |
ClassType |
classTypeFromSignature(java.lang.String signature)
Get a ClassType from a signature, e.g., JAVA_LANG_OBJECT_SIGNATURE. |
ClassType |
classTypeFromSlashedClassName(java.lang.String slashedClassName)
Get a ClassType from a class or interface name using slashes to separate package components, creating it if it doesn't exist. |
BasicType |
getBooleanType()
Get the boolean type. |
Type |
getBottomType()
Get the instance of the special BOTTOM type. |
BasicType |
getByteType()
Get the byte type. |
BasicType |
getCharType()
Get the char type. |
Type |
getDoubleExtraType()
Get the instance of the special double extra type. |
BasicType |
getDoubleType()
Get the double type. |
ObjectType |
getFirstCommonSuperclass(ObjectType a,
ObjectType b)
Get the first common superclass of two object types, in the sense used by the VM Spec. |
BasicType |
getFloatType()
Get the float type. |
BasicType |
getIntType()
Get the int type. |
Type |
getLongExtraType()
Get the instance of the special long extra type. |
BasicType |
getLongType()
Get the long type. |
Type |
getNullType()
Get the instance of the special NULL type. |
Type |
getReturnAddressType()
Get the instance of the return address type. |
BasicType |
getShortType()
Get the short type. |
ClassType |
getSuperclass(ClassType type)
Get the superclass of a class type. |
Type |
getTopType()
Get the instance of the special TOP type. |
BasicType |
getVoidType()
Get the void type. |
boolean |
isSubtype(ObjectType subtype,
ObjectType supertype)
Determine if one object type is a subtype of another. |
Type |
specialTypeFromSignature(java.lang.String signature)
Create a special type from a signature. |
Type |
typeFromSignature(java.lang.String signature)
Get an Type object representing the type whose JVM signature is given, creating it if it doesn't exist. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TypeRepository(ClassResolver resolver)
resolver
- the ClassResolver that will be used to
find inheritance hierarchy information for classesMethod Detail |
---|
public ClassType classTypeFromSignature(java.lang.String signature)
signature
- the class signature
public ClassType classTypeFromSlashedClassName(java.lang.String slashedClassName)
slashedClassName
- class name in slashed format
public ClassType classTypeFromDottedClassName(java.lang.String dottedClassName)
dottedClassName
- the class name in dotted format
public ArrayType arrayTypeFromSignature(java.lang.String signature) throws InvalidSignatureException
signature
- the array signature
InvalidSignatureException
public ArrayType arrayTypeFromDimensionsAndBaseType(int numDimensions, Type baseType)
numDimensions
- the number of dimensionsbaseType
- the base type (e.g, "Object" in the array type
"Object[][]"): must be created from this type repository
public ArrayType arrayTypeFromElementType(Type elementType)
elementType
- the element type
public BasicType basicTypeFromTypeCode(byte typeCode)
typeCode
- the basic type code (T_BOOLEAN, etc.)
public BasicType basicTypeFromSignature(java.lang.String signature) throws InvalidSignatureException
signature
- the signature
InvalidSignatureException
public Type specialTypeFromSignature(java.lang.String signature) throws InvalidSignatureException
SpecialTypeSignatures
.
signature
- special type signature
InvalidSignatureException
public Type typeFromSignature(java.lang.String signature) throws InvalidSignatureException
signature
- the JVM signature of the type: something
like "B" (the byte basic type), "Ljava/lang/String;"
(the type of a reference to java.lang.String), or
"[Ljava/lang/Object;" (the type of a reference to an array of
java.lang.Object references).
InvalidSignatureException
public BasicType getVoidType()
public BasicType getBooleanType()
public BasicType getByteType()
public BasicType getCharType()
public BasicType getShortType()
public BasicType getIntType()
public BasicType getLongType()
public BasicType getFloatType()
public BasicType getDoubleType()
public Type getTopType()
public Type getBottomType()
public Type getNullType()
public Type getLongExtraType()
public Type getDoubleExtraType()
public Type getReturnAddressType()
public void addSuperclassLink(ObjectType subclass, ObjectType superclass)
subclass
- the subclasssuperclass
- the superclasspublic void addInterfaceLink(ObjectType implementor, ClassType iface)
implementor
- the class or interface directly implementing the interface (i.e., the subtype)iface
- the implemented interface (i.e., the supertype)public boolean isSubtype(ObjectType subtype, ObjectType supertype) throws java.lang.ClassNotFoundException
subtype
- the potential subtypesupertype
- the potential supertype
java.lang.ClassNotFoundException
public ClassType getSuperclass(ClassType type) throws java.lang.ClassNotFoundException
type
- the class type
java.lang.ClassNotFoundException
public ObjectType getFirstCommonSuperclass(ObjectType a, ObjectType b) throws java.lang.ClassNotFoundException
This operation is commutative.
a
- an ObjectTypeb
- another ObjectType
java.lang.ClassNotFoundException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |