Returns all (direct and indirect) subclasses of the given class type.
Returns all (direct and indirect) subclasses of the given class type.
No explicit isKnown check is required; if the type is unknown an empty
iterator is returned.
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.
An ObjectType.
If true the given type is also included in the returned
set.
The set of all direct and indirect subtypes of the given type.
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.
,If you don't need the set, it is more efficient to use foreachSubtype.
No explicit isKnown check is required; if the type is unknown the
returned set will be empty.
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.
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.
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.
If true the returned set will also contain the given type if
it is an interface type.
The set of all supertypes of the given type.
The set of all supertypes of the given type.
If true the returned set will also contain the given type.
Calculates the set of all supertypes of the given types.
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:
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.
The type of the value that should be stored in the array. This type is compared against the component type of the array.
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.
The type of the array.
Specifies if the type information is precise;
i.e., whether arrayType models the precise runtime type (true)
or just an upper bound (false).
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.
A set of types that are in no inheritance relationship.
upperTypeBound must not be empty.
The direct subtypes of the given type (not reflexive).
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.
No explicit isKnown check is required; if the type is unknown nothing
will happen.
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.
No explicit isKnown check is required; if the type is unknown nothing
will happen.
Calls the given function f for each type that is known to the class hierarchy.
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.
For details regarding incomplete class hierarchies see foreachSubtype.
No explicit isKnown check is required; if the type is unknown nothing
will happen.
Iterates over all subinterfaces of the given interface type (or java.lang.Object) until the callback function returns "false".
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).
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 will be processed.
Classes are always traversed first.
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.
An ObjectType.
For details regarding incomplete class hierarchies see allSubtypes. *
,No explicit isKnown check is required; if the type is unknown nothing
will happen.
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.
See foreachSupertype for details.
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.
This method will
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.
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.
Any type or interface.
Any type or interface.
Option of ClassTypeSignature if the subtype extends or implements
the given supertype, None otherwise.
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>.
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 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.
Some ObjectType.
No explicit isKnown check is required.
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.
ifKnown(ObjectType.Serializable){isDirectSupertypeInformationComplete}
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.
No explicit isKnown check is required.
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.
An ObjectType.
No explicit isKnown check is required.
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.
Consider using isKnown(objectTypeId : Int) if you need the object ids anyway.
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.
false is returned if:
No explicit isKnown check is required.
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:
No explicit isKnown check is required.
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.
Any ClassTypeSignature.
Any FormalTypeParameter.
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.
This method does consider generics types specified within the FormalTypeParameter.
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.
Any ClassTypeSignature.
Any ClassTypeSignature.
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.
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.
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.
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.
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.
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.
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.
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.
Any class, interface or array type.
Any class, interface or array type.
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.
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.
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.
Any ObjectType.
Any ObjectType.
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.
No explicit isKnown check is required; if the type is unknown an empty
iterator is returned.
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.
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.
No explicit isKnown check is required.
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.
Consider using isUnknown(objectTypeId : Int) if you need the object ids anyway.
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.
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.
Calculates the most specific common supertype of two array types.
Calculates the most specific common supertype of two array types.
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.
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.
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.
A list (set) of ObjectTypes that are not in an mutual
inheritance relation.
(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.
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.
joinObjectTypesUntilSingleUpperBound(upperTypeBoundA: ObjectType,
upperTypeBoundB: ObjectType,reflexive: Boolean) for further details.
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.
A list (set) of ObjectTypes that are not in an
inheritance relation if reflexive is false.
/* 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.
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.
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
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.
The set of all types which have no subtypes.
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.
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.
Iterates over all interfaces which only inherit from java.lang.Object; that is, Iterates over all interfaces which are at the top of the interface inheritance hierarchy.
The set of all types which have no supertypes or for which we have no further supertype information because of an incomplete project.
The set of all types which have no supertypes or for which we have no
further supertype information because of an incomplete project.
If the class hierarchy is complete then this set contains exactly one element and
that element must identify java.lang.Object.
If we load an application and all the jars used to implement it or a library
and all the libraries it depends on, then the class hierarchy should not
contain multiple root types. However, the (complete) JDK already contains
some references to Eclipse classes which are not part of the JDK.
Returns some statistical data about the class hierarchy.
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.
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.
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.
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.
It may be more efficient to use foreachSuperclass(ObjectType,
ObjectType ⇒ Option[ClassFile])(ClassFile => Unit)
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.
Contains for each object type the set of class types and interface types it inherits from.
Contains for each object type the set of class types and interface types it
inherits from. This set is computed on a best-effort basis.
In some cases the supertype information may be incomplete, because the project
as such is incomplete. Whether the type information is complete for a given type
or not can be checked using isSupertypeInformationComplete.
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.
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 typejava.lang.Objectis always part of the class hierarchy. Hence, the class hierarchy may contain holes.Thread safety
This class is effectively immutable; concurrent access to the class hierarchy is supported.
Unless explicitly documented, it is an error to pass an instance of
,ObjectTypeto any method if theObjectTypewas not previously added. If in doubt, first check if the type is known (isKnown/ifKnown).Java 9 module definitions are completely ignored.