Class/Object

org.opalj.br

ClassHierarchy

Related Docs: object ClassHierarchy | package br

Permalink

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 except of java.lang.Object; the type java.lang.Object is always part of the class hierarchy.

Thread safety

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

Note

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. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def allSubclassTypes(objectType: ObjectType, reflexive: Boolean): Iterator[ObjectType]

    Permalink

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

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

    Permalink

    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

    A known ObjectType. (See ClassHierarchy.isKnown, ClassHierarchy.ifKnown for further details).

    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

    If the type hierarchy is not complete the answer may not be correct. 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.

    ,

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

  6. def allSuperinterfacetypes(objectType: ObjectType, reflexive: Boolean = false): Set[ObjectType]

    Permalink

    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.

  7. def allSupertypes(objectType: ObjectType, reflexive: Boolean = false): Set[ObjectType]

    Permalink

    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.

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

    Permalink

    Calculates the set of all supertypes of the given types.

  9. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  10. final def canBeStoredIn(elementValueType: FieldType, elementValueTypeIsPrecise: Boolean, arrayType: ArrayType, arrayTypeIsPrecise: Boolean): Answer

    Permalink

    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()
  11. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  12. def directSubtypesOf(upperTypeBound: UIDSet[ObjectType]): Set[ObjectType]

    Permalink

    upperTypeBound

    A set of types that are in no inheritance relationship.

  13. def directSubtypesOf(objectType: ObjectType): Set[ObjectType]

    Permalink

    The direct subtypes of the given type.

  14. def directSupertypes(objectType: ObjectType): Set[ObjectType]

    Permalink
  15. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  16. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  17. def existsSubclass(objectType: ObjectType, project: ClassFileRepository)(f: (ClassFile) ⇒ Boolean): Boolean

    Permalink

    Tests if a subtype of the given ObjectType exists that has the given property.

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

    Subtypes for which no ClassFile object is available are ignored.

  18. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  19. def foreachDirectSubclassType[T](objectType: ObjectType, project: ClassFileRepository)(f: (ClassFile) ⇒ T): Unit

    Permalink

    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.

  20. def foreachKnownType[T](f: (ObjectType) ⇒ T): Unit

    Permalink

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

  21. def foreachSubclass(objectType: ObjectType, project: ClassFileRepository)(f: (ClassFile) ⇒ Unit): Unit

    Permalink

    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 the f is invoked multiple times using the same ClassFile object.

    Subtypes for which no ClassFile object is available are ignored.

    Note

    For details regarding incomplete class hierarchies see foreachSubtype.

  22. def foreachSubtype(objectType: ObjectType)(f: (ObjectType) ⇒ Unit): Unit

    Permalink

    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. If the given objectType identifies an interface type then it is possible that f is passed the same ObjectType multiple times.

    objectType

    A known ObjectType. (See isKnown,ifKnown for further details).

    Note

    For details regarding incomplete class hierarchies see allSubtypes.

  23. def foreachSuperclass(objectType: ObjectType, project: ClassFileRepository)(f: (ClassFile) ⇒ Unit): Unit

    Permalink

    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.

  24. def foreachSupertype(objectType: ObjectType)(f: (ObjectType) ⇒ Unit): Unit

    Permalink

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

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

  25. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  26. final def getObjectType(objectTypeId: Int): ObjectType

    Permalink

    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.

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

    Permalink

    Determines whether the given ClassSignature of the potential subtype does implement or extend the given type supertype of type ObjectType.

    Determines whether the given ClassSignature of the potential subtype does implement or extend the given type supertype of type ObjectType. 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>.

  28. def hasSubtypes(objectType: ObjectType): Answer

    Permalink

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

    Retuns 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 maybe No even though the (running) project will contain (in)direct subtypes of the given type. For example, this will be the case if the class hierarchy is not complete, because not all class files (libraries) used by the project that is analyzed are also analyzed. A second case is that some class files are generated at runtime that inherit from the given ObjectType.

    objectType

    Some ObjectType.

  29. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  30. final def ifKnown[T](objectType: ObjectType)(f: (ObjectType) ⇒ T): Option[T]

    Permalink

    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}
  31. def isDirectSuperclassTypeInformationComplete(objectType: ObjectType): Boolean

    Permalink

    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()
  32. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  33. def isInterface(objectType: ObjectType): Boolean

    Permalink

    Returns true if the given objectType defines an interface type.

    Returns true if the given objectType defines an interface type.

    false is returned if:

    • the object type is unknown,
    • the object type is known not to be final or
    • the information is incomplete
    objectType

    An ObjectType.

    Annotations
    @inline()
    Note

    See isKnown, ifKnown for further details.

  34. final def isKnown(objectType: ObjectType): Boolean

    Permalink

    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()
  35. def isKnownToBeFinal(referenceType: ReferenceType): Boolean

    Permalink

    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 or – if the type identifies an array type – the component type is either known to be final or is a primitive/base type.

    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()
  36. def isKnownToBeFinal(objectType: ObjectType): Boolean

    Permalink

    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.

    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()
  37. def isSubtypeOf(subtype: ClassTypeSignature, supertype: FormalTypeParameter)(implicit project: ClassFileRepository): Answer

    Permalink

    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.

  38. def isSubtypeOf(subtype: ClassTypeSignature, supertype: ClassTypeSignature)(implicit project: ClassFileRepository): Answer

    Permalink

    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. 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 acctual bound TypeArgument at the postion 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 postion of the FormalTypeParameters of Foo and at the first postion 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.

    2. ,
    3. 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 defintion or the type definiton of a super class or a super interface (interface definiton of SomeInterface<String>). Once found the supertype, we can compare all TypeArguments of the supertype defintion 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.

    4. ,
    5. 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.

    6. ,
    7. 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.

    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.

  39. def isSubtypeOf(subtypes: UpperTypeBound, supertype: ReferenceType): Answer

    Permalink
  40. def isSubtypeOf(subtype: ReferenceType, supertypes: UpperTypeBound): Answer

    Permalink
  41. def isSubtypeOf(subtypes: UpperTypeBound, supertypes: UpperTypeBound): Answer

    Permalink

    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.

  42. final def isSubtypeOf(subtype: ReferenceType, supertype: ReferenceType): Answer

    Permalink

    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.

  43. def isSubtypeOf(subtype: ObjectType, theSupertype: ObjectType): Answer

    Permalink

    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

    This method 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.

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

    Permalink
    Annotations
    @inline()
  45. final def isUnknown(objectType: ObjectType): Boolean

    Permalink

    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()
  46. def joinAnyArrayTypeWithMultipleTypesBound(thatUpperTypeBound: UIDSet[ObjectType]): UIDSet[ObjectType]

    Permalink

    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.

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

    Permalink

    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.

  48. def joinArrayType(upperTypeBoundA: ArrayType, upperTypeBoundB: UpperTypeBound): UpperTypeBound

    Permalink
  49. def joinArrayTypes(thisUpperTypeBound: ArrayType, thatUpperTypeBound: ArrayType): Either[ArrayType, UIDSet[ObjectType]]

    Permalink

    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.

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

    Permalink

    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.

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

    Permalink

    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 an 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.

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

    Permalink

    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.

  53. def joinObjectTypesUntilSingleUpperBound(upperTypeBoundA: ObjectType, upperTypeBoundB: ObjectType, reflexive: Boolean): ObjectType

    Permalink
  54. def joinReferenceType(upperTypeBoundA: ReferenceType, upperTypeBoundB: UpperTypeBound): UpperTypeBound

    Permalink
  55. def joinReferenceTypes(upperTypeBoundA: UpperTypeBound, upperTypeBoundB: UpperTypeBound): UpperTypeBound

    Permalink
  56. def joinUpperTypeBounds(utbA: UpperTypeBound, utbB: UpperTypeBound): UpperTypeBound

    Permalink
  57. def joinUpperTypeBounds(upperTypeBoundsA: UIDSet[ObjectType], upperTypeBoundsB: UIDSet[ObjectType], reflexive: Boolean): UIDSet[ObjectType]

    Permalink

    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.
  58. def leafTypes(types: Set[ObjectType]): UIDSet[ObjectType]

    Permalink

    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.

    types

    A set of types that contains for each value (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 ClassHiearchy.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.

  59. val leafTypes: Set[ObjectType]

    Permalink
  60. implicit val logContext: LogContext

    Permalink
  61. def lookupImplementingMethods(receiverType: ObjectType, methodName: String, methodDescriptor: MethodDescriptor, project: ClassFileRepository, classesFilter: (ObjectType) ⇒ Boolean): Set[Method]

    Permalink

    Returns all classes that implement the given method by searching all subclasses of receiverType for implementations of the given method and also considering the superclasses of the receiverType up until the class (not interface) that defines the respective method.

    Returns all classes that implement the given method by searching all subclasses of receiverType for implementations of the given method and also considering the superclasses of the receiverType up until the class (not interface) that defines the respective method.

    receiverType

    An upper bound of the runtime type of some value. If the type is known to be precise (i.e., it is no approximation of the runtime type) then it is far more meaningful to directly call lookupMethodDefinition.

    methodName

    The name of the method.

    methodDescriptor

    The method's descriptor.

    project

    Required to get a type's implementing class file. This method expects unrestricted access to the pool of all class files.

    classesFilter

    A function that returns true, if the runtime type of the receiverType may be of the type defined by the given object type. For example, if you analyze a project and perform a lookup of all methods that implement the method toString, then this set would probably be very large. But, if you know that only instances of the class (e.g.) ArrayList have been created so far (up to the point in your analysis where you call this method), it is meaningful to sort out all other classes (such as Vector).

  62. def lookupMethodDefinition(receiverType: ObjectType, methodName: String, methodDescriptor: MethodDescriptor, project: ClassFileRepository): Option[Method]

    Permalink

    Looks up the class file and method which actually defines the method that is referred to by the given receiver type, method name and method descriptor.

    Looks up the class file and method which actually defines the method that is referred to by the given receiver type, method name and method descriptor. Given that we are searching for method definitions the search is limited to the superclasses of the class of the given receiver type.

    This method does not take visibility modifiers or the static modifier into account. If necessary, such checks need to be done by the caller.

    This method supports resolution of signature polymorphic methods (in this case however, it needs to be checked that the respective invoke instruction is an invokevirtual instruction.)

    returns

    Some(Method) if the method is found. None if the method is not found. This can basically happen under two circumstances: First, not all class files referred to/used by the project are (yet) analyzed; i.e., we do not have all class files belonging to the project. Second, the analyzed class files do not belong together (they either belong to different projects or to incompatible versions of the same project.) To get the method's defining class file use the project's respective method.

    Note

    In case that you analyze static source code dependencies and if an invoke instruction refers to a method that is not defined by the receiver's class, then it might be more meaningful to still create a dependency to the receiver's class than to look up the actual definition in one of the receiver's super classes.

  63. def lookupMethodInInterface(classFile: ClassFile, methodName: String, methodDescriptor: MethodDescriptor, project: ClassFileRepository): Option[Method]

    Permalink
  64. def lookupMethodInSuperinterfaces(classFile: ClassFile, methodName: String, methodDescriptor: MethodDescriptor, project: ClassFileRepository): Option[Method]

    Permalink
  65. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  66. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  67. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  68. final def resolveFieldReference(fieldAccess: FieldAccess, project: ClassFileRepository): Option[Field]

    Permalink

    See also

    resolveFieldReference(org.opalj.br.ObjectType,java.lang.String,org.opalj.br.FieldType,org.opalj.br.ClassFileRepository):scala.Option[org.opalj.br.Field]

  69. def resolveFieldReference(declaringClassType: ObjectType, fieldName: String, fieldType: FieldType, project: ClassFileRepository): Option[Field]

    Permalink

    Resolves a symbolic reference to a field.

    Resolves a symbolic reference to a field. Basically, the search starts with the given class c and then continues with c's superinterfaces before the search is continued with c's superclass (as prescribed by the JVM specification for the resolution of unresolved symbolic references.)

    Resolving a symbolic reference is particularly required to, e.g., get a field's annotations or to get a field's value (if it is static, final and has a constant value).

    declaringClassType

    The class (or a superclass thereof) that is expected to define the reference field.

    fieldName

    The name of the accessed field.

    fieldType

    The type of the accessed field (the field descriptor).

    project

    The project associated with this class hierarchy.

    returns

    The field that is referred to; if any. To get the defining ClassFile you can use the project.

    Note

    Resolution is final. I.e., either this algorithm has found the defining field or the field is not defined by one of the loaded classes. Searching for the field in subclasses is not meaningful as it is not possible to override fields.

    ,

    This implementation does not check for IllegalAccessError. This check needs to be done by the caller. The same applies for the check that the field is non-static if get-/putfield is used and static if a get/putstatic is used to access the field. In the latter case the JVM would throw a LinkingException. Furthermore, if the field cannot be found, it is the responsibility of the caller to handle that situation.

  70. def resolveInterfaceMethodReference(receiverType: ObjectType, methodName: String, methodDescriptor: MethodDescriptor, project: ClassFileRepository): Option[Method]

    Permalink
  71. def resolveMethodReference(receiverType: ObjectType, methodName: String, methodDescriptor: MethodDescriptor, project: ClassFileRepository): Option[Method]

    Permalink

    Tries to resolve a method reference as specified by the JVM specification.

    Tries to resolve a method reference as specified by the JVM specification. I.e., the algorithm tries to find the class that actually declares the referenced method. Resolution of signature polymorphic method calls is also supported; for details see lookupMethodDefinition).

    This method is the basis for the implementation of the semantics of the invokeXXX instructions. However, it does not check whether the resolved method can be accessed by the caller or if it is abstract. Additionally, it is still necessary that the caller makes a distinction between the statically (at compile time) identified declaring class and the dynamic type of the receiver in case of invokevirtual and invokeinterface instructions. I.e., additional processing is necessary on the client side.

    receiverType

    The type of the object that receives the method call. The type must be a class type and must not be an interface type.

    returns

    The resolved method Some(METHOD) or None. To get the defining class file use the project's respective method.

    Note

    This method just resolves a method reference. Additional checks, such as whether the resolved method is accessible, may be necessary.

    ,

    Generally, if the type of the receiver is not precise the receiver object's subtypes should also be searched for method implementations (at least those classes should be taken into consideration that may be instantiated).

  72. val rootTypes: Set[ObjectType]

    Permalink

    The set of all types which have no super type; 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.

    The set of all types which have no super type; 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

    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.

  73. def statistics: String

    Permalink

    Returns some statistical data about the class hierarchy.

  74. def structure: String

    Permalink

    A dump of the class hierarchy information in TSV format.

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

    Permalink

    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.

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

    Permalink

    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)

  77. def superinterfaceTypes(objectType: ObjectType): Option[Set[ObjectType]]

    Permalink

    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(Set(<OBJECTTYPES>)) is returned.

  78. def supertypes(objectType: ObjectType): Set[ObjectType]

    Permalink
  79. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  80. def toGraph(): Node

    Permalink

    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.

  81. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  82. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  83. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  84. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped