Packages

class ClassHierarchy extends AnyRef

Represents a project's class hierarchy. The class hierarchy only contains information about those classes that were explicitly added to it. Hence, the class hierarchy may contain holes. However, the type java.lang.Object is always part of the class hierarchy.

Thread safety

This class is effectively immutable; concurrent access to the class hierarchy is supported.

Source
ClassHierarchy.scala
Note

Java 9 module definitions are completely ignored.

,

Unless explicitly documented, it is an error to pass an instance of ObjectType to any method if the ObjectType was not previously added. If in doubt, first check if the type is known (isKnown/ifKnown).

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ClassHierarchy
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def allSubclassTypes(objectType: ObjectType, reflexive: Boolean): Iterator[ObjectType]

    Returns all (direct and indirect) subclass types of the given class type.

    Returns all (direct and indirect) subclass types of the given class type.

    Note

    No explicit isKnown check is required; if the type is unknown, an empty iterator is returned.

  5. def allSubtypes(objectType: ObjectType, reflexive: Boolean): Set[ObjectType]

    The set of all class- and interface-types that (directly or indirectly) inherit from the given type.

    The set of all class- and interface-types that (directly or indirectly) inherit from the given type.

    objectType

    An ObjectType.

    reflexive

    If true the given type is also included in the returned set.

    returns

    The set of all direct and indirect subtypes of the given type.

    Note

    No explicit isKnown check is required; if the type is unknown the returned set will be empty unless reflexive is true.

    ,

    If you don't need the set, it is more efficient to use foreachSubtype.

    ,

    If the type hierarchy is not complete, the answer may also be incomplete. E.g., if x inherits from y and y inherits from z, but y is not known to the class hierarchy then x will not be in the set of all (known) subtypes of z.

  6. def allSubtypesForeachIterator(objectType: ObjectType, reflexive: Boolean): ForeachRefIterator[ObjectType]
  7. def allSubtypesIterator(objectType: ObjectType, reflexive: Boolean): Iterator[ObjectType]
  8. def allSuperclassTypesInInitializationOrder(objectType: ObjectType): QualifiedCollection[List[ObjectType]]

    Returns the list of all super types in initialization order.

    Returns the list of all super types in initialization order. I.e., it will return the top level super class first - i.e., java.lang.Object and then all sub class types.

    If the given type is java.lang.Object, the empty list is returned.

    Interfaces are not further considered, because they generally don't need any instance initialization. If the given type is an interface type, the returned list will hence only contain java.lang.Object.

    Note

    If the class hierarchy is not complete, it may happen that the super class chain is not complete. In this case an org.opalj.collection.IncompleteCollection will be returned.

  9. def allSuperclassesIterator(ot: ObjectType, reflexive: Boolean = false)(implicit project: ClassFileRepository): Iterator[ClassFile]

    Efficient, best-effort iterator over all super types of the given type.

  10. def allSuperinterfacetypes(objectType: ObjectType, reflexive: Boolean = false): UIDSet[ObjectType]

    Returns the set of all interfaces directly or indirectly implemented by the given type.

    Returns the set of all interfaces directly or indirectly implemented by the given type.

    reflexive

    If true the returned set will also contain the given type if it is an interface type.

    Exceptions thrown

    NullPointerException if the project is very broken (e.g., if a class states that it inherits from class C, but class C is actually an interface).

  11. def allSupertypes(objectType: ObjectType, reflexive: Boolean = false): UIDSet[ObjectType]

    The set of all supertypes of the given type.

    The set of all supertypes of the given type.

    reflexive

    If true, the returned set will also contain the given type.

    Note

    Whenever possible, one of the higher-order functions should be used to avoid the creation of intermediate data-structures.

  12. def allSupertypesOf(types: UIDSet[ObjectType], reflexive: Boolean): UIDSet[ObjectType]

    Calculates the set of all supertypes of the given types.

  13. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  14. def asTSV: String

    A dump of the class hierarchy information in TSV format.

    A dump of the class hierarchy information in TSV format. The following information will be dumped:

    • type
    • id
    • (is) interface
    • (is) final
    • (is) root type
    • (is) leaf type
    • (is) supertype information complete
    • super class
    • super interfaces
    • sub classes
    • sub interfaces
  15. final def canBeStoredIn(elementValueType: FieldType, elementValueTypeIsPrecise: Boolean, arrayType: ArrayType, arrayTypeIsPrecise: Boolean): Answer

    Determines if a value of type elementValueType can be stored in an array of type arrayType.

    Determines if a value of type elementValueType can be stored in an array of type arrayType. E.g., a value of type IntegerType can be stored in an array (one-dimensional) of type ArrayType(IntegerType). This method takes the fact that a type may just model an upper type bound into account.

    elementValueType

    The type of the value that should be stored in the array. This type is compared against the component type of the array.

    elementValueTypeIsPrecise

    Specifies if the type information is precise; i.e., whether elementValueType models the precise runtime type (true) or just an upper bound (false). If the elementValueType is a base/ primitive type, then this value should be true; but actually it is ignored.

    arrayType

    The type of the array.

    arrayTypeIsPrecise

    Specifies if the type information is precise; i.e., whether arrayType models the precise runtime type (true) or just an upper bound (false).

    Annotations
    @tailrec()
  16. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
  17. def directSubclassesOf(objectType: ObjectType): UIDSet[ObjectType]
  18. def directSubinterfacesOf(objectType: ObjectType): UIDSet[ObjectType]
  19. def directSubtypesCount(objectTypeId: Int): Int
  20. def directSubtypesCount(objectType: ObjectType): Int
  21. def directSubtypesOf(upperTypeBound: UIDSet[ObjectType]): UIDSet[ObjectType]

    Computes the set of types which are subtypes (reflexive) of all types identified by the given upper type bound.

    Computes the set of types which are subtypes (reflexive) of all types identified by the given upper type bound. E.g., the class X which implements I and J, would be a direct subtype of the upper type bound consisting of I and J. If the bound consists of only one type, then the bound is returned.

    upperTypeBound

    A set of types that are in no inheritance relationship. upperTypeBound must not be empty.

  22. def directSubtypesOf(objectType: ObjectType): Iterator[ObjectType]

    The direct subtypes of the given type (not reflexive).

  23. def directSuperinterfacesOf(objectType: ObjectType): UIDSet[ObjectType]
  24. def directSupertypes(objectType: ObjectType): UIDSet[ObjectType]
  25. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  26. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  27. def existsSubclass(objectType: ObjectType, project: ClassFileRepository)(p: (ClassFile) => Boolean): Boolean

    Tests if a subtype of the given ObjectType exists that satisfies the given predicate.

    Tests if a subtype of the given ObjectType exists that satisfies the given predicate. In this case the subtype relation is not reflexive.

    Subtypes for which no ClassFile object is available are ignored.

    Note

    No explicit isKnown check is required; if the type is unknown nothing will happen.

  28. def foreachDirectSubclassType[T](objectType: ObjectType, project: ClassFileRepository)(f: (ClassFile) => T): Unit

    Executes the given function f for each known direct subclass of the given ObjectType.

    Executes the given function f for each known direct subclass of the given ObjectType. In this case the subclass relation is not reflexive and interfaces inheriting from the given object type are ignored.

    Subtypes for which no ClassFile object is available are ignored.

    Note

    No explicit isKnown check is required; if the type is unknown nothing will happen.

  29. def foreachDirectSubtypeOf[U](objectType: ObjectType)(f: (ObjectType) => U): Unit
  30. def foreachDirectSupertype(objectType: ObjectType)(f: (ObjectType) => Unit): Unit
  31. def foreachDirectSupertypeCF[U](objectType: ObjectType)(f: (ClassFile) => U)(implicit project: ClassFileRepository): Unit
  32. def foreachKnownType[T](f: (ObjectType) => T): Unit

    Calls the given function f for each type that is known to the class hierarchy.

  33. def foreachSubclass(objectType: ObjectType, project: ClassFileRepository)(f: (ClassFile) => Unit): Unit

    Executes the given function f for each subclass of the given ObjectType.

    Executes the given function f for each subclass of the given ObjectType. In this case the subclass relation is not reflexive. Furthermore, it may be possible that f is invoked multiple times using the same ClassFile object if the given objectType identifies an interface.

    Subtypes for which no ClassFile object is available are ignored.

    Note

    No explicit isKnown check is required; if the type is unknown nothing will happen.

    ,

    For details regarding incomplete class hierarchies see foreachSubtype.

  34. def foreachSubinterfaceType(interfaceType: ObjectType)(f: (ObjectType) => Boolean): Unit

    Iterates over all subinterfaces of the given interface type (or java.lang.Object) until the callback function returns "false".

  35. def foreachSubtype(objectType: ObjectType, reflexive: Boolean = false)(process: (ObjectType) => Boolean): Unit

    Iterates over all subtypes of the given type, by first iterating over the subclass types and then iterating over the subinterface types (if the given object type defines an interface type or identifies java.lang.Object).

    Iterates over all subtypes of the given type, by first iterating over the subclass types and then iterating over the subinterface types (if the given object type defines an interface type or identifies java.lang.Object).

    process

    The process function will be called for each subtype of the given type. If process returns false, subtypes of the current type will no longer be traversed. However, if a subtype of the current type is reachable via another path (by means of interface inheritance) then that subtype may be processed.

    Note

    Classes are always traversed first.

  36. def foreachSubtype(objectType: ObjectType)(f: (ObjectType) => Unit): Unit

    Calls the function f for each known (direct or indirect) subtype of the given type.

    Calls the function f for each known (direct or indirect) subtype of the given type.

    objectType

    An ObjectType.

    Note

    No explicit isKnown check is required; if the type is unknown nothing will happen.

    ,

    For details regarding incomplete class hierarchies see allSubtypes. *

  37. def foreachSubtypeCF(objectType: ObjectType, reflexive: Boolean = false)(process: (ClassFile) => Boolean)(implicit project: ClassFileRepository): Unit
  38. def foreachSuperclass(objectType: ObjectType, project: ClassFileRepository)(f: (ClassFile) => Unit): Unit

    Calls the function f for each supertype of the given object type for which the classfile is available.

    Calls the function f for each supertype of the given object type for which the classfile is available.

    It is possible that the class file of the same super interface type I is passed multiple times to f when I is implemented multiple times by the given type's supertypes.

    The algorithm first iterates over the type's super classes before it iterates over the super interfaces.

    Note

    See foreachSupertype for details.

  39. def foreachSuperinterfaceType(t: ObjectType)(f: (ObjectType) => Boolean): Unit

    Iterates over all direct and indirect (also by means of super classes) superinterfaces of the type until the callback function returns "false".

  40. def foreachSupertype(ot: ObjectType, reflexive: Boolean = false)(f: (ObjectType) => Unit): Unit

    Calls the given function f for each of the given type's supertypes.

  41. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  42. final def getObjectType(objectTypeId: Int): ObjectType

    Returns the ObjectType with the given Id.

    Returns the ObjectType with the given Id. The id has to be the id of a valid ObjectType.

  43. def getSupertypeDeclaration(subtype: ClassSignature, supertype: ObjectType)(implicit project: ClassFileRepository): Option[ClassTypeSignature]

    Determines whether the given ClassSignature of subtype implements or extends the given supertype.

    Determines whether the given ClassSignature of subtype implements or extends the given supertype. In case that the subtype does implement or extend the supertype, an Option of ClassTypeSignature is returned. Otherwise None will be returned.

    subtype

    Any type or interface.

    supertype

    Any type or interface.

    returns

    Option of ClassTypeSignature if the subtype extends or implements the given supertype, None otherwise.

    Example:
    1. subtype: ClassSignature from class A where A extends List<String> supertype: List as ObjectType This method scans all super classes and super interfaces of A in order to find the concrete class declaration of List where it is bound to String. The above example would yield the ClassTypeSignature of List<String>.

  44. def hasSubtypes(objectType: ObjectType): Answer

    Returns Yes if the class hierarchy contains subtypes of the given type and No if it contains no subtypes.

    Returns Yes if the class hierarchy contains subtypes of the given type and No if it contains no subtypes. Unknown is returned if the given type is not known.

    Please note, that the answer will be No even though the (running) project contains (in)direct subtypes of the given type, but the class hierarchy is not complete. I.e., not all class files (libraries) used by the project are analyzed. A second case is that some class files are generated at runtime that inherit from the given ObjectType.

    objectType

    Some ObjectType.

    Note

    No explicit isKnown check is required.

  45. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  46. final def ifKnown[T](objectType: ObjectType)(f: (ObjectType) => T): Option[T]

    Tests if the given objectType is known and if so executes the given function.

    Tests if the given objectType is known and if so executes the given function.

    Annotations
    @inline()
    Example:
    1. ifKnown(ObjectType.Serializable){isDirectSupertypeInformationComplete}
  47. def isASubtypeOf(subtype: ClassTypeSignature, supertype: FormalTypeParameter)(implicit p: ClassFileRepository): Answer

    Determines if the given class or interface type encoded in a ClassTypeSignature subtype is actually a subtype of the class, interface or intersection type encoded in the FormalTypeParameter of the supertype parameter.

    Determines if the given class or interface type encoded in a ClassTypeSignature subtype is actually a subtype of the class, interface or intersection type encoded in the FormalTypeParameter of the supertype parameter. The subtype relation is fulfilled if the subtype is a subtype of the class bound and/or all interface types that are prescribed by the formal type specification.

    subtype

    Any ClassTypeSignature.

    supertype

    Any FormalTypeParameter.

    returns

    Yes if subtype is a subtype of the given supertype. No if subtype is not a subtype of supertype and Unknown if the analysis is not conclusive. The latter can happen if the class hierarchy is not complete and hence precise information about a type's supertypes is not available.

    Note

    This method does consider generics types specified within the FormalTypeParameter.

  48. def isASubtypeOf(subtype: ClassTypeSignature, supertype: ClassTypeSignature)(implicit project: ClassFileRepository): Answer

    Determines if the given class or interface type encoded by the ClassTypeSignature subtype is actually a subtype of the class or interface type encoded in the ClassTypeSignature of the supertype.

    Determines if the given class or interface type encoded by the ClassTypeSignature subtype is actually a subtype of the class or interface type encoded in the ClassTypeSignature of the supertype.

    subtype

    Any ClassTypeSignature.

    supertype

    Any ClassTypeSignature.

    returns

    Yes if subtype is a subtype of the given supertype. No if subtype is not a subtype of supertype and Unknown if the analysis is not conclusive. The latter can happen if the class hierarchy is not complete and hence precise information about a type's supertypes is not available.

    Examples:
    1. Introduction

      Before looking in some examples, we have to set up the terminology. Type definition: List<String, ? extends Number, ?> ContainerType - A ContainerType is a type with parameters. In the previous type definition is List the ContainerType. TypeArgument - A TypeArgument is one of the parameters of the ContainerType. The above type definition has three TypeArguments. (String, ? extends Number and ?) VarianceIndicator - A VarianceIndicator is defined in the context of TypeArguments. There is a CovariantIndicator which can be defined in the type definition by using the extends keyword. (? extends Number is a covariant TypeArgument). The other one is the ContravariantIndicator which is defined using the super keyword.

    2. ,
    3. 1

      instance // definition subtype: List<String> // List<E> supertype: List<String> // List<E> If the ContainerType of the subtype is equal to the ContainerType of the supertype and non of the TypeArguments has a VarianceIndicator, then exists a subtype relation if and only if all of the TypeArguments are equal.

    4. ,
    5. 2

      subtype: SomeClass // SomeClass extends SomeInterface<String> supertype: SomeInterface<String> // SomeInterface<E> Is the subtype a ConcreteType without org.opalj.br.FormalTypeParameters and the supertype is a GenericType then we first have to check whether the subtype is a subtype of the given supertype. If not, then the subtype is not an actual subtype of the given supertype. Otherwise we have to find the definition of the supertype in the type definition or the type definition of a super class or a super interface (interface definition of SomeInterface<String>). Once found the supertype, we can compare all TypeArguments of the supertype definition of the subtype and the given supertype. (We are comparing String and String in this example) If all of them are equal, subtype is an actual subtype of the supertype.

    6. ,
    7. 3

      subtype: Foo<Integer, String> // Foo<T,E> extends Bar<E> supertype: Bar<String> // Bar<E> Does the subtype and supertype have FormalTypeParameters and the ContainerType of the subtype is a subtype of the ContainerType of the supertype, we have to compare the shared TypeArguments. In our example the subtype Foo has two FormalTypeParameter (T,E) and the supertype Bar has only one FormalTypeParameter (E). Since both of them specify E in the ClassSignature of Foo, they share E as FormalTypeParameter. So it is necessary to check whether the actual bound TypeArgument at the position of E is equal. At first we have to locate the shared parameter in the ClassSignature, so it is possible to find the correct TypeArguments. The above example shows that the shared parameter E is in the second position of the FormalTypeParameters of Foo and at the first position of the FormalTypeParameters of Bar. Second and last we know can compare the according TypeArguments. All other parameters can be ignored because they are no important to decide the subtype relation.

    Note

    This method relies – in case of a comparison of non generic types – on isSubtypeOf(org.opalj.br.ObjectType,org.opalj.br.ObjectType) of Project which performs an upwards search only. E.g., given the following type hierarchy: class D inherits from C class E inherits from D and the query isSubtypeOf(D,E) the answer will be Unknown if C is Unknown and No otherwise.

  49. def isASubtypeOf(subtypes: UIDSet[_ <: ReferenceType], supertype: ReferenceType): Answer
  50. def isASubtypeOf(subtype: ReferenceType, supertypes: UIDSet[_ <: ReferenceType]): Answer

    Returns Yes if the subtype is a subtype of all given supertypes.

    Returns Yes if the subtype is a subtype of all given supertypes. Hence, supertypes should not contain more than one class type.

  51. def isASubtypeOf(subtypes: UIDSet[_ <: ReferenceType], supertypes: UIDSet[_ <: ReferenceType]): Answer

    Determines if the type described by the first set of upper type bounds is a subtype of the second type.

    Determines if the type described by the first set of upper type bounds is a subtype of the second type. I.e., it checks, if for all types of the subtypes upper type bound, a type in the supertypes type exists that is a supertype of the respective subtype. If subtypes is empty, Yes will be returned; an empty upper type bound is expected to model null.

  52. final def isASubtypeOf(subtype: ReferenceType, supertype: ReferenceType): Answer

    Determines if subtype is a subtype of supertype using this class hierarchy.

    Determines if subtype is a subtype of supertype using this class hierarchy.

    This method can be used as a foundation for implementing the logic of the JVM's instanceof and classcast instructions. But, in both cases additional logic for handling null values and for considering the runtime type needs to be implemented by the caller of this method.

    subtype

    Any class, interface or array type.

    supertype

    Any class, interface or array type.

    returns

    Yes if subtype is indeed a subtype of the given supertype. No if subtype is not a subtype of supertype and Unknown if the analysis is not conclusive. The latter can happen if the class hierarchy is not completely available and hence precise information about a type's supertypes is not available.

    Annotations
    @tailrec()
    Note

    The answer No does not necessarily imply that two runtime values for which the given types are only upper bounds are not (w.r.t. their runtime types) in a subtype relation. E.g., if subtype denotes the type java.util.List and supertype denotes the type java.util.ArrayList then the answer is clearly No. But, at runtime, this may not be the case. I.e., only the answer Yes is conclusive. In case of No further information needs to be taken into account by the caller to determine what it means that the (upper) type (bounds) of the underlying values are not in an inheritance relation.

  53. def isASubtypeOf(subtype: ObjectType, theSupertype: ObjectType): Answer

    Determines if the given class or interface type subtype is actually a subtype of the class or interface type supertype.

    Determines if the given class or interface type subtype is actually a subtype of the class or interface type supertype.

    This method can be used as a foundation for implementing the logic of the JVM's instanceof and checkcast instructions. But, in that case additional logic for handling null values and for considering the runtime type needs to be implemented by the caller of this method.

    subtype

    Any ObjectType.

    theSupertype

    Any ObjectType.

    returns

    Yes if subtype is a subtype of the given supertype. No if subtype is not a subtype of supertype and Unknown if the analysis is not conclusive. The latter can happen if the class hierarchy is not complete and hence precise information about a type's supertypes is not available.

    Note

    No explicit isKnown check is required.

  54. def isDirectSuperclassTypeInformationComplete(objectType: ObjectType): Boolean

    Returns true if the type hierarchy information related to the given type's supertypes is complete.

    Returns true if the type hierarchy information related to the given type's supertypes is complete.

    Annotations
    @inline()
    Note

    No explicit isKnown check is required.

  55. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  56. def isInterface(objectType: ObjectType): Answer

    Returns true if the given objectType is known and defines an interface type.

    Returns true if the given objectType is known and defines an interface type.

    objectType

    An ObjectType.

    Annotations
    @inline()
    Note

    No explicit isKnown check is required.

  57. final def isKnown(objectTypeId: Int): Boolean
    Annotations
    @inline()
  58. final def isKnown(objectType: ObjectType): Boolean

    Returns true if the class hierarchy has some information about the given type.

    Returns true if the class hierarchy has some information about the given type.

    Annotations
    @inline()
    Note

    Consider using isKnown(objectTypeId : Int) if you need the object ids anyway.

  59. def isKnownToBeFinal(referenceType: ReferenceType): Boolean

    Returns true if the given type is known and is final.

    Returns true if the given type is known and is final. I.e., the declaring class was explicitly declared final or – if the type identifies an array type – the component type is either known to be final or is a primitive/base type.

    returns

    false is returned if:

    • the object type/component type is unknown,
    • the object type/component type is known not to be final or
    • the information about the object type/component type is incomplete
    Annotations
    @inline()
    Note

    No explicit isKnown check is required.

  60. def isKnownToBeFinal(objectTypeId: Int): Boolean
    Annotations
    @inline()
  61. def isKnownToBeFinal(objectType: ObjectType): Boolean

    Returns true if the given type is final.

    Returns true if the given type is final. I.e., the declaring class was explicitly declared final and no subtypes exist.

    returns

    false is returned if:

    • the object type is unknown,
    • the object type is known not to be final or
    • the information is incomplete
    Annotations
    @inline()
    Note

    No explicit isKnown check is required.

  62. def isSubtypeOf(subtypes: UIDSet[_ <: ReferenceType], supertype: ReferenceType): Boolean
  63. def isSubtypeOf(subtype: ReferenceType, supertypes: UIDSet[_ <: ReferenceType]): Boolean

    Returns true if the subtype is a subtype of all given supertypes.

    Returns true if the subtype is a subtype of all given supertypes. Hence, supertypes should not contain more than one class type.

  64. def isSubtypeOf(subtypes: UIDSet[_ <: ReferenceType], supertypes: UIDSet[_ <: ReferenceType]): Boolean

    Determines if the type described by the first set of upper type bounds is a subtype of the second type.

    Determines if the type described by the first set of upper type bounds is a subtype of the second type. I.e., it checks, if for all types of the subtypes upper type bound, a type in the supertypes type exists that is a supertype of the respective subtype. If subtypes is empty, true will be returned; an empty upper type bound is expected to model null.

  65. def isSubtypeOf(subtype: ObjectType, theSupertype: ObjectType): Boolean

    Returns true if subtype is a subtype of supertype; false is returned if the subtyping relationship is unknown OR subtype is not a subtype of supertype.

    Returns true if subtype is a subtype of supertype; false is returned if the subtyping relationship is unknown OR subtype is not a subtype of supertype. isSubtypeOf is reflexive.

    See isASubtypeOf if more precise information about the subtyping relationship is required.

  66. final def isSubtypeOf(subtype: ReferenceType, supertype: ReferenceType): Boolean

    Determines if subtype is a subtype of supertype using this class hierarchy.

    Determines if subtype is a subtype of supertype using this class hierarchy.

    This method can be used as a foundation for implementing the logic of the JVM's instanceof and classcast instructions. But, in both cases additional logic for handling null values and for considering the runtime type needs to be implemented by the caller of this method.

    subtype

    Any class, interface or array type.

    supertype

    Any class, interface or array type.

    returns

    true if subtype is indeed a subtype of the given supertype. false is returned if the typing relation is unknown OR if subtype is definitively not a subtype of supertype.

    Annotations
    @tailrec()
    Note

    The answer false does not necessarily imply that two runtime values for which the given types are only upper bounds are not (w.r.t. their runtime types) in a subtype relation. E.g., if subtype denotes the type java.util.List and supertype denotes the type java.util.ArrayList then the answer is clearly false. But, at runtime, this may not be the case. I.e., only the answer true is conclusive. In case of false further information needs to be taken into account by the caller to determine what it means that the (upper) type (bounds) of the underlying values are not in an inheritance relation.

  67. final def isSupertypeInformationComplete(objectType: ObjectType): Boolean

    Returns true if the type hierarchy has complete information about all supertypes of the given type.

    Returns true if the type hierarchy has complete information about all supertypes of the given type.

    Annotations
    @inline()
    Note

    No explicit isKnown check is required.

  68. final def isUnknown(objectTypeId: Int): Boolean
    Annotations
    @inline()
  69. final def isUnknown(objectType: ObjectType): Boolean

    Returns true if the type is unknown.

    Returns true if the type is unknown. This is true for all types that are referred to in the body of a method, but which are not referred to in the declarations of the class files that were analyzed.

    Annotations
    @inline()
    Note

    Consider using isUnknown(objectTypeId : Int) if you need the object ids anyway.

  70. def joinAnyArrayTypeWithMultipleTypesBound(thatUpperTypeBound: UIDSet[ObjectType]): UIDSet[ObjectType]

    Calculates the most specific common supertype of any array type and some class-/interface type.

    Calculates the most specific common supertype of any array type and some class-/interface type.

    Recall that (Java) arrays implement Cloneable and Serializable.

  71. def joinAnyArrayTypeWithObjectType(thatUpperTypeBound: ObjectType): UIDSet[ObjectType]

    Calculates the most specific common supertype of any array type and some class-/interface type.

    Calculates the most specific common supertype of any array type and some class-/interface type.

    Recall that (Java) arrays implement Cloneable and Serializable.

  72. def joinArrayType(upperTypeBoundA: ArrayType, upperTypeBoundB: UIDSet[_ <: ReferenceType]): UIDSet[_ <: ReferenceType]
  73. def joinArrayTypes(thisUpperTypeBound: ArrayType, thatUpperTypeBound: ArrayType): Either[ArrayType, UIDSet[ObjectType]]

    Calculates the most specific common supertype of two array types.

    Calculates the most specific common supertype of two array types.

    returns

    Left(<SOME_ARRAYTYPE>) if the calculated type can be represented using an ArrayType and Right(UIDList(ObjectType.Serializable, ObjectType.Cloneable)) if the two arrays do not have an ArrayType as a most specific common supertype.

  74. def joinObjectTypes(upperTypeBoundA: ObjectType, upperTypeBoundB: ObjectType, reflexive: Boolean): UIDSet[ObjectType]

    Tries to calculate the most specific common supertype of the two given types.

    Tries to calculate the most specific common supertype of the two given types. If reflexive is false, the two types do not have to be in an inheritance relation.

    If the class hierarchy is not complete, a best guess is made.

  75. def joinObjectTypes(upperTypeBoundA: ObjectType, upperTypeBoundB: UIDSet[ObjectType], reflexive: Boolean): UIDSet[ObjectType]

    Tries to calculate the most specific common supertype of the given types.

    Tries to calculate the most specific common supertype of the given types. If reflexive is false, the given types do not have to be in an inheritance relation.

    upperTypeBoundB

    A list (set) of ObjectTypes that are not in a mutual inheritance relation.

    returns

    (I) Returns (if reflexive is true) upperTypeBoundA if it is a supertype of at least one type of upperTypeBoundB. (II) Returns upperTypeBoundB if upperTypeBoundA is a subtype of all types of upperTypeBoundB. Otherwise a new upper type bound is calculated and returned.

  76. def joinObjectTypesUntilSingleUpperBound(upperTypeBound: UIDSet[ObjectType]): ObjectType

    Given an upper type bound a most specific type that is a common supertype of the given types is determined.

    Given an upper type bound a most specific type that is a common supertype of the given types is determined.

    See also

    joinObjectTypesUntilSingleUpperBound(upperTypeBoundA: ObjectType, upperTypeBoundB: ObjectType, reflexive: Boolean) for further details.

  77. def joinObjectTypesUntilSingleUpperBound(upperTypeBoundA: ObjectType, upperTypeBoundB: ObjectType, reflexive: Boolean): ObjectType
  78. def joinReferenceType(upperTypeBoundA: ReferenceType, upperTypeBoundB: UIDSet[_ <: ReferenceType]): UIDSet[_ <: ReferenceType]
  79. def joinReferenceTypes(upperTypeBoundA: UIDSet[_ <: ReferenceType], upperTypeBoundB: UIDSet[_ <: ReferenceType]): UIDSet[_ <: ReferenceType]
  80. def joinReferenceTypesUntilSingleUpperBound(upperTypeBound: UIDSet[_ <: ReferenceType]): ReferenceType
  81. def joinUpperTypeBounds(utbA: UIDSet[_ <: ReferenceType], utbB: UIDSet[_ <: ReferenceType]): UIDSet[_ <: ReferenceType]
  82. def joinUpperTypeBounds(upperTypeBoundsA: UIDSet[ObjectType], upperTypeBoundsB: UIDSet[ObjectType], reflexive: Boolean): UIDSet[ObjectType]

    Calculates the most specific common supertype of the given types.

    Calculates the most specific common supertype of the given types. If reflexive is false, no two types across both sets have to be in an inheritance relation; if in doubt use true.

    upperTypeBoundsB

    A list (set) of ObjectTypes that are not in an inheritance relation if reflexive is false.

    Example:
    1. /* Consider the following type hierarchy:
       *    Object <- Collection <- List
       *    Object <- Collection <- Set
       *    Object <- Externalizable
       *    Object <- Serializable
       */
      Object o = new ...
      if (...) {
           Set s = (Set) o;
           (( Externalizable)s).save(...)
           // => o(s) has to be a subtype of Set AND Externalizable
      } else {
           List l = (List) l;
           ((Serializable)l).store(...)
           // => o(l) has to be a subtype of List AND Serializable
      }
      // Here, o is either a set or a list. Hence, it is at least a Collection,
      // but we cannot deduce anything w.r.t. Serializable and Externalizable.
  83. def leafClassTypesIterator: Iterator[ObjectType]
  84. def leafTypes(types: UIDSet[ObjectType]): UIDSet[ObjectType]

    Selects all types of the given set of types that do not have any subtype in the given set.

    Selects all types of the given set of types that do not have any subtype in the given set. If the given set is empty, a set containing java.lang.Object is returned. A set which contains only one type will directly be returned.

    types

    A set of types that contains for each type stored in the set all direct and indirect supertypes or none. For example, the intersection of the sets of all supertypes (as returned, e.g., by ClassHierarchy.allSupertypes) of two (independent) types satisfies this condition. If types is empty, the returned leaf type is ObjectType.Object. which should always be a safe fallback.

  85. val leafTypes: UIDSet[ObjectType]
  86. implicit val logContext: LogContext
  87. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  88. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  89. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  90. def processSubtypes[T](objectType: ObjectType, reflexive: Boolean = false)(initial: T)(f: (T, ObjectType) => (T, Boolean, Boolean)): T

    Enables the guided processing of all subtypes of the given type.

    Enables the guided processing of all subtypes of the given type. This function enables you to compute some value based on the subtypes of the given type and – at the same time – to control the process of traversing the subtypes.

    initial

    The initial value of the computation. This is also the value that will be returned if the given type has no subtypes and reflexive is false.

    f

    A function that computes the new value given the current value and which also returns the information whether the computation should be aborted using the current value of type t or if the subtypes of the current subtype should be traversed. The commented signature of f is:

    f: (T, ObjectType) => (T /*result*/ , Boolean /*skip subtypes*/ , Boolean /*abort*/ )
  91. def rootClassTypesIterator: Iterator[ObjectType]

    The set of all class types (excluding interfaces) which have no super type or for which the supertype information is incomplete; that is all (pseudo) root types.

    The set of all class types (excluding interfaces) which have no super type or for which the supertype information is incomplete; that is all (pseudo) root types. If the class hierarchy is complete, then this set contains exactly one element and that element must identify java.lang.Object.

    Note

    The returned root class types are not necessarily a subset of rootTypes. A class which has an unknown super class, but implements a known interface is considered to belong to be a root class type but is not a member of rootTypes because some supertype information exists!

    ,

    If we load an application and all the jars used to implement it or a library and all the library it depends on, then the class hierarchy should not contain multiple root types. However, the (complete) JDK contains some references to Eclipse classes which are not part of the JDK.

  92. def rootInterfaceTypes(collection: Growable[ObjectType]): rootInterfaceTypes.collection.type

    Iterates over all interfaces which only inherit from java.lang.Object and adds the types to the given Growable collection.

    Iterates over all interfaces which only inherit from java.lang.Object and adds the types to the given Growable collection. I.e., iterates over all interfaces which are at the top of the interface inheritance hierarchy.

  93. val rootTypes: UIDSet[ObjectType]
  94. def statistics: String

    Returns some statistical data about the class hierarchy.

  95. def subtypeInformation(objectType: ObjectType): Option[SubtypeInformation]

    Returns the subtype information if the given type is known.

    Returns the subtype information if the given type is known. If the given type is unknown None is returned.

  96. def superclassType(objectTypeId: Int): ObjectType

    Returns the supertype of the object type identified by the given object type id or null if the type is unknown or if the type has no supertype.

  97. def superclassType(objectType: ObjectType): Option[ObjectType]

    Returns the immediate superclass of the given object type, if the given type is known and if it has a superclass.

    Returns the immediate superclass of the given object type, if the given type is known and if it has a superclass. I.e., in case of java.lang.Object None is returned.

  98. def superclasses(objectType: ObjectType, project: ClassFileRepository)(classFileFilter: (ClassFile) => Boolean = _ => true): Iterable[ClassFile]

    Returns the set of all classes/interfaces from which the given type inherits and for which the respective class file is available.

    Returns the set of all classes/interfaces from which the given type inherits and for which the respective class file is available.

    returns

    An Iterable over all class files of all super types of the given objectType that pass the given filter and for which the class file is available.

    Note

    It may be more efficient to use foreachSuperclass(ObjectType, ObjectType => Option[ClassFile])(ClassFile => Unit)

  99. def superinterfaceTypes(objectType: ObjectType): Option[UIDSet[ObjectType]]

    Returns Some(<SUPERTYPES>) if this type is known and information about the supertypes is available.

    Returns Some(<SUPERTYPES>) if this type is known and information about the supertypes is available. I.e., if this type is not known, None is returned; if the given type's superinterfaces are known (even if this class does not implement (directly or indirectly) any interface) Some(UIDSet(<OBJECTTYPES>)) is returned.

  100. def supertypeInformation(objectType: ObjectType): Option[SupertypeInformation]

    Returns the supertype information if the given type is known.

    Returns the supertype information if the given type is known. If the given type is unknown None is returned.

  101. def supertypes(objectType: ObjectType): UIDSet[ObjectType]
  102. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  103. def toGraph(): Node

    Returns a view of the class hierarchy as a graph (which can then be transformed into a dot representation Graphviz).

    Returns a view of the class hierarchy as a graph (which can then be transformed into a dot representation Graphviz). This graph can be a multi-graph if the class hierarchy contains holes.

  104. def toString(): String
    Definition Classes
    ClassHierarchy → AnyRef → Any
  105. def updatedLogContext(newLogContext: LogContext): ClassHierarchy
  106. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  107. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  108. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

Inherited from AnyRef

Inherited from Any

Ungrouped