package cg
- Alphabetic
- Public
- Protected
Type Members
- abstract class AbstractClassExtensibility extends ClassExtensibility
- class AllPackagesClosed extends ClosedPackages
Treats all packages as being closed.
Treats all packages as being closed. This analysis is useable, e.g., for simple applications which have no concept of plug-ins or a similar mechanism. In this case every package is supposed to be closed since the entire code base is available at analysis time. Generally, not useable for libraries/frameworks/code which can be "freely" extended.
To use this analysis set the config key:
org.opalj.br.analyses.cg.ClosedPackagesKey.analysis
toorg.opalj.br.analyses.cg.AllPackagesClosed
- Note
An application that uses reflection to load functionality at runtime has a well-defined extension point and is not a simple application in the above sense.
- trait ApplicationEntryPointsFinder extends EntryPointFinder
This trait provides an analysis to compute the entry points of a standard command-line application.
This trait provides an analysis to compute the entry points of a standard command-line application. Please note that a command-line application can provide multiple entry points. This analysis identifies **all** main methods of the given code.
- Note
If it is required to find only a specific main method as entry point, please use the configuration-based entry point finder.
- trait ApplicationInstantiatedTypesFinder extends InstantiatedTypesFinder
This trait considers only the type java.lang.String as instantiated that is the type that is be instantiated for command line applications for their command line parameters.
- trait ApplicationWithoutJREEntryPointsFinder extends ApplicationEntryPointsFinder
Similar to the ApplicationEntryPointsFinder this trait selects main methods as entry points for standard command line applications.
Similar to the ApplicationEntryPointsFinder this trait selects main methods as entry points for standard command line applications. It excludes, however, main methods found in the Java Runtime Environment to prevent analyses of applications where the JRE is included in the project from being polluted by these entry points that are not part of the application.
- class CallBySignatureTargets extends AnyRef
- abstract class ClassExtensibility extends (ObjectType) => Answer
Determines whether a class or interface is directly extensible by a (yet unknown) client application/library.
Determines whether a class or interface is directly extensible by a (yet unknown) client application/library. A class/interface is directly extensible if a developer can define a direct - not transitive - subtype that is not part of the given application/library.
This analysis uses the ClosedPackages information.
- class ClassHierarchyIsNotExtensible extends ClassExtensibility
- abstract class ClosedPackages extends (String) => Boolean
Determines which packages are open or closed; that is, determines to which packages code - which is not yet known - can potentially be contributed to.
Determines which packages are open or closed; that is, determines to which packages code - which is not yet known - can potentially be contributed to. In other words, a package is considered open, if a developer is allowed to define a new type within the package's namespace. If a developer cannot define a new type within the package's namespace, the package is considered closed.
An example for closed packages are the packages within the java.* namespace of the JRE. Additionally, with Java 9 packages defined in modules can be considered closed.
The set of open/closed packages may influence call-graph construction as well as other analyses.
The concrete set of open/closed packages is specified in OPAL's configuration file. The relevant configuration key is:
org.opalj.br.analyses.cg.ClosedPackagesKey
.The concrete analysis which determines the open/closed packages is instantiated reflectively by ClosedPackagesKey. This facilitates the configuration of project specific closed packages. The class can be configured using the config key:
org.opalj.br.analyses.cg.ClosedPackagesKey.analysis={ClosedPackagesAnalysis}
- Note
The concept of open and closed packages - and the reason why it matters - is discussed in "Call Graph Construction for Java Libraries"
- class ClosedPackagesConfiguration extends ClosedPackages
Determines the closed packages using a regular expression.
Determines the closed packages using a regular expression.
The regular expression can be defined using the general configuration key:
org.opalj.br.analyses.cg.ClosedPackagesKey.closedPackages
org.opalj.br.analyses.cg.ClosedPackagesKey.closedPackages = "java/*|com/sun/*"
The previous example treats all packages starting with
java
andcom.sun
as closed.
Example: - trait ConfigurationEntryPointsFinder extends EntryPointFinder
This trait provides an analysis that loads entry points from the project configuration file.
This trait provides an analysis that loads entry points from the project configuration file.
All entry points must be configured under the following configuration key: **org.opalj.br.analyses.cg.InitialEntryPointsKey.entryPoints**
Example:
org.opalj.br.analyses.cg { InitialEntryPointKey { analysis = "org.opalj.br.analyses.cg.ConfigurationEntryPointsFinder" entryPoints = [ {declaringClass = "java/util/List+", name = "add"}, {declaringClass = "java/util/List", name = "remove", descriptor = "(I)Z"} ] } }
Please note that the first entry point, by adding the "+" to the declaring class' name, considers all "add" methods from all subtypes independently from the respective method's descriptor. In contrast, the second entry does specify a descriptor and does not consider List's subtypes (by not suffixing a plus to the declaringClass) which implies that only the remove method with this descriptor is considered as entry point.
- trait ConfigurationInstantiatedTypesFinder extends InstantiatedTypesFinder
This trait provides an analysis that loads instantiated types from the given project configuration file.
This trait provides an analysis that loads instantiated types from the given project configuration file.
All instantiated types must be configured under the following configuration key: **org.opalj.br.analyses.cg.InitialInstantiatedTypesKey.instantiatedTypes**
Example:
org.opalj.br.analyses.cg { InitialInstantiatedTypesKey { analysis = "org.opalj.br.analyses.cg.ConfigurationInstantiatedTypesFinder" instantiatedTypes = [ "java/util/List+", "java/util/HashSet" ] } }
Please note that the first instantiated type, by adding the "+" to the class' name, considers all subtypes of List as instantiated. In contrast, the second entry does not consider any subtypes of HashSet (by not suffixing a plus to class), so only the single class is considered to be instantiated.
- class ConfiguredExtensibleClasses extends AbstractClassExtensibility
Determines whether a type is directly extensible by a (yet unknown) client application/library using the base analysis ClassExtensibility and an explicitly configured list of extensible types where the list overrides the findings of the analysis.
Determines whether a type is directly extensible by a (yet unknown) client application/library using the base analysis ClassExtensibility and an explicitly configured list of extensible types where the list overrides the findings of the analysis. This enables domain specific configurations.
Additional configuration has to be done using OPAL's configuration file. To specify extensible classes/interfaces the following key has to be used:
ClassExtensibilityKey.ConfigKeyPrefix + extensibleClasses
The following example configuration would consider
java/util/Math
andcom/example/Type
as extensible.org.opalj.br.analyses.cg.ClassExtensibilityKey.extensibleClasses = ["java/util/Math", "com/example/Type"]
Example: - class ConfiguredFinalClasses extends AbstractClassExtensibility
Determines whether a type is directly extensible by a (yet unknown) client application/library using the base analysis ClassExtensibility and an explicitly configured list of final (not extensible) types; the configuration is always considered first.
Determines whether a type is directly extensible by a (yet unknown) client application/library using the base analysis ClassExtensibility and an explicitly configured list of final (not extensible) types; the configuration is always considered first. This enables domain specific configurations.
Additional configuration has to be done using OPAL's configuration file. To specify classes/interfaces that are not extensible/that are final the following key has to be used:
ClassExtensibilityKey.ConfigKeyPrefix + finalClasses
The following example configuration would consider
java/util/Math
andcom/exmaple/Type
as not extensible.org.opalj.br.analyses.cg.ClassExtensibilityKey.finalClasses = ["java/util/Math", "com/example/Type"]
Example: - class DefaultClassExtensibility extends AbstractClassExtensibility
- sealed trait EntryPointFinder extends AnyRef
The EntryPointFinder trait is a common trait for all analyses that can derive an programs entry points.
The EntryPointFinder trait is a common trait for all analyses that can derive an programs entry points. The concrete entry point finder that is used to determines a programs entry points directly impacts the computation of a programs call graph.
All subclasses should be implemented in a way that it is possible to chain them. (Decorator)
- sealed trait InstantiatedTypesFinder extends AnyRef
- trait LibraryEntryPointsFinder extends EntryPointFinder
This trait provides an analysis to compute a libraries' default entry points.
This trait provides an analysis to compute a libraries' default entry points. The analysis thus depends on the type extensibility, method overridability, and closed packages information. Hence, its behaviour and output heavily depends on the configuration settings.
- Note
If the target program relies on frameworks with additional custom entry points, you can combine this analysis with the additional configurable entry points.
- trait LibraryInstantiatedTypesFinder extends InstantiatedTypesFinder
This trait considers those types instantiated that can be instantiated by an application using the project under analysis as a library, i.e., those types that can be instantiated because they are public or inside an open package and that have a constructor that is accessible.
- class OpenCodeBase extends ClosedPackages
A conservative ClosedPackages analysis which considers all packages (except of those starting with
java
) as being open.A conservative ClosedPackages analysis which considers all packages (except of those starting with
java
) as being open. Thejava.*
packages are protected by the JVM itself. This analysis can safely be used by every analysis, but - depending on the context - may result in imprecise analysis results.To use this analysis set the config key:
org.opalj.br.analyses.cg.ClosedPackagesKey.analysis
toorg.opalj.br.analyses.cg.OpenCodeBase
- class TypeExtensibilityAnalysis extends (ObjectType) => Answer
Determines if a type (class or interface) is further (transitively) extensible by yet unknown types (that is, can be (transitively) inherited from).
Determines if a type (class or interface) is further (transitively) extensible by yet unknown types (that is, can be (transitively) inherited from).
Special cases
If a class is defined in a package starting with java.*, it always has to be treated like classes that belong to a closed package. This is necessary because the default
ClassLoader
prevents the definition of further classes within these packages, hence, they are closed by definition.If the analyzed codebase has an incomplete type hierarchy, which leads to unknown subtype relationships, it is necessary to add these particular classes to the computed set of extensible classes.
Value Members
- object AllEntryPointsFinder extends EntryPointFinder
The AllEntryPointsFinder considers all methods as entry points.
The AllEntryPointsFinder considers all methods as entry points. It can be configured to consider only project methods as entry points instead of project and library methods by specifying **org.opalj.br.analyses.cg.InitialEntryPointsKey.AllEntryPointsFinder.projectMethodsOnly=true**.
- object AllInstantiatedTypesFinder extends InstantiatedTypesFinder
The AllInstantiatedTypesFinder considers all class files' types as instantiated.
The AllInstantiatedTypesFinder considers all class files' types as instantiated. It can be configured to consider only project class files instead of project and library class files by specifying **org.opalj.br.analyses.cg.InitialInstantiatedTypesKey.AllInstantiatedTypesFinder.projectClassesOnly=true**.
- object ApplicationEntryPointsFinder extends ApplicationEntryPointsFinder with ConfigurationEntryPointsFinder
The ApplicationEntryPointsFinder considers all main methods plus additionally configured entry points.
- object ApplicationInstantiatedTypesFinder extends ApplicationInstantiatedTypesFinder with ConfigurationInstantiatedTypesFinder
- object ApplicationWithoutJREEntryPointsFinder extends ApplicationWithoutJREEntryPointsFinder with ConfigurationEntryPointsFinder
- object CallBySignatureKey extends ProjectInformationKey[CallBySignatureTargets, Nothing]
The key object to get the interface methods for which call-by-signature resolution needs to be done.
The key object to get the interface methods for which call-by-signature resolution needs to be done.
- Note
To get call-by-signature information use the org.opalj.br.analyses.Project's
get
method and pass inthis
object.- See also
CallBySignatureResolution for further information.
- object ClassExtensibilityKey extends ProjectInformationKey[ClassExtensibility, Nothing]
The key object to get a function that determines whether a type is directly extensible or not.
The key object to get a function that determines whether a type is directly extensible or not.
- See also
ClassExtensibility for further information.
- object ClosedPackagesKey extends ProjectInformationKey[ClosedPackages, Nothing]
The key object to get a function that determines whether a package is closed or not.
The key object to get a function that determines whether a package is closed or not. See ClosedPackages for further details.
This key reflectively instantiates the analysis that determines whether a package is closed or not. The respective analysis has to extend the abstract ClosedPackages class. To configure which analysis is used use the key
org.opalj.br.analyses.cg.ClosedPackagesKey.analysis
to specify the name of the class which implements the analysis.org.opalj.br.analyses.cg { ClosedPackagesKey { analysis = "org.opalj.br.analyses.cg.ClosedPackagesConfiguration" closedPackages = "java(/.*)*" } }
- Note
Please see the documentation of ClosedPackages and its subtypes for more information.
,The default configuration is the conservative OpenCodeBase analysis.
Example: - object ConfigurationEntryPointsFinder extends ConfigurationEntryPointsFinder
The ConfigurationEntryPointsFinder considers only configured entry points.
- object ConfigurationInstantiatedTypesFinder extends ConfigurationInstantiatedTypesFinder
- object InitialEntryPointsKey extends ProjectInformationKey[Iterable[Method], Nothing]
The key object to get a traversable of entry points.
The key object to get a traversable of entry points. Entry points are particularly relevant to construct call graphs. See InitialEntryPointsKey for further details.
This key reflectively instantiates the analysis that determines the program's entry points. The respective analysis has to extend the trait InitialEntryPointsKey class.
To configure which analysis is used use the key
org.opalj.br.analyses.cg.InitialEntryPointKey.analysis
to specify the name of the class which implements the analysis.org.opalj.br.analyses.cg { InitialEntryPointKey { analysis = "org.opalj.br.analyses.cg.ApplicationEntryPointFinder" } }
- Note
Please see the documentation of EntryPointFinder and its subtypes for more information.
Example: - object InitialInstantiatedTypesKey extends ProjectInformationKey[Iterable[ObjectType], Nothing]
Creates the InstantiatedTypesFinder as specified in the ConfigKeyPrefix config key.
Creates the InstantiatedTypesFinder as specified in the ConfigKeyPrefix config key.
org.opalj.br.analyses.cg { InitialInstantiatedTypesKey { analysis = "org.opalj.br.analyses.cg.ApplicationInstantiatedTypesFinder" } }
- Note
Please see the documentation of InstantiatedTypesFinder and its subtypes for more information.
Example: - object IsOverridableMethodKey extends ProjectInformationKey[(Method) => Answer, Nothing]
The key object to get a function that determines whether a method can be overridden by a not yet existing type.
The key object to get a function that determines whether a method can be overridden by a not yet existing type. A method can be overridden if it's declaring type _dt_is extensible by an (unknown) type _ut_ (e.g., when the analysis assumes an open world) and if the method is not overridden by another subtype _s_ such that _ut <: s <: st_ and if the method can be overridden according to the JVM's semantics.
- object LibraryEntryPointsFinder extends LibraryEntryPointsFinder with ConfigurationEntryPointsFinder
The ApplicationEntryPointsFinder considers all main methods plus additionally configured entry points.
- object LibraryInstantiatedTypesFinder extends LibraryInstantiatedTypesFinder with ConfigurationInstantiatedTypesFinder
- object MetaEntryPointsFinder extends ApplicationEntryPointsFinder with LibraryEntryPointsFinder with ConfigurationEntryPointsFinder
The MetaEntryPointsFinder is a conservative EntryPoints finder triggers all known finders.
- object TypeExtensibilityKey extends ProjectInformationKey[(ObjectType) => Answer, Nothing]
Key to get the function that determines whether a type (i.e., we abstract over a class/ interface and all its subtypes) is extensible or not. A type is extensible if a developer could define a sub(*)type that is not part of the given application/library.